babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. }
  335. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  336. /**
  337. * Does exist one action manager with at least one trigger
  338. **/
  339. get: function () {
  340. for (var t in AbstractActionManager.Triggers) {
  341. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  342. return true;
  343. }
  344. }
  345. return false;
  346. },
  347. enumerable: true,
  348. configurable: true
  349. });
  350. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  351. /**
  352. * Does exist one action manager with at least one pick trigger
  353. **/
  354. get: function () {
  355. for (var t in AbstractActionManager.Triggers) {
  356. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  357. var t_int = parseInt(t);
  358. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  359. return true;
  360. }
  361. }
  362. }
  363. return false;
  364. },
  365. enumerable: true,
  366. configurable: true
  367. });
  368. /**
  369. * Does exist one action manager that handles actions of a given trigger
  370. * @param trigger defines the trigger to be tested
  371. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  372. **/
  373. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  374. for (var t in AbstractActionManager.Triggers) {
  375. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  376. var t_int = parseInt(t);
  377. if (t_int === trigger) {
  378. return true;
  379. }
  380. }
  381. }
  382. return false;
  383. };
  384. /** Gets the list of active triggers */
  385. AbstractActionManager.Triggers = {};
  386. return AbstractActionManager;
  387. }());
  388. /***/ }),
  389. /***/ "./Actions/action.ts":
  390. /*!***************************!*\
  391. !*** ./Actions/action.ts ***!
  392. \***************************/
  393. /*! exports provided: Action */
  394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  395. "use strict";
  396. __webpack_require__.r(__webpack_exports__);
  397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  398. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  400. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  401. /**
  402. * The action to be carried out following a trigger
  403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  404. */
  405. var Action = /** @class */ (function () {
  406. /**
  407. * Creates a new Action
  408. * @param triggerOptions the trigger, with or without parameters, for the action
  409. * @param condition an optional determinant of action
  410. */
  411. function Action(
  412. /** the trigger, with or without parameters, for the action */
  413. triggerOptions, condition) {
  414. this.triggerOptions = triggerOptions;
  415. /**
  416. * An event triggered prior to action being executed.
  417. */
  418. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  419. if (triggerOptions.parameter) {
  420. this.trigger = triggerOptions.trigger;
  421. this._triggerParameter = triggerOptions.parameter;
  422. }
  423. else if (triggerOptions.trigger) {
  424. this.trigger = triggerOptions.trigger;
  425. }
  426. else {
  427. this.trigger = triggerOptions;
  428. }
  429. this._nextActiveAction = this;
  430. this._condition = condition;
  431. }
  432. /**
  433. * Internal only
  434. * @hidden
  435. */
  436. Action.prototype._prepare = function () {
  437. };
  438. /**
  439. * Gets the trigger parameters
  440. * @returns the trigger parameters
  441. */
  442. Action.prototype.getTriggerParameter = function () {
  443. return this._triggerParameter;
  444. };
  445. /**
  446. * Internal only - executes current action event
  447. * @hidden
  448. */
  449. Action.prototype._executeCurrent = function (evt) {
  450. if (this._nextActiveAction._condition) {
  451. var condition = this._nextActiveAction._condition;
  452. var currentRenderId = this._actionManager.getScene().getRenderId();
  453. // We cache the current evaluation for the current frame
  454. if (condition._evaluationId === currentRenderId) {
  455. if (!condition._currentResult) {
  456. return;
  457. }
  458. }
  459. else {
  460. condition._evaluationId = currentRenderId;
  461. if (!condition.isValid()) {
  462. condition._currentResult = false;
  463. return;
  464. }
  465. condition._currentResult = true;
  466. }
  467. }
  468. this.onBeforeExecuteObservable.notifyObservers(this);
  469. this._nextActiveAction.execute(evt);
  470. this.skipToNextActiveAction();
  471. };
  472. /**
  473. * Execute placeholder for child classes
  474. * @param evt optional action event
  475. */
  476. Action.prototype.execute = function (evt) {
  477. };
  478. /**
  479. * Skips to next active action
  480. */
  481. Action.prototype.skipToNextActiveAction = function () {
  482. if (this._nextActiveAction._child) {
  483. if (!this._nextActiveAction._child._actionManager) {
  484. this._nextActiveAction._child._actionManager = this._actionManager;
  485. }
  486. this._nextActiveAction = this._nextActiveAction._child;
  487. }
  488. else {
  489. this._nextActiveAction = this;
  490. }
  491. };
  492. /**
  493. * Adds action to chain of actions, may be a DoNothingAction
  494. * @param action defines the next action to execute
  495. * @returns The action passed in
  496. * @see https://www.babylonjs-playground.com/#1T30HR#0
  497. */
  498. Action.prototype.then = function (action) {
  499. this._child = action;
  500. action._actionManager = this._actionManager;
  501. action._prepare();
  502. return action;
  503. };
  504. /**
  505. * Internal only
  506. * @hidden
  507. */
  508. Action.prototype._getProperty = function (propertyPath) {
  509. return this._actionManager._getProperty(propertyPath);
  510. };
  511. /**
  512. * Internal only
  513. * @hidden
  514. */
  515. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  516. return this._actionManager._getEffectiveTarget(target, propertyPath);
  517. };
  518. /**
  519. * Serialize placeholder for child classes
  520. * @param parent of child
  521. * @returns the serialized object
  522. */
  523. Action.prototype.serialize = function (parent) {
  524. };
  525. /**
  526. * Internal only called by serialize
  527. * @hidden
  528. */
  529. Action.prototype._serialize = function (serializedAction, parent) {
  530. var serializationObject = {
  531. type: 1,
  532. children: [],
  533. name: serializedAction.name,
  534. properties: serializedAction.properties || []
  535. };
  536. // Serialize child
  537. if (this._child) {
  538. this._child.serialize(serializationObject);
  539. }
  540. // Check if "this" has a condition
  541. if (this._condition) {
  542. var serializedCondition = this._condition.serialize();
  543. serializedCondition.children.push(serializationObject);
  544. if (parent) {
  545. parent.children.push(serializedCondition);
  546. }
  547. return serializedCondition;
  548. }
  549. if (parent) {
  550. parent.children.push(serializationObject);
  551. }
  552. return serializationObject;
  553. };
  554. /**
  555. * Internal only
  556. * @hidden
  557. */
  558. Action._SerializeValueAsString = function (value) {
  559. if (typeof value === "number") {
  560. return value.toString();
  561. }
  562. if (typeof value === "boolean") {
  563. return value ? "true" : "false";
  564. }
  565. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  566. return value.x + ", " + value.y;
  567. }
  568. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  569. return value.x + ", " + value.y + ", " + value.z;
  570. }
  571. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  572. return value.r + ", " + value.g + ", " + value.b;
  573. }
  574. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  575. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  576. }
  577. return value; // string
  578. };
  579. /**
  580. * Internal only
  581. * @hidden
  582. */
  583. Action._GetTargetProperty = function (target) {
  584. return {
  585. name: "target",
  586. targetType: target._isMesh ? "MeshProperties"
  587. : target._isLight ? "LightProperties"
  588. : target._isCamera ? "CameraProperties"
  589. : "SceneProperties",
  590. value: target._isScene ? "Scene" : target.name
  591. };
  592. };
  593. return Action;
  594. }());
  595. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  596. /***/ }),
  597. /***/ "./Actions/actionEvent.ts":
  598. /*!********************************!*\
  599. !*** ./Actions/actionEvent.ts ***!
  600. \********************************/
  601. /*! exports provided: ActionEvent */
  602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  603. "use strict";
  604. __webpack_require__.r(__webpack_exports__);
  605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  606. /**
  607. * ActionEvent is the event being sent when an action is triggered.
  608. */
  609. var ActionEvent = /** @class */ (function () {
  610. /**
  611. * Creates a new ActionEvent
  612. * @param source The mesh or sprite that triggered the action
  613. * @param pointerX The X mouse cursor position at the time of the event
  614. * @param pointerY The Y mouse cursor position at the time of the event
  615. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  616. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  617. * @param additionalData additional data for the event
  618. */
  619. function ActionEvent(
  620. /** The mesh or sprite that triggered the action */
  621. source,
  622. /** The X mouse cursor position at the time of the event */
  623. pointerX,
  624. /** The Y mouse cursor position at the time of the event */
  625. pointerY,
  626. /** The mesh that is currently pointed at (can be null) */
  627. meshUnderPointer,
  628. /** the original (browser) event that triggered the ActionEvent */
  629. sourceEvent,
  630. /** additional data for the event */
  631. additionalData) {
  632. this.source = source;
  633. this.pointerX = pointerX;
  634. this.pointerY = pointerY;
  635. this.meshUnderPointer = meshUnderPointer;
  636. this.sourceEvent = sourceEvent;
  637. this.additionalData = additionalData;
  638. }
  639. /**
  640. * Helper function to auto-create an ActionEvent from a source mesh.
  641. * @param source The source mesh that triggered the event
  642. * @param evt The original (browser) event
  643. * @param additionalData additional data for the event
  644. * @returns the new ActionEvent
  645. */
  646. ActionEvent.CreateNew = function (source, evt, additionalData) {
  647. var scene = source.getScene();
  648. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  649. };
  650. /**
  651. * Helper function to auto-create an ActionEvent from a source sprite
  652. * @param source The source sprite that triggered the event
  653. * @param scene Scene associated with the sprite
  654. * @param evt The original (browser) event
  655. * @param additionalData additional data for the event
  656. * @returns the new ActionEvent
  657. */
  658. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  659. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  660. };
  661. /**
  662. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  663. * @param scene the scene where the event occurred
  664. * @param evt The original (browser) event
  665. * @returns the new ActionEvent
  666. */
  667. ActionEvent.CreateNewFromScene = function (scene, evt) {
  668. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  669. };
  670. /**
  671. * Helper function to auto-create an ActionEvent from a primitive
  672. * @param prim defines the target primitive
  673. * @param pointerPos defines the pointer position
  674. * @param evt The original (browser) event
  675. * @param additionalData additional data for the event
  676. * @returns the new ActionEvent
  677. */
  678. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  679. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  680. };
  681. return ActionEvent;
  682. }());
  683. /***/ }),
  684. /***/ "./Actions/actionManager.ts":
  685. /*!**********************************!*\
  686. !*** ./Actions/actionManager.ts ***!
  687. \**********************************/
  688. /*! exports provided: ActionManager */
  689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  690. "use strict";
  691. __webpack_require__.r(__webpack_exports__);
  692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  695. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  696. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  697. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  698. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  699. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  700. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  701. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  702. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  703. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  704. /**
  705. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  706. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  708. */
  709. var ActionManager = /** @class */ (function (_super) {
  710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  711. /**
  712. * Creates a new action manager
  713. * @param scene defines the hosting scene
  714. */
  715. function ActionManager(scene) {
  716. var _this = _super.call(this) || this;
  717. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  718. scene.actionManagers.push(_this);
  719. return _this;
  720. }
  721. // Methods
  722. /**
  723. * Releases all associated resources
  724. */
  725. ActionManager.prototype.dispose = function () {
  726. var index = this._scene.actionManagers.indexOf(this);
  727. for (var i = 0; i < this.actions.length; i++) {
  728. var action = this.actions[i];
  729. ActionManager.Triggers[action.trigger]--;
  730. if (ActionManager.Triggers[action.trigger] === 0) {
  731. delete ActionManager.Triggers[action.trigger];
  732. }
  733. }
  734. if (index > -1) {
  735. this._scene.actionManagers.splice(index, 1);
  736. }
  737. };
  738. /**
  739. * Gets hosting scene
  740. * @returns the hosting scene
  741. */
  742. ActionManager.prototype.getScene = function () {
  743. return this._scene;
  744. };
  745. /**
  746. * Does this action manager handles actions of any of the given triggers
  747. * @param triggers defines the triggers to be tested
  748. * @return a boolean indicating whether one (or more) of the triggers is handled
  749. */
  750. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  751. for (var index = 0; index < this.actions.length; index++) {
  752. var action = this.actions[index];
  753. if (triggers.indexOf(action.trigger) > -1) {
  754. return true;
  755. }
  756. }
  757. return false;
  758. };
  759. /**
  760. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  761. * speed.
  762. * @param triggerA defines the trigger to be tested
  763. * @param triggerB defines the trigger to be tested
  764. * @return a boolean indicating whether one (or more) of the triggers is handled
  765. */
  766. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  767. for (var index = 0; index < this.actions.length; index++) {
  768. var action = this.actions[index];
  769. if (triggerA == action.trigger || triggerB == action.trigger) {
  770. return true;
  771. }
  772. }
  773. return false;
  774. };
  775. /**
  776. * Does this action manager handles actions of a given trigger
  777. * @param trigger defines the trigger to be tested
  778. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  779. * @return whether the trigger is handled
  780. */
  781. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  782. for (var index = 0; index < this.actions.length; index++) {
  783. var action = this.actions[index];
  784. if (action.trigger === trigger) {
  785. if (parameterPredicate) {
  786. if (parameterPredicate(action.getTriggerParameter())) {
  787. return true;
  788. }
  789. }
  790. else {
  791. return true;
  792. }
  793. }
  794. }
  795. return false;
  796. };
  797. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  798. /**
  799. * Does this action manager has pointer triggers
  800. */
  801. get: function () {
  802. for (var index = 0; index < this.actions.length; index++) {
  803. var action = this.actions[index];
  804. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  805. return true;
  806. }
  807. }
  808. return false;
  809. },
  810. enumerable: true,
  811. configurable: true
  812. });
  813. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  814. /**
  815. * Does this action manager has pick 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.OnPickUpTrigger) {
  821. return true;
  822. }
  823. }
  824. return false;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Registers an action to this action manager
  831. * @param action defines the action to be registered
  832. * @return the action amended (prepared) after registration
  833. */
  834. ActionManager.prototype.registerAction = function (action) {
  835. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  836. if (this.getScene().actionManager !== this) {
  837. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  838. return null;
  839. }
  840. }
  841. this.actions.push(action);
  842. if (ActionManager.Triggers[action.trigger]) {
  843. ActionManager.Triggers[action.trigger]++;
  844. }
  845. else {
  846. ActionManager.Triggers[action.trigger] = 1;
  847. }
  848. action._actionManager = this;
  849. action._prepare();
  850. return action;
  851. };
  852. /**
  853. * Unregisters an action to this action manager
  854. * @param action defines the action to be unregistered
  855. * @return a boolean indicating whether the action has been unregistered
  856. */
  857. ActionManager.prototype.unregisterAction = function (action) {
  858. var index = this.actions.indexOf(action);
  859. if (index !== -1) {
  860. this.actions.splice(index, 1);
  861. ActionManager.Triggers[action.trigger] -= 1;
  862. if (ActionManager.Triggers[action.trigger] === 0) {
  863. delete ActionManager.Triggers[action.trigger];
  864. }
  865. delete action._actionManager;
  866. return true;
  867. }
  868. return false;
  869. };
  870. /**
  871. * Process a specific trigger
  872. * @param trigger defines the trigger to process
  873. * @param evt defines the event details to be processed
  874. */
  875. ActionManager.prototype.processTrigger = function (trigger, evt) {
  876. for (var index = 0; index < this.actions.length; index++) {
  877. var action = this.actions[index];
  878. if (action.trigger === trigger) {
  879. if (evt) {
  880. if (trigger === ActionManager.OnKeyUpTrigger
  881. || trigger === ActionManager.OnKeyDownTrigger) {
  882. var parameter = action.getTriggerParameter();
  883. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  884. if (!parameter.toLowerCase) {
  885. continue;
  886. }
  887. var lowerCase = parameter.toLowerCase();
  888. if (lowerCase !== evt.sourceEvent.key) {
  889. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  890. var actualkey = String.fromCharCode(unicode).toLowerCase();
  891. if (actualkey !== lowerCase) {
  892. continue;
  893. }
  894. }
  895. }
  896. }
  897. }
  898. action._executeCurrent(evt);
  899. }
  900. }
  901. };
  902. /** @hidden */
  903. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  904. var properties = propertyPath.split(".");
  905. for (var index = 0; index < properties.length - 1; index++) {
  906. target = target[properties[index]];
  907. }
  908. return target;
  909. };
  910. /** @hidden */
  911. ActionManager.prototype._getProperty = function (propertyPath) {
  912. var properties = propertyPath.split(".");
  913. return properties[properties.length - 1];
  914. };
  915. /**
  916. * Serialize this manager to a JSON object
  917. * @param name defines the property name to store this manager
  918. * @returns a JSON representation of this manager
  919. */
  920. ActionManager.prototype.serialize = function (name) {
  921. var root = {
  922. children: new Array(),
  923. name: name,
  924. type: 3,
  925. properties: new Array() // Empty for root but required
  926. };
  927. for (var i = 0; i < this.actions.length; i++) {
  928. var triggerObject = {
  929. type: 0,
  930. children: new Array(),
  931. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  932. properties: new Array()
  933. };
  934. var triggerOptions = this.actions[i].triggerOptions;
  935. if (triggerOptions && typeof triggerOptions !== "number") {
  936. if (triggerOptions.parameter instanceof Node) {
  937. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  938. }
  939. else {
  940. var parameter = {};
  941. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  942. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  943. parameter._meshId = triggerOptions.parameter.mesh.id;
  944. }
  945. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  946. }
  947. }
  948. // Serialize child action, recursively
  949. this.actions[i].serialize(triggerObject);
  950. // Add serialized trigger
  951. root.children.push(triggerObject);
  952. }
  953. return root;
  954. };
  955. /**
  956. * Creates a new ActionManager from a JSON data
  957. * @param parsedActions defines the JSON data to read from
  958. * @param object defines the hosting mesh
  959. * @param scene defines the hosting scene
  960. */
  961. ActionManager.Parse = function (parsedActions, object, scene) {
  962. var actionManager = new ActionManager(scene);
  963. if (object === null) {
  964. scene.actionManager = actionManager;
  965. }
  966. else {
  967. object.actionManager = actionManager;
  968. }
  969. // instanciate a new object
  970. var instanciate = function (name, params) {
  971. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  972. if (internalClassType) {
  973. var newInstance = Object.create(internalClassType.prototype);
  974. newInstance.constructor.apply(newInstance, params);
  975. return newInstance;
  976. }
  977. };
  978. var parseParameter = function (name, value, target, propertyPath) {
  979. if (propertyPath === null) {
  980. // String, boolean or float
  981. var floatValue = parseFloat(value);
  982. if (value === "true" || value === "false") {
  983. return value === "true";
  984. }
  985. else {
  986. return isNaN(floatValue) ? value : floatValue;
  987. }
  988. }
  989. var effectiveTarget = propertyPath.split(".");
  990. var values = value.split(",");
  991. // Get effective Target
  992. for (var i = 0; i < effectiveTarget.length; i++) {
  993. target = target[effectiveTarget[i]];
  994. }
  995. // Return appropriate value with its type
  996. if (typeof (target) === "boolean") {
  997. return values[0] === "true";
  998. }
  999. if (typeof (target) === "string") {
  1000. return values[0];
  1001. }
  1002. // Parameters with multiple values such as Vector3 etc.
  1003. var split = new Array();
  1004. for (var i = 0; i < values.length; i++) {
  1005. split.push(parseFloat(values[i]));
  1006. }
  1007. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1008. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1009. }
  1010. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1011. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1012. }
  1013. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1014. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1015. }
  1016. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1017. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1018. }
  1019. return parseFloat(values[0]);
  1020. };
  1021. // traverse graph per trigger
  1022. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1023. if (combineArray === void 0) { combineArray = null; }
  1024. if (parsedAction.detached) {
  1025. return;
  1026. }
  1027. var parameters = new Array();
  1028. var target = null;
  1029. var propertyPath = null;
  1030. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1031. // Parameters
  1032. if (parsedAction.type === 2) {
  1033. parameters.push(actionManager);
  1034. }
  1035. else {
  1036. parameters.push(trigger);
  1037. }
  1038. if (combine) {
  1039. var actions = new Array();
  1040. for (var j = 0; j < parsedAction.combine.length; j++) {
  1041. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1042. }
  1043. parameters.push(actions);
  1044. }
  1045. else {
  1046. for (var i = 0; i < parsedAction.properties.length; i++) {
  1047. var value = parsedAction.properties[i].value;
  1048. var name = parsedAction.properties[i].name;
  1049. var targetType = parsedAction.properties[i].targetType;
  1050. if (name === "target") {
  1051. if (targetType !== null && targetType === "SceneProperties") {
  1052. value = target = scene;
  1053. }
  1054. else {
  1055. value = target = scene.getNodeByName(value);
  1056. }
  1057. }
  1058. else if (name === "parent") {
  1059. value = scene.getNodeByName(value);
  1060. }
  1061. else if (name === "sound") {
  1062. // Can not externalize to component, so only checks for the presence off the API.
  1063. if (scene.getSoundByName) {
  1064. value = scene.getSoundByName(value);
  1065. }
  1066. }
  1067. else if (name !== "propertyPath") {
  1068. if (parsedAction.type === 2 && name === "operator") {
  1069. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1070. }
  1071. else {
  1072. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1073. }
  1074. }
  1075. else {
  1076. propertyPath = value;
  1077. }
  1078. parameters.push(value);
  1079. }
  1080. }
  1081. if (combineArray === null) {
  1082. parameters.push(condition);
  1083. }
  1084. else {
  1085. parameters.push(null);
  1086. }
  1087. // If interpolate value action
  1088. if (parsedAction.name === "InterpolateValueAction") {
  1089. var param = parameters[parameters.length - 2];
  1090. parameters[parameters.length - 1] = param;
  1091. parameters[parameters.length - 2] = condition;
  1092. }
  1093. // Action or condition(s) and not CombineAction
  1094. var newAction = instanciate(parsedAction.name, parameters);
  1095. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1096. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1097. if (action) {
  1098. action.then(nothing);
  1099. }
  1100. else {
  1101. actionManager.registerAction(nothing);
  1102. }
  1103. action = nothing;
  1104. }
  1105. if (combineArray === null) {
  1106. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1107. condition = newAction;
  1108. newAction = action;
  1109. }
  1110. else {
  1111. condition = null;
  1112. if (action) {
  1113. action.then(newAction);
  1114. }
  1115. else {
  1116. actionManager.registerAction(newAction);
  1117. }
  1118. }
  1119. }
  1120. else {
  1121. combineArray.push(newAction);
  1122. }
  1123. for (var i = 0; i < parsedAction.children.length; i++) {
  1124. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1125. }
  1126. };
  1127. // triggers
  1128. for (var i = 0; i < parsedActions.children.length; i++) {
  1129. var triggerParams;
  1130. var trigger = parsedActions.children[i];
  1131. if (trigger.properties.length > 0) {
  1132. var param = trigger.properties[0].value;
  1133. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1134. if (value._meshId) {
  1135. value.mesh = scene.getMeshByID(value._meshId);
  1136. }
  1137. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1138. }
  1139. else {
  1140. triggerParams = ActionManager[trigger.name];
  1141. }
  1142. for (var j = 0; j < trigger.children.length; j++) {
  1143. if (!trigger.detached) {
  1144. traverse(trigger.children[j], triggerParams, null, null);
  1145. }
  1146. }
  1147. }
  1148. };
  1149. /**
  1150. * Get a trigger name by index
  1151. * @param trigger defines the trigger index
  1152. * @returns a trigger name
  1153. */
  1154. ActionManager.GetTriggerName = function (trigger) {
  1155. switch (trigger) {
  1156. case 0: return "NothingTrigger";
  1157. case 1: return "OnPickTrigger";
  1158. case 2: return "OnLeftPickTrigger";
  1159. case 3: return "OnRightPickTrigger";
  1160. case 4: return "OnCenterPickTrigger";
  1161. case 5: return "OnPickDownTrigger";
  1162. case 6: return "OnPickUpTrigger";
  1163. case 7: return "OnLongPressTrigger";
  1164. case 8: return "OnPointerOverTrigger";
  1165. case 9: return "OnPointerOutTrigger";
  1166. case 10: return "OnEveryFrameTrigger";
  1167. case 11: return "OnIntersectionEnterTrigger";
  1168. case 12: return "OnIntersectionExitTrigger";
  1169. case 13: return "OnKeyDownTrigger";
  1170. case 14: return "OnKeyUpTrigger";
  1171. case 15: return "OnPickOutTrigger";
  1172. default: return "";
  1173. }
  1174. };
  1175. /**
  1176. * Nothing
  1177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1178. */
  1179. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1180. /**
  1181. * On pick
  1182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1183. */
  1184. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1185. /**
  1186. * On left pick
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1188. */
  1189. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1190. /**
  1191. * On right pick
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1193. */
  1194. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1195. /**
  1196. * On center pick
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1198. */
  1199. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1200. /**
  1201. * On pick down
  1202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1203. */
  1204. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1205. /**
  1206. * On double pick
  1207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1208. */
  1209. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1210. /**
  1211. * On pick up
  1212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1213. */
  1214. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1215. /**
  1216. * On pick out.
  1217. * This trigger will only be raised if you also declared a OnPickDown
  1218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1219. */
  1220. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1221. /**
  1222. * On long press
  1223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1224. */
  1225. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1226. /**
  1227. * On pointer over
  1228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1229. */
  1230. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1231. /**
  1232. * On pointer out
  1233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1234. */
  1235. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1236. /**
  1237. * On every frame
  1238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1239. */
  1240. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1241. /**
  1242. * On intersection enter
  1243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1244. */
  1245. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1246. /**
  1247. * On intersection exit
  1248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1249. */
  1250. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1251. /**
  1252. * On key down
  1253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1254. */
  1255. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1256. /**
  1257. * On key up
  1258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1259. */
  1260. ActionManager.OnKeyUpTrigger = 15;
  1261. return ActionManager;
  1262. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1263. /***/ }),
  1264. /***/ "./Actions/condition.ts":
  1265. /*!******************************!*\
  1266. !*** ./Actions/condition.ts ***!
  1267. \******************************/
  1268. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1270. "use strict";
  1271. __webpack_require__.r(__webpack_exports__);
  1272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1277. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1278. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1279. /**
  1280. * A Condition applied to an Action
  1281. */
  1282. var Condition = /** @class */ (function () {
  1283. /**
  1284. * Creates a new Condition
  1285. * @param actionManager the manager of the action the condition is applied to
  1286. */
  1287. function Condition(actionManager) {
  1288. this._actionManager = actionManager;
  1289. }
  1290. /**
  1291. * Check if the current condition is valid
  1292. * @returns a boolean
  1293. */
  1294. Condition.prototype.isValid = function () {
  1295. return true;
  1296. };
  1297. /**
  1298. * Internal only
  1299. * @hidden
  1300. */
  1301. Condition.prototype._getProperty = function (propertyPath) {
  1302. return this._actionManager._getProperty(propertyPath);
  1303. };
  1304. /**
  1305. * Internal only
  1306. * @hidden
  1307. */
  1308. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1309. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1310. };
  1311. /**
  1312. * Serialize placeholder for child classes
  1313. * @returns the serialized object
  1314. */
  1315. Condition.prototype.serialize = function () {
  1316. };
  1317. /**
  1318. * Internal only
  1319. * @hidden
  1320. */
  1321. Condition.prototype._serialize = function (serializedCondition) {
  1322. return {
  1323. type: 2,
  1324. children: [],
  1325. name: serializedCondition.name,
  1326. properties: serializedCondition.properties
  1327. };
  1328. };
  1329. return Condition;
  1330. }());
  1331. /**
  1332. * Defines specific conditional operators as extensions of Condition
  1333. */
  1334. var ValueCondition = /** @class */ (function (_super) {
  1335. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1336. /**
  1337. * Creates a new ValueCondition
  1338. * @param actionManager manager for the action the condition applies to
  1339. * @param target for the action
  1340. * @param propertyPath path to specify the property of the target the conditional operator uses
  1341. * @param value the value compared by the conditional operator against the current value of the property
  1342. * @param operator the conditional operator, default ValueCondition.IsEqual
  1343. */
  1344. function ValueCondition(actionManager, target,
  1345. /** path to specify the property of the target the conditional operator uses */
  1346. propertyPath,
  1347. /** the value compared by the conditional operator against the current value of the property */
  1348. value,
  1349. /** the conditional operator, default ValueCondition.IsEqual */
  1350. operator) {
  1351. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1352. var _this = _super.call(this, actionManager) || this;
  1353. _this.propertyPath = propertyPath;
  1354. _this.value = value;
  1355. _this.operator = operator;
  1356. _this._target = target;
  1357. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1358. _this._property = _this._getProperty(_this.propertyPath);
  1359. return _this;
  1360. }
  1361. Object.defineProperty(ValueCondition, "IsEqual", {
  1362. /**
  1363. * returns the number for IsEqual
  1364. */
  1365. get: function () {
  1366. return ValueCondition._IsEqual;
  1367. },
  1368. enumerable: true,
  1369. configurable: true
  1370. });
  1371. Object.defineProperty(ValueCondition, "IsDifferent", {
  1372. /**
  1373. * Returns the number for IsDifferent
  1374. */
  1375. get: function () {
  1376. return ValueCondition._IsDifferent;
  1377. },
  1378. enumerable: true,
  1379. configurable: true
  1380. });
  1381. Object.defineProperty(ValueCondition, "IsGreater", {
  1382. /**
  1383. * Returns the number for IsGreater
  1384. */
  1385. get: function () {
  1386. return ValueCondition._IsGreater;
  1387. },
  1388. enumerable: true,
  1389. configurable: true
  1390. });
  1391. Object.defineProperty(ValueCondition, "IsLesser", {
  1392. /**
  1393. * Returns the number for IsLesser
  1394. */
  1395. get: function () {
  1396. return ValueCondition._IsLesser;
  1397. },
  1398. enumerable: true,
  1399. configurable: true
  1400. });
  1401. /**
  1402. * Compares the given value with the property value for the specified conditional operator
  1403. * @returns the result of the comparison
  1404. */
  1405. ValueCondition.prototype.isValid = function () {
  1406. switch (this.operator) {
  1407. case ValueCondition.IsGreater:
  1408. return this._effectiveTarget[this._property] > this.value;
  1409. case ValueCondition.IsLesser:
  1410. return this._effectiveTarget[this._property] < this.value;
  1411. case ValueCondition.IsEqual:
  1412. case ValueCondition.IsDifferent:
  1413. var check;
  1414. if (this.value.equals) {
  1415. check = this.value.equals(this._effectiveTarget[this._property]);
  1416. }
  1417. else {
  1418. check = this.value === this._effectiveTarget[this._property];
  1419. }
  1420. return this.operator === ValueCondition.IsEqual ? check : !check;
  1421. }
  1422. return false;
  1423. };
  1424. /**
  1425. * Serialize the ValueCondition into a JSON compatible object
  1426. * @returns serialization object
  1427. */
  1428. ValueCondition.prototype.serialize = function () {
  1429. return this._serialize({
  1430. name: "ValueCondition",
  1431. properties: [
  1432. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1433. { name: "propertyPath", value: this.propertyPath },
  1434. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1435. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1436. ]
  1437. });
  1438. };
  1439. /**
  1440. * Gets the name of the conditional operator for the ValueCondition
  1441. * @param operator the conditional operator
  1442. * @returns the name
  1443. */
  1444. ValueCondition.GetOperatorName = function (operator) {
  1445. switch (operator) {
  1446. case ValueCondition._IsEqual: return "IsEqual";
  1447. case ValueCondition._IsDifferent: return "IsDifferent";
  1448. case ValueCondition._IsGreater: return "IsGreater";
  1449. case ValueCondition._IsLesser: return "IsLesser";
  1450. default: return "";
  1451. }
  1452. };
  1453. /**
  1454. * Internal only
  1455. * @hidden
  1456. */
  1457. ValueCondition._IsEqual = 0;
  1458. /**
  1459. * Internal only
  1460. * @hidden
  1461. */
  1462. ValueCondition._IsDifferent = 1;
  1463. /**
  1464. * Internal only
  1465. * @hidden
  1466. */
  1467. ValueCondition._IsGreater = 2;
  1468. /**
  1469. * Internal only
  1470. * @hidden
  1471. */
  1472. ValueCondition._IsLesser = 3;
  1473. return ValueCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a predicate condition as an extension of Condition
  1477. */
  1478. var PredicateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1480. /**
  1481. * Creates a new PredicateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param predicate defines the predicate function used to validate the condition
  1484. */
  1485. function PredicateCondition(actionManager,
  1486. /** defines the predicate function used to validate the condition */
  1487. predicate) {
  1488. var _this = _super.call(this, actionManager) || this;
  1489. _this.predicate = predicate;
  1490. return _this;
  1491. }
  1492. /**
  1493. * @returns the validity of the predicate condition
  1494. */
  1495. PredicateCondition.prototype.isValid = function () {
  1496. return this.predicate();
  1497. };
  1498. return PredicateCondition;
  1499. }(Condition));
  1500. /**
  1501. * Defines a state condition as an extension of Condition
  1502. */
  1503. var StateCondition = /** @class */ (function (_super) {
  1504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1505. /**
  1506. * Creates a new StateCondition
  1507. * @param actionManager manager for the action the condition applies to
  1508. * @param target of the condition
  1509. * @param value to compare with target state
  1510. */
  1511. function StateCondition(actionManager, target,
  1512. /** Value to compare with target state */
  1513. value) {
  1514. var _this = _super.call(this, actionManager) || this;
  1515. _this.value = value;
  1516. _this._target = target;
  1517. return _this;
  1518. }
  1519. /**
  1520. * Gets a boolean indicating if the current condition is met
  1521. * @returns the validity of the state
  1522. */
  1523. StateCondition.prototype.isValid = function () {
  1524. return this._target.state === this.value;
  1525. };
  1526. /**
  1527. * Serialize the StateCondition into a JSON compatible object
  1528. * @returns serialization object
  1529. */
  1530. StateCondition.prototype.serialize = function () {
  1531. return this._serialize({
  1532. name: "StateCondition",
  1533. properties: [
  1534. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1535. { name: "value", value: this.value }
  1536. ]
  1537. });
  1538. };
  1539. return StateCondition;
  1540. }(Condition));
  1541. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1542. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1543. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1544. /***/ }),
  1545. /***/ "./Actions/directActions.ts":
  1546. /*!**********************************!*\
  1547. !*** ./Actions/directActions.ts ***!
  1548. \**********************************/
  1549. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1551. "use strict";
  1552. __webpack_require__.r(__webpack_exports__);
  1553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1564. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1565. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1566. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1568. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1569. /**
  1570. * This defines an action responsible to toggle a boolean once triggered.
  1571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1572. */
  1573. var SwitchBooleanAction = /** @class */ (function (_super) {
  1574. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1575. /**
  1576. * Instantiate the action
  1577. * @param triggerOptions defines the trigger options
  1578. * @param target defines the object containing the boolean
  1579. * @param propertyPath defines the path to the boolean property in the target object
  1580. * @param condition defines the trigger related conditions
  1581. */
  1582. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1583. var _this = _super.call(this, triggerOptions, condition) || this;
  1584. _this.propertyPath = propertyPath;
  1585. _this._target = _this._effectiveTarget = target;
  1586. return _this;
  1587. }
  1588. /** @hidden */
  1589. SwitchBooleanAction.prototype._prepare = function () {
  1590. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1591. this._property = this._getProperty(this.propertyPath);
  1592. };
  1593. /**
  1594. * Execute the action toggle the boolean value.
  1595. */
  1596. SwitchBooleanAction.prototype.execute = function () {
  1597. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1598. };
  1599. /**
  1600. * Serializes the actions and its related information.
  1601. * @param parent defines the object to serialize in
  1602. * @returns the serialized object
  1603. */
  1604. SwitchBooleanAction.prototype.serialize = function (parent) {
  1605. return _super.prototype._serialize.call(this, {
  1606. name: "SwitchBooleanAction",
  1607. properties: [
  1608. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1609. { name: "propertyPath", value: this.propertyPath }
  1610. ]
  1611. }, parent);
  1612. };
  1613. return SwitchBooleanAction;
  1614. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1615. /**
  1616. * This defines an action responsible to set a the state field of the target
  1617. * to a desired value once triggered.
  1618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1619. */
  1620. var SetStateAction = /** @class */ (function (_super) {
  1621. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1622. /**
  1623. * Instantiate the action
  1624. * @param triggerOptions defines the trigger options
  1625. * @param target defines the object containing the state property
  1626. * @param value defines the value to store in the state field
  1627. * @param condition defines the trigger related conditions
  1628. */
  1629. function SetStateAction(triggerOptions, target, value, condition) {
  1630. var _this = _super.call(this, triggerOptions, condition) || this;
  1631. _this.value = value;
  1632. _this._target = target;
  1633. return _this;
  1634. }
  1635. /**
  1636. * Execute the action and store the value on the target state property.
  1637. */
  1638. SetStateAction.prototype.execute = function () {
  1639. this._target.state = this.value;
  1640. };
  1641. /**
  1642. * Serializes the actions and its related information.
  1643. * @param parent defines the object to serialize in
  1644. * @returns the serialized object
  1645. */
  1646. SetStateAction.prototype.serialize = function (parent) {
  1647. return _super.prototype._serialize.call(this, {
  1648. name: "SetStateAction",
  1649. properties: [
  1650. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1651. { name: "value", value: this.value }
  1652. ]
  1653. }, parent);
  1654. };
  1655. return SetStateAction;
  1656. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1657. /**
  1658. * This defines an action responsible to set a property of the target
  1659. * to a desired value once triggered.
  1660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1661. */
  1662. var SetValueAction = /** @class */ (function (_super) {
  1663. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1664. /**
  1665. * Instantiate the action
  1666. * @param triggerOptions defines the trigger options
  1667. * @param target defines the object containing the property
  1668. * @param propertyPath defines the path of the property to set in the target
  1669. * @param value defines the value to set in the property
  1670. * @param condition defines the trigger related conditions
  1671. */
  1672. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1673. var _this = _super.call(this, triggerOptions, condition) || this;
  1674. _this.propertyPath = propertyPath;
  1675. _this.value = value;
  1676. _this._target = _this._effectiveTarget = target;
  1677. return _this;
  1678. }
  1679. /** @hidden */
  1680. SetValueAction.prototype._prepare = function () {
  1681. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1682. this._property = this._getProperty(this.propertyPath);
  1683. };
  1684. /**
  1685. * Execute the action and set the targetted property to the desired value.
  1686. */
  1687. SetValueAction.prototype.execute = function () {
  1688. this._effectiveTarget[this._property] = this.value;
  1689. if (this._target.markAsDirty) {
  1690. this._target.markAsDirty(this._property);
  1691. }
  1692. };
  1693. /**
  1694. * Serializes the actions and its related information.
  1695. * @param parent defines the object to serialize in
  1696. * @returns the serialized object
  1697. */
  1698. SetValueAction.prototype.serialize = function (parent) {
  1699. return _super.prototype._serialize.call(this, {
  1700. name: "SetValueAction",
  1701. properties: [
  1702. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1703. { name: "propertyPath", value: this.propertyPath },
  1704. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1705. ]
  1706. }, parent);
  1707. };
  1708. return SetValueAction;
  1709. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1710. /**
  1711. * This defines an action responsible to increment the target value
  1712. * to a desired value once triggered.
  1713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1714. */
  1715. var IncrementValueAction = /** @class */ (function (_super) {
  1716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1717. /**
  1718. * Instantiate the action
  1719. * @param triggerOptions defines the trigger options
  1720. * @param target defines the object containing the property
  1721. * @param propertyPath defines the path of the property to increment in the target
  1722. * @param value defines the value value we should increment the property by
  1723. * @param condition defines the trigger related conditions
  1724. */
  1725. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1726. var _this = _super.call(this, triggerOptions, condition) || this;
  1727. _this.propertyPath = propertyPath;
  1728. _this.value = value;
  1729. _this._target = _this._effectiveTarget = target;
  1730. return _this;
  1731. }
  1732. /** @hidden */
  1733. IncrementValueAction.prototype._prepare = function () {
  1734. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1735. this._property = this._getProperty(this.propertyPath);
  1736. if (typeof this._effectiveTarget[this._property] !== "number") {
  1737. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1738. }
  1739. };
  1740. /**
  1741. * Execute the action and increment the target of the value amount.
  1742. */
  1743. IncrementValueAction.prototype.execute = function () {
  1744. this._effectiveTarget[this._property] += this.value;
  1745. if (this._target.markAsDirty) {
  1746. this._target.markAsDirty(this._property);
  1747. }
  1748. };
  1749. /**
  1750. * Serializes the actions and its related information.
  1751. * @param parent defines the object to serialize in
  1752. * @returns the serialized object
  1753. */
  1754. IncrementValueAction.prototype.serialize = function (parent) {
  1755. return _super.prototype._serialize.call(this, {
  1756. name: "IncrementValueAction",
  1757. properties: [
  1758. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1759. { name: "propertyPath", value: this.propertyPath },
  1760. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1761. ]
  1762. }, parent);
  1763. };
  1764. return IncrementValueAction;
  1765. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1766. /**
  1767. * This defines an action responsible to start an animation once triggered.
  1768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1769. */
  1770. var PlayAnimationAction = /** @class */ (function (_super) {
  1771. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1772. /**
  1773. * Instantiate the action
  1774. * @param triggerOptions defines the trigger options
  1775. * @param target defines the target animation or animation name
  1776. * @param from defines from where the animation should start (animation frame)
  1777. * @param end defines where the animation should stop (animation frame)
  1778. * @param loop defines if the animation should loop or stop after the first play
  1779. * @param condition defines the trigger related conditions
  1780. */
  1781. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1782. var _this = _super.call(this, triggerOptions, condition) || this;
  1783. _this.from = from;
  1784. _this.to = to;
  1785. _this.loop = loop;
  1786. _this._target = target;
  1787. return _this;
  1788. }
  1789. /** @hidden */
  1790. PlayAnimationAction.prototype._prepare = function () {
  1791. };
  1792. /**
  1793. * Execute the action and play the animation.
  1794. */
  1795. PlayAnimationAction.prototype.execute = function () {
  1796. var scene = this._actionManager.getScene();
  1797. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1798. };
  1799. /**
  1800. * Serializes the actions and its related information.
  1801. * @param parent defines the object to serialize in
  1802. * @returns the serialized object
  1803. */
  1804. PlayAnimationAction.prototype.serialize = function (parent) {
  1805. return _super.prototype._serialize.call(this, {
  1806. name: "PlayAnimationAction",
  1807. properties: [
  1808. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1809. { name: "from", value: String(this.from) },
  1810. { name: "to", value: String(this.to) },
  1811. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1812. ]
  1813. }, parent);
  1814. };
  1815. return PlayAnimationAction;
  1816. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1817. /**
  1818. * This defines an action responsible to stop an animation once triggered.
  1819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1820. */
  1821. var StopAnimationAction = /** @class */ (function (_super) {
  1822. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1823. /**
  1824. * Instantiate the action
  1825. * @param triggerOptions defines the trigger options
  1826. * @param target defines the target animation or animation name
  1827. * @param condition defines the trigger related conditions
  1828. */
  1829. function StopAnimationAction(triggerOptions, target, condition) {
  1830. var _this = _super.call(this, triggerOptions, condition) || this;
  1831. _this._target = target;
  1832. return _this;
  1833. }
  1834. /** @hidden */
  1835. StopAnimationAction.prototype._prepare = function () {
  1836. };
  1837. /**
  1838. * Execute the action and stop the animation.
  1839. */
  1840. StopAnimationAction.prototype.execute = function () {
  1841. var scene = this._actionManager.getScene();
  1842. scene.stopAnimation(this._target);
  1843. };
  1844. /**
  1845. * Serializes the actions and its related information.
  1846. * @param parent defines the object to serialize in
  1847. * @returns the serialized object
  1848. */
  1849. StopAnimationAction.prototype.serialize = function (parent) {
  1850. return _super.prototype._serialize.call(this, {
  1851. name: "StopAnimationAction",
  1852. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1853. }, parent);
  1854. };
  1855. return StopAnimationAction;
  1856. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1857. /**
  1858. * This defines an action responsible that does nothing once triggered.
  1859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1860. */
  1861. var DoNothingAction = /** @class */ (function (_super) {
  1862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1863. /**
  1864. * Instantiate the action
  1865. * @param triggerOptions defines the trigger options
  1866. * @param condition defines the trigger related conditions
  1867. */
  1868. function DoNothingAction(triggerOptions, condition) {
  1869. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1870. return _super.call(this, triggerOptions, condition) || this;
  1871. }
  1872. /**
  1873. * Execute the action and do nothing.
  1874. */
  1875. DoNothingAction.prototype.execute = function () {
  1876. };
  1877. /**
  1878. * Serializes the actions and its related information.
  1879. * @param parent defines the object to serialize in
  1880. * @returns the serialized object
  1881. */
  1882. DoNothingAction.prototype.serialize = function (parent) {
  1883. return _super.prototype._serialize.call(this, {
  1884. name: "DoNothingAction",
  1885. properties: []
  1886. }, parent);
  1887. };
  1888. return DoNothingAction;
  1889. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1890. /**
  1891. * This defines an action responsible to trigger several actions once triggered.
  1892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1893. */
  1894. var CombineAction = /** @class */ (function (_super) {
  1895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1896. /**
  1897. * Instantiate the action
  1898. * @param triggerOptions defines the trigger options
  1899. * @param children defines the list of aggregated animations to run
  1900. * @param condition defines the trigger related conditions
  1901. */
  1902. function CombineAction(triggerOptions, children, condition) {
  1903. var _this = _super.call(this, triggerOptions, condition) || this;
  1904. _this.children = children;
  1905. return _this;
  1906. }
  1907. /** @hidden */
  1908. CombineAction.prototype._prepare = function () {
  1909. for (var index = 0; index < this.children.length; index++) {
  1910. this.children[index]._actionManager = this._actionManager;
  1911. this.children[index]._prepare();
  1912. }
  1913. };
  1914. /**
  1915. * Execute the action and executes all the aggregated actions.
  1916. */
  1917. CombineAction.prototype.execute = function (evt) {
  1918. for (var index = 0; index < this.children.length; index++) {
  1919. this.children[index].execute(evt);
  1920. }
  1921. };
  1922. /**
  1923. * Serializes the actions and its related information.
  1924. * @param parent defines the object to serialize in
  1925. * @returns the serialized object
  1926. */
  1927. CombineAction.prototype.serialize = function (parent) {
  1928. var serializationObject = _super.prototype._serialize.call(this, {
  1929. name: "CombineAction",
  1930. properties: [],
  1931. combine: []
  1932. }, parent);
  1933. for (var i = 0; i < this.children.length; i++) {
  1934. serializationObject.combine.push(this.children[i].serialize(null));
  1935. }
  1936. return serializationObject;
  1937. };
  1938. return CombineAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to run code (external event) once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var ExecuteCodeAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param func defines the callback function to run
  1950. * @param condition defines the trigger related conditions
  1951. */
  1952. function ExecuteCodeAction(triggerOptions, func, condition) {
  1953. var _this = _super.call(this, triggerOptions, condition) || this;
  1954. _this.func = func;
  1955. return _this;
  1956. }
  1957. /**
  1958. * Execute the action and run the attached code.
  1959. */
  1960. ExecuteCodeAction.prototype.execute = function (evt) {
  1961. this.func(evt);
  1962. };
  1963. return ExecuteCodeAction;
  1964. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1965. /**
  1966. * This defines an action responsible to set the parent property of the target once triggered.
  1967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1968. */
  1969. var SetParentAction = /** @class */ (function (_super) {
  1970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1971. /**
  1972. * Instantiate the action
  1973. * @param triggerOptions defines the trigger options
  1974. * @param target defines the target containing the parent property
  1975. * @param parent defines from where the animation should start (animation frame)
  1976. * @param condition defines the trigger related conditions
  1977. */
  1978. function SetParentAction(triggerOptions, target, parent, condition) {
  1979. var _this = _super.call(this, triggerOptions, condition) || this;
  1980. _this._target = target;
  1981. _this._parent = parent;
  1982. return _this;
  1983. }
  1984. /** @hidden */
  1985. SetParentAction.prototype._prepare = function () {
  1986. };
  1987. /**
  1988. * Execute the action and set the parent property.
  1989. */
  1990. SetParentAction.prototype.execute = function () {
  1991. if (this._target.parent === this._parent) {
  1992. return;
  1993. }
  1994. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1995. invertParentWorldMatrix.invert();
  1996. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1997. this._target.parent = this._parent;
  1998. };
  1999. /**
  2000. * Serializes the actions and its related information.
  2001. * @param parent defines the object to serialize in
  2002. * @returns the serialized object
  2003. */
  2004. SetParentAction.prototype.serialize = function (parent) {
  2005. return _super.prototype._serialize.call(this, {
  2006. name: "SetParentAction",
  2007. properties: [
  2008. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2009. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2010. ]
  2011. }, parent);
  2012. };
  2013. return SetParentAction;
  2014. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2016. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2017. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2018. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2024. /***/ }),
  2025. /***/ "./Actions/directAudioActions.ts":
  2026. /*!***************************************!*\
  2027. !*** ./Actions/directAudioActions.ts ***!
  2028. \***************************************/
  2029. /*! exports provided: PlaySoundAction, StopSoundAction */
  2030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2031. "use strict";
  2032. __webpack_require__.r(__webpack_exports__);
  2033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2036. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2037. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2038. /**
  2039. * This defines an action helpful to play a defined sound on a triggered action.
  2040. */
  2041. var PlaySoundAction = /** @class */ (function (_super) {
  2042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2043. /**
  2044. * Instantiate the action
  2045. * @param triggerOptions defines the trigger options
  2046. * @param sound defines the sound to play
  2047. * @param condition defines the trigger related conditions
  2048. */
  2049. function PlaySoundAction(triggerOptions, sound, condition) {
  2050. var _this = _super.call(this, triggerOptions, condition) || this;
  2051. _this._sound = sound;
  2052. return _this;
  2053. }
  2054. /** @hidden */
  2055. PlaySoundAction.prototype._prepare = function () {
  2056. };
  2057. /**
  2058. * Execute the action and play the sound.
  2059. */
  2060. PlaySoundAction.prototype.execute = function () {
  2061. if (this._sound !== undefined) {
  2062. this._sound.play();
  2063. }
  2064. };
  2065. /**
  2066. * Serializes the actions and its related information.
  2067. * @param parent defines the object to serialize in
  2068. * @returns the serialized object
  2069. */
  2070. PlaySoundAction.prototype.serialize = function (parent) {
  2071. return _super.prototype._serialize.call(this, {
  2072. name: "PlaySoundAction",
  2073. properties: [{ name: "sound", value: this._sound.name }]
  2074. }, parent);
  2075. };
  2076. return PlaySoundAction;
  2077. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2078. /**
  2079. * This defines an action helpful to stop a defined sound on a triggered action.
  2080. */
  2081. var StopSoundAction = /** @class */ (function (_super) {
  2082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2083. /**
  2084. * Instantiate the action
  2085. * @param triggerOptions defines the trigger options
  2086. * @param sound defines the sound to stop
  2087. * @param condition defines the trigger related conditions
  2088. */
  2089. function StopSoundAction(triggerOptions, sound, condition) {
  2090. var _this = _super.call(this, triggerOptions, condition) || this;
  2091. _this._sound = sound;
  2092. return _this;
  2093. }
  2094. /** @hidden */
  2095. StopSoundAction.prototype._prepare = function () {
  2096. };
  2097. /**
  2098. * Execute the action and stop the sound.
  2099. */
  2100. StopSoundAction.prototype.execute = function () {
  2101. if (this._sound !== undefined) {
  2102. this._sound.stop();
  2103. }
  2104. };
  2105. /**
  2106. * Serializes the actions and its related information.
  2107. * @param parent defines the object to serialize in
  2108. * @returns the serialized object
  2109. */
  2110. StopSoundAction.prototype.serialize = function (parent) {
  2111. return _super.prototype._serialize.call(this, {
  2112. name: "StopSoundAction",
  2113. properties: [{ name: "sound", value: this._sound.name }]
  2114. }, parent);
  2115. };
  2116. return StopSoundAction;
  2117. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2118. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2119. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2120. /***/ }),
  2121. /***/ "./Actions/index.ts":
  2122. /*!**************************!*\
  2123. !*** ./Actions/index.ts ***!
  2124. \**************************/
  2125. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2127. "use strict";
  2128. __webpack_require__.r(__webpack_exports__);
  2129. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2131. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2133. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2135. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2140. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2151. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2154. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2156. /***/ }),
  2157. /***/ "./Actions/interpolateValueAction.ts":
  2158. /*!*******************************************!*\
  2159. !*** ./Actions/interpolateValueAction.ts ***!
  2160. \*******************************************/
  2161. /*! exports provided: InterpolateValueAction */
  2162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2163. "use strict";
  2164. __webpack_require__.r(__webpack_exports__);
  2165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2167. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2168. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2169. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2171. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2172. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2173. /**
  2174. * This defines an action responsible to change the value of a property
  2175. * by interpolating between its current value and the newly set one once triggered.
  2176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2177. */
  2178. var InterpolateValueAction = /** @class */ (function (_super) {
  2179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2180. /**
  2181. * Instantiate the action
  2182. * @param triggerOptions defines the trigger options
  2183. * @param target defines the object containing the value to interpolate
  2184. * @param propertyPath defines the path to the property in the target object
  2185. * @param value defines the target value at the end of the interpolation
  2186. * @param duration deines the time it will take for the property to interpolate to the value.
  2187. * @param condition defines the trigger related conditions
  2188. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2189. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2190. */
  2191. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2192. if (duration === void 0) { duration = 1000; }
  2193. var _this = _super.call(this, triggerOptions, condition) || this;
  2194. /**
  2195. * Defines the time it will take for the property to interpolate to the value.
  2196. */
  2197. _this.duration = 1000;
  2198. /**
  2199. * Observable triggered once the interpolation animation has been done.
  2200. */
  2201. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2202. _this.propertyPath = propertyPath;
  2203. _this.value = value;
  2204. _this.duration = duration;
  2205. _this.stopOtherAnimations = stopOtherAnimations;
  2206. _this.onInterpolationDone = onInterpolationDone;
  2207. _this._target = _this._effectiveTarget = target;
  2208. return _this;
  2209. }
  2210. /** @hidden */
  2211. InterpolateValueAction.prototype._prepare = function () {
  2212. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2213. this._property = this._getProperty(this.propertyPath);
  2214. };
  2215. /**
  2216. * Execute the action starts the value interpolation.
  2217. */
  2218. InterpolateValueAction.prototype.execute = function () {
  2219. var _this = this;
  2220. var scene = this._actionManager.getScene();
  2221. var keys = [
  2222. {
  2223. frame: 0,
  2224. value: this._effectiveTarget[this._property]
  2225. }, {
  2226. frame: 100,
  2227. value: this.value
  2228. }
  2229. ];
  2230. var dataType;
  2231. if (typeof this.value === "number") {
  2232. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2233. }
  2234. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2235. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2236. }
  2237. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2238. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2239. }
  2240. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2241. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2242. }
  2243. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2244. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2245. }
  2246. else {
  2247. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2248. return;
  2249. }
  2250. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2251. animation.setKeys(keys);
  2252. if (this.stopOtherAnimations) {
  2253. scene.stopAnimation(this._effectiveTarget);
  2254. }
  2255. var wrapper = function () {
  2256. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2257. if (_this.onInterpolationDone) {
  2258. _this.onInterpolationDone();
  2259. }
  2260. };
  2261. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2262. };
  2263. /**
  2264. * Serializes the actions and its related information.
  2265. * @param parent defines the object to serialize in
  2266. * @returns the serialized object
  2267. */
  2268. InterpolateValueAction.prototype.serialize = function (parent) {
  2269. return _super.prototype._serialize.call(this, {
  2270. name: "InterpolateValueAction",
  2271. properties: [
  2272. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2273. { name: "propertyPath", value: this.propertyPath },
  2274. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2275. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2276. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2277. ]
  2278. }, parent);
  2279. };
  2280. return InterpolateValueAction;
  2281. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2282. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2283. /***/ }),
  2284. /***/ "./Animations/animatable.ts":
  2285. /*!**********************************!*\
  2286. !*** ./Animations/animatable.ts ***!
  2287. \**********************************/
  2288. /*! exports provided: Animatable */
  2289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2290. "use strict";
  2291. __webpack_require__.r(__webpack_exports__);
  2292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2293. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2294. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2295. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2296. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2298. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2299. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2300. /**
  2301. * Class used to store an actual running animation
  2302. */
  2303. var Animatable = /** @class */ (function () {
  2304. /**
  2305. * Creates a new Animatable
  2306. * @param scene defines the hosting scene
  2307. * @param target defines the target object
  2308. * @param fromFrame defines the starting frame number (default is 0)
  2309. * @param toFrame defines the ending frame number (default is 100)
  2310. * @param loopAnimation defines if the animation must loop (default is false)
  2311. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2312. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2313. * @param animations defines a group of animation to add to the new Animatable
  2314. * @param onAnimationLoop defines a callback to call when animation loops
  2315. */
  2316. function Animatable(scene,
  2317. /** defines the target object */
  2318. target,
  2319. /** defines the starting frame number (default is 0) */
  2320. fromFrame,
  2321. /** defines the ending frame number (default is 100) */
  2322. toFrame,
  2323. /** defines if the animation must loop (default is false) */
  2324. loopAnimation, speedRatio,
  2325. /** defines a callback to call when animation ends if it is not looping */
  2326. onAnimationEnd, animations,
  2327. /** defines a callback to call when animation loops */
  2328. onAnimationLoop) {
  2329. if (fromFrame === void 0) { fromFrame = 0; }
  2330. if (toFrame === void 0) { toFrame = 100; }
  2331. if (loopAnimation === void 0) { loopAnimation = false; }
  2332. if (speedRatio === void 0) { speedRatio = 1.0; }
  2333. this.target = target;
  2334. this.fromFrame = fromFrame;
  2335. this.toFrame = toFrame;
  2336. this.loopAnimation = loopAnimation;
  2337. this.onAnimationEnd = onAnimationEnd;
  2338. this.onAnimationLoop = onAnimationLoop;
  2339. this._localDelayOffset = null;
  2340. this._pausedDelay = null;
  2341. this._runtimeAnimations = new Array();
  2342. this._paused = false;
  2343. this._speedRatio = 1;
  2344. this._weight = -1.0;
  2345. /**
  2346. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2347. * This will only apply for non looping animation (default is true)
  2348. */
  2349. this.disposeOnEnd = true;
  2350. /**
  2351. * Gets a boolean indicating if the animation has started
  2352. */
  2353. this.animationStarted = false;
  2354. /**
  2355. * Observer raised when the animation ends
  2356. */
  2357. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2358. /**
  2359. * Observer raised when the animation loops
  2360. */
  2361. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. this._scene = scene;
  2363. if (animations) {
  2364. this.appendAnimations(target, animations);
  2365. }
  2366. this._speedRatio = speedRatio;
  2367. scene._activeAnimatables.push(this);
  2368. }
  2369. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2370. /**
  2371. * Gets the root Animatable used to synchronize and normalize animations
  2372. */
  2373. get: function () {
  2374. return this._syncRoot;
  2375. },
  2376. enumerable: true,
  2377. configurable: true
  2378. });
  2379. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2380. /**
  2381. * Gets the current frame of the first RuntimeAnimation
  2382. * Used to synchronize Animatables
  2383. */
  2384. get: function () {
  2385. if (this._runtimeAnimations.length === 0) {
  2386. return 0;
  2387. }
  2388. return this._runtimeAnimations[0].currentFrame;
  2389. },
  2390. enumerable: true,
  2391. configurable: true
  2392. });
  2393. Object.defineProperty(Animatable.prototype, "weight", {
  2394. /**
  2395. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2396. */
  2397. get: function () {
  2398. return this._weight;
  2399. },
  2400. set: function (value) {
  2401. if (value === -1) { // -1 is ok and means no weight
  2402. this._weight = -1;
  2403. return;
  2404. }
  2405. // Else weight must be in [0, 1] range
  2406. this._weight = Math.min(Math.max(value, 0), 1.0);
  2407. },
  2408. enumerable: true,
  2409. configurable: true
  2410. });
  2411. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2412. /**
  2413. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2414. */
  2415. get: function () {
  2416. return this._speedRatio;
  2417. },
  2418. set: function (value) {
  2419. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2420. var animation = this._runtimeAnimations[index];
  2421. animation._prepareForSpeedRatioChange(value);
  2422. }
  2423. this._speedRatio = value;
  2424. },
  2425. enumerable: true,
  2426. configurable: true
  2427. });
  2428. // Methods
  2429. /**
  2430. * Synchronize and normalize current Animatable with a source Animatable
  2431. * This is useful when using animation weights and when animations are not of the same length
  2432. * @param root defines the root Animatable to synchronize with
  2433. * @returns the current Animatable
  2434. */
  2435. Animatable.prototype.syncWith = function (root) {
  2436. this._syncRoot = root;
  2437. if (root) {
  2438. // Make sure this animatable will animate after the root
  2439. var index = this._scene._activeAnimatables.indexOf(this);
  2440. if (index > -1) {
  2441. this._scene._activeAnimatables.splice(index, 1);
  2442. this._scene._activeAnimatables.push(this);
  2443. }
  2444. }
  2445. return this;
  2446. };
  2447. /**
  2448. * Gets the list of runtime animations
  2449. * @returns an array of RuntimeAnimation
  2450. */
  2451. Animatable.prototype.getAnimations = function () {
  2452. return this._runtimeAnimations;
  2453. };
  2454. /**
  2455. * Adds more animations to the current animatable
  2456. * @param target defines the target of the animations
  2457. * @param animations defines the new animations to add
  2458. */
  2459. Animatable.prototype.appendAnimations = function (target, animations) {
  2460. for (var index = 0; index < animations.length; index++) {
  2461. var animation = animations[index];
  2462. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2463. }
  2464. };
  2465. /**
  2466. * Gets the source animation for a specific property
  2467. * @param property defines the propertyu to look for
  2468. * @returns null or the source animation for the given property
  2469. */
  2470. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2471. var runtimeAnimations = this._runtimeAnimations;
  2472. for (var index = 0; index < runtimeAnimations.length; index++) {
  2473. if (runtimeAnimations[index].animation.targetProperty === property) {
  2474. return runtimeAnimations[index].animation;
  2475. }
  2476. }
  2477. return null;
  2478. };
  2479. /**
  2480. * Gets the runtime animation for a specific property
  2481. * @param property defines the propertyu to look for
  2482. * @returns null or the runtime animation for the given property
  2483. */
  2484. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2485. var runtimeAnimations = this._runtimeAnimations;
  2486. for (var index = 0; index < runtimeAnimations.length; index++) {
  2487. if (runtimeAnimations[index].animation.targetProperty === property) {
  2488. return runtimeAnimations[index];
  2489. }
  2490. }
  2491. return null;
  2492. };
  2493. /**
  2494. * Resets the animatable to its original state
  2495. */
  2496. Animatable.prototype.reset = function () {
  2497. var runtimeAnimations = this._runtimeAnimations;
  2498. for (var index = 0; index < runtimeAnimations.length; index++) {
  2499. runtimeAnimations[index].reset(true);
  2500. }
  2501. this._localDelayOffset = null;
  2502. this._pausedDelay = null;
  2503. };
  2504. /**
  2505. * Allows the animatable to blend with current running animations
  2506. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2507. * @param blendingSpeed defines the blending speed to use
  2508. */
  2509. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2510. var runtimeAnimations = this._runtimeAnimations;
  2511. for (var index = 0; index < runtimeAnimations.length; index++) {
  2512. runtimeAnimations[index].animation.enableBlending = true;
  2513. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2514. }
  2515. };
  2516. /**
  2517. * Disable animation blending
  2518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2519. */
  2520. Animatable.prototype.disableBlending = function () {
  2521. var runtimeAnimations = this._runtimeAnimations;
  2522. for (var index = 0; index < runtimeAnimations.length; index++) {
  2523. runtimeAnimations[index].animation.enableBlending = false;
  2524. }
  2525. };
  2526. /**
  2527. * Jump directly to a given frame
  2528. * @param frame defines the frame to jump to
  2529. */
  2530. Animatable.prototype.goToFrame = function (frame) {
  2531. var runtimeAnimations = this._runtimeAnimations;
  2532. if (runtimeAnimations[0]) {
  2533. var fps = runtimeAnimations[0].animation.framePerSecond;
  2534. var currentFrame = runtimeAnimations[0].currentFrame;
  2535. var adjustTime = frame - currentFrame;
  2536. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2537. if (this._localDelayOffset === null) {
  2538. this._localDelayOffset = 0;
  2539. }
  2540. this._localDelayOffset -= delay;
  2541. }
  2542. for (var index = 0; index < runtimeAnimations.length; index++) {
  2543. runtimeAnimations[index].goToFrame(frame);
  2544. }
  2545. };
  2546. /**
  2547. * Pause the animation
  2548. */
  2549. Animatable.prototype.pause = function () {
  2550. if (this._paused) {
  2551. return;
  2552. }
  2553. this._paused = true;
  2554. };
  2555. /**
  2556. * Restart the animation
  2557. */
  2558. Animatable.prototype.restart = function () {
  2559. this._paused = false;
  2560. };
  2561. Animatable.prototype._raiseOnAnimationEnd = function () {
  2562. if (this.onAnimationEnd) {
  2563. this.onAnimationEnd();
  2564. }
  2565. this.onAnimationEndObservable.notifyObservers(this);
  2566. };
  2567. /**
  2568. * Stop and delete the current animation
  2569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2570. * @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)
  2571. */
  2572. Animatable.prototype.stop = function (animationName, targetMask) {
  2573. if (animationName || targetMask) {
  2574. var idx = this._scene._activeAnimatables.indexOf(this);
  2575. if (idx > -1) {
  2576. var runtimeAnimations = this._runtimeAnimations;
  2577. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2578. var runtimeAnimation = runtimeAnimations[index];
  2579. if (animationName && runtimeAnimation.animation.name != animationName) {
  2580. continue;
  2581. }
  2582. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2583. continue;
  2584. }
  2585. runtimeAnimation.dispose();
  2586. runtimeAnimations.splice(index, 1);
  2587. }
  2588. if (runtimeAnimations.length == 0) {
  2589. this._scene._activeAnimatables.splice(idx, 1);
  2590. this._raiseOnAnimationEnd();
  2591. }
  2592. }
  2593. }
  2594. else {
  2595. var index = this._scene._activeAnimatables.indexOf(this);
  2596. if (index > -1) {
  2597. this._scene._activeAnimatables.splice(index, 1);
  2598. var runtimeAnimations = this._runtimeAnimations;
  2599. for (var index = 0; index < runtimeAnimations.length; index++) {
  2600. runtimeAnimations[index].dispose();
  2601. }
  2602. this._raiseOnAnimationEnd();
  2603. }
  2604. }
  2605. };
  2606. /**
  2607. * Wait asynchronously for the animation to end
  2608. * @returns a promise which will be fullfilled when the animation ends
  2609. */
  2610. Animatable.prototype.waitAsync = function () {
  2611. var _this = this;
  2612. return new Promise(function (resolve, reject) {
  2613. _this.onAnimationEndObservable.add(function () {
  2614. resolve(_this);
  2615. }, undefined, undefined, _this, true);
  2616. });
  2617. };
  2618. /** @hidden */
  2619. Animatable.prototype._animate = function (delay) {
  2620. var _this = this;
  2621. if (this._paused) {
  2622. this.animationStarted = false;
  2623. if (this._pausedDelay === null) {
  2624. this._pausedDelay = delay;
  2625. }
  2626. return true;
  2627. }
  2628. if (this._localDelayOffset === null) {
  2629. this._localDelayOffset = delay;
  2630. this._pausedDelay = null;
  2631. }
  2632. else if (this._pausedDelay !== null) {
  2633. this._localDelayOffset += delay - this._pausedDelay;
  2634. this._pausedDelay = null;
  2635. }
  2636. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2637. return true;
  2638. }
  2639. // Animating
  2640. var running = false;
  2641. var runtimeAnimations = this._runtimeAnimations;
  2642. var index;
  2643. for (index = 0; index < runtimeAnimations.length; index++) {
  2644. var animation = runtimeAnimations[index];
  2645. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2646. _this.onAnimationLoopObservable.notifyObservers(_this);
  2647. if (_this.onAnimationLoop) {
  2648. _this.onAnimationLoop();
  2649. }
  2650. });
  2651. running = running || isRunning;
  2652. }
  2653. this.animationStarted = running;
  2654. if (!running) {
  2655. if (this.disposeOnEnd) {
  2656. // Remove from active animatables
  2657. index = this._scene._activeAnimatables.indexOf(this);
  2658. this._scene._activeAnimatables.splice(index, 1);
  2659. // Dispose all runtime animations
  2660. for (index = 0; index < runtimeAnimations.length; index++) {
  2661. runtimeAnimations[index].dispose();
  2662. }
  2663. }
  2664. this._raiseOnAnimationEnd();
  2665. if (this.disposeOnEnd) {
  2666. this.onAnimationEnd = null;
  2667. this.onAnimationLoop = null;
  2668. this.onAnimationLoopObservable.clear();
  2669. this.onAnimationEndObservable.clear();
  2670. }
  2671. }
  2672. return running;
  2673. };
  2674. return Animatable;
  2675. }());
  2676. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2677. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2678. return;
  2679. }
  2680. // Getting time
  2681. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2682. if (!this._animationTimeLast) {
  2683. if (this._pendingData.length > 0) {
  2684. return;
  2685. }
  2686. this._animationTimeLast = now;
  2687. }
  2688. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2689. this._animationTime += deltaTime;
  2690. this._animationTimeLast = now;
  2691. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2692. this._activeAnimatables[index]._animate(this._animationTime);
  2693. }
  2694. // Late animation bindings
  2695. this._processLateAnimationBindings();
  2696. };
  2697. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2698. if (weight === void 0) { weight = 1.0; }
  2699. if (speedRatio === void 0) { speedRatio = 1.0; }
  2700. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2701. returnedAnimatable.weight = weight;
  2702. return returnedAnimatable;
  2703. };
  2704. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2705. if (speedRatio === void 0) { speedRatio = 1.0; }
  2706. if (stopCurrent === void 0) { stopCurrent = true; }
  2707. if (from > to && speedRatio > 0) {
  2708. speedRatio *= -1;
  2709. }
  2710. if (stopCurrent) {
  2711. this.stopAnimation(target, undefined, targetMask);
  2712. }
  2713. if (!animatable) {
  2714. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2715. }
  2716. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2717. // Local animations
  2718. if (target.animations && shouldRunTargetAnimations) {
  2719. animatable.appendAnimations(target, target.animations);
  2720. }
  2721. // Children animations
  2722. if (target.getAnimatables) {
  2723. var animatables = target.getAnimatables();
  2724. for (var index = 0; index < animatables.length; index++) {
  2725. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2726. }
  2727. }
  2728. animatable.reset();
  2729. return animatable;
  2730. };
  2731. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2732. if (speedRatio === void 0) { speedRatio = 1.0; }
  2733. if (stopCurrent === void 0) { stopCurrent = true; }
  2734. var children = target.getDescendants(directDescendantsOnly);
  2735. var result = [];
  2736. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2737. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2738. var child = children_1[_i];
  2739. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2740. }
  2741. return result;
  2742. };
  2743. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2744. if (speedRatio === undefined) {
  2745. speedRatio = 1.0;
  2746. }
  2747. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2748. return animatable;
  2749. };
  2750. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2751. var children = target.getDescendants(directDescendantsOnly);
  2752. var result = [];
  2753. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2754. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2755. var child = children_2[_i];
  2756. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2757. }
  2758. return result;
  2759. };
  2760. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2761. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2762. if (this._activeAnimatables[index].target === target) {
  2763. return this._activeAnimatables[index];
  2764. }
  2765. }
  2766. return null;
  2767. };
  2768. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2769. var result = [];
  2770. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2771. if (this._activeAnimatables[index].target === target) {
  2772. result.push(this._activeAnimatables[index]);
  2773. }
  2774. }
  2775. return result;
  2776. };
  2777. /**
  2778. * Will stop the animation of the given target
  2779. * @param target - the target
  2780. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2781. * @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)
  2782. */
  2783. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2784. var animatables = this.getAllAnimatablesByTarget(target);
  2785. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2786. var animatable = animatables_1[_i];
  2787. animatable.stop(animationName, targetMask);
  2788. }
  2789. };
  2790. /**
  2791. * Stops and removes all animations that have been applied to the scene
  2792. */
  2793. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2794. if (this._activeAnimatables) {
  2795. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2796. this._activeAnimatables[i].stop();
  2797. }
  2798. this._activeAnimatables = [];
  2799. }
  2800. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2801. var group = _a[_i];
  2802. group.stop();
  2803. }
  2804. };
  2805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2806. var target = runtimeAnimation.target;
  2807. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2808. if (!target._lateAnimationHolders) {
  2809. target._lateAnimationHolders = {};
  2810. }
  2811. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2812. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2813. totalWeight: 0,
  2814. animations: [],
  2815. originalValue: originalValue
  2816. };
  2817. }
  2818. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2819. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2820. };
  2821. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2822. var normalizer = 1.0;
  2823. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2824. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2825. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2826. var startIndex = 0;
  2827. var originalAnimation = holder.animations[0];
  2828. var originalValue = holder.originalValue;
  2829. var scale = 1;
  2830. if (holder.totalWeight < 1.0) {
  2831. // We need to mix the original value in
  2832. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2833. scale = 1.0 - holder.totalWeight;
  2834. }
  2835. else {
  2836. startIndex = 1;
  2837. // We need to normalize the weights
  2838. normalizer = holder.totalWeight;
  2839. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2840. scale = originalAnimation.weight / normalizer;
  2841. if (scale == 1) {
  2842. return originalAnimation.currentValue;
  2843. }
  2844. }
  2845. finalScaling.scaleInPlace(scale);
  2846. finalPosition.scaleInPlace(scale);
  2847. finalQuaternion.scaleInPlace(scale);
  2848. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2849. var runtimeAnimation = holder.animations[animIndex];
  2850. var scale = runtimeAnimation.weight / normalizer;
  2851. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2852. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2853. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2854. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2855. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2856. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2857. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2858. }
  2859. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2860. return originalAnimation._workValue;
  2861. };
  2862. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2863. var originalAnimation = holder.animations[0];
  2864. var originalValue = holder.originalValue;
  2865. if (holder.animations.length === 1) {
  2866. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2867. return refQuaternion;
  2868. }
  2869. var normalizer = 1.0;
  2870. var quaternions;
  2871. var weights;
  2872. if (holder.totalWeight < 1.0) {
  2873. var scale = 1.0 - holder.totalWeight;
  2874. quaternions = [];
  2875. weights = [];
  2876. quaternions.push(originalValue);
  2877. weights.push(scale);
  2878. }
  2879. else {
  2880. if (holder.animations.length === 2) { // Slerp as soon as we can
  2881. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2882. return refQuaternion;
  2883. }
  2884. quaternions = [];
  2885. weights = [];
  2886. normalizer = holder.totalWeight;
  2887. }
  2888. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2889. var runtimeAnimation = holder.animations[animIndex];
  2890. quaternions.push(runtimeAnimation.currentValue);
  2891. weights.push(runtimeAnimation.weight / normalizer);
  2892. }
  2893. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2894. var cumulativeAmount = 0;
  2895. var cumulativeQuaternion = null;
  2896. for (var index = 0; index < quaternions.length;) {
  2897. if (!cumulativeQuaternion) {
  2898. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2899. cumulativeQuaternion = refQuaternion;
  2900. cumulativeAmount = weights[index] + weights[index + 1];
  2901. index += 2;
  2902. continue;
  2903. }
  2904. cumulativeAmount += weights[index];
  2905. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2906. index++;
  2907. }
  2908. return cumulativeQuaternion;
  2909. };
  2910. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2911. if (!this._registeredForLateAnimationBindings.length) {
  2912. return;
  2913. }
  2914. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2915. var target = this._registeredForLateAnimationBindings.data[index];
  2916. for (var path in target._lateAnimationHolders) {
  2917. var holder = target._lateAnimationHolders[path];
  2918. var originalAnimation = holder.animations[0];
  2919. var originalValue = holder.originalValue;
  2920. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2921. var finalValue = target[path];
  2922. if (matrixDecomposeMode) {
  2923. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2924. }
  2925. else {
  2926. var quaternionMode = originalValue.w !== undefined;
  2927. if (quaternionMode) {
  2928. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2929. }
  2930. else {
  2931. var startIndex = 0;
  2932. var normalizer = 1.0;
  2933. if (holder.totalWeight < 1.0) {
  2934. // We need to mix the original value in
  2935. if (originalValue.scale) {
  2936. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2937. }
  2938. else {
  2939. finalValue = originalValue * (1.0 - holder.totalWeight);
  2940. }
  2941. }
  2942. else {
  2943. // We need to normalize the weights
  2944. normalizer = holder.totalWeight;
  2945. var scale_1 = originalAnimation.weight / normalizer;
  2946. if (scale_1 !== 1) {
  2947. if (originalAnimation.currentValue.scale) {
  2948. finalValue = originalAnimation.currentValue.scale(scale_1);
  2949. }
  2950. else {
  2951. finalValue = originalAnimation.currentValue * scale_1;
  2952. }
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue;
  2956. }
  2957. startIndex = 1;
  2958. }
  2959. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2960. var runtimeAnimation = holder.animations[animIndex];
  2961. var scale = runtimeAnimation.weight / normalizer;
  2962. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2963. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2964. }
  2965. else {
  2966. finalValue += runtimeAnimation.currentValue * scale;
  2967. }
  2968. }
  2969. }
  2970. }
  2971. target[path] = finalValue;
  2972. }
  2973. target._lateAnimationHolders = {};
  2974. }
  2975. this._registeredForLateAnimationBindings.reset();
  2976. };
  2977. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2978. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2979. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2980. // all animation may be coming from a library skeleton, so may need to create animation
  2981. if (this.animations.length === 0) {
  2982. 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));
  2983. this.animations[0].setKeys([]);
  2984. }
  2985. // get animation info / verify there is such a range from the source bone
  2986. var sourceRange = source.animations[0].getRange(rangeName);
  2987. if (!sourceRange) {
  2988. return false;
  2989. }
  2990. var from = sourceRange.from;
  2991. var to = sourceRange.to;
  2992. var sourceKeys = source.animations[0].getKeys();
  2993. // rescaling prep
  2994. var sourceBoneLength = source.length;
  2995. var sourceParent = source.getParent();
  2996. var parent = this.getParent();
  2997. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  2998. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  2999. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3000. var destKeys = this.animations[0].getKeys();
  3001. // loop vars declaration
  3002. var orig;
  3003. var origTranslation;
  3004. var mat;
  3005. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3006. orig = sourceKeys[key];
  3007. if (orig.frame >= from && orig.frame <= to) {
  3008. if (rescaleAsRequired) {
  3009. mat = orig.value.clone();
  3010. // scale based on parent ratio, when bone has parent
  3011. if (parentScalingReqd) {
  3012. origTranslation = mat.getTranslation();
  3013. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3014. // scale based on skeleton dimension ratio when root bone, and value is passed
  3015. }
  3016. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3017. origTranslation = mat.getTranslation();
  3018. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3019. // use original when root bone, and no data for skelDimensionsRatio
  3020. }
  3021. else {
  3022. mat = orig.value;
  3023. }
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3029. }
  3030. }
  3031. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3032. return true;
  3033. };
  3034. /***/ }),
  3035. /***/ "./Animations/animation.ts":
  3036. /*!*********************************!*\
  3037. !*** ./Animations/animation.ts ***!
  3038. \*********************************/
  3039. /*! exports provided: Animation */
  3040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3041. "use strict";
  3042. __webpack_require__.r(__webpack_exports__);
  3043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3044. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3045. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3046. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3047. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3048. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3049. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3050. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3051. /**
  3052. * Class used to store any kind of animation
  3053. */
  3054. var Animation = /** @class */ (function () {
  3055. /**
  3056. * Initializes the animation
  3057. * @param name Name of the animation
  3058. * @param targetProperty Property to animate
  3059. * @param framePerSecond The frames per second of the animation
  3060. * @param dataType The data type of the animation
  3061. * @param loopMode The loop mode of the animation
  3062. * @param enableBlending Specifies if blending should be enabled
  3063. */
  3064. function Animation(
  3065. /**Name of the animation */
  3066. name,
  3067. /**Property to animate */
  3068. targetProperty,
  3069. /**The frames per second of the animation */
  3070. framePerSecond,
  3071. /**The data type of the animation */
  3072. dataType,
  3073. /**The loop mode of the animation */
  3074. loopMode,
  3075. /**Specifies if blending should be enabled */
  3076. enableBlending) {
  3077. this.name = name;
  3078. this.targetProperty = targetProperty;
  3079. this.framePerSecond = framePerSecond;
  3080. this.dataType = dataType;
  3081. this.loopMode = loopMode;
  3082. this.enableBlending = enableBlending;
  3083. /**
  3084. * @hidden Internal use only
  3085. */
  3086. this._runtimeAnimations = new Array();
  3087. /**
  3088. * The set of event that will be linked to this animation
  3089. */
  3090. this._events = new Array();
  3091. /**
  3092. * Stores the blending speed of the animation
  3093. */
  3094. this.blendingSpeed = 0.01;
  3095. /**
  3096. * Stores the animation ranges for the animation
  3097. */
  3098. this._ranges = {};
  3099. this.targetPropertyPath = targetProperty.split(".");
  3100. this.dataType = dataType;
  3101. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3102. }
  3103. /**
  3104. * @hidden Internal use
  3105. */
  3106. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3107. var dataType = undefined;
  3108. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3109. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3110. }
  3111. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3112. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3113. }
  3114. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3115. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3116. }
  3117. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3118. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3119. }
  3120. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3121. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3122. }
  3123. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3124. dataType = Animation.ANIMATIONTYPE_SIZE;
  3125. }
  3126. if (dataType == undefined) {
  3127. return null;
  3128. }
  3129. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3130. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3131. animation.setKeys(keys);
  3132. if (easingFunction !== undefined) {
  3133. animation.setEasingFunction(easingFunction);
  3134. }
  3135. return animation;
  3136. };
  3137. /**
  3138. * Sets up an animation
  3139. * @param property The property to animate
  3140. * @param animationType The animation type to apply
  3141. * @param framePerSecond The frames per second of the animation
  3142. * @param easingFunction The easing function used in the animation
  3143. * @returns The created animation
  3144. */
  3145. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3146. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3147. animation.setEasingFunction(easingFunction);
  3148. return animation;
  3149. };
  3150. /**
  3151. * Create and start an animation on a node
  3152. * @param name defines the name of the global animation that will be run on all nodes
  3153. * @param node defines the root node where the animation will take place
  3154. * @param targetProperty defines property to animate
  3155. * @param framePerSecond defines the number of frame per second yo use
  3156. * @param totalFrame defines the number of frames in total
  3157. * @param from defines the initial value
  3158. * @param to defines the final value
  3159. * @param loopMode defines which loop mode you want to use (off by default)
  3160. * @param easingFunction defines the easing function to use (linear by default)
  3161. * @param onAnimationEnd defines the callback to call when animation end
  3162. * @returns the animatable created for this animation
  3163. */
  3164. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3165. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3166. if (!animation) {
  3167. return null;
  3168. }
  3169. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3170. };
  3171. /**
  3172. * Create and start an animation on a node and its descendants
  3173. * @param name defines the name of the global animation that will be run on all nodes
  3174. * @param node defines the root node where the animation will take place
  3175. * @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
  3176. * @param targetProperty defines property to animate
  3177. * @param framePerSecond defines the number of frame per second to use
  3178. * @param totalFrame defines the number of frames in total
  3179. * @param from defines the initial value
  3180. * @param to defines the final value
  3181. * @param loopMode defines which loop mode you want to use (off by default)
  3182. * @param easingFunction defines the easing function to use (linear by default)
  3183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3184. * @returns the list of animatables created for all nodes
  3185. * @example https://www.babylonjs-playground.com/#MH0VLI
  3186. */
  3187. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3188. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3189. if (!animation) {
  3190. return null;
  3191. }
  3192. var scene = node.getScene();
  3193. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3194. };
  3195. /**
  3196. * Creates a new animation, merges it with the existing animations and starts it
  3197. * @param name Name of the animation
  3198. * @param node Node which contains the scene that begins the animations
  3199. * @param targetProperty Specifies which property to animate
  3200. * @param framePerSecond The frames per second of the animation
  3201. * @param totalFrame The total number of frames
  3202. * @param from The frame at the beginning of the animation
  3203. * @param to The frame at the end of the animation
  3204. * @param loopMode Specifies the loop mode of the animation
  3205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3206. * @param onAnimationEnd Callback to run once the animation is complete
  3207. * @returns Nullable animation
  3208. */
  3209. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3210. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3211. if (!animation) {
  3212. return null;
  3213. }
  3214. node.animations.push(animation);
  3215. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3216. };
  3217. /**
  3218. * Transition property of an host to the target Value
  3219. * @param property The property to transition
  3220. * @param targetValue The target Value of the property
  3221. * @param host The object where the property to animate belongs
  3222. * @param scene Scene used to run the animation
  3223. * @param frameRate Framerate (in frame/s) to use
  3224. * @param transition The transition type we want to use
  3225. * @param duration The duration of the animation, in milliseconds
  3226. * @param onAnimationEnd Callback trigger at the end of the animation
  3227. * @returns Nullable animation
  3228. */
  3229. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3230. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3231. if (duration <= 0) {
  3232. host[property] = targetValue;
  3233. if (onAnimationEnd) {
  3234. onAnimationEnd();
  3235. }
  3236. return null;
  3237. }
  3238. var endFrame = frameRate * (duration / 1000);
  3239. transition.setKeys([{
  3240. frame: 0,
  3241. value: host[property].clone ? host[property].clone() : host[property]
  3242. },
  3243. {
  3244. frame: endFrame,
  3245. value: targetValue
  3246. }]);
  3247. if (!host.animations) {
  3248. host.animations = [];
  3249. }
  3250. host.animations.push(transition);
  3251. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3252. animation.onAnimationEnd = onAnimationEnd;
  3253. return animation;
  3254. };
  3255. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3256. /**
  3257. * Return the array of runtime animations currently using this animation
  3258. */
  3259. get: function () {
  3260. return this._runtimeAnimations;
  3261. },
  3262. enumerable: true,
  3263. configurable: true
  3264. });
  3265. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3266. /**
  3267. * Specifies if any of the runtime animations are currently running
  3268. */
  3269. get: function () {
  3270. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3271. var runtimeAnimation = _a[_i];
  3272. if (!runtimeAnimation.isStopped) {
  3273. return true;
  3274. }
  3275. }
  3276. return false;
  3277. },
  3278. enumerable: true,
  3279. configurable: true
  3280. });
  3281. // Methods
  3282. /**
  3283. * Converts the animation to a string
  3284. * @param fullDetails support for multiple levels of logging within scene loading
  3285. * @returns String form of the animation
  3286. */
  3287. Animation.prototype.toString = function (fullDetails) {
  3288. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3289. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3290. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3291. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3292. if (fullDetails) {
  3293. ret += ", Ranges: {";
  3294. var first = true;
  3295. for (var name in this._ranges) {
  3296. if (first) {
  3297. ret += ", ";
  3298. first = false;
  3299. }
  3300. ret += name;
  3301. }
  3302. ret += "}";
  3303. }
  3304. return ret;
  3305. };
  3306. /**
  3307. * Add an event to this animation
  3308. * @param event Event to add
  3309. */
  3310. Animation.prototype.addEvent = function (event) {
  3311. this._events.push(event);
  3312. };
  3313. /**
  3314. * Remove all events found at the given frame
  3315. * @param frame The frame to remove events from
  3316. */
  3317. Animation.prototype.removeEvents = function (frame) {
  3318. for (var index = 0; index < this._events.length; index++) {
  3319. if (this._events[index].frame === frame) {
  3320. this._events.splice(index, 1);
  3321. index--;
  3322. }
  3323. }
  3324. };
  3325. /**
  3326. * Retrieves all the events from the animation
  3327. * @returns Events from the animation
  3328. */
  3329. Animation.prototype.getEvents = function () {
  3330. return this._events;
  3331. };
  3332. /**
  3333. * Creates an animation range
  3334. * @param name Name of the animation range
  3335. * @param from Starting frame of the animation range
  3336. * @param to Ending frame of the animation
  3337. */
  3338. Animation.prototype.createRange = function (name, from, to) {
  3339. // check name not already in use; could happen for bones after serialized
  3340. if (!this._ranges[name]) {
  3341. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3342. }
  3343. };
  3344. /**
  3345. * Deletes an animation range by name
  3346. * @param name Name of the animation range to delete
  3347. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3348. */
  3349. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3350. if (deleteFrames === void 0) { deleteFrames = true; }
  3351. var range = this._ranges[name];
  3352. if (!range) {
  3353. return;
  3354. }
  3355. if (deleteFrames) {
  3356. var from = range.from;
  3357. var to = range.to;
  3358. // this loop MUST go high to low for multiple splices to work
  3359. for (var key = this._keys.length - 1; key >= 0; key--) {
  3360. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3361. this._keys.splice(key, 1);
  3362. }
  3363. }
  3364. }
  3365. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3366. };
  3367. /**
  3368. * Gets the animation range by name, or null if not defined
  3369. * @param name Name of the animation range
  3370. * @returns Nullable animation range
  3371. */
  3372. Animation.prototype.getRange = function (name) {
  3373. return this._ranges[name];
  3374. };
  3375. /**
  3376. * Gets the key frames from the animation
  3377. * @returns The key frames of the animation
  3378. */
  3379. Animation.prototype.getKeys = function () {
  3380. return this._keys;
  3381. };
  3382. /**
  3383. * Gets the highest frame rate of the animation
  3384. * @returns Highest frame rate of the animation
  3385. */
  3386. Animation.prototype.getHighestFrame = function () {
  3387. var ret = 0;
  3388. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3389. if (ret < this._keys[key].frame) {
  3390. ret = this._keys[key].frame;
  3391. }
  3392. }
  3393. return ret;
  3394. };
  3395. /**
  3396. * Gets the easing function of the animation
  3397. * @returns Easing function of the animation
  3398. */
  3399. Animation.prototype.getEasingFunction = function () {
  3400. return this._easingFunction;
  3401. };
  3402. /**
  3403. * Sets the easing function of the animation
  3404. * @param easingFunction A custom mathematical formula for animation
  3405. */
  3406. Animation.prototype.setEasingFunction = function (easingFunction) {
  3407. this._easingFunction = easingFunction;
  3408. };
  3409. /**
  3410. * Interpolates a scalar linearly
  3411. * @param startValue Start value of the animation curve
  3412. * @param endValue End value of the animation curve
  3413. * @param gradient Scalar amount to interpolate
  3414. * @returns Interpolated scalar value
  3415. */
  3416. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3417. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3418. };
  3419. /**
  3420. * Interpolates a scalar cubically
  3421. * @param startValue Start value of the animation curve
  3422. * @param outTangent End tangent of the animation
  3423. * @param endValue End value of the animation curve
  3424. * @param inTangent Start tangent of the animation curve
  3425. * @param gradient Scalar amount to interpolate
  3426. * @returns Interpolated scalar value
  3427. */
  3428. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3429. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3430. };
  3431. /**
  3432. * Interpolates a quaternion using a spherical linear interpolation
  3433. * @param startValue Start value of the animation curve
  3434. * @param endValue End value of the animation curve
  3435. * @param gradient Scalar amount to interpolate
  3436. * @returns Interpolated quaternion value
  3437. */
  3438. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3439. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3440. };
  3441. /**
  3442. * Interpolates a quaternion cubically
  3443. * @param startValue Start value of the animation curve
  3444. * @param outTangent End tangent of the animation curve
  3445. * @param endValue End value of the animation curve
  3446. * @param inTangent Start tangent of the animation curve
  3447. * @param gradient Scalar amount to interpolate
  3448. * @returns Interpolated quaternion value
  3449. */
  3450. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3451. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3452. };
  3453. /**
  3454. * Interpolates a Vector3 linearl
  3455. * @param startValue Start value of the animation curve
  3456. * @param endValue End value of the animation curve
  3457. * @param gradient Scalar amount to interpolate
  3458. * @returns Interpolated scalar value
  3459. */
  3460. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3461. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3462. };
  3463. /**
  3464. * Interpolates a Vector3 cubically
  3465. * @param startValue Start value of the animation curve
  3466. * @param outTangent End tangent of the animation
  3467. * @param endValue End value of the animation curve
  3468. * @param inTangent Start tangent of the animation curve
  3469. * @param gradient Scalar amount to interpolate
  3470. * @returns InterpolatedVector3 value
  3471. */
  3472. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3473. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3474. };
  3475. /**
  3476. * Interpolates a Vector2 linearly
  3477. * @param startValue Start value of the animation curve
  3478. * @param endValue End value of the animation curve
  3479. * @param gradient Scalar amount to interpolate
  3480. * @returns Interpolated Vector2 value
  3481. */
  3482. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3483. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3484. };
  3485. /**
  3486. * Interpolates a Vector2 cubically
  3487. * @param startValue Start value of the animation curve
  3488. * @param outTangent End tangent of the animation
  3489. * @param endValue End value of the animation curve
  3490. * @param inTangent Start tangent of the animation curve
  3491. * @param gradient Scalar amount to interpolate
  3492. * @returns Interpolated Vector2 value
  3493. */
  3494. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3495. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3496. };
  3497. /**
  3498. * Interpolates a size linearly
  3499. * @param startValue Start value of the animation curve
  3500. * @param endValue End value of the animation curve
  3501. * @param gradient Scalar amount to interpolate
  3502. * @returns Interpolated Size value
  3503. */
  3504. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3505. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3506. };
  3507. /**
  3508. * Interpolates a Color3 linearly
  3509. * @param startValue Start value of the animation curve
  3510. * @param endValue End value of the animation curve
  3511. * @param gradient Scalar amount to interpolate
  3512. * @returns Interpolated Color3 value
  3513. */
  3514. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3515. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3516. };
  3517. /**
  3518. * @hidden Internal use only
  3519. */
  3520. Animation.prototype._getKeyValue = function (value) {
  3521. if (typeof value === "function") {
  3522. return value();
  3523. }
  3524. return value;
  3525. };
  3526. /**
  3527. * @hidden Internal use only
  3528. */
  3529. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3530. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3531. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3532. }
  3533. var keys = this.getKeys();
  3534. // Try to get a hash to find the right key
  3535. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3536. if (keys[startKeyIndex].frame >= currentFrame) {
  3537. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3538. startKeyIndex--;
  3539. }
  3540. }
  3541. for (var key = startKeyIndex; key < keys.length; key++) {
  3542. var endKey = keys[key + 1];
  3543. if (endKey.frame >= currentFrame) {
  3544. var startKey = keys[key];
  3545. var startValue = this._getKeyValue(startKey.value);
  3546. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3547. return startValue;
  3548. }
  3549. var endValue = this._getKeyValue(endKey.value);
  3550. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3551. var frameDelta = endKey.frame - startKey.frame;
  3552. // gradient : percent of currentFrame between the frame inf and the frame sup
  3553. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3554. // check for easingFunction and correction of gradient
  3555. var easingFunction = this.getEasingFunction();
  3556. if (easingFunction != null) {
  3557. gradient = easingFunction.ease(gradient);
  3558. }
  3559. switch (this.dataType) {
  3560. // Float
  3561. case Animation.ANIMATIONTYPE_FLOAT:
  3562. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3563. switch (loopMode) {
  3564. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3565. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3566. return floatValue;
  3567. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3568. return offsetValue * repeatCount + floatValue;
  3569. }
  3570. break;
  3571. // Quaternion
  3572. case Animation.ANIMATIONTYPE_QUATERNION:
  3573. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3574. switch (loopMode) {
  3575. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3576. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3577. return quatValue;
  3578. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3579. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3580. }
  3581. return quatValue;
  3582. // Vector3
  3583. case Animation.ANIMATIONTYPE_VECTOR3:
  3584. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3585. switch (loopMode) {
  3586. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3587. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3588. return vec3Value;
  3589. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3590. return vec3Value.add(offsetValue.scale(repeatCount));
  3591. }
  3592. // Vector2
  3593. case Animation.ANIMATIONTYPE_VECTOR2:
  3594. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3595. switch (loopMode) {
  3596. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3597. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3598. return vec2Value;
  3599. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3600. return vec2Value.add(offsetValue.scale(repeatCount));
  3601. }
  3602. // Size
  3603. case Animation.ANIMATIONTYPE_SIZE:
  3604. switch (loopMode) {
  3605. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3606. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3607. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3608. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3609. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3610. }
  3611. // Color3
  3612. case Animation.ANIMATIONTYPE_COLOR3:
  3613. switch (loopMode) {
  3614. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3615. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3616. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3617. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3618. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3619. }
  3620. // Matrix
  3621. case Animation.ANIMATIONTYPE_MATRIX:
  3622. switch (loopMode) {
  3623. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3624. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3625. if (Animation.AllowMatricesInterpolation) {
  3626. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3627. }
  3628. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3629. return startValue;
  3630. }
  3631. default:
  3632. break;
  3633. }
  3634. break;
  3635. }
  3636. }
  3637. return this._getKeyValue(keys[keys.length - 1].value);
  3638. };
  3639. /**
  3640. * Defines the function to use to interpolate matrices
  3641. * @param startValue defines the start matrix
  3642. * @param endValue defines the end matrix
  3643. * @param gradient defines the gradient between both matrices
  3644. * @param result defines an optional target matrix where to store the interpolation
  3645. * @returns the interpolated matrix
  3646. */
  3647. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3648. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3649. if (result) {
  3650. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3651. return result;
  3652. }
  3653. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3654. }
  3655. if (result) {
  3656. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3657. return result;
  3658. }
  3659. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3660. };
  3661. /**
  3662. * Makes a copy of the animation
  3663. * @returns Cloned animation
  3664. */
  3665. Animation.prototype.clone = function () {
  3666. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3667. clone.enableBlending = this.enableBlending;
  3668. clone.blendingSpeed = this.blendingSpeed;
  3669. if (this._keys) {
  3670. clone.setKeys(this._keys);
  3671. }
  3672. if (this._ranges) {
  3673. clone._ranges = {};
  3674. for (var name in this._ranges) {
  3675. var range = this._ranges[name];
  3676. if (!range) {
  3677. continue;
  3678. }
  3679. clone._ranges[name] = range.clone();
  3680. }
  3681. }
  3682. return clone;
  3683. };
  3684. /**
  3685. * Sets the key frames of the animation
  3686. * @param values The animation key frames to set
  3687. */
  3688. Animation.prototype.setKeys = function (values) {
  3689. this._keys = values.slice(0);
  3690. };
  3691. /**
  3692. * Serializes the animation to an object
  3693. * @returns Serialized object
  3694. */
  3695. Animation.prototype.serialize = function () {
  3696. var serializationObject = {};
  3697. serializationObject.name = this.name;
  3698. serializationObject.property = this.targetProperty;
  3699. serializationObject.framePerSecond = this.framePerSecond;
  3700. serializationObject.dataType = this.dataType;
  3701. serializationObject.loopBehavior = this.loopMode;
  3702. serializationObject.enableBlending = this.enableBlending;
  3703. serializationObject.blendingSpeed = this.blendingSpeed;
  3704. var dataType = this.dataType;
  3705. serializationObject.keys = [];
  3706. var keys = this.getKeys();
  3707. for (var index = 0; index < keys.length; index++) {
  3708. var animationKey = keys[index];
  3709. var key = {};
  3710. key.frame = animationKey.frame;
  3711. switch (dataType) {
  3712. case Animation.ANIMATIONTYPE_FLOAT:
  3713. key.values = [animationKey.value];
  3714. break;
  3715. case Animation.ANIMATIONTYPE_QUATERNION:
  3716. case Animation.ANIMATIONTYPE_MATRIX:
  3717. case Animation.ANIMATIONTYPE_VECTOR3:
  3718. case Animation.ANIMATIONTYPE_COLOR3:
  3719. key.values = animationKey.value.asArray();
  3720. break;
  3721. }
  3722. serializationObject.keys.push(key);
  3723. }
  3724. serializationObject.ranges = [];
  3725. for (var name in this._ranges) {
  3726. var source = this._ranges[name];
  3727. if (!source) {
  3728. continue;
  3729. }
  3730. var range = {};
  3731. range.name = name;
  3732. range.from = source.from;
  3733. range.to = source.to;
  3734. serializationObject.ranges.push(range);
  3735. }
  3736. return serializationObject;
  3737. };
  3738. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3739. /**
  3740. * Get the float animation type
  3741. */
  3742. get: function () {
  3743. return Animation._ANIMATIONTYPE_FLOAT;
  3744. },
  3745. enumerable: true,
  3746. configurable: true
  3747. });
  3748. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3749. /**
  3750. * Get the Vector3 animation type
  3751. */
  3752. get: function () {
  3753. return Animation._ANIMATIONTYPE_VECTOR3;
  3754. },
  3755. enumerable: true,
  3756. configurable: true
  3757. });
  3758. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3759. /**
  3760. * Get the Vector2 animation type
  3761. */
  3762. get: function () {
  3763. return Animation._ANIMATIONTYPE_VECTOR2;
  3764. },
  3765. enumerable: true,
  3766. configurable: true
  3767. });
  3768. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3769. /**
  3770. * Get the Size animation type
  3771. */
  3772. get: function () {
  3773. return Animation._ANIMATIONTYPE_SIZE;
  3774. },
  3775. enumerable: true,
  3776. configurable: true
  3777. });
  3778. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3779. /**
  3780. * Get the Quaternion animation type
  3781. */
  3782. get: function () {
  3783. return Animation._ANIMATIONTYPE_QUATERNION;
  3784. },
  3785. enumerable: true,
  3786. configurable: true
  3787. });
  3788. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3789. /**
  3790. * Get the Matrix animation type
  3791. */
  3792. get: function () {
  3793. return Animation._ANIMATIONTYPE_MATRIX;
  3794. },
  3795. enumerable: true,
  3796. configurable: true
  3797. });
  3798. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3799. /**
  3800. * Get the Color3 animation type
  3801. */
  3802. get: function () {
  3803. return Animation._ANIMATIONTYPE_COLOR3;
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3809. /**
  3810. * Get the Relative Loop Mode
  3811. */
  3812. get: function () {
  3813. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3814. },
  3815. enumerable: true,
  3816. configurable: true
  3817. });
  3818. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3819. /**
  3820. * Get the Cycle Loop Mode
  3821. */
  3822. get: function () {
  3823. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3824. },
  3825. enumerable: true,
  3826. configurable: true
  3827. });
  3828. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3829. /**
  3830. * Get the Constant Loop Mode
  3831. */
  3832. get: function () {
  3833. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3834. },
  3835. enumerable: true,
  3836. configurable: true
  3837. });
  3838. /** @hidden */
  3839. Animation._UniversalLerp = function (left, right, amount) {
  3840. var constructor = left.constructor;
  3841. if (constructor.Lerp) { // Lerp supported
  3842. return constructor.Lerp(left, right, amount);
  3843. }
  3844. else if (constructor.Slerp) { // Slerp supported
  3845. return constructor.Slerp(left, right, amount);
  3846. }
  3847. else if (left.toFixed) { // Number
  3848. return left * (1.0 - amount) + amount * right;
  3849. }
  3850. else { // Blending not supported
  3851. return right;
  3852. }
  3853. };
  3854. /**
  3855. * Parses an animation object and creates an animation
  3856. * @param parsedAnimation Parsed animation object
  3857. * @returns Animation object
  3858. */
  3859. Animation.Parse = function (parsedAnimation) {
  3860. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3861. var dataType = parsedAnimation.dataType;
  3862. var keys = [];
  3863. var data;
  3864. var index;
  3865. if (parsedAnimation.enableBlending) {
  3866. animation.enableBlending = parsedAnimation.enableBlending;
  3867. }
  3868. if (parsedAnimation.blendingSpeed) {
  3869. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3870. }
  3871. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3872. var key = parsedAnimation.keys[index];
  3873. var inTangent;
  3874. var outTangent;
  3875. switch (dataType) {
  3876. case Animation.ANIMATIONTYPE_FLOAT:
  3877. data = key.values[0];
  3878. if (key.values.length >= 1) {
  3879. inTangent = key.values[1];
  3880. }
  3881. if (key.values.length >= 2) {
  3882. outTangent = key.values[2];
  3883. }
  3884. break;
  3885. case Animation.ANIMATIONTYPE_QUATERNION:
  3886. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3887. if (key.values.length >= 8) {
  3888. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3889. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3890. inTangent = _inTangent;
  3891. }
  3892. }
  3893. if (key.values.length >= 12) {
  3894. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3895. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3896. outTangent = _outTangent;
  3897. }
  3898. }
  3899. break;
  3900. case Animation.ANIMATIONTYPE_MATRIX:
  3901. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3902. break;
  3903. case Animation.ANIMATIONTYPE_COLOR3:
  3904. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3905. break;
  3906. case Animation.ANIMATIONTYPE_VECTOR3:
  3907. default:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3909. break;
  3910. }
  3911. var keyData = {};
  3912. keyData.frame = key.frame;
  3913. keyData.value = data;
  3914. if (inTangent != undefined) {
  3915. keyData.inTangent = inTangent;
  3916. }
  3917. if (outTangent != undefined) {
  3918. keyData.outTangent = outTangent;
  3919. }
  3920. keys.push(keyData);
  3921. }
  3922. animation.setKeys(keys);
  3923. if (parsedAnimation.ranges) {
  3924. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3925. data = parsedAnimation.ranges[index];
  3926. animation.createRange(data.name, data.from, data.to);
  3927. }
  3928. }
  3929. return animation;
  3930. };
  3931. /**
  3932. * Appends the serialized animations from the source animations
  3933. * @param source Source containing the animations
  3934. * @param destination Target to store the animations
  3935. */
  3936. Animation.AppendSerializedAnimations = function (source, destination) {
  3937. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3938. };
  3939. /**
  3940. * Use matrix interpolation instead of using direct key value when animating matrices
  3941. */
  3942. Animation.AllowMatricesInterpolation = false;
  3943. /**
  3944. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3945. */
  3946. Animation.AllowMatrixDecomposeForInterpolation = true;
  3947. // Statics
  3948. /**
  3949. * Float animation type
  3950. */
  3951. Animation._ANIMATIONTYPE_FLOAT = 0;
  3952. /**
  3953. * Vector3 animation type
  3954. */
  3955. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3956. /**
  3957. * Quaternion animation type
  3958. */
  3959. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3960. /**
  3961. * Matrix animation type
  3962. */
  3963. Animation._ANIMATIONTYPE_MATRIX = 3;
  3964. /**
  3965. * Color3 animation type
  3966. */
  3967. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3968. /**
  3969. * Vector2 animation type
  3970. */
  3971. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3972. /**
  3973. * Size animation type
  3974. */
  3975. Animation._ANIMATIONTYPE_SIZE = 6;
  3976. /**
  3977. * Relative Loop Mode
  3978. */
  3979. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3980. /**
  3981. * Cycle Loop Mode
  3982. */
  3983. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3984. /**
  3985. * Constant Loop Mode
  3986. */
  3987. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3988. return Animation;
  3989. }());
  3990. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3991. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3992. /***/ }),
  3993. /***/ "./Animations/animationEvent.ts":
  3994. /*!**************************************!*\
  3995. !*** ./Animations/animationEvent.ts ***!
  3996. \**************************************/
  3997. /*! exports provided: AnimationEvent */
  3998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3999. "use strict";
  4000. __webpack_require__.r(__webpack_exports__);
  4001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4002. /**
  4003. * Composed of a frame, and an action function
  4004. */
  4005. var AnimationEvent = /** @class */ (function () {
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. function AnimationEvent(
  4013. /** The frame for which the event is triggered **/
  4014. frame,
  4015. /** The event to perform when triggered **/
  4016. action,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce) {
  4019. this.frame = frame;
  4020. this.action = action;
  4021. this.onlyOnce = onlyOnce;
  4022. /**
  4023. * Specifies if the animation event is done
  4024. */
  4025. this.isDone = false;
  4026. }
  4027. /** @hidden */
  4028. AnimationEvent.prototype._clone = function () {
  4029. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4030. };
  4031. return AnimationEvent;
  4032. }());
  4033. /***/ }),
  4034. /***/ "./Animations/animationGroup.ts":
  4035. /*!**************************************!*\
  4036. !*** ./Animations/animationGroup.ts ***!
  4037. \**************************************/
  4038. /*! exports provided: TargetedAnimation, AnimationGroup */
  4039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4040. "use strict";
  4041. __webpack_require__.r(__webpack_exports__);
  4042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4044. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4045. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4046. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4047. /**
  4048. * This class defines the direct association between an animation and a target
  4049. */
  4050. var TargetedAnimation = /** @class */ (function () {
  4051. function TargetedAnimation() {
  4052. }
  4053. return TargetedAnimation;
  4054. }());
  4055. /**
  4056. * Use this class to create coordinated animations on multiple targets
  4057. */
  4058. var AnimationGroup = /** @class */ (function () {
  4059. /**
  4060. * Instantiates a new Animation Group.
  4061. * This helps managing several animations at once.
  4062. * @see http://doc.babylonjs.com/how_to/group
  4063. * @param name Defines the name of the group
  4064. * @param scene Defines the scene the group belongs to
  4065. */
  4066. function AnimationGroup(
  4067. /** The name of the animation group */
  4068. name, scene) {
  4069. if (scene === void 0) { scene = null; }
  4070. this.name = name;
  4071. this._targetedAnimations = new Array();
  4072. this._animatables = new Array();
  4073. this._from = Number.MAX_VALUE;
  4074. this._to = -Number.MAX_VALUE;
  4075. this._speedRatio = 1;
  4076. /**
  4077. * This observable will notify when one animation have ended
  4078. */
  4079. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4080. /**
  4081. * Observer raised when one animation loops
  4082. */
  4083. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4084. /**
  4085. * This observable will notify when all animations have ended.
  4086. */
  4087. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4088. /**
  4089. * This observable will notify when all animations have paused.
  4090. */
  4091. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4092. /**
  4093. * This observable will notify when all animations are playing.
  4094. */
  4095. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4096. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4097. this.uniqueId = this._scene.getUniqueId();
  4098. this._scene.animationGroups.push(this);
  4099. }
  4100. Object.defineProperty(AnimationGroup.prototype, "from", {
  4101. /**
  4102. * Gets the first frame
  4103. */
  4104. get: function () {
  4105. return this._from;
  4106. },
  4107. enumerable: true,
  4108. configurable: true
  4109. });
  4110. Object.defineProperty(AnimationGroup.prototype, "to", {
  4111. /**
  4112. * Gets the last frame
  4113. */
  4114. get: function () {
  4115. return this._to;
  4116. },
  4117. enumerable: true,
  4118. configurable: true
  4119. });
  4120. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4121. /**
  4122. * Define if the animations are started
  4123. */
  4124. get: function () {
  4125. return this._isStarted;
  4126. },
  4127. enumerable: true,
  4128. configurable: true
  4129. });
  4130. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4131. /**
  4132. * Gets a value indicating that the current group is playing
  4133. */
  4134. get: function () {
  4135. return this._isStarted && !this._isPaused;
  4136. },
  4137. enumerable: true,
  4138. configurable: true
  4139. });
  4140. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4141. /**
  4142. * Gets or sets the speed ratio to use for all animations
  4143. */
  4144. get: function () {
  4145. return this._speedRatio;
  4146. },
  4147. /**
  4148. * Gets or sets the speed ratio to use for all animations
  4149. */
  4150. set: function (value) {
  4151. if (this._speedRatio === value) {
  4152. return;
  4153. }
  4154. this._speedRatio = value;
  4155. for (var index = 0; index < this._animatables.length; index++) {
  4156. var animatable = this._animatables[index];
  4157. animatable.speedRatio = this._speedRatio;
  4158. }
  4159. },
  4160. enumerable: true,
  4161. configurable: true
  4162. });
  4163. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4164. /**
  4165. * Gets the targeted animations for this animation group
  4166. */
  4167. get: function () {
  4168. return this._targetedAnimations;
  4169. },
  4170. enumerable: true,
  4171. configurable: true
  4172. });
  4173. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4174. /**
  4175. * returning the list of animatables controlled by this animation group.
  4176. */
  4177. get: function () {
  4178. return this._animatables;
  4179. },
  4180. enumerable: true,
  4181. configurable: true
  4182. });
  4183. /**
  4184. * Add an animation (with its target) in the group
  4185. * @param animation defines the animation we want to add
  4186. * @param target defines the target of the animation
  4187. * @returns the TargetedAnimation object
  4188. */
  4189. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4190. var targetedAnimation = {
  4191. animation: animation,
  4192. target: target
  4193. };
  4194. var keys = animation.getKeys();
  4195. if (this._from > keys[0].frame) {
  4196. this._from = keys[0].frame;
  4197. }
  4198. if (this._to < keys[keys.length - 1].frame) {
  4199. this._to = keys[keys.length - 1].frame;
  4200. }
  4201. this._targetedAnimations.push(targetedAnimation);
  4202. return targetedAnimation;
  4203. };
  4204. /**
  4205. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4206. * It can add constant keys at begin or end
  4207. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4208. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4209. * @returns the animation group
  4210. */
  4211. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4212. if (beginFrame === void 0) { beginFrame = null; }
  4213. if (endFrame === void 0) { endFrame = null; }
  4214. if (beginFrame == null) {
  4215. beginFrame = this._from;
  4216. }
  4217. if (endFrame == null) {
  4218. endFrame = this._to;
  4219. }
  4220. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4221. var targetedAnimation = this._targetedAnimations[index];
  4222. var keys = targetedAnimation.animation.getKeys();
  4223. var startKey = keys[0];
  4224. var endKey = keys[keys.length - 1];
  4225. if (startKey.frame > beginFrame) {
  4226. var newKey = {
  4227. frame: beginFrame,
  4228. value: startKey.value,
  4229. inTangent: startKey.inTangent,
  4230. outTangent: startKey.outTangent,
  4231. interpolation: startKey.interpolation
  4232. };
  4233. keys.splice(0, 0, newKey);
  4234. }
  4235. if (endKey.frame < endFrame) {
  4236. var newKey = {
  4237. frame: endFrame,
  4238. value: endKey.value,
  4239. inTangent: endKey.outTangent,
  4240. outTangent: endKey.outTangent,
  4241. interpolation: endKey.interpolation
  4242. };
  4243. keys.push(newKey);
  4244. }
  4245. }
  4246. this._from = beginFrame;
  4247. this._to = endFrame;
  4248. return this;
  4249. };
  4250. /**
  4251. * Start all animations on given targets
  4252. * @param loop defines if animations must loop
  4253. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4254. * @param from defines the from key (optional)
  4255. * @param to defines the to key (optional)
  4256. * @returns the current animation group
  4257. */
  4258. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4259. var _this = this;
  4260. if (loop === void 0) { loop = false; }
  4261. if (speedRatio === void 0) { speedRatio = 1; }
  4262. if (this._isStarted || this._targetedAnimations.length === 0) {
  4263. return this;
  4264. }
  4265. var _loop_1 = function (targetedAnimation) {
  4266. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4267. animatable.onAnimationEnd = function () {
  4268. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4269. _this._checkAnimationGroupEnded(animatable);
  4270. };
  4271. animatable.onAnimationLoop = function () {
  4272. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4273. };
  4274. this_1._animatables.push(animatable);
  4275. };
  4276. var this_1 = this;
  4277. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4278. var targetedAnimation = _a[_i];
  4279. _loop_1(targetedAnimation);
  4280. }
  4281. this._speedRatio = speedRatio;
  4282. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4283. this._speedRatio = -speedRatio;
  4284. }
  4285. this._isStarted = true;
  4286. this._isPaused = false;
  4287. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4288. return this;
  4289. };
  4290. /**
  4291. * Pause all animations
  4292. * @returns the animation group
  4293. */
  4294. AnimationGroup.prototype.pause = function () {
  4295. if (!this._isStarted) {
  4296. return this;
  4297. }
  4298. this._isPaused = true;
  4299. for (var index = 0; index < this._animatables.length; index++) {
  4300. var animatable = this._animatables[index];
  4301. animatable.pause();
  4302. }
  4303. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4304. return this;
  4305. };
  4306. /**
  4307. * Play all animations to initial state
  4308. * This function will start() the animations if they were not started or will restart() them if they were paused
  4309. * @param loop defines if animations must loop
  4310. * @returns the animation group
  4311. */
  4312. AnimationGroup.prototype.play = function (loop) {
  4313. // only if all animatables are ready and exist
  4314. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4315. if (loop !== undefined) {
  4316. for (var index = 0; index < this._animatables.length; index++) {
  4317. var animatable = this._animatables[index];
  4318. animatable.loopAnimation = loop;
  4319. }
  4320. }
  4321. this.restart();
  4322. }
  4323. else {
  4324. this.stop();
  4325. this.start(loop, this._speedRatio);
  4326. }
  4327. this._isPaused = false;
  4328. return this;
  4329. };
  4330. /**
  4331. * Reset all animations to initial state
  4332. * @returns the animation group
  4333. */
  4334. AnimationGroup.prototype.reset = function () {
  4335. if (!this._isStarted) {
  4336. return this;
  4337. }
  4338. for (var index = 0; index < this._animatables.length; index++) {
  4339. var animatable = this._animatables[index];
  4340. animatable.reset();
  4341. }
  4342. return this;
  4343. };
  4344. /**
  4345. * Restart animations from key 0
  4346. * @returns the animation group
  4347. */
  4348. AnimationGroup.prototype.restart = function () {
  4349. if (!this._isStarted) {
  4350. return this;
  4351. }
  4352. for (var index = 0; index < this._animatables.length; index++) {
  4353. var animatable = this._animatables[index];
  4354. animatable.restart();
  4355. }
  4356. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4357. return this;
  4358. };
  4359. /**
  4360. * Stop all animations
  4361. * @returns the animation group
  4362. */
  4363. AnimationGroup.prototype.stop = function () {
  4364. if (!this._isStarted) {
  4365. return this;
  4366. }
  4367. var list = this._animatables.slice();
  4368. for (var index = 0; index < list.length; index++) {
  4369. list[index].stop();
  4370. }
  4371. this._isStarted = false;
  4372. return this;
  4373. };
  4374. /**
  4375. * Set animation weight for all animatables
  4376. * @param weight defines the weight to use
  4377. * @return the animationGroup
  4378. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4379. */
  4380. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4381. for (var index = 0; index < this._animatables.length; index++) {
  4382. var animatable = this._animatables[index];
  4383. animatable.weight = weight;
  4384. }
  4385. return this;
  4386. };
  4387. /**
  4388. * Synchronize and normalize all animatables with a source animatable
  4389. * @param root defines the root animatable to synchronize with
  4390. * @return the animationGroup
  4391. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4392. */
  4393. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4394. for (var index = 0; index < this._animatables.length; index++) {
  4395. var animatable = this._animatables[index];
  4396. animatable.syncWith(root);
  4397. }
  4398. return this;
  4399. };
  4400. /**
  4401. * Goes to a specific frame in this animation group
  4402. * @param frame the frame number to go to
  4403. * @return the animationGroup
  4404. */
  4405. AnimationGroup.prototype.goToFrame = function (frame) {
  4406. if (!this._isStarted) {
  4407. return this;
  4408. }
  4409. for (var index = 0; index < this._animatables.length; index++) {
  4410. var animatable = this._animatables[index];
  4411. animatable.goToFrame(frame);
  4412. }
  4413. return this;
  4414. };
  4415. /**
  4416. * Dispose all associated resources
  4417. */
  4418. AnimationGroup.prototype.dispose = function () {
  4419. this._targetedAnimations = [];
  4420. this._animatables = [];
  4421. var index = this._scene.animationGroups.indexOf(this);
  4422. if (index > -1) {
  4423. this._scene.animationGroups.splice(index, 1);
  4424. }
  4425. this.onAnimationEndObservable.clear();
  4426. this.onAnimationGroupEndObservable.clear();
  4427. this.onAnimationGroupPauseObservable.clear();
  4428. this.onAnimationGroupPlayObservable.clear();
  4429. this.onAnimationLoopObservable.clear();
  4430. };
  4431. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4432. // animatable should be taken out of the array
  4433. var idx = this._animatables.indexOf(animatable);
  4434. if (idx > -1) {
  4435. this._animatables.splice(idx, 1);
  4436. }
  4437. // all animatables were removed? animation group ended!
  4438. if (this._animatables.length === 0) {
  4439. this._isStarted = false;
  4440. this.onAnimationGroupEndObservable.notifyObservers(this);
  4441. }
  4442. };
  4443. // Statics
  4444. /**
  4445. * Returns a new AnimationGroup object parsed from the source provided.
  4446. * @param parsedAnimationGroup defines the source
  4447. * @param scene defines the scene that will receive the animationGroup
  4448. * @returns a new AnimationGroup
  4449. */
  4450. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4451. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4452. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4453. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4454. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4455. var id = targetedAnimation.targetId;
  4456. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4457. var morphTarget = scene.getMorphTargetById(id);
  4458. if (morphTarget) {
  4459. animationGroup.addTargetedAnimation(animation, morphTarget);
  4460. }
  4461. }
  4462. else {
  4463. var targetNode = scene.getNodeByID(id);
  4464. if (targetNode != null) {
  4465. animationGroup.addTargetedAnimation(animation, targetNode);
  4466. }
  4467. }
  4468. }
  4469. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4470. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4471. }
  4472. return animationGroup;
  4473. };
  4474. /**
  4475. * Returns the string "AnimationGroup"
  4476. * @returns "AnimationGroup"
  4477. */
  4478. AnimationGroup.prototype.getClassName = function () {
  4479. return "AnimationGroup";
  4480. };
  4481. /**
  4482. * Creates a detailled string about the object
  4483. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4484. * @returns a string representing the object
  4485. */
  4486. AnimationGroup.prototype.toString = function (fullDetails) {
  4487. var ret = "Name: " + this.name;
  4488. ret += ", type: " + this.getClassName();
  4489. if (fullDetails) {
  4490. ret += ", from: " + this._from;
  4491. ret += ", to: " + this._to;
  4492. ret += ", isStarted: " + this._isStarted;
  4493. ret += ", speedRatio: " + this._speedRatio;
  4494. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4495. ret += ", animatables length: " + this._animatables;
  4496. }
  4497. return ret;
  4498. };
  4499. return AnimationGroup;
  4500. }());
  4501. /***/ }),
  4502. /***/ "./Animations/animationKey.ts":
  4503. /*!************************************!*\
  4504. !*** ./Animations/animationKey.ts ***!
  4505. \************************************/
  4506. /*! exports provided: AnimationKeyInterpolation */
  4507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4508. "use strict";
  4509. __webpack_require__.r(__webpack_exports__);
  4510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4511. /**
  4512. * Enum for the animation key frame interpolation type
  4513. */
  4514. var AnimationKeyInterpolation;
  4515. (function (AnimationKeyInterpolation) {
  4516. /**
  4517. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4518. */
  4519. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4520. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4521. /***/ }),
  4522. /***/ "./Animations/animationPropertiesOverride.ts":
  4523. /*!***************************************************!*\
  4524. !*** ./Animations/animationPropertiesOverride.ts ***!
  4525. \***************************************************/
  4526. /*! exports provided: AnimationPropertiesOverride */
  4527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4528. "use strict";
  4529. __webpack_require__.r(__webpack_exports__);
  4530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4531. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4532. /**
  4533. * Class used to override all child animations of a given target
  4534. */
  4535. var AnimationPropertiesOverride = /** @class */ (function () {
  4536. function AnimationPropertiesOverride() {
  4537. /**
  4538. * Gets or sets a value indicating if animation blending must be used
  4539. */
  4540. this.enableBlending = false;
  4541. /**
  4542. * Gets or sets the blending speed to use when enableBlending is true
  4543. */
  4544. this.blendingSpeed = 0.01;
  4545. /**
  4546. * Gets or sets the default loop mode to use
  4547. */
  4548. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4549. }
  4550. return AnimationPropertiesOverride;
  4551. }());
  4552. /***/ }),
  4553. /***/ "./Animations/animationRange.ts":
  4554. /*!**************************************!*\
  4555. !*** ./Animations/animationRange.ts ***!
  4556. \**************************************/
  4557. /*! exports provided: AnimationRange */
  4558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4559. "use strict";
  4560. __webpack_require__.r(__webpack_exports__);
  4561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4562. /**
  4563. * Represents the range of an animation
  4564. */
  4565. var AnimationRange = /** @class */ (function () {
  4566. /**
  4567. * Initializes the range of an animation
  4568. * @param name The name of the animation range
  4569. * @param from The starting frame of the animation
  4570. * @param to The ending frame of the animation
  4571. */
  4572. function AnimationRange(
  4573. /**The name of the animation range**/
  4574. name,
  4575. /**The starting frame of the animation */
  4576. from,
  4577. /**The ending frame of the animation*/
  4578. to) {
  4579. this.name = name;
  4580. this.from = from;
  4581. this.to = to;
  4582. }
  4583. /**
  4584. * Makes a copy of the animation range
  4585. * @returns A copy of the animation range
  4586. */
  4587. AnimationRange.prototype.clone = function () {
  4588. return new AnimationRange(this.name, this.from, this.to);
  4589. };
  4590. return AnimationRange;
  4591. }());
  4592. /***/ }),
  4593. /***/ "./Animations/easing.ts":
  4594. /*!******************************!*\
  4595. !*** ./Animations/easing.ts ***!
  4596. \******************************/
  4597. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4599. "use strict";
  4600. __webpack_require__.r(__webpack_exports__);
  4601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4615. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4616. /**
  4617. * Base class used for every default easing function.
  4618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4619. */
  4620. var EasingFunction = /** @class */ (function () {
  4621. function EasingFunction() {
  4622. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4623. }
  4624. /**
  4625. * Sets the easing mode of the current function.
  4626. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4627. */
  4628. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4629. var n = Math.min(Math.max(easingMode, 0), 2);
  4630. this._easingMode = n;
  4631. };
  4632. /**
  4633. * Gets the current easing mode.
  4634. * @returns the easing mode
  4635. */
  4636. EasingFunction.prototype.getEasingMode = function () {
  4637. return this._easingMode;
  4638. };
  4639. /**
  4640. * @hidden
  4641. */
  4642. EasingFunction.prototype.easeInCore = function (gradient) {
  4643. throw new Error('You must implement this method');
  4644. };
  4645. /**
  4646. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4647. * of the easing function.
  4648. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4649. * @returns the corresponding value on the curve defined by the easing function
  4650. */
  4651. EasingFunction.prototype.ease = function (gradient) {
  4652. switch (this._easingMode) {
  4653. case EasingFunction.EASINGMODE_EASEIN:
  4654. return this.easeInCore(gradient);
  4655. case EasingFunction.EASINGMODE_EASEOUT:
  4656. return (1 - this.easeInCore(1 - gradient));
  4657. }
  4658. if (gradient >= 0.5) {
  4659. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4660. }
  4661. return (this.easeInCore(gradient * 2) * 0.5);
  4662. };
  4663. /**
  4664. * Interpolation follows the mathematical formula associated with the easing function.
  4665. */
  4666. EasingFunction.EASINGMODE_EASEIN = 0;
  4667. /**
  4668. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4669. */
  4670. EasingFunction.EASINGMODE_EASEOUT = 1;
  4671. /**
  4672. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4673. */
  4674. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4675. return EasingFunction;
  4676. }());
  4677. /**
  4678. * Easing function with a circle shape (see link below).
  4679. * @see https://easings.net/#easeInCirc
  4680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4681. */
  4682. var CircleEase = /** @class */ (function (_super) {
  4683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4684. function CircleEase() {
  4685. return _super !== null && _super.apply(this, arguments) || this;
  4686. }
  4687. /** @hidden */
  4688. CircleEase.prototype.easeInCore = function (gradient) {
  4689. gradient = Math.max(0, Math.min(1, gradient));
  4690. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4691. };
  4692. return CircleEase;
  4693. }(EasingFunction));
  4694. /**
  4695. * Easing function with a ease back shape (see link below).
  4696. * @see https://easings.net/#easeInBack
  4697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4698. */
  4699. var BackEase = /** @class */ (function (_super) {
  4700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4701. /**
  4702. * Instantiates a back ease easing
  4703. * @see https://easings.net/#easeInBack
  4704. * @param amplitude Defines the amplitude of the function
  4705. */
  4706. function BackEase(
  4707. /** Defines the amplitude of the function */
  4708. amplitude) {
  4709. if (amplitude === void 0) { amplitude = 1; }
  4710. var _this = _super.call(this) || this;
  4711. _this.amplitude = amplitude;
  4712. return _this;
  4713. }
  4714. /** @hidden */
  4715. BackEase.prototype.easeInCore = function (gradient) {
  4716. var num = Math.max(0, this.amplitude);
  4717. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4718. };
  4719. return BackEase;
  4720. }(EasingFunction));
  4721. /**
  4722. * Easing function with a bouncing shape (see link below).
  4723. * @see https://easings.net/#easeInBounce
  4724. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4725. */
  4726. var BounceEase = /** @class */ (function (_super) {
  4727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4728. /**
  4729. * Instantiates a bounce easing
  4730. * @see https://easings.net/#easeInBounce
  4731. * @param bounces Defines the number of bounces
  4732. * @param bounciness Defines the amplitude of the bounce
  4733. */
  4734. function BounceEase(
  4735. /** Defines the number of bounces */
  4736. bounces,
  4737. /** Defines the amplitude of the bounce */
  4738. bounciness) {
  4739. if (bounces === void 0) { bounces = 3; }
  4740. if (bounciness === void 0) { bounciness = 2; }
  4741. var _this = _super.call(this) || this;
  4742. _this.bounces = bounces;
  4743. _this.bounciness = bounciness;
  4744. return _this;
  4745. }
  4746. /** @hidden */
  4747. BounceEase.prototype.easeInCore = function (gradient) {
  4748. var y = Math.max(0.0, this.bounces);
  4749. var bounciness = this.bounciness;
  4750. if (bounciness <= 1.0) {
  4751. bounciness = 1.001;
  4752. }
  4753. var num9 = Math.pow(bounciness, y);
  4754. var num5 = 1.0 - bounciness;
  4755. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4756. var num15 = gradient * num4;
  4757. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4758. var num3 = Math.floor(num65);
  4759. var num13 = num3 + 1.0;
  4760. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4761. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4762. var num7 = (num8 + num12) * 0.5;
  4763. var num6 = gradient - num7;
  4764. var num2 = num7 - num8;
  4765. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4766. };
  4767. return BounceEase;
  4768. }(EasingFunction));
  4769. /**
  4770. * Easing function with a power of 3 shape (see link below).
  4771. * @see https://easings.net/#easeInCubic
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. var CubicEase = /** @class */ (function (_super) {
  4775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4776. function CubicEase() {
  4777. return _super !== null && _super.apply(this, arguments) || this;
  4778. }
  4779. /** @hidden */
  4780. CubicEase.prototype.easeInCore = function (gradient) {
  4781. return (gradient * gradient * gradient);
  4782. };
  4783. return CubicEase;
  4784. }(EasingFunction));
  4785. /**
  4786. * Easing function with an elastic shape (see link below).
  4787. * @see https://easings.net/#easeInElastic
  4788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4789. */
  4790. var ElasticEase = /** @class */ (function (_super) {
  4791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4792. /**
  4793. * Instantiates an elastic easing function
  4794. * @see https://easings.net/#easeInElastic
  4795. * @param oscillations Defines the number of oscillations
  4796. * @param springiness Defines the amplitude of the oscillations
  4797. */
  4798. function ElasticEase(
  4799. /** Defines the number of oscillations*/
  4800. oscillations,
  4801. /** Defines the amplitude of the oscillations*/
  4802. springiness) {
  4803. if (oscillations === void 0) { oscillations = 3; }
  4804. if (springiness === void 0) { springiness = 3; }
  4805. var _this = _super.call(this) || this;
  4806. _this.oscillations = oscillations;
  4807. _this.springiness = springiness;
  4808. return _this;
  4809. }
  4810. /** @hidden */
  4811. ElasticEase.prototype.easeInCore = function (gradient) {
  4812. var num2;
  4813. var num3 = Math.max(0.0, this.oscillations);
  4814. var num = Math.max(0.0, this.springiness);
  4815. if (num == 0) {
  4816. num2 = gradient;
  4817. }
  4818. else {
  4819. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4820. }
  4821. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4822. };
  4823. return ElasticEase;
  4824. }(EasingFunction));
  4825. /**
  4826. * Easing function with an exponential shape (see link below).
  4827. * @see https://easings.net/#easeInExpo
  4828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4829. */
  4830. var ExponentialEase = /** @class */ (function (_super) {
  4831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4832. /**
  4833. * Instantiates an exponential easing function
  4834. * @see https://easings.net/#easeInExpo
  4835. * @param exponent Defines the exponent of the function
  4836. */
  4837. function ExponentialEase(
  4838. /** Defines the exponent of the function */
  4839. exponent) {
  4840. if (exponent === void 0) { exponent = 2; }
  4841. var _this = _super.call(this) || this;
  4842. _this.exponent = exponent;
  4843. return _this;
  4844. }
  4845. /** @hidden */
  4846. ExponentialEase.prototype.easeInCore = function (gradient) {
  4847. if (this.exponent <= 0) {
  4848. return gradient;
  4849. }
  4850. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4851. };
  4852. return ExponentialEase;
  4853. }(EasingFunction));
  4854. /**
  4855. * Easing function with a power shape (see link below).
  4856. * @see https://easings.net/#easeInQuad
  4857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4858. */
  4859. var PowerEase = /** @class */ (function (_super) {
  4860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4861. /**
  4862. * Instantiates an power base easing function
  4863. * @see https://easings.net/#easeInQuad
  4864. * @param power Defines the power of the function
  4865. */
  4866. function PowerEase(
  4867. /** Defines the power of the function */
  4868. power) {
  4869. if (power === void 0) { power = 2; }
  4870. var _this = _super.call(this) || this;
  4871. _this.power = power;
  4872. return _this;
  4873. }
  4874. /** @hidden */
  4875. PowerEase.prototype.easeInCore = function (gradient) {
  4876. var y = Math.max(0.0, this.power);
  4877. return Math.pow(gradient, y);
  4878. };
  4879. return PowerEase;
  4880. }(EasingFunction));
  4881. /**
  4882. * Easing function with a power of 2 shape (see link below).
  4883. * @see https://easings.net/#easeInQuad
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. var QuadraticEase = /** @class */ (function (_super) {
  4887. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4888. function QuadraticEase() {
  4889. return _super !== null && _super.apply(this, arguments) || this;
  4890. }
  4891. /** @hidden */
  4892. QuadraticEase.prototype.easeInCore = function (gradient) {
  4893. return (gradient * gradient);
  4894. };
  4895. return QuadraticEase;
  4896. }(EasingFunction));
  4897. /**
  4898. * Easing function with a power of 4 shape (see link below).
  4899. * @see https://easings.net/#easeInQuart
  4900. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4901. */
  4902. var QuarticEase = /** @class */ (function (_super) {
  4903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4904. function QuarticEase() {
  4905. return _super !== null && _super.apply(this, arguments) || this;
  4906. }
  4907. /** @hidden */
  4908. QuarticEase.prototype.easeInCore = function (gradient) {
  4909. return (gradient * gradient * gradient * gradient);
  4910. };
  4911. return QuarticEase;
  4912. }(EasingFunction));
  4913. /**
  4914. * Easing function with a power of 5 shape (see link below).
  4915. * @see https://easings.net/#easeInQuint
  4916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4917. */
  4918. var QuinticEase = /** @class */ (function (_super) {
  4919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4920. function QuinticEase() {
  4921. return _super !== null && _super.apply(this, arguments) || this;
  4922. }
  4923. /** @hidden */
  4924. QuinticEase.prototype.easeInCore = function (gradient) {
  4925. return (gradient * gradient * gradient * gradient * gradient);
  4926. };
  4927. return QuinticEase;
  4928. }(EasingFunction));
  4929. /**
  4930. * Easing function with a sin shape (see link below).
  4931. * @see https://easings.net/#easeInSine
  4932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4933. */
  4934. var SineEase = /** @class */ (function (_super) {
  4935. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4936. function SineEase() {
  4937. return _super !== null && _super.apply(this, arguments) || this;
  4938. }
  4939. /** @hidden */
  4940. SineEase.prototype.easeInCore = function (gradient) {
  4941. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4942. };
  4943. return SineEase;
  4944. }(EasingFunction));
  4945. /**
  4946. * Easing function with a bezier shape (see link below).
  4947. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4949. */
  4950. var BezierCurveEase = /** @class */ (function (_super) {
  4951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4952. /**
  4953. * Instantiates a bezier function
  4954. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4955. * @param x1 Defines the x component of the start tangent in the bezier curve
  4956. * @param y1 Defines the y component of the start tangent in the bezier curve
  4957. * @param x2 Defines the x component of the end tangent in the bezier curve
  4958. * @param y2 Defines the y component of the end tangent in the bezier curve
  4959. */
  4960. function BezierCurveEase(
  4961. /** Defines the x component of the start tangent in the bezier curve */
  4962. x1,
  4963. /** Defines the y component of the start tangent in the bezier curve */
  4964. y1,
  4965. /** Defines the x component of the end tangent in the bezier curve */
  4966. x2,
  4967. /** Defines the y component of the end tangent in the bezier curve */
  4968. y2) {
  4969. if (x1 === void 0) { x1 = 0; }
  4970. if (y1 === void 0) { y1 = 0; }
  4971. if (x2 === void 0) { x2 = 1; }
  4972. if (y2 === void 0) { y2 = 1; }
  4973. var _this = _super.call(this) || this;
  4974. _this.x1 = x1;
  4975. _this.y1 = y1;
  4976. _this.x2 = x2;
  4977. _this.y2 = y2;
  4978. return _this;
  4979. }
  4980. /** @hidden */
  4981. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4982. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4983. };
  4984. return BezierCurveEase;
  4985. }(EasingFunction));
  4986. /***/ }),
  4987. /***/ "./Animations/index.ts":
  4988. /*!*****************************!*\
  4989. !*** ./Animations/index.ts ***!
  4990. \*****************************/
  4991. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  4992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4993. "use strict";
  4994. __webpack_require__.r(__webpack_exports__);
  4995. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  4997. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  4999. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5002. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5004. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5018. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5020. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5022. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5024. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5026. /***/ }),
  5027. /***/ "./Animations/runtimeAnimation.ts":
  5028. /*!****************************************!*\
  5029. !*** ./Animations/runtimeAnimation.ts ***!
  5030. \****************************************/
  5031. /*! exports provided: RuntimeAnimation */
  5032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5033. "use strict";
  5034. __webpack_require__.r(__webpack_exports__);
  5035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5037. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5038. // Static values to help the garbage collector
  5039. // Quaternion
  5040. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5041. // Vector3
  5042. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5043. // Vector2
  5044. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5045. // Size
  5046. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5047. // Color3
  5048. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5049. /**
  5050. * Defines a runtime animation
  5051. */
  5052. var RuntimeAnimation = /** @class */ (function () {
  5053. /**
  5054. * Create a new RuntimeAnimation object
  5055. * @param target defines the target of the animation
  5056. * @param animation defines the source animation object
  5057. * @param scene defines the hosting scene
  5058. * @param host defines the initiating Animatable
  5059. */
  5060. function RuntimeAnimation(target, animation, scene, host) {
  5061. var _this = this;
  5062. this._events = new Array();
  5063. /**
  5064. * The current frame of the runtime animation
  5065. */
  5066. this._currentFrame = 0;
  5067. /**
  5068. * The original value of the runtime animation
  5069. */
  5070. this._originalValue = new Array();
  5071. /**
  5072. * The offsets cache of the runtime animation
  5073. */
  5074. this._offsetsCache = {};
  5075. /**
  5076. * The high limits cache of the runtime animation
  5077. */
  5078. this._highLimitsCache = {};
  5079. /**
  5080. * Specifies if the runtime animation has been stopped
  5081. */
  5082. this._stopped = false;
  5083. /**
  5084. * The blending factor of the runtime animation
  5085. */
  5086. this._blendingFactor = 0;
  5087. /**
  5088. * The target path of the runtime animation
  5089. */
  5090. this._targetPath = "";
  5091. /**
  5092. * The weight of the runtime animation
  5093. */
  5094. this._weight = 1.0;
  5095. /**
  5096. * The ratio offset of the runtime animation
  5097. */
  5098. this._ratioOffset = 0;
  5099. /**
  5100. * The previous delay of the runtime animation
  5101. */
  5102. this._previousDelay = 0;
  5103. /**
  5104. * The previous ratio of the runtime animation
  5105. */
  5106. this._previousRatio = 0;
  5107. this._animation = animation;
  5108. this._target = target;
  5109. this._scene = scene;
  5110. this._host = host;
  5111. animation._runtimeAnimations.push(this);
  5112. // Cloning events locally
  5113. var events = animation.getEvents();
  5114. if (events && events.length > 0) {
  5115. events.forEach(function (e) {
  5116. _this._events.push(e._clone());
  5117. });
  5118. }
  5119. }
  5120. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5121. /**
  5122. * Gets the current frame of the runtime animation
  5123. */
  5124. get: function () {
  5125. return this._currentFrame;
  5126. },
  5127. enumerable: true,
  5128. configurable: true
  5129. });
  5130. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5131. /**
  5132. * Gets the weight of the runtime animation
  5133. */
  5134. get: function () {
  5135. return this._weight;
  5136. },
  5137. enumerable: true,
  5138. configurable: true
  5139. });
  5140. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5141. /**
  5142. * Gets the current value of the runtime animation
  5143. */
  5144. get: function () {
  5145. return this._currentValue;
  5146. },
  5147. enumerable: true,
  5148. configurable: true
  5149. });
  5150. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5151. /**
  5152. * Gets the target path of the runtime animation
  5153. */
  5154. get: function () {
  5155. return this._targetPath;
  5156. },
  5157. enumerable: true,
  5158. configurable: true
  5159. });
  5160. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5161. /**
  5162. * Gets the actual target of the runtime animation
  5163. */
  5164. get: function () {
  5165. return this._activeTarget;
  5166. },
  5167. enumerable: true,
  5168. configurable: true
  5169. });
  5170. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5171. /**
  5172. * Gets the animation from the runtime animation
  5173. */
  5174. get: function () {
  5175. return this._animation;
  5176. },
  5177. enumerable: true,
  5178. configurable: true
  5179. });
  5180. /**
  5181. * Resets the runtime animation to the beginning
  5182. * @param restoreOriginal defines whether to restore the target property to the original value
  5183. */
  5184. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5185. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5186. if (restoreOriginal) {
  5187. if (this._target instanceof Array) {
  5188. var index = 0;
  5189. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5190. var target = _a[_i];
  5191. if (this._originalValue[index] !== undefined) {
  5192. this._setValue(target, this._originalValue[index], -1);
  5193. }
  5194. index++;
  5195. }
  5196. }
  5197. else {
  5198. if (this._originalValue[0] !== undefined) {
  5199. this._setValue(this._target, this._originalValue[0], -1);
  5200. }
  5201. }
  5202. }
  5203. this._offsetsCache = {};
  5204. this._highLimitsCache = {};
  5205. this._currentFrame = 0;
  5206. this._blendingFactor = 0;
  5207. this._originalValue = new Array();
  5208. // Events
  5209. for (var index = 0; index < this._events.length; index++) {
  5210. this._events[index].isDone = false;
  5211. }
  5212. };
  5213. /**
  5214. * Specifies if the runtime animation is stopped
  5215. * @returns Boolean specifying if the runtime animation is stopped
  5216. */
  5217. RuntimeAnimation.prototype.isStopped = function () {
  5218. return this._stopped;
  5219. };
  5220. /**
  5221. * Disposes of the runtime animation
  5222. */
  5223. RuntimeAnimation.prototype.dispose = function () {
  5224. var index = this._animation.runtimeAnimations.indexOf(this);
  5225. if (index > -1) {
  5226. this._animation.runtimeAnimations.splice(index, 1);
  5227. }
  5228. };
  5229. /**
  5230. * Interpolates the animation from the current frame
  5231. * @param currentFrame The frame to interpolate the animation to
  5232. * @param repeatCount The number of times that the animation should loop
  5233. * @param loopMode The type of looping mode to use
  5234. * @param offsetValue Animation offset value
  5235. * @param highLimitValue The high limit value
  5236. * @returns The interpolated value
  5237. */
  5238. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5239. this._currentFrame = currentFrame;
  5240. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5241. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5242. }
  5243. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5244. };
  5245. /**
  5246. * Apply the interpolated value to the target
  5247. * @param currentValue defines the value computed by the animation
  5248. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5249. */
  5250. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5251. if (weight === void 0) { weight = 1.0; }
  5252. if (this._target instanceof Array) {
  5253. var index = 0;
  5254. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5255. var target = _a[_i];
  5256. this._setValue(target, currentValue, weight, index);
  5257. index++;
  5258. }
  5259. }
  5260. else {
  5261. this._setValue(this._target, currentValue, weight);
  5262. }
  5263. };
  5264. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5265. if (targetIndex === void 0) { targetIndex = 0; }
  5266. // Set value
  5267. var path;
  5268. var destination;
  5269. var targetPropertyPath = this._animation.targetPropertyPath;
  5270. if (targetPropertyPath.length > 1) {
  5271. var property = target[targetPropertyPath[0]];
  5272. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5273. property = property[targetPropertyPath[index]];
  5274. }
  5275. path = targetPropertyPath[targetPropertyPath.length - 1];
  5276. destination = property;
  5277. }
  5278. else {
  5279. path = targetPropertyPath[0];
  5280. destination = target;
  5281. }
  5282. this._targetPath = path;
  5283. this._activeTarget = destination;
  5284. this._weight = weight;
  5285. if (this._originalValue[targetIndex] === undefined) {
  5286. var originalValue = void 0;
  5287. if (destination.getRestPose && path === "_matrix") { // For bones
  5288. originalValue = destination.getRestPose();
  5289. }
  5290. else {
  5291. originalValue = destination[path];
  5292. }
  5293. if (originalValue && originalValue.clone) {
  5294. this._originalValue[targetIndex] = originalValue.clone();
  5295. }
  5296. else {
  5297. this._originalValue[targetIndex] = originalValue;
  5298. }
  5299. }
  5300. // Blending
  5301. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5302. if (enableBlending && this._blendingFactor <= 1.0) {
  5303. if (!this._originalBlendValue) {
  5304. var originalValue = destination[path];
  5305. if (originalValue.clone) {
  5306. this._originalBlendValue = originalValue.clone();
  5307. }
  5308. else {
  5309. this._originalBlendValue = originalValue;
  5310. }
  5311. }
  5312. if (this._originalBlendValue.m) { // Matrix
  5313. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5314. if (this._currentValue) {
  5315. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5316. }
  5317. else {
  5318. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5319. }
  5320. }
  5321. else {
  5322. if (this._currentValue) {
  5323. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5324. }
  5325. else {
  5326. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5327. }
  5328. }
  5329. }
  5330. else {
  5331. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5332. }
  5333. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5334. this._blendingFactor += blendingSpeed;
  5335. }
  5336. else {
  5337. this._currentValue = currentValue;
  5338. }
  5339. if (weight !== -1.0) {
  5340. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5341. }
  5342. else {
  5343. destination[path] = this._currentValue;
  5344. }
  5345. if (target.markAsDirty) {
  5346. target.markAsDirty(this._animation.targetProperty);
  5347. }
  5348. };
  5349. /**
  5350. * Gets the loop pmode of the runtime animation
  5351. * @returns Loop Mode
  5352. */
  5353. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5354. if (this._target && this._target.animationPropertiesOverride) {
  5355. return this._target.animationPropertiesOverride.loopMode;
  5356. }
  5357. return this._animation.loopMode;
  5358. };
  5359. /**
  5360. * Move the current animation to a given frame
  5361. * @param frame defines the frame to move to
  5362. */
  5363. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5364. var keys = this._animation.getKeys();
  5365. if (frame < keys[0].frame) {
  5366. frame = keys[0].frame;
  5367. }
  5368. else if (frame > keys[keys.length - 1].frame) {
  5369. frame = keys[keys.length - 1].frame;
  5370. }
  5371. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5372. this.setValue(currentValue, -1);
  5373. };
  5374. /**
  5375. * @hidden Internal use only
  5376. */
  5377. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5378. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5379. this._ratioOffset = this._previousRatio - newRatio;
  5380. };
  5381. /**
  5382. * Execute the current animation
  5383. * @param delay defines the delay to add to the current frame
  5384. * @param from defines the lower bound of the animation range
  5385. * @param to defines the upper bound of the animation range
  5386. * @param loop defines if the current animation must loop
  5387. * @param speedRatio defines the current speed ratio
  5388. * @param weight defines the weight of the animation (default is -1 so no weight)
  5389. * @param onLoop optional callback called when animation loops
  5390. * @returns a boolean indicating if the animation is running
  5391. */
  5392. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5393. if (weight === void 0) { weight = -1.0; }
  5394. var targetPropertyPath = this._animation.targetPropertyPath;
  5395. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5396. this._stopped = true;
  5397. return false;
  5398. }
  5399. var returnValue = true;
  5400. var keys = this._animation.getKeys();
  5401. // Adding a start key at frame 0 if missing
  5402. if (keys[0].frame !== 0) {
  5403. var newKey = { frame: 0, value: keys[0].value };
  5404. keys.splice(0, 0, newKey);
  5405. }
  5406. // Adding a duplicate key when there is only one key at frame zero
  5407. else if (keys.length === 1) {
  5408. var newKey = { frame: 0.001, value: keys[0].value };
  5409. keys.push(newKey);
  5410. }
  5411. // Check limits
  5412. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5413. from = keys[0].frame;
  5414. }
  5415. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5416. to = keys[keys.length - 1].frame;
  5417. }
  5418. //to and from cannot be the same key
  5419. if (from === to) {
  5420. if (from > keys[0].frame) {
  5421. from--;
  5422. }
  5423. else if (to < keys[keys.length - 1].frame) {
  5424. to++;
  5425. }
  5426. }
  5427. // Compute ratio
  5428. var range = to - from;
  5429. var offsetValue;
  5430. // ratio represents the frame delta between from and to
  5431. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5432. var highLimitValue = 0;
  5433. this._previousDelay = delay;
  5434. this._previousRatio = ratio;
  5435. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5436. returnValue = false;
  5437. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5438. }
  5439. else {
  5440. // Get max value if required
  5441. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5442. var keyOffset = to.toString() + from.toString();
  5443. if (!this._offsetsCache[keyOffset]) {
  5444. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5445. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5446. switch (this._animation.dataType) {
  5447. // Float
  5448. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5449. this._offsetsCache[keyOffset] = toValue - fromValue;
  5450. break;
  5451. // Quaternion
  5452. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5453. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5454. break;
  5455. // Vector3
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5457. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5458. // Vector2
  5459. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5460. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5461. // Size
  5462. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5463. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5464. // Color3
  5465. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5466. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5467. default:
  5468. break;
  5469. }
  5470. this._highLimitsCache[keyOffset] = toValue;
  5471. }
  5472. highLimitValue = this._highLimitsCache[keyOffset];
  5473. offsetValue = this._offsetsCache[keyOffset];
  5474. }
  5475. }
  5476. if (offsetValue === undefined) {
  5477. switch (this._animation.dataType) {
  5478. // Float
  5479. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5480. offsetValue = 0;
  5481. break;
  5482. // Quaternion
  5483. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5484. offsetValue = _staticOffsetValueQuaternion;
  5485. break;
  5486. // Vector3
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5488. offsetValue = _staticOffsetValueVector3;
  5489. break;
  5490. // Vector2
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5492. offsetValue = _staticOffsetValueVector2;
  5493. break;
  5494. // Size
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5496. offsetValue = _staticOffsetValueSize;
  5497. break;
  5498. // Color3
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5500. offsetValue = _staticOffsetValueColor3;
  5501. }
  5502. }
  5503. // Compute value
  5504. var repeatCount = (ratio / range) >> 0;
  5505. var currentFrame = returnValue ? from + ratio % range : to;
  5506. // Need to normalize?
  5507. if (this._host && this._host.syncRoot) {
  5508. var syncRoot = this._host.syncRoot;
  5509. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5510. currentFrame = from + (to - from) * hostNormalizedFrame;
  5511. }
  5512. // Reset events if looping
  5513. var events = this._events;
  5514. if (range > 0 && this.currentFrame > currentFrame ||
  5515. range < 0 && this.currentFrame < currentFrame) {
  5516. if (onLoop) {
  5517. onLoop();
  5518. }
  5519. // Need to reset animation events
  5520. for (var index = 0; index < events.length; index++) {
  5521. if (!events[index].onlyOnce) {
  5522. // reset event, the animation is looping
  5523. events[index].isDone = false;
  5524. }
  5525. }
  5526. }
  5527. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5528. // Set value
  5529. this.setValue(currentValue, weight);
  5530. // Check events
  5531. for (var index = 0; index < events.length; index++) {
  5532. // Make sure current frame has passed event frame and that event frame is within the current range
  5533. // Also, handle both forward and reverse animations
  5534. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5535. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5536. var event = events[index];
  5537. if (!event.isDone) {
  5538. // If event should be done only once, remove it.
  5539. if (event.onlyOnce) {
  5540. events.splice(index, 1);
  5541. index--;
  5542. }
  5543. event.isDone = true;
  5544. event.action(currentFrame);
  5545. } // Don't do anything if the event has already be done.
  5546. }
  5547. }
  5548. if (!returnValue) {
  5549. this._stopped = true;
  5550. }
  5551. return returnValue;
  5552. };
  5553. return RuntimeAnimation;
  5554. }());
  5555. /***/ }),
  5556. /***/ "./Audio/analyser.ts":
  5557. /*!***************************!*\
  5558. !*** ./Audio/analyser.ts ***!
  5559. \***************************/
  5560. /*! exports provided: Analyser */
  5561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5562. "use strict";
  5563. __webpack_require__.r(__webpack_exports__);
  5564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5565. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5566. /**
  5567. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5569. */
  5570. var Analyser = /** @class */ (function () {
  5571. /**
  5572. * Creates a new analyser
  5573. * @param scene defines hosting scene
  5574. */
  5575. function Analyser(scene) {
  5576. /**
  5577. * Gets or sets the smoothing
  5578. * @ignorenaming
  5579. */
  5580. this.SMOOTHING = 0.75;
  5581. /**
  5582. * Gets or sets the FFT table size
  5583. * @ignorenaming
  5584. */
  5585. this.FFT_SIZE = 512;
  5586. /**
  5587. * Gets or sets the bar graph amplitude
  5588. * @ignorenaming
  5589. */
  5590. this.BARGRAPHAMPLITUDE = 256;
  5591. /**
  5592. * Gets or sets the position of the debug canvas
  5593. * @ignorenaming
  5594. */
  5595. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5596. /**
  5597. * Gets or sets the debug canvas size
  5598. * @ignorenaming
  5599. */
  5600. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5601. this._scene = scene;
  5602. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5603. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5604. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5605. this._webAudioAnalyser.minDecibels = -140;
  5606. this._webAudioAnalyser.maxDecibels = 0;
  5607. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5608. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5609. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5610. }
  5611. }
  5612. /**
  5613. * Get the number of data values you will have to play with for the visualization
  5614. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5615. * @returns a number
  5616. */
  5617. Analyser.prototype.getFrequencyBinCount = function () {
  5618. if (this._audioEngine.canUseWebAudio) {
  5619. return this._webAudioAnalyser.frequencyBinCount;
  5620. }
  5621. else {
  5622. return 0;
  5623. }
  5624. };
  5625. /**
  5626. * Gets the current frequency data as a byte array
  5627. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5628. * @returns a Uint8Array
  5629. */
  5630. Analyser.prototype.getByteFrequencyData = function () {
  5631. if (this._audioEngine.canUseWebAudio) {
  5632. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5633. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5634. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5635. }
  5636. return this._byteFreqs;
  5637. };
  5638. /**
  5639. * Gets the current waveform as a byte array
  5640. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5641. * @returns a Uint8Array
  5642. */
  5643. Analyser.prototype.getByteTimeDomainData = function () {
  5644. if (this._audioEngine.canUseWebAudio) {
  5645. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5646. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5647. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5648. }
  5649. return this._byteTime;
  5650. };
  5651. /**
  5652. * Gets the current frequency data as a float array
  5653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5654. * @returns a Float32Array
  5655. */
  5656. Analyser.prototype.getFloatFrequencyData = function () {
  5657. if (this._audioEngine.canUseWebAudio) {
  5658. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5659. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5660. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5661. }
  5662. return this._floatFreqs;
  5663. };
  5664. /**
  5665. * Renders the debug canvas
  5666. */
  5667. Analyser.prototype.drawDebugCanvas = function () {
  5668. var _this = this;
  5669. if (this._audioEngine.canUseWebAudio) {
  5670. if (!this._debugCanvas) {
  5671. this._debugCanvas = document.createElement("canvas");
  5672. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5673. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5674. this._debugCanvas.style.position = "absolute";
  5675. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5676. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5677. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5678. document.body.appendChild(this._debugCanvas);
  5679. this._registerFunc = function () {
  5680. _this.drawDebugCanvas();
  5681. };
  5682. this._scene.registerBeforeRender(this._registerFunc);
  5683. }
  5684. if (this._registerFunc && this._debugCanvasContext) {
  5685. var workingArray = this.getByteFrequencyData();
  5686. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5687. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5688. // Draw the frequency domain chart.
  5689. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5690. var value = workingArray[i];
  5691. var percent = value / this.BARGRAPHAMPLITUDE;
  5692. var height = this.DEBUGCANVASSIZE.height * percent;
  5693. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5694. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5695. var hue = i / this.getFrequencyBinCount() * 360;
  5696. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5697. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5698. }
  5699. }
  5700. }
  5701. };
  5702. /**
  5703. * Stops rendering the debug canvas and removes it
  5704. */
  5705. Analyser.prototype.stopDebugCanvas = function () {
  5706. if (this._debugCanvas) {
  5707. if (this._registerFunc) {
  5708. this._scene.unregisterBeforeRender(this._registerFunc);
  5709. this._registerFunc = null;
  5710. }
  5711. document.body.removeChild(this._debugCanvas);
  5712. this._debugCanvas = null;
  5713. this._debugCanvasContext = null;
  5714. }
  5715. };
  5716. /**
  5717. * Connects two audio nodes
  5718. * @param inputAudioNode defines first node to connect
  5719. * @param outputAudioNode defines second node to connect
  5720. */
  5721. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5722. if (this._audioEngine.canUseWebAudio) {
  5723. inputAudioNode.connect(this._webAudioAnalyser);
  5724. this._webAudioAnalyser.connect(outputAudioNode);
  5725. }
  5726. };
  5727. /**
  5728. * Releases all associated resources
  5729. */
  5730. Analyser.prototype.dispose = function () {
  5731. if (this._audioEngine.canUseWebAudio) {
  5732. this._webAudioAnalyser.disconnect();
  5733. }
  5734. };
  5735. return Analyser;
  5736. }());
  5737. /***/ }),
  5738. /***/ "./Audio/audioEngine.ts":
  5739. /*!******************************!*\
  5740. !*** ./Audio/audioEngine.ts ***!
  5741. \******************************/
  5742. /*! exports provided: AudioEngine */
  5743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5744. "use strict";
  5745. __webpack_require__.r(__webpack_exports__);
  5746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5747. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5748. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5749. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5750. // Sets the default audio engine to Babylon.js
  5751. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5752. /**
  5753. * This represents the default audio engine used in babylon.
  5754. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5756. */
  5757. var AudioEngine = /** @class */ (function () {
  5758. /**
  5759. * Instantiates a new audio engine.
  5760. *
  5761. * There should be only one per page as some browsers restrict the number
  5762. * of audio contexts you can create.
  5763. * @param hostElement defines the host element where to display the mute icon if necessary
  5764. */
  5765. function AudioEngine(hostElement) {
  5766. if (hostElement === void 0) { hostElement = null; }
  5767. var _this = this;
  5768. this._audioContext = null;
  5769. this._audioContextInitialized = false;
  5770. this._muteButton = null;
  5771. /**
  5772. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5773. */
  5774. this.canUseWebAudio = false;
  5775. /**
  5776. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5777. * @ignoreNaming
  5778. */
  5779. this.WarnedWebAudioUnsupported = false;
  5780. /**
  5781. * Gets whether or not mp3 are supported by your browser.
  5782. */
  5783. this.isMP3supported = false;
  5784. /**
  5785. * Gets whether or not ogg are supported by your browser.
  5786. */
  5787. this.isOGGsupported = false;
  5788. /**
  5789. * Gets whether audio has been unlocked on the device.
  5790. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5791. * a user interaction has happened.
  5792. */
  5793. this.unlocked = true;
  5794. /**
  5795. * Defines if the audio engine relies on a custom unlocked button.
  5796. * In this case, the embedded button will not be displayed.
  5797. */
  5798. this.useCustomUnlockedButton = false;
  5799. /**
  5800. * Event raised when audio has been unlocked on the browser.
  5801. */
  5802. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5803. /**
  5804. * Event raised when audio has been locked on the browser.
  5805. */
  5806. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5807. this._tryToRun = false;
  5808. this._onResize = function () {
  5809. _this._moveButtonToTopLeft();
  5810. };
  5811. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5812. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5813. this.canUseWebAudio = true;
  5814. }
  5815. var audioElem = document.createElement('audio');
  5816. this._hostElement = hostElement;
  5817. try {
  5818. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5819. this.isMP3supported = true;
  5820. }
  5821. }
  5822. catch (e) {
  5823. // protect error during capability check.
  5824. }
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5827. this.isOGGsupported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. }
  5834. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5835. /**
  5836. * Gets the current AudioContext if available.
  5837. */
  5838. get: function () {
  5839. if (!this._audioContextInitialized) {
  5840. this._initializeAudioContext();
  5841. }
  5842. else {
  5843. if (!this.unlocked && !this._muteButton) {
  5844. this._displayMuteButton();
  5845. }
  5846. }
  5847. return this._audioContext;
  5848. },
  5849. enumerable: true,
  5850. configurable: true
  5851. });
  5852. /**
  5853. * Flags the audio engine in Locked state.
  5854. * This happens due to new browser policies preventing audio to autoplay.
  5855. */
  5856. AudioEngine.prototype.lock = function () {
  5857. this._triggerSuspendedState();
  5858. };
  5859. /**
  5860. * Unlocks the audio engine once a user action has been done on the dom.
  5861. * This is helpful to resume play once browser policies have been satisfied.
  5862. */
  5863. AudioEngine.prototype.unlock = function () {
  5864. this._triggerRunningState();
  5865. };
  5866. AudioEngine.prototype._resumeAudioContext = function () {
  5867. var result;
  5868. if (this._audioContext.resume) {
  5869. result = this._audioContext.resume();
  5870. }
  5871. return result || Promise.resolve();
  5872. };
  5873. AudioEngine.prototype._initializeAudioContext = function () {
  5874. try {
  5875. if (this.canUseWebAudio) {
  5876. this._audioContext = new AudioContext();
  5877. // create a global volume gain node
  5878. this.masterGain = this._audioContext.createGain();
  5879. this.masterGain.gain.value = 1;
  5880. this.masterGain.connect(this._audioContext.destination);
  5881. this._audioContextInitialized = true;
  5882. if (this._audioContext.state === "running") {
  5883. // Do not wait for the promise to unlock.
  5884. this._triggerRunningState();
  5885. }
  5886. }
  5887. }
  5888. catch (e) {
  5889. this.canUseWebAudio = false;
  5890. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5891. }
  5892. };
  5893. AudioEngine.prototype._triggerRunningState = function () {
  5894. var _this = this;
  5895. if (this._tryToRun) {
  5896. return;
  5897. }
  5898. this._tryToRun = true;
  5899. this._resumeAudioContext()
  5900. .then(function () {
  5901. _this._tryToRun = false;
  5902. if (_this._muteButton) {
  5903. _this._hideMuteButton();
  5904. }
  5905. }).catch(function () {
  5906. _this._tryToRun = false;
  5907. _this.unlocked = false;
  5908. });
  5909. // Notify users that the audio stack is unlocked/unmuted
  5910. this.unlocked = true;
  5911. this.onAudioUnlockedObservable.notifyObservers(this);
  5912. };
  5913. AudioEngine.prototype._triggerSuspendedState = function () {
  5914. this.unlocked = false;
  5915. this.onAudioLockedObservable.notifyObservers(this);
  5916. this._displayMuteButton();
  5917. };
  5918. AudioEngine.prototype._displayMuteButton = function () {
  5919. var _this = this;
  5920. if (this.useCustomUnlockedButton || this._muteButton) {
  5921. return;
  5922. }
  5923. this._muteButton = document.createElement("BUTTON");
  5924. this._muteButton.className = "babylonUnmuteIcon";
  5925. this._muteButton.id = "babylonUnmuteIconBtn";
  5926. this._muteButton.title = "Unmute";
  5927. 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) }";
  5928. var style = document.createElement('style');
  5929. style.appendChild(document.createTextNode(css));
  5930. document.getElementsByTagName('head')[0].appendChild(style);
  5931. document.body.appendChild(this._muteButton);
  5932. this._moveButtonToTopLeft();
  5933. this._muteButton.addEventListener('touchend', function () {
  5934. _this._triggerRunningState();
  5935. }, true);
  5936. this._muteButton.addEventListener('click', function () {
  5937. _this._triggerRunningState();
  5938. }, true);
  5939. window.addEventListener("resize", this._onResize);
  5940. };
  5941. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5942. if (this._hostElement && this._muteButton) {
  5943. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5944. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5945. }
  5946. };
  5947. AudioEngine.prototype._hideMuteButton = function () {
  5948. if (this._muteButton) {
  5949. document.body.removeChild(this._muteButton);
  5950. this._muteButton = null;
  5951. }
  5952. };
  5953. /**
  5954. * Destroy and release the resources associated with the audio ccontext.
  5955. */
  5956. AudioEngine.prototype.dispose = function () {
  5957. if (this.canUseWebAudio && this._audioContextInitialized) {
  5958. if (this._connectedAnalyser && this._audioContext) {
  5959. this._connectedAnalyser.stopDebugCanvas();
  5960. this._connectedAnalyser.dispose();
  5961. this.masterGain.disconnect();
  5962. this.masterGain.connect(this._audioContext.destination);
  5963. this._connectedAnalyser = null;
  5964. }
  5965. this.masterGain.gain.value = 1;
  5966. }
  5967. this.WarnedWebAudioUnsupported = false;
  5968. this._hideMuteButton();
  5969. window.removeEventListener("resize", this._onResize);
  5970. this.onAudioUnlockedObservable.clear();
  5971. this.onAudioLockedObservable.clear();
  5972. };
  5973. /**
  5974. * Gets the global volume sets on the master gain.
  5975. * @returns the global volume if set or -1 otherwise
  5976. */
  5977. AudioEngine.prototype.getGlobalVolume = function () {
  5978. if (this.canUseWebAudio && this._audioContextInitialized) {
  5979. return this.masterGain.gain.value;
  5980. }
  5981. else {
  5982. return -1;
  5983. }
  5984. };
  5985. /**
  5986. * Sets the global volume of your experience (sets on the master gain).
  5987. * @param newVolume Defines the new global volume of the application
  5988. */
  5989. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5990. if (this.canUseWebAudio && this._audioContextInitialized) {
  5991. this.masterGain.gain.value = newVolume;
  5992. }
  5993. };
  5994. /**
  5995. * Connect the audio engine to an audio analyser allowing some amazing
  5996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5998. * @param analyser The analyser to connect to the engine
  5999. */
  6000. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6001. if (this._connectedAnalyser) {
  6002. this._connectedAnalyser.stopDebugCanvas();
  6003. }
  6004. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6005. this._connectedAnalyser = analyser;
  6006. this.masterGain.disconnect();
  6007. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6008. }
  6009. };
  6010. return AudioEngine;
  6011. }());
  6012. /***/ }),
  6013. /***/ "./Audio/audioSceneComponent.ts":
  6014. /*!**************************************!*\
  6015. !*** ./Audio/audioSceneComponent.ts ***!
  6016. \**************************************/
  6017. /*! exports provided: AudioSceneComponent */
  6018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6019. "use strict";
  6020. __webpack_require__.r(__webpack_exports__);
  6021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6022. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6023. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6024. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6026. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6027. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6028. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6029. // Adds the parser to the scene parsers.
  6030. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6031. // TODO: add sound
  6032. var loadedSounds = [];
  6033. var loadedSound;
  6034. container.sounds = container.sounds || [];
  6035. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6036. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6037. var parsedSound = parsedData.sounds[index];
  6038. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6039. if (!parsedSound.url) {
  6040. parsedSound.url = parsedSound.name;
  6041. }
  6042. if (!loadedSounds[parsedSound.url]) {
  6043. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6044. loadedSounds[parsedSound.url] = loadedSound;
  6045. container.sounds.push(loadedSound);
  6046. }
  6047. else {
  6048. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6049. }
  6050. }
  6051. else {
  6052. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6053. }
  6054. }
  6055. }
  6056. loadedSounds = [];
  6057. });
  6058. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6059. get: function () {
  6060. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6061. if (!compo) {
  6062. compo = new AudioSceneComponent(this);
  6063. this._addComponent(compo);
  6064. }
  6065. if (!this._mainSoundTrack) {
  6066. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6067. }
  6068. return this._mainSoundTrack;
  6069. },
  6070. enumerable: true,
  6071. configurable: true
  6072. });
  6073. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6074. var index;
  6075. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6076. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6077. return this.mainSoundTrack.soundCollection[index];
  6078. }
  6079. }
  6080. if (this.soundTracks) {
  6081. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6082. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6083. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6084. return this.soundTracks[sdIndex].soundCollection[index];
  6085. }
  6086. }
  6087. }
  6088. }
  6089. return null;
  6090. };
  6091. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6092. get: function () {
  6093. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6094. if (!compo) {
  6095. compo = new AudioSceneComponent(this);
  6096. this._addComponent(compo);
  6097. }
  6098. return compo.audioEnabled;
  6099. },
  6100. set: function (value) {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. if (value) {
  6107. compo.enableAudio();
  6108. }
  6109. else {
  6110. compo.disableAudio();
  6111. }
  6112. },
  6113. enumerable: true,
  6114. configurable: true
  6115. });
  6116. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6117. get: function () {
  6118. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6119. if (!compo) {
  6120. compo = new AudioSceneComponent(this);
  6121. this._addComponent(compo);
  6122. }
  6123. return compo.headphone;
  6124. },
  6125. set: function (value) {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. if (value) {
  6132. compo.switchAudioModeForHeadphones();
  6133. }
  6134. else {
  6135. compo.switchAudioModeForNormalSpeakers();
  6136. }
  6137. },
  6138. enumerable: true,
  6139. configurable: true
  6140. });
  6141. /**
  6142. * Defines the sound scene component responsible to manage any sounds
  6143. * in a given scene.
  6144. */
  6145. var AudioSceneComponent = /** @class */ (function () {
  6146. /**
  6147. * Creates a new instance of the component for the given scene
  6148. * @param scene Defines the scene to register the component in
  6149. */
  6150. function AudioSceneComponent(scene) {
  6151. /**
  6152. * The component name helpfull to identify the component in the list of scene components.
  6153. */
  6154. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6155. this._audioEnabled = true;
  6156. this._headphone = false;
  6157. this.scene = scene;
  6158. scene.soundTracks = new Array();
  6159. scene.sounds = new Array();
  6160. }
  6161. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6162. /**
  6163. * Gets whether audio is enabled or not.
  6164. * Please use related enable/disable method to switch state.
  6165. */
  6166. get: function () {
  6167. return this._audioEnabled;
  6168. },
  6169. enumerable: true,
  6170. configurable: true
  6171. });
  6172. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6173. /**
  6174. * Gets whether audio is outputing to headphone or not.
  6175. * Please use the according Switch methods to change output.
  6176. */
  6177. get: function () {
  6178. return this._headphone;
  6179. },
  6180. enumerable: true,
  6181. configurable: true
  6182. });
  6183. /**
  6184. * Registers the component in a given scene
  6185. */
  6186. AudioSceneComponent.prototype.register = function () {
  6187. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6188. };
  6189. /**
  6190. * Rebuilds the elements related to this component in case of
  6191. * context lost for instance.
  6192. */
  6193. AudioSceneComponent.prototype.rebuild = function () {
  6194. // Nothing to do here. (Not rendering related)
  6195. };
  6196. /**
  6197. * Serializes the component data to the specified json object
  6198. * @param serializationObject The object to serialize to
  6199. */
  6200. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6201. serializationObject.sounds = [];
  6202. if (this.scene.soundTracks) {
  6203. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6204. var soundtrack = this.scene.soundTracks[index];
  6205. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6206. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6207. }
  6208. }
  6209. }
  6210. };
  6211. /**
  6212. * Adds all the element from the container to the scene
  6213. * @param container the container holding the elements
  6214. */
  6215. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6216. var _this = this;
  6217. if (!container.sounds) {
  6218. return;
  6219. }
  6220. container.sounds.forEach(function (sound) {
  6221. sound.play();
  6222. sound.autoplay = true;
  6223. _this.scene.mainSoundTrack.AddSound(sound);
  6224. });
  6225. };
  6226. /**
  6227. * Removes all the elements in the container from the scene
  6228. * @param container contains the elements to remove
  6229. */
  6230. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6231. var _this = this;
  6232. if (!container.sounds) {
  6233. return;
  6234. }
  6235. container.sounds.forEach(function (sound) {
  6236. sound.stop();
  6237. sound.autoplay = false;
  6238. _this.scene.mainSoundTrack.RemoveSound(sound);
  6239. });
  6240. };
  6241. /**
  6242. * Disposes the component and the associated ressources.
  6243. */
  6244. AudioSceneComponent.prototype.dispose = function () {
  6245. var scene = this.scene;
  6246. if (scene._mainSoundTrack) {
  6247. scene.mainSoundTrack.dispose();
  6248. }
  6249. if (scene.soundTracks) {
  6250. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6251. scene.soundTracks[scIndex].dispose();
  6252. }
  6253. }
  6254. };
  6255. /**
  6256. * Disables audio in the associated scene.
  6257. */
  6258. AudioSceneComponent.prototype.disableAudio = function () {
  6259. var scene = this.scene;
  6260. this._audioEnabled = false;
  6261. var i;
  6262. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6263. scene.mainSoundTrack.soundCollection[i].pause();
  6264. }
  6265. if (scene.soundTracks) {
  6266. for (i = 0; i < scene.soundTracks.length; i++) {
  6267. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6268. scene.soundTracks[i].soundCollection[j].pause();
  6269. }
  6270. }
  6271. }
  6272. };
  6273. /**
  6274. * Enables audio in the associated scene.
  6275. */
  6276. AudioSceneComponent.prototype.enableAudio = function () {
  6277. var scene = this.scene;
  6278. this._audioEnabled = true;
  6279. var i;
  6280. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6281. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6282. scene.mainSoundTrack.soundCollection[i].play();
  6283. }
  6284. }
  6285. if (scene.soundTracks) {
  6286. for (i = 0; i < scene.soundTracks.length; i++) {
  6287. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6288. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6289. scene.soundTracks[i].soundCollection[j].play();
  6290. }
  6291. }
  6292. }
  6293. }
  6294. };
  6295. /**
  6296. * Switch audio to headphone output.
  6297. */
  6298. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6299. var scene = this.scene;
  6300. this._headphone = true;
  6301. scene.mainSoundTrack.switchPanningModelToHRTF();
  6302. if (scene.soundTracks) {
  6303. for (var i = 0; i < scene.soundTracks.length; i++) {
  6304. scene.soundTracks[i].switchPanningModelToHRTF();
  6305. }
  6306. }
  6307. };
  6308. /**
  6309. * Switch audio to normal speakers.
  6310. */
  6311. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6312. var scene = this.scene;
  6313. this._headphone = false;
  6314. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6315. if (scene.soundTracks) {
  6316. for (var i = 0; i < scene.soundTracks.length; i++) {
  6317. scene.soundTracks[i].switchPanningModelToEqualPower();
  6318. }
  6319. }
  6320. };
  6321. AudioSceneComponent.prototype._afterRender = function () {
  6322. var scene = this.scene;
  6323. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6324. return;
  6325. }
  6326. var listeningCamera;
  6327. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6328. if (scene.activeCameras.length > 0) {
  6329. listeningCamera = scene.activeCameras[0];
  6330. }
  6331. else {
  6332. listeningCamera = scene.activeCamera;
  6333. }
  6334. if (listeningCamera && audioEngine.audioContext) {
  6335. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6336. // for VR cameras
  6337. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6338. listeningCamera = listeningCamera.rigCameras[0];
  6339. }
  6340. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6341. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6342. cameraDirection.normalize();
  6343. // To avoid some errors on GearVR
  6344. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6345. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6346. }
  6347. var i;
  6348. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6349. var sound = scene.mainSoundTrack.soundCollection[i];
  6350. if (sound.useCustomAttenuation) {
  6351. sound.updateDistanceFromListener();
  6352. }
  6353. }
  6354. if (scene.soundTracks) {
  6355. for (i = 0; i < scene.soundTracks.length; i++) {
  6356. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6357. sound = scene.soundTracks[i].soundCollection[j];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. }
  6363. }
  6364. }
  6365. };
  6366. return AudioSceneComponent;
  6367. }());
  6368. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6369. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6370. if (!compo) {
  6371. compo = new AudioSceneComponent(scene);
  6372. scene._addComponent(compo);
  6373. }
  6374. };
  6375. /***/ }),
  6376. /***/ "./Audio/index.ts":
  6377. /*!************************!*\
  6378. !*** ./Audio/index.ts ***!
  6379. \************************/
  6380. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6382. "use strict";
  6383. __webpack_require__.r(__webpack_exports__);
  6384. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6386. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6388. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6390. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6392. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6394. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6396. /***/ }),
  6397. /***/ "./Audio/sound.ts":
  6398. /*!************************!*\
  6399. !*** ./Audio/sound.ts ***!
  6400. \************************/
  6401. /*! exports provided: Sound */
  6402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6403. "use strict";
  6404. __webpack_require__.r(__webpack_exports__);
  6405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6406. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6408. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6409. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6410. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6411. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6412. /**
  6413. * Defines a sound that can be played in the application.
  6414. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6416. */
  6417. var Sound = /** @class */ (function () {
  6418. /**
  6419. * Create a sound and attach it to a scene
  6420. * @param name Name of your sound
  6421. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6422. * @param scene defines the scene the sound belongs to
  6423. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6424. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6425. */
  6426. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6427. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6428. var _this = this;
  6429. /**
  6430. * Does the sound autoplay once loaded.
  6431. */
  6432. this.autoplay = false;
  6433. /**
  6434. * Does the sound loop after it finishes playing once.
  6435. */
  6436. this.loop = false;
  6437. /**
  6438. * Does the sound use a custom attenuation curve to simulate the falloff
  6439. * happening when the source gets further away from the camera.
  6440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6441. */
  6442. this.useCustomAttenuation = false;
  6443. /**
  6444. * Is this sound currently played.
  6445. */
  6446. this.isPlaying = false;
  6447. /**
  6448. * Is this sound currently paused.
  6449. */
  6450. this.isPaused = false;
  6451. /**
  6452. * Does this sound enables spatial sound.
  6453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6454. */
  6455. this.spatialSound = false;
  6456. /**
  6457. * Define the reference distance the sound should be heard perfectly.
  6458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6459. */
  6460. this.refDistance = 1;
  6461. /**
  6462. * Define the roll off factor of spatial sounds.
  6463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6464. */
  6465. this.rolloffFactor = 1;
  6466. /**
  6467. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6469. */
  6470. this.maxDistance = 100;
  6471. /**
  6472. * Define the distance attenuation model the sound will follow.
  6473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6474. */
  6475. this.distanceModel = "linear";
  6476. /**
  6477. * Observable event when the current playing sound finishes.
  6478. */
  6479. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6480. this._panningModel = "equalpower";
  6481. this._playbackRate = 1;
  6482. this._streaming = false;
  6483. this._startTime = 0;
  6484. this._startOffset = 0;
  6485. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6486. /** @hidden */
  6487. this._positionInEmitterSpace = false;
  6488. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6489. this._volume = 1;
  6490. this._isReadyToPlay = false;
  6491. this._isDirectional = false;
  6492. // Used if you'd like to create a directional sound.
  6493. // If not set, the sound will be omnidirectional
  6494. this._coneInnerAngle = 360;
  6495. this._coneOuterAngle = 360;
  6496. this._coneOuterGain = 0;
  6497. this._isOutputConnected = false;
  6498. this._urlType = "Unknown";
  6499. this.name = name;
  6500. this._scene = scene;
  6501. Sound._SceneComponentInitialization(scene);
  6502. this._readyToPlayCallback = readyToPlayCallback;
  6503. // Default custom attenuation function is a linear attenuation
  6504. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6505. if (currentDistance < maxDistance) {
  6506. return currentVolume * (1 - currentDistance / maxDistance);
  6507. }
  6508. else {
  6509. return 0;
  6510. }
  6511. };
  6512. if (options) {
  6513. this.autoplay = options.autoplay || false;
  6514. this.loop = options.loop || false;
  6515. // if volume === 0, we need another way to check this option
  6516. if (options.volume !== undefined) {
  6517. this._volume = options.volume;
  6518. }
  6519. this.spatialSound = options.spatialSound || false;
  6520. this.maxDistance = options.maxDistance || 100;
  6521. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6522. this.rolloffFactor = options.rolloffFactor || 1;
  6523. this.refDistance = options.refDistance || 1;
  6524. this.distanceModel = options.distanceModel || "linear";
  6525. this._playbackRate = options.playbackRate || 1;
  6526. this._streaming = options.streaming || false;
  6527. }
  6528. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6529. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6530. this._soundGain.gain.value = this._volume;
  6531. this._inputAudioNode = this._soundGain;
  6532. this._outputAudioNode = this._soundGain;
  6533. if (this.spatialSound) {
  6534. this._createSpatialParameters();
  6535. }
  6536. this._scene.mainSoundTrack.AddSound(this);
  6537. var validParameter = true;
  6538. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6539. if (urlOrArrayBuffer) {
  6540. try {
  6541. if (typeof (urlOrArrayBuffer) === "string") {
  6542. this._urlType = "String";
  6543. }
  6544. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6545. this._urlType = "ArrayBuffer";
  6546. }
  6547. else if (urlOrArrayBuffer instanceof MediaStream) {
  6548. this._urlType = "MediaStream";
  6549. }
  6550. else if (Array.isArray(urlOrArrayBuffer)) {
  6551. this._urlType = "Array";
  6552. }
  6553. var urls = [];
  6554. var codecSupportedFound = false;
  6555. switch (this._urlType) {
  6556. case "MediaStream":
  6557. this._streaming = true;
  6558. this._isReadyToPlay = true;
  6559. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6560. if (this.autoplay) {
  6561. this.play();
  6562. }
  6563. if (this._readyToPlayCallback) {
  6564. this._readyToPlayCallback();
  6565. }
  6566. break;
  6567. case "ArrayBuffer":
  6568. if (urlOrArrayBuffer.byteLength > 0) {
  6569. codecSupportedFound = true;
  6570. this._soundLoaded(urlOrArrayBuffer);
  6571. }
  6572. break;
  6573. case "String":
  6574. urls.push(urlOrArrayBuffer);
  6575. case "Array":
  6576. if (urls.length === 0) {
  6577. urls = urlOrArrayBuffer;
  6578. }
  6579. // If we found a supported format, we load it immediately and stop the loop
  6580. for (var i = 0; i < urls.length; i++) {
  6581. var url = urls[i];
  6582. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6583. codecSupportedFound = true;
  6584. }
  6585. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6586. codecSupportedFound = true;
  6587. }
  6588. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6589. codecSupportedFound = true;
  6590. }
  6591. if (url.indexOf("blob:") !== -1) {
  6592. codecSupportedFound = true;
  6593. }
  6594. if (codecSupportedFound) {
  6595. // Loading sound using XHR2
  6596. if (!this._streaming) {
  6597. this._scene._loadFile(url, function (data) {
  6598. _this._soundLoaded(data);
  6599. }, undefined, true, true, function (exception) {
  6600. if (exception) {
  6601. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6602. }
  6603. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6604. _this._scene.mainSoundTrack.RemoveSound(_this);
  6605. });
  6606. }
  6607. // Streaming sound using HTML5 Audio tag
  6608. else {
  6609. this._htmlAudioElement = new Audio(url);
  6610. this._htmlAudioElement.controls = false;
  6611. this._htmlAudioElement.loop = this.loop;
  6612. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6613. this._htmlAudioElement.preload = "auto";
  6614. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6615. _this._isReadyToPlay = true;
  6616. if (_this.autoplay) {
  6617. _this.play();
  6618. }
  6619. if (_this._readyToPlayCallback) {
  6620. _this._readyToPlayCallback();
  6621. }
  6622. });
  6623. document.body.appendChild(this._htmlAudioElement);
  6624. this._htmlAudioElement.load();
  6625. }
  6626. break;
  6627. }
  6628. }
  6629. break;
  6630. default:
  6631. validParameter = false;
  6632. break;
  6633. }
  6634. if (!validParameter) {
  6635. _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.");
  6636. }
  6637. else {
  6638. if (!codecSupportedFound) {
  6639. this._isReadyToPlay = true;
  6640. // Simulating a ready to play event to avoid breaking code path
  6641. if (this._readyToPlayCallback) {
  6642. window.setTimeout(function () {
  6643. if (_this._readyToPlayCallback) {
  6644. _this._readyToPlayCallback();
  6645. }
  6646. }, 1000);
  6647. }
  6648. }
  6649. }
  6650. }
  6651. catch (ex) {
  6652. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6653. this._scene.mainSoundTrack.RemoveSound(this);
  6654. }
  6655. }
  6656. }
  6657. else {
  6658. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6659. this._scene.mainSoundTrack.AddSound(this);
  6660. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6661. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6662. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6663. }
  6664. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6665. if (this._readyToPlayCallback) {
  6666. window.setTimeout(function () {
  6667. if (_this._readyToPlayCallback) {
  6668. _this._readyToPlayCallback();
  6669. }
  6670. }, 1000);
  6671. }
  6672. }
  6673. }
  6674. /**
  6675. * Release the sound and its associated resources
  6676. */
  6677. Sound.prototype.dispose = function () {
  6678. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6679. if (this.isPlaying) {
  6680. this.stop();
  6681. }
  6682. this._isReadyToPlay = false;
  6683. if (this.soundTrackId === -1) {
  6684. this._scene.mainSoundTrack.RemoveSound(this);
  6685. }
  6686. else if (this._scene.soundTracks) {
  6687. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6688. }
  6689. if (this._soundGain) {
  6690. this._soundGain.disconnect();
  6691. this._soundGain = null;
  6692. }
  6693. if (this._soundPanner) {
  6694. this._soundPanner.disconnect();
  6695. this._soundPanner = null;
  6696. }
  6697. if (this._soundSource) {
  6698. this._soundSource.disconnect();
  6699. this._soundSource = null;
  6700. }
  6701. this._audioBuffer = null;
  6702. if (this._htmlAudioElement) {
  6703. this._htmlAudioElement.pause();
  6704. this._htmlAudioElement.src = "";
  6705. document.body.removeChild(this._htmlAudioElement);
  6706. }
  6707. if (this._streamingSource) {
  6708. this._streamingSource.disconnect();
  6709. }
  6710. if (this._connectedTransformNode && this._registerFunc) {
  6711. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6712. this._connectedTransformNode = null;
  6713. }
  6714. }
  6715. };
  6716. /**
  6717. * Gets if the sounds is ready to be played or not.
  6718. * @returns true if ready, otherwise false
  6719. */
  6720. Sound.prototype.isReady = function () {
  6721. return this._isReadyToPlay;
  6722. };
  6723. Sound.prototype._soundLoaded = function (audioData) {
  6724. var _this = this;
  6725. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6726. return;
  6727. }
  6728. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6729. _this._audioBuffer = buffer;
  6730. _this._isReadyToPlay = true;
  6731. if (_this.autoplay) {
  6732. _this.play();
  6733. }
  6734. if (_this._readyToPlayCallback) {
  6735. _this._readyToPlayCallback();
  6736. }
  6737. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6738. };
  6739. /**
  6740. * Sets the data of the sound from an audiobuffer
  6741. * @param audioBuffer The audioBuffer containing the data
  6742. */
  6743. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6744. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6745. this._audioBuffer = audioBuffer;
  6746. this._isReadyToPlay = true;
  6747. }
  6748. };
  6749. /**
  6750. * Updates the current sounds options such as maxdistance, loop...
  6751. * @param options A JSON object containing values named as the object properties
  6752. */
  6753. Sound.prototype.updateOptions = function (options) {
  6754. if (options) {
  6755. this.loop = options.loop || this.loop;
  6756. this.maxDistance = options.maxDistance || this.maxDistance;
  6757. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6758. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6759. this.refDistance = options.refDistance || this.refDistance;
  6760. this.distanceModel = options.distanceModel || this.distanceModel;
  6761. this._playbackRate = options.playbackRate || this._playbackRate;
  6762. this._updateSpatialParameters();
  6763. if (this.isPlaying) {
  6764. if (this._streaming && this._htmlAudioElement) {
  6765. this._htmlAudioElement.playbackRate = this._playbackRate;
  6766. }
  6767. else {
  6768. if (this._soundSource) {
  6769. this._soundSource.playbackRate.value = this._playbackRate;
  6770. }
  6771. }
  6772. }
  6773. }
  6774. };
  6775. Sound.prototype._createSpatialParameters = function () {
  6776. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6777. if (this._scene.headphone) {
  6778. this._panningModel = "HRTF";
  6779. }
  6780. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6781. this._updateSpatialParameters();
  6782. this._soundPanner.connect(this._outputAudioNode);
  6783. this._inputAudioNode = this._soundPanner;
  6784. }
  6785. };
  6786. Sound.prototype._updateSpatialParameters = function () {
  6787. if (this.spatialSound && this._soundPanner) {
  6788. if (this.useCustomAttenuation) {
  6789. // Tricks to disable in a way embedded Web Audio attenuation
  6790. this._soundPanner.distanceModel = "linear";
  6791. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6792. this._soundPanner.refDistance = 1;
  6793. this._soundPanner.rolloffFactor = 1;
  6794. this._soundPanner.panningModel = this._panningModel;
  6795. }
  6796. else {
  6797. this._soundPanner.distanceModel = this.distanceModel;
  6798. this._soundPanner.maxDistance = this.maxDistance;
  6799. this._soundPanner.refDistance = this.refDistance;
  6800. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6801. this._soundPanner.panningModel = this._panningModel;
  6802. }
  6803. }
  6804. };
  6805. /**
  6806. * Switch the panning model to HRTF:
  6807. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6809. */
  6810. Sound.prototype.switchPanningModelToHRTF = function () {
  6811. this._panningModel = "HRTF";
  6812. this._switchPanningModel();
  6813. };
  6814. /**
  6815. * Switch the panning model to Equal Power:
  6816. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6818. */
  6819. Sound.prototype.switchPanningModelToEqualPower = function () {
  6820. this._panningModel = "equalpower";
  6821. this._switchPanningModel();
  6822. };
  6823. Sound.prototype._switchPanningModel = function () {
  6824. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6825. this._soundPanner.panningModel = this._panningModel;
  6826. }
  6827. };
  6828. /**
  6829. * Connect this sound to a sound track audio node like gain...
  6830. * @param soundTrackAudioNode the sound track audio node to connect to
  6831. */
  6832. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6833. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6834. if (this._isOutputConnected) {
  6835. this._outputAudioNode.disconnect();
  6836. }
  6837. this._outputAudioNode.connect(soundTrackAudioNode);
  6838. this._isOutputConnected = true;
  6839. }
  6840. };
  6841. /**
  6842. * Transform this sound into a directional source
  6843. * @param coneInnerAngle Size of the inner cone in degree
  6844. * @param coneOuterAngle Size of the outer cone in degree
  6845. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6846. */
  6847. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6848. if (coneOuterAngle < coneInnerAngle) {
  6849. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6850. return;
  6851. }
  6852. this._coneInnerAngle = coneInnerAngle;
  6853. this._coneOuterAngle = coneOuterAngle;
  6854. this._coneOuterGain = coneOuterGain;
  6855. this._isDirectional = true;
  6856. if (this.isPlaying && this.loop) {
  6857. this.stop();
  6858. this.play();
  6859. }
  6860. };
  6861. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6862. /**
  6863. * Gets or sets the inner angle for the directional cone.
  6864. */
  6865. get: function () {
  6866. return this._coneInnerAngle;
  6867. },
  6868. /**
  6869. * Gets or sets the inner angle for the directional cone.
  6870. */
  6871. set: function (value) {
  6872. if (value != this._coneInnerAngle) {
  6873. if (this._coneOuterAngle < value) {
  6874. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6875. return;
  6876. }
  6877. this._coneInnerAngle = value;
  6878. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6879. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6880. }
  6881. }
  6882. },
  6883. enumerable: true,
  6884. configurable: true
  6885. });
  6886. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6887. /**
  6888. * Gets or sets the outer angle for the directional cone.
  6889. */
  6890. get: function () {
  6891. return this._coneOuterAngle;
  6892. },
  6893. /**
  6894. * Gets or sets the outer angle for the directional cone.
  6895. */
  6896. set: function (value) {
  6897. if (value != this._coneOuterAngle) {
  6898. if (value < this._coneInnerAngle) {
  6899. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6900. return;
  6901. }
  6902. this._coneOuterAngle = value;
  6903. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6904. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6905. }
  6906. }
  6907. },
  6908. enumerable: true,
  6909. configurable: true
  6910. });
  6911. /**
  6912. * Sets the position of the emitter if spatial sound is enabled
  6913. * @param newPosition Defines the new posisiton
  6914. */
  6915. Sound.prototype.setPosition = function (newPosition) {
  6916. this._position = newPosition;
  6917. 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)) {
  6918. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6919. }
  6920. };
  6921. /**
  6922. * Sets the local direction of the emitter if spatial sound is enabled
  6923. * @param newLocalDirection Defines the new local direction
  6924. */
  6925. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6926. this._localDirection = newLocalDirection;
  6927. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6928. this._updateDirection();
  6929. }
  6930. };
  6931. Sound.prototype._updateDirection = function () {
  6932. if (!this._connectedTransformNode || !this._soundPanner) {
  6933. return;
  6934. }
  6935. var mat = this._connectedTransformNode.getWorldMatrix();
  6936. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6937. direction.normalize();
  6938. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6939. };
  6940. /** @hidden */
  6941. Sound.prototype.updateDistanceFromListener = function () {
  6942. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6943. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6944. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6945. }
  6946. };
  6947. /**
  6948. * Sets a new custom attenuation function for the sound.
  6949. * @param callback Defines the function used for the attenuation
  6950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6951. */
  6952. Sound.prototype.setAttenuationFunction = function (callback) {
  6953. this._customAttenuationFunction = callback;
  6954. };
  6955. /**
  6956. * Play the sound
  6957. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6958. * @param offset (optional) Start the sound setting it at a specific time
  6959. */
  6960. Sound.prototype.play = function (time, offset) {
  6961. var _this = this;
  6962. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6963. try {
  6964. if (this._startOffset < 0) {
  6965. time = -this._startOffset;
  6966. this._startOffset = 0;
  6967. }
  6968. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6969. if (!this._soundSource || !this._streamingSource) {
  6970. if (this.spatialSound && this._soundPanner) {
  6971. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6972. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6973. }
  6974. if (this._isDirectional) {
  6975. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6976. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6977. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6978. if (this._connectedTransformNode) {
  6979. this._updateDirection();
  6980. }
  6981. else {
  6982. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6983. }
  6984. }
  6985. }
  6986. }
  6987. if (this._streaming) {
  6988. if (!this._streamingSource) {
  6989. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6990. this._htmlAudioElement.onended = function () { _this._onended(); };
  6991. this._htmlAudioElement.playbackRate = this._playbackRate;
  6992. }
  6993. this._streamingSource.disconnect();
  6994. this._streamingSource.connect(this._inputAudioNode);
  6995. if (this._htmlAudioElement) {
  6996. // required to manage properly the new suspended default state of Chrome
  6997. // When the option 'streaming: true' is used, we need first to wait for
  6998. // the audio engine to be unlocked by a user gesture before trying to play
  6999. // an HTML Audio elememt
  7000. var tryToPlay = function () {
  7001. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7002. var playPromise = _this._htmlAudioElement.play();
  7003. // In browsers that don’t yet support this functionality,
  7004. // playPromise won’t be defined.
  7005. if (playPromise !== undefined) {
  7006. playPromise.catch(function (error) {
  7007. // Automatic playback failed.
  7008. // Waiting for the audio engine to be unlocked by user click on unmute
  7009. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7010. if (_this.loop || _this.autoplay) {
  7011. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7012. }
  7013. });
  7014. }
  7015. }
  7016. else {
  7017. if (_this.loop || _this.autoplay) {
  7018. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7019. }
  7020. }
  7021. };
  7022. tryToPlay();
  7023. }
  7024. }
  7025. else {
  7026. var tryToPlay = function () {
  7027. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7028. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7029. _this._soundSource.buffer = _this._audioBuffer;
  7030. _this._soundSource.connect(_this._inputAudioNode);
  7031. _this._soundSource.loop = _this.loop;
  7032. _this._soundSource.playbackRate.value = _this._playbackRate;
  7033. _this._soundSource.onended = function () { _this._onended(); };
  7034. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7035. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7036. }
  7037. };
  7038. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7039. // Wait a bit for FF as context seems late to be ready.
  7040. setTimeout(function () {
  7041. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7042. // Automatic playback failed.
  7043. // Waiting for the audio engine to be unlocked by user click on unmute
  7044. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7045. if (_this.loop || _this.autoplay) {
  7046. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7047. }
  7048. }
  7049. else {
  7050. tryToPlay();
  7051. }
  7052. }, 500);
  7053. }
  7054. else {
  7055. tryToPlay();
  7056. }
  7057. }
  7058. this._startTime = startTime;
  7059. this.isPlaying = true;
  7060. this.isPaused = false;
  7061. }
  7062. catch (ex) {
  7063. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7064. }
  7065. }
  7066. };
  7067. Sound.prototype._onended = function () {
  7068. this.isPlaying = false;
  7069. if (this.onended) {
  7070. this.onended();
  7071. }
  7072. this.onEndedObservable.notifyObservers(this);
  7073. };
  7074. /**
  7075. * Stop the sound
  7076. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7077. */
  7078. Sound.prototype.stop = function (time) {
  7079. if (this.isPlaying) {
  7080. if (this._streaming) {
  7081. if (this._htmlAudioElement) {
  7082. this._htmlAudioElement.pause();
  7083. // Test needed for Firefox or it will generate an Invalid State Error
  7084. if (this._htmlAudioElement.currentTime > 0) {
  7085. this._htmlAudioElement.currentTime = 0;
  7086. }
  7087. }
  7088. else {
  7089. this._streamingSource.disconnect();
  7090. }
  7091. }
  7092. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7093. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7094. this._soundSource.stop(stopTime);
  7095. this._soundSource.onended = function () { };
  7096. if (!this.isPaused) {
  7097. this._startOffset = 0;
  7098. }
  7099. }
  7100. this.isPlaying = false;
  7101. }
  7102. };
  7103. /**
  7104. * Put the sound in pause
  7105. */
  7106. Sound.prototype.pause = function () {
  7107. if (this.isPlaying) {
  7108. this.isPaused = true;
  7109. if (this._streaming) {
  7110. if (this._htmlAudioElement) {
  7111. this._htmlAudioElement.pause();
  7112. }
  7113. else {
  7114. this._streamingSource.disconnect();
  7115. }
  7116. }
  7117. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7118. this.stop(0);
  7119. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7120. }
  7121. }
  7122. };
  7123. /**
  7124. * Sets a dedicated volume for this sounds
  7125. * @param newVolume Define the new volume of the sound
  7126. * @param time Define in how long the sound should be at this value
  7127. */
  7128. Sound.prototype.setVolume = function (newVolume, time) {
  7129. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7130. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7131. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7132. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7133. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7134. }
  7135. else {
  7136. this._soundGain.gain.value = newVolume;
  7137. }
  7138. }
  7139. this._volume = newVolume;
  7140. };
  7141. /**
  7142. * Set the sound play back rate
  7143. * @param newPlaybackRate Define the playback rate the sound should be played at
  7144. */
  7145. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7146. this._playbackRate = newPlaybackRate;
  7147. if (this.isPlaying) {
  7148. if (this._streaming && this._htmlAudioElement) {
  7149. this._htmlAudioElement.playbackRate = this._playbackRate;
  7150. }
  7151. else if (this._soundSource) {
  7152. this._soundSource.playbackRate.value = this._playbackRate;
  7153. }
  7154. }
  7155. };
  7156. /**
  7157. * Gets the volume of the sound.
  7158. * @returns the volume of the sound
  7159. */
  7160. Sound.prototype.getVolume = function () {
  7161. return this._volume;
  7162. };
  7163. /**
  7164. * Attach the sound to a dedicated mesh
  7165. * @param transformNode The transform node to connect the sound with
  7166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7167. */
  7168. Sound.prototype.attachToMesh = function (transformNode) {
  7169. var _this = this;
  7170. if (this._connectedTransformNode && this._registerFunc) {
  7171. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7172. this._registerFunc = null;
  7173. }
  7174. this._connectedTransformNode = transformNode;
  7175. if (!this.spatialSound) {
  7176. this.spatialSound = true;
  7177. this._createSpatialParameters();
  7178. if (this.isPlaying && this.loop) {
  7179. this.stop();
  7180. this.play();
  7181. }
  7182. }
  7183. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7184. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7185. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7186. };
  7187. /**
  7188. * Detach the sound from the previously attached mesh
  7189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7190. */
  7191. Sound.prototype.detachFromMesh = function () {
  7192. if (this._connectedTransformNode && this._registerFunc) {
  7193. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7194. this._registerFunc = null;
  7195. this._connectedTransformNode = null;
  7196. }
  7197. };
  7198. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7199. if (!node.getBoundingInfo) {
  7200. return;
  7201. }
  7202. var mesh = node;
  7203. if (this._positionInEmitterSpace) {
  7204. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7205. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7206. }
  7207. else {
  7208. var boundingInfo = mesh.getBoundingInfo();
  7209. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7210. }
  7211. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7212. this._updateDirection();
  7213. }
  7214. };
  7215. /**
  7216. * Clone the current sound in the scene.
  7217. * @returns the new sound clone
  7218. */
  7219. Sound.prototype.clone = function () {
  7220. var _this = this;
  7221. if (!this._streaming) {
  7222. var setBufferAndRun = function () {
  7223. if (_this._isReadyToPlay) {
  7224. clonedSound._audioBuffer = _this.getAudioBuffer();
  7225. clonedSound._isReadyToPlay = true;
  7226. if (clonedSound.autoplay) {
  7227. clonedSound.play();
  7228. }
  7229. }
  7230. else {
  7231. window.setTimeout(setBufferAndRun, 300);
  7232. }
  7233. };
  7234. var currentOptions = {
  7235. autoplay: this.autoplay, loop: this.loop,
  7236. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7237. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7238. refDistance: this.refDistance, distanceModel: this.distanceModel
  7239. };
  7240. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7241. if (this.useCustomAttenuation) {
  7242. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7243. }
  7244. clonedSound.setPosition(this._position);
  7245. clonedSound.setPlaybackRate(this._playbackRate);
  7246. setBufferAndRun();
  7247. return clonedSound;
  7248. }
  7249. // Can't clone a streaming sound
  7250. else {
  7251. return null;
  7252. }
  7253. };
  7254. /**
  7255. * Gets the current underlying audio buffer containing the data
  7256. * @returns the audio buffer
  7257. */
  7258. Sound.prototype.getAudioBuffer = function () {
  7259. return this._audioBuffer;
  7260. };
  7261. /**
  7262. * Serializes the Sound in a JSON representation
  7263. * @returns the JSON representation of the sound
  7264. */
  7265. Sound.prototype.serialize = function () {
  7266. var serializationObject = {
  7267. name: this.name,
  7268. url: this.name,
  7269. autoplay: this.autoplay,
  7270. loop: this.loop,
  7271. volume: this._volume,
  7272. spatialSound: this.spatialSound,
  7273. maxDistance: this.maxDistance,
  7274. rolloffFactor: this.rolloffFactor,
  7275. refDistance: this.refDistance,
  7276. distanceModel: this.distanceModel,
  7277. playbackRate: this._playbackRate,
  7278. panningModel: this._panningModel,
  7279. soundTrackId: this.soundTrackId
  7280. };
  7281. if (this.spatialSound) {
  7282. if (this._connectedTransformNode) {
  7283. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7284. }
  7285. serializationObject.position = this._position.asArray();
  7286. serializationObject.refDistance = this.refDistance;
  7287. serializationObject.distanceModel = this.distanceModel;
  7288. serializationObject.isDirectional = this._isDirectional;
  7289. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7290. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7291. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7292. serializationObject.coneOuterGain = this._coneOuterGain;
  7293. }
  7294. return serializationObject;
  7295. };
  7296. /**
  7297. * Parse a JSON representation of a sound to innstantiate in a given scene
  7298. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7299. * @param scene Define the scene the new parsed sound should be created in
  7300. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7301. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7302. * @returns the newly parsed sound
  7303. */
  7304. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7305. var soundName = parsedSound.name;
  7306. var soundUrl;
  7307. if (parsedSound.url) {
  7308. soundUrl = rootUrl + parsedSound.url;
  7309. }
  7310. else {
  7311. soundUrl = rootUrl + soundName;
  7312. }
  7313. var options = {
  7314. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7315. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7316. rolloffFactor: parsedSound.rolloffFactor,
  7317. refDistance: parsedSound.refDistance,
  7318. distanceModel: parsedSound.distanceModel,
  7319. playbackRate: parsedSound.playbackRate
  7320. };
  7321. var newSound;
  7322. if (!sourceSound) {
  7323. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7324. scene._addPendingData(newSound);
  7325. }
  7326. else {
  7327. var setBufferAndRun = function () {
  7328. if (sourceSound._isReadyToPlay) {
  7329. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7330. newSound._isReadyToPlay = true;
  7331. if (newSound.autoplay) {
  7332. newSound.play();
  7333. }
  7334. }
  7335. else {
  7336. window.setTimeout(setBufferAndRun, 300);
  7337. }
  7338. };
  7339. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7340. setBufferAndRun();
  7341. }
  7342. if (parsedSound.position) {
  7343. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7344. newSound.setPosition(soundPosition);
  7345. }
  7346. if (parsedSound.isDirectional) {
  7347. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7348. if (parsedSound.localDirectionToMesh) {
  7349. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7350. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7351. }
  7352. }
  7353. if (parsedSound.connectedMeshId) {
  7354. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7355. if (connectedMesh) {
  7356. newSound.attachToMesh(connectedMesh);
  7357. }
  7358. }
  7359. return newSound;
  7360. };
  7361. /** @hidden */
  7362. Sound._SceneComponentInitialization = function (_) {
  7363. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7364. };
  7365. return Sound;
  7366. }());
  7367. /***/ }),
  7368. /***/ "./Audio/soundTrack.ts":
  7369. /*!*****************************!*\
  7370. !*** ./Audio/soundTrack.ts ***!
  7371. \*****************************/
  7372. /*! exports provided: SoundTrack */
  7373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7374. "use strict";
  7375. __webpack_require__.r(__webpack_exports__);
  7376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7377. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7378. /**
  7379. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7380. * It will be also used in a future release to apply effects on a specific track.
  7381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7382. */
  7383. var SoundTrack = /** @class */ (function () {
  7384. /**
  7385. * Creates a new sound track.
  7386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7387. * @param scene Define the scene the sound track belongs to
  7388. * @param options
  7389. */
  7390. function SoundTrack(scene, options) {
  7391. if (options === void 0) { options = {}; }
  7392. /**
  7393. * The unique identifier of the sound track in the scene.
  7394. */
  7395. this.id = -1;
  7396. this._isMainTrack = false;
  7397. this._isInitialized = false;
  7398. this._scene = scene;
  7399. this.soundCollection = new Array();
  7400. this._options = options;
  7401. if (!this._isMainTrack && this._scene.soundTracks) {
  7402. this._scene.soundTracks.push(this);
  7403. this.id = this._scene.soundTracks.length - 1;
  7404. }
  7405. }
  7406. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7407. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7408. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7409. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7410. if (this._options) {
  7411. if (this._options.volume) {
  7412. this._outputAudioNode.gain.value = this._options.volume;
  7413. }
  7414. if (this._options.mainTrack) {
  7415. this._isMainTrack = this._options.mainTrack;
  7416. }
  7417. }
  7418. this._isInitialized = true;
  7419. }
  7420. };
  7421. /**
  7422. * Release the sound track and its associated resources
  7423. */
  7424. SoundTrack.prototype.dispose = function () {
  7425. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7426. if (this._connectedAnalyser) {
  7427. this._connectedAnalyser.stopDebugCanvas();
  7428. }
  7429. while (this.soundCollection.length) {
  7430. this.soundCollection[0].dispose();
  7431. }
  7432. if (this._outputAudioNode) {
  7433. this._outputAudioNode.disconnect();
  7434. }
  7435. this._outputAudioNode = null;
  7436. }
  7437. };
  7438. /**
  7439. * Adds a sound to this sound track
  7440. * @param sound define the cound to add
  7441. * @ignoreNaming
  7442. */
  7443. SoundTrack.prototype.AddSound = function (sound) {
  7444. if (!this._isInitialized) {
  7445. this._initializeSoundTrackAudioGraph();
  7446. }
  7447. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7448. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7449. }
  7450. if (sound.soundTrackId) {
  7451. if (sound.soundTrackId === -1) {
  7452. this._scene.mainSoundTrack.RemoveSound(sound);
  7453. }
  7454. else if (this._scene.soundTracks) {
  7455. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7456. }
  7457. }
  7458. this.soundCollection.push(sound);
  7459. sound.soundTrackId = this.id;
  7460. };
  7461. /**
  7462. * Removes a sound to this sound track
  7463. * @param sound define the cound to remove
  7464. * @ignoreNaming
  7465. */
  7466. SoundTrack.prototype.RemoveSound = function (sound) {
  7467. var index = this.soundCollection.indexOf(sound);
  7468. if (index !== -1) {
  7469. this.soundCollection.splice(index, 1);
  7470. }
  7471. };
  7472. /**
  7473. * Set a global volume for the full sound track.
  7474. * @param newVolume Define the new volume of the sound track
  7475. */
  7476. SoundTrack.prototype.setVolume = function (newVolume) {
  7477. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7478. this._outputAudioNode.gain.value = newVolume;
  7479. }
  7480. };
  7481. /**
  7482. * Switch the panning model to HRTF:
  7483. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7485. */
  7486. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7487. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7488. for (var i = 0; i < this.soundCollection.length; i++) {
  7489. this.soundCollection[i].switchPanningModelToHRTF();
  7490. }
  7491. }
  7492. };
  7493. /**
  7494. * Switch the panning model to Equal Power:
  7495. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7497. */
  7498. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7499. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7500. for (var i = 0; i < this.soundCollection.length; i++) {
  7501. this.soundCollection[i].switchPanningModelToEqualPower();
  7502. }
  7503. }
  7504. };
  7505. /**
  7506. * Connect the sound track to an audio analyser allowing some amazing
  7507. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7509. * @param analyser The analyser to connect to the engine
  7510. */
  7511. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7512. if (this._connectedAnalyser) {
  7513. this._connectedAnalyser.stopDebugCanvas();
  7514. }
  7515. this._connectedAnalyser = analyser;
  7516. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7517. this._outputAudioNode.disconnect();
  7518. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7519. }
  7520. };
  7521. return SoundTrack;
  7522. }());
  7523. /***/ }),
  7524. /***/ "./Audio/weightedsound.ts":
  7525. /*!********************************!*\
  7526. !*** ./Audio/weightedsound.ts ***!
  7527. \********************************/
  7528. /*! exports provided: WeightedSound */
  7529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7530. "use strict";
  7531. __webpack_require__.r(__webpack_exports__);
  7532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7533. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7534. /**
  7535. * Wraps one or more Sound objects and selects one with random weight for playback.
  7536. */
  7537. var WeightedSound = /** @class */ (function () {
  7538. /**
  7539. * Creates a new WeightedSound from the list of sounds given.
  7540. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7541. * @param sounds Array of Sounds that will be selected from.
  7542. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7543. */
  7544. function WeightedSound(loop, sounds, weights) {
  7545. var _this = this;
  7546. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7547. this.loop = false;
  7548. this._coneInnerAngle = 360;
  7549. this._coneOuterAngle = 360;
  7550. this._volume = 1;
  7551. /** A Sound is currently playing. */
  7552. this.isPlaying = false;
  7553. /** A Sound is currently paused. */
  7554. this.isPaused = false;
  7555. this._sounds = [];
  7556. this._weights = [];
  7557. if (sounds.length !== weights.length) {
  7558. throw new Error('Sounds length does not equal weights length');
  7559. }
  7560. this.loop = loop;
  7561. this._weights = weights;
  7562. // Normalize the weights
  7563. var weightSum = 0;
  7564. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7565. var weight = weights_1[_i];
  7566. weightSum += weight;
  7567. }
  7568. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7569. for (var i = 0; i < this._weights.length; i++) {
  7570. this._weights[i] *= invWeightSum;
  7571. }
  7572. this._sounds = sounds;
  7573. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7574. var sound = _b[_a];
  7575. sound.onEndedObservable.add(function () { _this._onended(); });
  7576. }
  7577. }
  7578. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7579. /**
  7580. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7581. */
  7582. get: function () {
  7583. return this._coneInnerAngle;
  7584. },
  7585. /**
  7586. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7587. */
  7588. set: function (value) {
  7589. if (value !== this._coneInnerAngle) {
  7590. if (this._coneOuterAngle < value) {
  7591. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7592. return;
  7593. }
  7594. this._coneInnerAngle = value;
  7595. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7596. var sound = _a[_i];
  7597. sound.directionalConeInnerAngle = value;
  7598. }
  7599. }
  7600. },
  7601. enumerable: true,
  7602. configurable: true
  7603. });
  7604. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7605. /**
  7606. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7607. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7608. */
  7609. get: function () {
  7610. return this._coneOuterAngle;
  7611. },
  7612. /**
  7613. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7614. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7615. */
  7616. set: function (value) {
  7617. if (value !== this._coneOuterAngle) {
  7618. if (value < this._coneInnerAngle) {
  7619. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7620. return;
  7621. }
  7622. this._coneOuterAngle = value;
  7623. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7624. var sound = _a[_i];
  7625. sound.directionalConeOuterAngle = value;
  7626. }
  7627. }
  7628. },
  7629. enumerable: true,
  7630. configurable: true
  7631. });
  7632. Object.defineProperty(WeightedSound.prototype, "volume", {
  7633. /**
  7634. * Playback volume.
  7635. */
  7636. get: function () {
  7637. return this._volume;
  7638. },
  7639. /**
  7640. * Playback volume.
  7641. */
  7642. set: function (value) {
  7643. if (value !== this._volume) {
  7644. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7645. var sound = _a[_i];
  7646. sound.setVolume(value);
  7647. }
  7648. }
  7649. },
  7650. enumerable: true,
  7651. configurable: true
  7652. });
  7653. WeightedSound.prototype._onended = function () {
  7654. if (this._currentIndex !== undefined) {
  7655. this._sounds[this._currentIndex].autoplay = false;
  7656. }
  7657. if (this.loop && this.isPlaying) {
  7658. this.play();
  7659. }
  7660. else {
  7661. this.isPlaying = false;
  7662. }
  7663. };
  7664. /**
  7665. * Suspend playback
  7666. */
  7667. WeightedSound.prototype.pause = function () {
  7668. this.isPaused = true;
  7669. if (this._currentIndex !== undefined) {
  7670. this._sounds[this._currentIndex].pause();
  7671. }
  7672. };
  7673. /**
  7674. * Stop playback
  7675. */
  7676. WeightedSound.prototype.stop = function () {
  7677. this.isPlaying = false;
  7678. if (this._currentIndex !== undefined) {
  7679. this._sounds[this._currentIndex].stop();
  7680. }
  7681. };
  7682. /**
  7683. * Start playback.
  7684. * @param startOffset Position the clip head at a specific time in seconds.
  7685. */
  7686. WeightedSound.prototype.play = function (startOffset) {
  7687. if (!this.isPaused) {
  7688. this.stop();
  7689. var randomValue = Math.random();
  7690. var total = 0;
  7691. for (var i = 0; i < this._weights.length; i++) {
  7692. total += this._weights[i];
  7693. if (randomValue <= total) {
  7694. this._currentIndex = i;
  7695. break;
  7696. }
  7697. }
  7698. }
  7699. var sound = this._sounds[this._currentIndex];
  7700. if (sound.isReady()) {
  7701. sound.play(0, this.isPaused ? undefined : startOffset);
  7702. }
  7703. else {
  7704. sound.autoplay = true;
  7705. }
  7706. this.isPlaying = true;
  7707. this.isPaused = false;
  7708. };
  7709. return WeightedSound;
  7710. }());
  7711. /***/ }),
  7712. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7713. /*!***************************************************!*\
  7714. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7715. \***************************************************/
  7716. /*! exports provided: AutoRotationBehavior */
  7717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7718. "use strict";
  7719. __webpack_require__.r(__webpack_exports__);
  7720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7721. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7722. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7723. /**
  7724. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7726. */
  7727. var AutoRotationBehavior = /** @class */ (function () {
  7728. function AutoRotationBehavior() {
  7729. this._zoomStopsAnimation = false;
  7730. this._idleRotationSpeed = 0.05;
  7731. this._idleRotationWaitTime = 2000;
  7732. this._idleRotationSpinupTime = 2000;
  7733. this._isPointerDown = false;
  7734. this._lastFrameTime = null;
  7735. this._lastInteractionTime = -Infinity;
  7736. this._cameraRotationSpeed = 0;
  7737. this._lastFrameRadius = 0;
  7738. }
  7739. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7740. /**
  7741. * Gets the name of the behavior.
  7742. */
  7743. get: function () {
  7744. return "AutoRotation";
  7745. },
  7746. enumerable: true,
  7747. configurable: true
  7748. });
  7749. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7750. /**
  7751. * Gets the flag that indicates if user zooming should stop animation.
  7752. */
  7753. get: function () {
  7754. return this._zoomStopsAnimation;
  7755. },
  7756. /**
  7757. * Sets the flag that indicates if user zooming should stop animation.
  7758. */
  7759. set: function (flag) {
  7760. this._zoomStopsAnimation = flag;
  7761. },
  7762. enumerable: true,
  7763. configurable: true
  7764. });
  7765. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7766. /**
  7767. * Gets the default speed at which the camera rotates around the model.
  7768. */
  7769. get: function () {
  7770. return this._idleRotationSpeed;
  7771. },
  7772. /**
  7773. * Sets the default speed at which the camera rotates around the model.
  7774. */
  7775. set: function (speed) {
  7776. this._idleRotationSpeed = speed;
  7777. },
  7778. enumerable: true,
  7779. configurable: true
  7780. });
  7781. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7782. /**
  7783. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7784. */
  7785. get: function () {
  7786. return this._idleRotationWaitTime;
  7787. },
  7788. /**
  7789. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7790. */
  7791. set: function (time) {
  7792. this._idleRotationWaitTime = time;
  7793. },
  7794. enumerable: true,
  7795. configurable: true
  7796. });
  7797. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7798. /**
  7799. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7800. */
  7801. get: function () {
  7802. return this._idleRotationSpinupTime;
  7803. },
  7804. /**
  7805. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7806. */
  7807. set: function (time) {
  7808. this._idleRotationSpinupTime = time;
  7809. },
  7810. enumerable: true,
  7811. configurable: true
  7812. });
  7813. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7814. /**
  7815. * Gets a value indicating if the camera is currently rotating because of this behavior
  7816. */
  7817. get: function () {
  7818. return Math.abs(this._cameraRotationSpeed) > 0;
  7819. },
  7820. enumerable: true,
  7821. configurable: true
  7822. });
  7823. /**
  7824. * Initializes the behavior.
  7825. */
  7826. AutoRotationBehavior.prototype.init = function () {
  7827. // Do notihng
  7828. };
  7829. /**
  7830. * Attaches the behavior to its arc rotate camera.
  7831. * @param camera Defines the camera to attach the behavior to
  7832. */
  7833. AutoRotationBehavior.prototype.attach = function (camera) {
  7834. var _this = this;
  7835. this._attachedCamera = camera;
  7836. var scene = this._attachedCamera.getScene();
  7837. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7838. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7839. _this._isPointerDown = true;
  7840. return;
  7841. }
  7842. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7843. _this._isPointerDown = false;
  7844. }
  7845. });
  7846. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7847. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7848. var dt = 0;
  7849. if (_this._lastFrameTime != null) {
  7850. dt = now - _this._lastFrameTime;
  7851. }
  7852. _this._lastFrameTime = now;
  7853. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7854. _this._applyUserInteraction();
  7855. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7856. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7857. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7858. // Step camera rotation by rotation speed
  7859. if (_this._attachedCamera) {
  7860. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7861. }
  7862. });
  7863. };
  7864. /**
  7865. * Detaches the behavior from its current arc rotate camera.
  7866. */
  7867. AutoRotationBehavior.prototype.detach = function () {
  7868. if (!this._attachedCamera) {
  7869. return;
  7870. }
  7871. var scene = this._attachedCamera.getScene();
  7872. if (this._onPrePointerObservableObserver) {
  7873. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7874. }
  7875. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7876. this._attachedCamera = null;
  7877. };
  7878. /**
  7879. * Returns true if user is scrolling.
  7880. * @return true if user is scrolling.
  7881. */
  7882. AutoRotationBehavior.prototype._userIsZooming = function () {
  7883. if (!this._attachedCamera) {
  7884. return false;
  7885. }
  7886. return this._attachedCamera.inertialRadiusOffset !== 0;
  7887. };
  7888. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7889. if (!this._attachedCamera) {
  7890. return false;
  7891. }
  7892. var zoomHasHitLimit = false;
  7893. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7894. zoomHasHitLimit = true;
  7895. }
  7896. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7897. this._lastFrameRadius = this._attachedCamera.radius;
  7898. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7899. };
  7900. /**
  7901. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7902. */
  7903. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7904. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7905. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7906. }
  7907. };
  7908. // Tools
  7909. AutoRotationBehavior.prototype._userIsMoving = function () {
  7910. if (!this._attachedCamera) {
  7911. return false;
  7912. }
  7913. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7914. this._attachedCamera.inertialBetaOffset !== 0 ||
  7915. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7916. this._attachedCamera.inertialPanningX !== 0 ||
  7917. this._attachedCamera.inertialPanningY !== 0 ||
  7918. this._isPointerDown;
  7919. };
  7920. return AutoRotationBehavior;
  7921. }());
  7922. /***/ }),
  7923. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7924. /*!***********************************************!*\
  7925. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7926. \***********************************************/
  7927. /*! exports provided: BouncingBehavior */
  7928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7929. "use strict";
  7930. __webpack_require__.r(__webpack_exports__);
  7931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7932. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7933. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7934. /**
  7935. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7937. */
  7938. var BouncingBehavior = /** @class */ (function () {
  7939. function BouncingBehavior() {
  7940. /**
  7941. * The duration of the animation, in milliseconds
  7942. */
  7943. this.transitionDuration = 450;
  7944. /**
  7945. * Length of the distance animated by the transition when lower radius is reached
  7946. */
  7947. this.lowerRadiusTransitionRange = 2;
  7948. /**
  7949. * Length of the distance animated by the transition when upper radius is reached
  7950. */
  7951. this.upperRadiusTransitionRange = -2;
  7952. this._autoTransitionRange = false;
  7953. // Animations
  7954. this._radiusIsAnimating = false;
  7955. this._radiusBounceTransition = null;
  7956. this._animatables = new Array();
  7957. }
  7958. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7959. /**
  7960. * Gets the name of the behavior.
  7961. */
  7962. get: function () {
  7963. return "Bouncing";
  7964. },
  7965. enumerable: true,
  7966. configurable: true
  7967. });
  7968. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7969. /**
  7970. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7971. */
  7972. get: function () {
  7973. return this._autoTransitionRange;
  7974. },
  7975. /**
  7976. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7977. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7978. */
  7979. set: function (value) {
  7980. var _this = this;
  7981. if (this._autoTransitionRange === value) {
  7982. return;
  7983. }
  7984. this._autoTransitionRange = value;
  7985. var camera = this._attachedCamera;
  7986. if (!camera) {
  7987. return;
  7988. }
  7989. if (value) {
  7990. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7991. if (!mesh) {
  7992. return;
  7993. }
  7994. mesh.computeWorldMatrix(true);
  7995. var diagonal = mesh.getBoundingInfo().diagonalLength;
  7996. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  7997. _this.upperRadiusTransitionRange = diagonal * 0.05;
  7998. });
  7999. }
  8000. else if (this._onMeshTargetChangedObserver) {
  8001. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8002. }
  8003. },
  8004. enumerable: true,
  8005. configurable: true
  8006. });
  8007. /**
  8008. * Initializes the behavior.
  8009. */
  8010. BouncingBehavior.prototype.init = function () {
  8011. // Do notihng
  8012. };
  8013. /**
  8014. * Attaches the behavior to its arc rotate camera.
  8015. * @param camera Defines the camera to attach the behavior to
  8016. */
  8017. BouncingBehavior.prototype.attach = function (camera) {
  8018. var _this = this;
  8019. this._attachedCamera = camera;
  8020. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8021. if (!_this._attachedCamera) {
  8022. return;
  8023. }
  8024. // Add the bounce animation to the lower radius limit
  8025. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8026. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8027. }
  8028. // Add the bounce animation to the upper radius limit
  8029. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8030. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8031. }
  8032. });
  8033. };
  8034. /**
  8035. * Detaches the behavior from its current arc rotate camera.
  8036. */
  8037. BouncingBehavior.prototype.detach = function () {
  8038. if (!this._attachedCamera) {
  8039. return;
  8040. }
  8041. if (this._onAfterCheckInputsObserver) {
  8042. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8043. }
  8044. if (this._onMeshTargetChangedObserver) {
  8045. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8046. }
  8047. this._attachedCamera = null;
  8048. };
  8049. /**
  8050. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8051. * @param radiusLimit The limit to check against.
  8052. * @return Bool to indicate if at limit.
  8053. */
  8054. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8055. if (!this._attachedCamera) {
  8056. return false;
  8057. }
  8058. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8059. return true;
  8060. }
  8061. return false;
  8062. };
  8063. /**
  8064. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8065. * @param radiusDelta The delta by which to animate to. Can be negative.
  8066. */
  8067. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8068. var _this = this;
  8069. if (!this._attachedCamera) {
  8070. return;
  8071. }
  8072. if (!this._radiusBounceTransition) {
  8073. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8074. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8075. }
  8076. // Prevent zoom until bounce has completed
  8077. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8078. this._attachedCamera.wheelPrecision = Infinity;
  8079. this._attachedCamera.inertialRadiusOffset = 0;
  8080. // Animate to the radius limit
  8081. this.stopAllAnimations();
  8082. this._radiusIsAnimating = true;
  8083. 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(); });
  8084. if (animatable) {
  8085. this._animatables.push(animatable);
  8086. }
  8087. };
  8088. /**
  8089. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8090. */
  8091. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8092. this._radiusIsAnimating = false;
  8093. if (this._attachedCamera) {
  8094. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8095. }
  8096. };
  8097. /**
  8098. * Stops and removes all animations that have been applied to the camera
  8099. */
  8100. BouncingBehavior.prototype.stopAllAnimations = function () {
  8101. if (this._attachedCamera) {
  8102. this._attachedCamera.animations = [];
  8103. }
  8104. while (this._animatables.length) {
  8105. this._animatables[0].onAnimationEnd = null;
  8106. this._animatables[0].stop();
  8107. this._animatables.shift();
  8108. }
  8109. };
  8110. /**
  8111. * The easing function used by animations
  8112. */
  8113. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8114. /**
  8115. * The easing mode used by animations
  8116. */
  8117. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8118. return BouncingBehavior;
  8119. }());
  8120. /***/ }),
  8121. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8122. /*!**********************************************!*\
  8123. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8124. \**********************************************/
  8125. /*! exports provided: FramingBehavior */
  8126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8127. "use strict";
  8128. __webpack_require__.r(__webpack_exports__);
  8129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8130. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8131. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8132. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8133. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8135. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8136. /**
  8137. * 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.
  8138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8139. */
  8140. var FramingBehavior = /** @class */ (function () {
  8141. function FramingBehavior() {
  8142. this._mode = FramingBehavior.FitFrustumSidesMode;
  8143. this._radiusScale = 1.0;
  8144. this._positionScale = 0.5;
  8145. this._defaultElevation = 0.3;
  8146. this._elevationReturnTime = 1500;
  8147. this._elevationReturnWaitTime = 1000;
  8148. this._zoomStopsAnimation = false;
  8149. this._framingTime = 1500;
  8150. /**
  8151. * Define if the behavior should automatically change the configured
  8152. * camera limits and sensibilities.
  8153. */
  8154. this.autoCorrectCameraLimitsAndSensibility = true;
  8155. this._isPointerDown = false;
  8156. this._lastInteractionTime = -Infinity;
  8157. // Framing control
  8158. this._animatables = new Array();
  8159. this._betaIsAnimating = false;
  8160. }
  8161. Object.defineProperty(FramingBehavior.prototype, "name", {
  8162. /**
  8163. * Gets the name of the behavior.
  8164. */
  8165. get: function () {
  8166. return "Framing";
  8167. },
  8168. enumerable: true,
  8169. configurable: true
  8170. });
  8171. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8172. /**
  8173. * Gets current mode used by the behavior.
  8174. */
  8175. get: function () {
  8176. return this._mode;
  8177. },
  8178. /**
  8179. * Sets the current mode used by the behavior
  8180. */
  8181. set: function (mode) {
  8182. this._mode = mode;
  8183. },
  8184. enumerable: true,
  8185. configurable: true
  8186. });
  8187. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8188. /**
  8189. * Gets the scale applied to the radius
  8190. */
  8191. get: function () {
  8192. return this._radiusScale;
  8193. },
  8194. /**
  8195. * Sets the scale applied to the radius (1 by default)
  8196. */
  8197. set: function (radius) {
  8198. this._radiusScale = radius;
  8199. },
  8200. enumerable: true,
  8201. configurable: true
  8202. });
  8203. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8204. /**
  8205. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8206. */
  8207. get: function () {
  8208. return this._positionScale;
  8209. },
  8210. /**
  8211. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8212. */
  8213. set: function (scale) {
  8214. this._positionScale = scale;
  8215. },
  8216. enumerable: true,
  8217. configurable: true
  8218. });
  8219. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8220. /**
  8221. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8222. * behaviour is triggered, in radians.
  8223. */
  8224. get: function () {
  8225. return this._defaultElevation;
  8226. },
  8227. /**
  8228. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8229. * behaviour is triggered, in radians.
  8230. */
  8231. set: function (elevation) {
  8232. this._defaultElevation = elevation;
  8233. },
  8234. enumerable: true,
  8235. configurable: true
  8236. });
  8237. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8238. /**
  8239. * Gets the time (in milliseconds) taken to return to the default beta position.
  8240. * Negative value indicates camera should not return to default.
  8241. */
  8242. get: function () {
  8243. return this._elevationReturnTime;
  8244. },
  8245. /**
  8246. * Sets the time (in milliseconds) taken to return to the default beta position.
  8247. * Negative value indicates camera should not return to default.
  8248. */
  8249. set: function (speed) {
  8250. this._elevationReturnTime = speed;
  8251. },
  8252. enumerable: true,
  8253. configurable: true
  8254. });
  8255. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8256. /**
  8257. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8258. */
  8259. get: function () {
  8260. return this._elevationReturnWaitTime;
  8261. },
  8262. /**
  8263. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8264. */
  8265. set: function (time) {
  8266. this._elevationReturnWaitTime = time;
  8267. },
  8268. enumerable: true,
  8269. configurable: true
  8270. });
  8271. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8272. /**
  8273. * Gets the flag that indicates if user zooming should stop animation.
  8274. */
  8275. get: function () {
  8276. return this._zoomStopsAnimation;
  8277. },
  8278. /**
  8279. * Sets the flag that indicates if user zooming should stop animation.
  8280. */
  8281. set: function (flag) {
  8282. this._zoomStopsAnimation = flag;
  8283. },
  8284. enumerable: true,
  8285. configurable: true
  8286. });
  8287. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8288. /**
  8289. * Gets the transition time when framing the mesh, in milliseconds
  8290. */
  8291. get: function () {
  8292. return this._framingTime;
  8293. },
  8294. /**
  8295. * Sets the transition time when framing the mesh, in milliseconds
  8296. */
  8297. set: function (time) {
  8298. this._framingTime = time;
  8299. },
  8300. enumerable: true,
  8301. configurable: true
  8302. });
  8303. /**
  8304. * Initializes the behavior.
  8305. */
  8306. FramingBehavior.prototype.init = function () {
  8307. // Do notihng
  8308. };
  8309. /**
  8310. * Attaches the behavior to its arc rotate camera.
  8311. * @param camera Defines the camera to attach the behavior to
  8312. */
  8313. FramingBehavior.prototype.attach = function (camera) {
  8314. var _this = this;
  8315. this._attachedCamera = camera;
  8316. var scene = this._attachedCamera.getScene();
  8317. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8318. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8319. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8320. _this._isPointerDown = true;
  8321. return;
  8322. }
  8323. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8324. _this._isPointerDown = false;
  8325. }
  8326. });
  8327. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8328. if (mesh) {
  8329. _this.zoomOnMesh(mesh);
  8330. }
  8331. });
  8332. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8333. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8334. _this._applyUserInteraction();
  8335. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8336. // back to the default position after a given timeout
  8337. _this._maintainCameraAboveGround();
  8338. });
  8339. };
  8340. /**
  8341. * Detaches the behavior from its current arc rotate camera.
  8342. */
  8343. FramingBehavior.prototype.detach = function () {
  8344. if (!this._attachedCamera) {
  8345. return;
  8346. }
  8347. var scene = this._attachedCamera.getScene();
  8348. if (this._onPrePointerObservableObserver) {
  8349. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8350. }
  8351. if (this._onAfterCheckInputsObserver) {
  8352. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8353. }
  8354. if (this._onMeshTargetChangedObserver) {
  8355. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8356. }
  8357. this._attachedCamera = null;
  8358. };
  8359. /**
  8360. * Targets the given mesh and updates zoom level accordingly.
  8361. * @param mesh The mesh to target.
  8362. * @param radius Optional. If a cached radius position already exists, overrides default.
  8363. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8366. */
  8367. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8368. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8369. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8370. mesh.computeWorldMatrix(true);
  8371. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8372. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8373. };
  8374. /**
  8375. * Targets the given mesh with its children and updates zoom level accordingly.
  8376. * @param mesh The mesh to target.
  8377. * @param radius Optional. If a cached radius position already exists, overrides default.
  8378. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8379. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8380. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8381. */
  8382. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8383. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8384. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8385. mesh.computeWorldMatrix(true);
  8386. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8387. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8388. };
  8389. /**
  8390. * Targets the given meshes with their children and updates zoom level accordingly.
  8391. * @param meshes The mesh to target.
  8392. * @param radius Optional. If a cached radius position already exists, overrides default.
  8393. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8396. */
  8397. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8398. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8399. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8400. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8401. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8402. for (var i = 0; i < meshes.length; i++) {
  8403. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8404. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8405. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8406. }
  8407. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8408. };
  8409. /**
  8410. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8411. * @param minimumWorld Determines the smaller position of the bounding box extend
  8412. * @param maximumWorld Determines the bigger position of the bounding box extend
  8413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8415. */
  8416. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8417. var _this = this;
  8418. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8419. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8420. var zoomTarget;
  8421. if (!this._attachedCamera) {
  8422. return;
  8423. }
  8424. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8425. var bottom = minimumWorld.y;
  8426. var top = maximumWorld.y;
  8427. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8428. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8429. if (focusOnOriginXZ) {
  8430. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8431. }
  8432. else {
  8433. var centerWorld = minimumWorld.add(radiusWorld);
  8434. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8435. }
  8436. if (!this._vectorTransition) {
  8437. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8438. }
  8439. this._betaIsAnimating = true;
  8440. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8441. if (animatable) {
  8442. this._animatables.push(animatable);
  8443. }
  8444. // sets the radius and lower radius bounds
  8445. // Small delta ensures camera is not always at lower zoom limit.
  8446. var radius = 0;
  8447. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8448. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8449. if (this.autoCorrectCameraLimitsAndSensibility) {
  8450. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8451. }
  8452. radius = position;
  8453. }
  8454. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8455. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8456. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8457. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8458. }
  8459. }
  8460. // Set sensibilities
  8461. if (this.autoCorrectCameraLimitsAndSensibility) {
  8462. var extend = maximumWorld.subtract(minimumWorld).length();
  8463. this._attachedCamera.panningSensibility = 5000 / extend;
  8464. this._attachedCamera.wheelPrecision = 100 / radius;
  8465. }
  8466. // transition to new radius
  8467. if (!this._radiusTransition) {
  8468. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8469. }
  8470. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8471. _this.stopAllAnimations();
  8472. if (onAnimationEnd) {
  8473. onAnimationEnd();
  8474. }
  8475. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8476. _this._attachedCamera.storeState();
  8477. }
  8478. });
  8479. if (animatable) {
  8480. this._animatables.push(animatable);
  8481. }
  8482. };
  8483. /**
  8484. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8485. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8486. * frustum width.
  8487. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8488. * to fully enclose the mesh in the viewing frustum.
  8489. */
  8490. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8491. var size = maximumWorld.subtract(minimumWorld);
  8492. var boxVectorGlobalDiagonal = size.length();
  8493. var frustumSlope = this._getFrustumSlope();
  8494. // Formula for setting distance
  8495. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8496. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8497. // Horizon distance
  8498. var radius = radiusWithoutFraming * this._radiusScale;
  8499. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8500. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8501. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8502. var camera = this._attachedCamera;
  8503. if (!camera) {
  8504. return 0;
  8505. }
  8506. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8507. // Don't exceed the requested limit
  8508. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8509. }
  8510. // Don't exceed the upper radius limit
  8511. if (camera.upperRadiusLimit) {
  8512. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8513. }
  8514. return distance;
  8515. };
  8516. /**
  8517. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8518. * is automatically returned to its default position (expected to be above ground plane).
  8519. */
  8520. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8521. var _this = this;
  8522. if (this._elevationReturnTime < 0) {
  8523. return;
  8524. }
  8525. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8526. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8527. var limitBeta = Math.PI * 0.5;
  8528. // Bring the camera back up if below the ground plane
  8529. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8530. this._betaIsAnimating = true;
  8531. //Transition to new position
  8532. this.stopAllAnimations();
  8533. if (!this._betaTransition) {
  8534. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8535. }
  8536. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8537. _this._clearAnimationLocks();
  8538. _this.stopAllAnimations();
  8539. });
  8540. if (animatabe) {
  8541. this._animatables.push(animatabe);
  8542. }
  8543. }
  8544. };
  8545. /**
  8546. * Returns the frustum slope based on the canvas ratio and camera FOV
  8547. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8548. */
  8549. FramingBehavior.prototype._getFrustumSlope = function () {
  8550. // Calculate the viewport ratio
  8551. // Aspect Ratio is Height/Width.
  8552. var camera = this._attachedCamera;
  8553. if (!camera) {
  8554. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8555. }
  8556. var engine = camera.getScene().getEngine();
  8557. var aspectRatio = engine.getAspectRatio(camera);
  8558. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8559. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8560. var frustumSlopeY = Math.tan(camera.fov / 2);
  8561. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8562. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8563. // along the forward vector.
  8564. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8565. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8566. };
  8567. /**
  8568. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8569. */
  8570. FramingBehavior.prototype._clearAnimationLocks = function () {
  8571. this._betaIsAnimating = false;
  8572. };
  8573. /**
  8574. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8575. */
  8576. FramingBehavior.prototype._applyUserInteraction = function () {
  8577. if (this.isUserIsMoving) {
  8578. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8579. this.stopAllAnimations();
  8580. this._clearAnimationLocks();
  8581. }
  8582. };
  8583. /**
  8584. * Stops and removes all animations that have been applied to the camera
  8585. */
  8586. FramingBehavior.prototype.stopAllAnimations = function () {
  8587. if (this._attachedCamera) {
  8588. this._attachedCamera.animations = [];
  8589. }
  8590. while (this._animatables.length) {
  8591. if (this._animatables[0]) {
  8592. this._animatables[0].onAnimationEnd = null;
  8593. this._animatables[0].stop();
  8594. }
  8595. this._animatables.shift();
  8596. }
  8597. };
  8598. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8599. /**
  8600. * Gets a value indicating if the user is moving the camera
  8601. */
  8602. get: function () {
  8603. if (!this._attachedCamera) {
  8604. return false;
  8605. }
  8606. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8607. this._attachedCamera.inertialBetaOffset !== 0 ||
  8608. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8609. this._attachedCamera.inertialPanningX !== 0 ||
  8610. this._attachedCamera.inertialPanningY !== 0 ||
  8611. this._isPointerDown;
  8612. },
  8613. enumerable: true,
  8614. configurable: true
  8615. });
  8616. /**
  8617. * The easing function used by animations
  8618. */
  8619. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8620. /**
  8621. * The easing mode used by animations
  8622. */
  8623. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8624. // Statics
  8625. /**
  8626. * The camera can move all the way towards the mesh.
  8627. */
  8628. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8629. /**
  8630. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8631. */
  8632. FramingBehavior.FitFrustumSidesMode = 1;
  8633. return FramingBehavior;
  8634. }());
  8635. /***/ }),
  8636. /***/ "./Behaviors/Cameras/index.ts":
  8637. /*!************************************!*\
  8638. !*** ./Behaviors/Cameras/index.ts ***!
  8639. \************************************/
  8640. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8642. "use strict";
  8643. __webpack_require__.r(__webpack_exports__);
  8644. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8646. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8648. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8650. /***/ }),
  8651. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8652. /*!*************************************************!*\
  8653. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8654. \*************************************************/
  8655. /*! exports provided: AttachToBoxBehavior */
  8656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8657. "use strict";
  8658. __webpack_require__.r(__webpack_exports__);
  8659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8660. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8661. /**
  8662. * @hidden
  8663. */
  8664. var FaceDirectionInfo = /** @class */ (function () {
  8665. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8666. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8667. if (diff === void 0) { diff = 0; }
  8668. if (ignore === void 0) { ignore = false; }
  8669. this.direction = direction;
  8670. this.rotatedDirection = rotatedDirection;
  8671. this.diff = diff;
  8672. this.ignore = ignore;
  8673. }
  8674. return FaceDirectionInfo;
  8675. }());
  8676. /**
  8677. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8678. */
  8679. var AttachToBoxBehavior = /** @class */ (function () {
  8680. /**
  8681. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8682. * @param ui The transform node that should be attched to the mesh
  8683. */
  8684. function AttachToBoxBehavior(ui) {
  8685. this.ui = ui;
  8686. /**
  8687. * The name of the behavior
  8688. */
  8689. this.name = "AttachToBoxBehavior";
  8690. /**
  8691. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8692. */
  8693. this.distanceAwayFromFace = 0.15;
  8694. /**
  8695. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8696. */
  8697. this.distanceAwayFromBottomOfFace = 0.15;
  8698. this._faceVectors = [new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8699. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8700. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8701. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8702. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8703. /* Does nothing */
  8704. }
  8705. /**
  8706. * Initializes the behavior
  8707. */
  8708. AttachToBoxBehavior.prototype.init = function () {
  8709. /* Does nothing */
  8710. };
  8711. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8712. var _this = this;
  8713. // Go over each face and calculate the angle between the face's normal and targetDirection
  8714. this._faceVectors.forEach(function (v) {
  8715. if (!_this._target.rotationQuaternion) {
  8716. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8717. }
  8718. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8719. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8720. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8721. });
  8722. // Return the face information of the one with the normal closeset to target direction
  8723. return this._faceVectors.reduce(function (min, p) {
  8724. if (min.ignore) {
  8725. return p;
  8726. }
  8727. else if (p.ignore) {
  8728. return min;
  8729. }
  8730. else {
  8731. return min.diff < p.diff ? min : p;
  8732. }
  8733. }, this._faceVectors[0]);
  8734. };
  8735. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8736. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8737. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8738. this._lookAtTmpMatrix.invert();
  8739. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8740. };
  8741. /**
  8742. * Attaches the AttachToBoxBehavior to the passed in mesh
  8743. * @param target The mesh that the specified node will be attached to
  8744. */
  8745. AttachToBoxBehavior.prototype.attach = function (target) {
  8746. var _this = this;
  8747. this._target = target;
  8748. this._scene = this._target.getScene();
  8749. // Every frame, update the app bars position
  8750. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8751. if (!_this._scene.activeCamera) {
  8752. return;
  8753. }
  8754. // Find the face closest to the cameras position
  8755. var cameraPos = _this._scene.activeCamera.position;
  8756. if (_this._scene.activeCamera.devicePosition) {
  8757. cameraPos = _this._scene.activeCamera.devicePosition;
  8758. }
  8759. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8760. if (_this._scene.activeCamera.leftCamera) {
  8761. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8762. }
  8763. else {
  8764. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8765. }
  8766. // Get camera up direction
  8767. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8768. // Ignore faces to not select a parrelel face for the up vector of the UI
  8769. _this._faceVectors.forEach(function (v) {
  8770. if (facing.direction.x && v.direction.x) {
  8771. v.ignore = true;
  8772. }
  8773. if (facing.direction.y && v.direction.y) {
  8774. v.ignore = true;
  8775. }
  8776. if (facing.direction.z && v.direction.z) {
  8777. v.ignore = true;
  8778. }
  8779. });
  8780. var facingUp = _this._closestFace(_this._tmpVector);
  8781. // Unignore faces
  8782. _this._faceVectors.forEach(function (v) {
  8783. v.ignore = false;
  8784. });
  8785. // Position the app bar on that face
  8786. _this.ui.position.copyFrom(target.position);
  8787. if (facing.direction.x) {
  8788. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8789. _this.ui.position.addInPlace(_this._tmpVector);
  8790. }
  8791. if (facing.direction.y) {
  8792. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8793. _this.ui.position.addInPlace(_this._tmpVector);
  8794. }
  8795. if (facing.direction.z) {
  8796. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8797. _this.ui.position.addInPlace(_this._tmpVector);
  8798. }
  8799. // Rotate to be oriented properly to the camera
  8800. if (!_this.ui.rotationQuaternion) {
  8801. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8802. }
  8803. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8804. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8805. // Place ui the correct distance from the bottom of the mesh
  8806. if (facingUp.direction.x) {
  8807. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8808. }
  8809. if (facingUp.direction.y) {
  8810. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8811. }
  8812. if (facingUp.direction.z) {
  8813. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8814. }
  8815. _this.ui.position.addInPlace(_this._tmpVector);
  8816. });
  8817. };
  8818. /**
  8819. * Detaches the behavior from the mesh
  8820. */
  8821. AttachToBoxBehavior.prototype.detach = function () {
  8822. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8823. };
  8824. return AttachToBoxBehavior;
  8825. }());
  8826. /***/ }),
  8827. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8828. /*!***********************************************!*\
  8829. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8830. \***********************************************/
  8831. /*! exports provided: FadeInOutBehavior */
  8832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8833. "use strict";
  8834. __webpack_require__.r(__webpack_exports__);
  8835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8836. /**
  8837. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8838. */
  8839. var FadeInOutBehavior = /** @class */ (function () {
  8840. /**
  8841. * Instatiates the FadeInOutBehavior
  8842. */
  8843. function FadeInOutBehavior() {
  8844. var _this = this;
  8845. /**
  8846. * Time in milliseconds to delay before fading in (Default: 0)
  8847. */
  8848. this.delay = 0;
  8849. /**
  8850. * Time in milliseconds for the mesh to fade in (Default: 300)
  8851. */
  8852. this.fadeInTime = 300;
  8853. this._millisecondsPerFrame = 1000 / 60;
  8854. this._hovered = false;
  8855. this._hoverValue = 0;
  8856. this._ownerNode = null;
  8857. this._update = function () {
  8858. if (_this._ownerNode) {
  8859. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8860. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8861. if (_this._ownerNode.visibility > 1) {
  8862. _this._setAllVisibility(_this._ownerNode, 1);
  8863. _this._hoverValue = _this.fadeInTime + _this.delay;
  8864. return;
  8865. }
  8866. else if (_this._ownerNode.visibility < 0) {
  8867. _this._setAllVisibility(_this._ownerNode, 0);
  8868. if (_this._hoverValue < 0) {
  8869. _this._hoverValue = 0;
  8870. return;
  8871. }
  8872. }
  8873. setTimeout(_this._update, _this._millisecondsPerFrame);
  8874. }
  8875. };
  8876. }
  8877. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8878. /**
  8879. * The name of the behavior
  8880. */
  8881. get: function () {
  8882. return "FadeInOut";
  8883. },
  8884. enumerable: true,
  8885. configurable: true
  8886. });
  8887. /**
  8888. * Initializes the behavior
  8889. */
  8890. FadeInOutBehavior.prototype.init = function () {
  8891. };
  8892. /**
  8893. * Attaches the fade behavior on the passed in mesh
  8894. * @param ownerNode The mesh that will be faded in/out once attached
  8895. */
  8896. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8897. this._ownerNode = ownerNode;
  8898. this._setAllVisibility(this._ownerNode, 0);
  8899. };
  8900. /**
  8901. * Detaches the behavior from the mesh
  8902. */
  8903. FadeInOutBehavior.prototype.detach = function () {
  8904. this._ownerNode = null;
  8905. };
  8906. /**
  8907. * Triggers the mesh to begin fading in or out
  8908. * @param value if the object should fade in or out (true to fade in)
  8909. */
  8910. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8911. this._hovered = value;
  8912. this._update();
  8913. };
  8914. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8915. var _this = this;
  8916. mesh.visibility = value;
  8917. mesh.getChildMeshes().forEach(function (c) {
  8918. _this._setAllVisibility(c, value);
  8919. });
  8920. };
  8921. return FadeInOutBehavior;
  8922. }());
  8923. /***/ }),
  8924. /***/ "./Behaviors/Meshes/index.ts":
  8925. /*!***********************************!*\
  8926. !*** ./Behaviors/Meshes/index.ts ***!
  8927. \***********************************/
  8928. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8930. "use strict";
  8931. __webpack_require__.r(__webpack_exports__);
  8932. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8934. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8936. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8938. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8940. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8942. /***/ }),
  8943. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8944. /*!*******************************************************!*\
  8945. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8946. \*******************************************************/
  8947. /*! exports provided: MultiPointerScaleBehavior */
  8948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8949. "use strict";
  8950. __webpack_require__.r(__webpack_exports__);
  8951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8952. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8953. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8954. /**
  8955. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8956. */
  8957. var MultiPointerScaleBehavior = /** @class */ (function () {
  8958. /**
  8959. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8960. */
  8961. function MultiPointerScaleBehavior() {
  8962. this._startDistance = 0;
  8963. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8964. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8965. this._sceneRenderObserver = null;
  8966. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8967. this._dragBehaviorA.moveAttached = false;
  8968. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8969. this._dragBehaviorB.moveAttached = false;
  8970. }
  8971. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8972. /**
  8973. * The name of the behavior
  8974. */
  8975. get: function () {
  8976. return "MultiPointerScale";
  8977. },
  8978. enumerable: true,
  8979. configurable: true
  8980. });
  8981. /**
  8982. * Initializes the behavior
  8983. */
  8984. MultiPointerScaleBehavior.prototype.init = function () { };
  8985. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8986. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8987. };
  8988. /**
  8989. * Attaches the scale behavior the passed in mesh
  8990. * @param ownerNode The mesh that will be scaled around once attached
  8991. */
  8992. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8993. var _this = this;
  8994. this._ownerNode = ownerNode;
  8995. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  8996. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  8997. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8998. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8999. _this._dragBehaviorA.releaseDrag();
  9000. }
  9001. else {
  9002. _this._initialScale.copyFrom(ownerNode.scaling);
  9003. _this._startDistance = _this._getCurrentDistance();
  9004. }
  9005. }
  9006. });
  9007. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9008. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9009. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9010. _this._dragBehaviorB.releaseDrag();
  9011. }
  9012. else {
  9013. _this._initialScale.copyFrom(ownerNode.scaling);
  9014. _this._startDistance = _this._getCurrentDistance();
  9015. }
  9016. }
  9017. });
  9018. // Once both drag behaviors are active scale based on the distance between the two pointers
  9019. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9020. behavior.onDragObservable.add(function () {
  9021. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9022. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9023. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9024. }
  9025. });
  9026. });
  9027. ownerNode.addBehavior(this._dragBehaviorA);
  9028. ownerNode.addBehavior(this._dragBehaviorB);
  9029. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9030. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9031. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9032. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9033. if (change.length() > 0.01) {
  9034. ownerNode.scaling.addInPlace(change);
  9035. }
  9036. }
  9037. });
  9038. };
  9039. /**
  9040. * Detaches the behavior from the mesh
  9041. */
  9042. MultiPointerScaleBehavior.prototype.detach = function () {
  9043. var _this = this;
  9044. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9045. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9046. behavior.onDragStartObservable.clear();
  9047. behavior.onDragObservable.clear();
  9048. _this._ownerNode.removeBehavior(behavior);
  9049. });
  9050. };
  9051. return MultiPointerScaleBehavior;
  9052. }());
  9053. /***/ }),
  9054. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9055. /*!*************************************************!*\
  9056. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9057. \*************************************************/
  9058. /*! exports provided: PointerDragBehavior */
  9059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9060. "use strict";
  9061. __webpack_require__.r(__webpack_exports__);
  9062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9063. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9064. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9065. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9066. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9067. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9068. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9069. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9070. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9071. /**
  9072. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9073. */
  9074. var PointerDragBehavior = /** @class */ (function () {
  9075. /**
  9076. * Creates a pointer drag behavior that can be attached to a mesh
  9077. * @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)
  9078. */
  9079. function PointerDragBehavior(options) {
  9080. /**
  9081. * 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)
  9082. */
  9083. this.maxDragAngle = 0;
  9084. /**
  9085. * @hidden
  9086. */
  9087. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9088. /**
  9089. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9090. */
  9091. this.currentDraggingPointerID = -1;
  9092. /**
  9093. * If the behavior is currently in a dragging state
  9094. */
  9095. this.dragging = false;
  9096. /**
  9097. * 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)
  9098. */
  9099. this.dragDeltaRatio = 0.2;
  9100. /**
  9101. * If the drag plane orientation should be updated during the dragging (Default: true)
  9102. */
  9103. this.updateDragPlane = true;
  9104. // Debug mode will display drag planes to help visualize behavior
  9105. this._debugMode = false;
  9106. this._moving = false;
  9107. /**
  9108. * Fires each time the attached mesh is dragged with the pointer
  9109. * * delta between last drag position and current drag position in world space
  9110. * * dragDistance along the drag axis
  9111. * * dragPlaneNormal normal of the current drag plane used during the drag
  9112. * * dragPlanePoint in world space where the drag intersects the drag plane
  9113. */
  9114. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9115. /**
  9116. * Fires each time a drag begins (eg. mouse down on mesh)
  9117. */
  9118. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9119. /**
  9120. * Fires each time a drag ends (eg. mouse release after drag)
  9121. */
  9122. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9123. /**
  9124. * If the attached mesh should be moved when dragged
  9125. */
  9126. this.moveAttached = true;
  9127. /**
  9128. * If the drag behavior will react to drag events (Default: true)
  9129. */
  9130. this.enabled = true;
  9131. /**
  9132. * If camera controls should be detached during the drag
  9133. */
  9134. this.detachCameraControls = true;
  9135. /**
  9136. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9137. */
  9138. this.useObjectOrienationForDragging = true;
  9139. /**
  9140. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9141. */
  9142. this.validateDrag = function (targetPosition) { return true; };
  9143. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9144. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9145. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9146. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9147. this._attachedElement = null;
  9148. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9149. this._lastPointerRay = {};
  9150. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9151. // Variables to avoid instantiation in the below method
  9152. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9153. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9154. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9155. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9156. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9157. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9158. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9159. this._options = options ? options : {};
  9160. var optionCount = 0;
  9161. if (this._options.dragAxis) {
  9162. optionCount++;
  9163. }
  9164. if (this._options.dragPlaneNormal) {
  9165. optionCount++;
  9166. }
  9167. if (optionCount > 1) {
  9168. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9169. }
  9170. }
  9171. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9172. /**
  9173. * The name of the behavior
  9174. */
  9175. get: function () {
  9176. return "PointerDrag";
  9177. },
  9178. enumerable: true,
  9179. configurable: true
  9180. });
  9181. /**
  9182. * Initializes the behavior
  9183. */
  9184. PointerDragBehavior.prototype.init = function () { };
  9185. /**
  9186. * Attaches the drag behavior the passed in mesh
  9187. * @param ownerNode The mesh that will be dragged around once attached
  9188. */
  9189. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9190. var _this = this;
  9191. this._scene = ownerNode.getScene();
  9192. this._attachedNode = ownerNode;
  9193. // Initialize drag plane to not interfere with existing scene
  9194. if (!PointerDragBehavior._planeScene) {
  9195. if (this._debugMode) {
  9196. PointerDragBehavior._planeScene = this._scene;
  9197. }
  9198. else {
  9199. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9200. PointerDragBehavior._planeScene.detachControl();
  9201. this._scene.getEngine().scenes.pop();
  9202. this._scene.onDisposeObservable.addOnce(function () {
  9203. PointerDragBehavior._planeScene.dispose();
  9204. PointerDragBehavior._planeScene = null;
  9205. });
  9206. }
  9207. }
  9208. 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);
  9209. // State of the drag
  9210. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9211. var pickPredicate = function (m) {
  9212. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9213. };
  9214. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9215. if (!_this.enabled) {
  9216. return;
  9217. }
  9218. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9219. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9220. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9221. }
  9222. }
  9223. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9224. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9225. _this.releaseDrag();
  9226. }
  9227. }
  9228. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9229. var pointerId = pointerInfo.event.pointerId;
  9230. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9231. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9232. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9233. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9234. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9235. }
  9236. _this.currentDraggingPointerID = pointerId;
  9237. }
  9238. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9239. if (!_this._lastPointerRay[pointerId]) {
  9240. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9241. }
  9242. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9243. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9244. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9245. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9246. _this._moveDrag(pointerInfo.pickInfo.ray);
  9247. }
  9248. }
  9249. }
  9250. });
  9251. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9252. if (_this._moving && _this.moveAttached) {
  9253. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9254. // Slowly move mesh to avoid jitter
  9255. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9256. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9257. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9258. if (_this.validateDrag(_this._tmpVector)) {
  9259. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9260. }
  9261. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9262. }
  9263. });
  9264. };
  9265. /**
  9266. * Force relase the drag action by code.
  9267. */
  9268. PointerDragBehavior.prototype.releaseDrag = function () {
  9269. this.dragging = false;
  9270. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9271. this.currentDraggingPointerID = -1;
  9272. this._moving = false;
  9273. // Reattach camera controls
  9274. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9275. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9276. }
  9277. };
  9278. /**
  9279. * Simulates the start of a pointer drag event on the behavior
  9280. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9281. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9282. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9283. */
  9284. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9285. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9286. this._startDrag(pointerId, fromRay, startPickedPoint);
  9287. var lastRay = this._lastPointerRay[pointerId];
  9288. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9289. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9290. }
  9291. if (lastRay) {
  9292. // if there was a last pointer ray drag the object there
  9293. this._moveDrag(lastRay);
  9294. }
  9295. };
  9296. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9297. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9298. return;
  9299. }
  9300. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9301. // Create start ray from the camera to the object
  9302. if (fromRay) {
  9303. this._startDragRay.direction.copyFrom(fromRay.direction);
  9304. this._startDragRay.origin.copyFrom(fromRay.origin);
  9305. }
  9306. else {
  9307. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9308. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9309. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9310. }
  9311. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9312. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9313. if (pickedPoint) {
  9314. this.dragging = true;
  9315. this.currentDraggingPointerID = pointerId;
  9316. this.lastDragPosition.copyFrom(pickedPoint);
  9317. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9318. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9319. // Detatch camera controls
  9320. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9321. if (this._scene.activeCamera.inputs.attachedElement) {
  9322. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9323. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9324. }
  9325. else {
  9326. this._attachedElement = null;
  9327. }
  9328. }
  9329. }
  9330. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9331. };
  9332. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9333. this._moving = true;
  9334. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9335. if (pickedPoint) {
  9336. if (this.updateDragPlane) {
  9337. this._updateDragPlanePosition(ray, pickedPoint);
  9338. }
  9339. var dragLength = 0;
  9340. // depending on the drag mode option drag accordingly
  9341. if (this._options.dragAxis) {
  9342. // Convert local drag axis to world
  9343. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9344. // Project delta drag from the drag plane onto the drag axis
  9345. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9346. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9347. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9348. }
  9349. else {
  9350. dragLength = this._dragDelta.length();
  9351. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9352. }
  9353. this._targetPosition.addInPlace(this._dragDelta);
  9354. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9355. this.lastDragPosition.copyFrom(pickedPoint);
  9356. }
  9357. };
  9358. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9359. var _this = this;
  9360. if (!ray) {
  9361. return null;
  9362. }
  9363. // Calculate angle between plane normal and ray
  9364. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9365. // Correct if ray is casted from oposite side
  9366. if (angle > Math.PI / 2) {
  9367. angle = Math.PI - angle;
  9368. }
  9369. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9370. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9371. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9372. // Invert ray direction along the towards object axis
  9373. this._tmpVector.copyFrom(ray.direction);
  9374. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9375. this._alternatePickedPoint.normalize();
  9376. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9377. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9378. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9379. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9380. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9381. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9382. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9383. return this._alternatePickedPoint;
  9384. }
  9385. else {
  9386. return null;
  9387. }
  9388. }
  9389. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9390. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9391. return pickResult.pickedPoint;
  9392. }
  9393. else {
  9394. return null;
  9395. }
  9396. };
  9397. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9398. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9399. this._pointA.copyFrom(dragPlanePosition);
  9400. if (this._options.dragAxis) {
  9401. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9402. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9403. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9404. ray.origin.subtractToRef(this._pointA, this._pointC);
  9405. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9406. // Get perpendicular line from direction to camera and drag axis
  9407. this._pointB.subtractToRef(this._pointA, this._lineA);
  9408. this._pointC.subtractToRef(this._pointA, this._lineB);
  9409. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9410. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9411. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9412. this._lookAt.normalize();
  9413. this._dragPlane.position.copyFrom(this._pointA);
  9414. this._pointA.addToRef(this._lookAt, this._lookAt);
  9415. this._dragPlane.lookAt(this._lookAt);
  9416. }
  9417. else if (this._options.dragPlaneNormal) {
  9418. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9419. this._dragPlane.position.copyFrom(this._pointA);
  9420. this._pointA.addToRef(this._localAxis, this._lookAt);
  9421. this._dragPlane.lookAt(this._lookAt);
  9422. }
  9423. else {
  9424. this._dragPlane.position.copyFrom(this._pointA);
  9425. this._dragPlane.lookAt(ray.origin);
  9426. }
  9427. this._dragPlane.computeWorldMatrix(true);
  9428. };
  9429. /**
  9430. * Detaches the behavior from the mesh
  9431. */
  9432. PointerDragBehavior.prototype.detach = function () {
  9433. if (this._pointerObserver) {
  9434. this._scene.onPointerObservable.remove(this._pointerObserver);
  9435. }
  9436. if (this._beforeRenderObserver) {
  9437. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9438. }
  9439. };
  9440. PointerDragBehavior._AnyMouseID = -2;
  9441. return PointerDragBehavior;
  9442. }());
  9443. /***/ }),
  9444. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9445. /*!************************************************!*\
  9446. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9447. \************************************************/
  9448. /*! exports provided: SixDofDragBehavior */
  9449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9450. "use strict";
  9451. __webpack_require__.r(__webpack_exports__);
  9452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9453. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9454. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9455. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9457. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9458. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9459. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9460. /**
  9461. * 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
  9462. */
  9463. var SixDofDragBehavior = /** @class */ (function () {
  9464. /**
  9465. * 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
  9466. */
  9467. function SixDofDragBehavior() {
  9468. this._sceneRenderObserver = null;
  9469. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9470. this._moving = false;
  9471. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9472. /**
  9473. * 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)
  9474. */
  9475. this.zDragFactor = 3;
  9476. /**
  9477. * If the object should rotate to face the drag origin
  9478. */
  9479. this.rotateDraggedObject = true;
  9480. /**
  9481. * If the behavior is currently in a dragging state
  9482. */
  9483. this.dragging = false;
  9484. /**
  9485. * 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)
  9486. */
  9487. this.dragDeltaRatio = 0.2;
  9488. /**
  9489. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9490. */
  9491. this.currentDraggingPointerID = -1;
  9492. /**
  9493. * If camera controls should be detached during the drag
  9494. */
  9495. this.detachCameraControls = true;
  9496. /**
  9497. * Fires each time a drag starts
  9498. */
  9499. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9500. /**
  9501. * Fires each time a drag ends (eg. mouse release after drag)
  9502. */
  9503. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9504. }
  9505. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9506. /**
  9507. * The name of the behavior
  9508. */
  9509. get: function () {
  9510. return "SixDofDrag";
  9511. },
  9512. enumerable: true,
  9513. configurable: true
  9514. });
  9515. /**
  9516. * Initializes the behavior
  9517. */
  9518. SixDofDragBehavior.prototype.init = function () { };
  9519. /**
  9520. * Attaches the scale behavior the passed in mesh
  9521. * @param ownerNode The mesh that will be scaled around once attached
  9522. */
  9523. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9524. var _this = this;
  9525. this._ownerNode = ownerNode;
  9526. this._scene = this._ownerNode.getScene();
  9527. if (!SixDofDragBehavior._virtualScene) {
  9528. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9529. SixDofDragBehavior._virtualScene.detachControl();
  9530. this._scene.getEngine().scenes.pop();
  9531. }
  9532. var pickedMesh = null;
  9533. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9534. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9535. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9536. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9537. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9538. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9539. var pickPredicate = function (m) {
  9540. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9541. };
  9542. var attachedElement = null;
  9543. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9544. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9545. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9546. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9547. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9548. }
  9549. pickedMesh = _this._ownerNode;
  9550. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9551. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9552. // Set position and orientation of the controller
  9553. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9554. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9555. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9556. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9557. pickedMesh.computeWorldMatrix();
  9558. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9559. if (!pickedMesh.rotationQuaternion) {
  9560. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9561. }
  9562. var oldParent = pickedMesh.parent;
  9563. pickedMesh.setParent(null);
  9564. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9565. pickedMesh.setParent(oldParent);
  9566. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9567. // Update state
  9568. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9569. _this.dragging = true;
  9570. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9571. // Detatch camera controls
  9572. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9573. if (_this._scene.activeCamera.inputs.attachedElement) {
  9574. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9575. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9576. }
  9577. else {
  9578. attachedElement = null;
  9579. }
  9580. }
  9581. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9582. _this.onDragStartObservable.notifyObservers({});
  9583. }
  9584. }
  9585. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9586. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9587. _this.dragging = false;
  9588. _this._moving = false;
  9589. _this.currentDraggingPointerID = -1;
  9590. pickedMesh = null;
  9591. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9592. // Reattach camera controls
  9593. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9594. _this._scene.activeCamera.attachControl(attachedElement, true);
  9595. }
  9596. _this.onDragEndObservable.notifyObservers({});
  9597. }
  9598. }
  9599. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9600. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9601. var zDragFactor = _this.zDragFactor;
  9602. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9603. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9604. zDragFactor = 0;
  9605. }
  9606. // Calculate controller drag distance in controller space
  9607. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9608. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9609. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9610. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9611. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9612. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9613. if (_this._virtualDragMesh.position.z < 0) {
  9614. _this._virtualDragMesh.position.z = 0;
  9615. }
  9616. // Update the controller position
  9617. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9618. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9619. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9620. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9621. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9622. if (pickedMesh.parent) {
  9623. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9624. }
  9625. if (!_this._moving) {
  9626. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9627. }
  9628. _this._moving = true;
  9629. }
  9630. }
  9631. });
  9632. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9633. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9634. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9635. if (_this.dragging && _this._moving && pickedMesh) {
  9636. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9637. // Slowly move mesh to avoid jitter
  9638. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9639. if (_this.rotateDraggedObject) {
  9640. // Get change in rotation
  9641. tmpQuaternion.copyFrom(_this._startingOrientation);
  9642. tmpQuaternion.x = -tmpQuaternion.x;
  9643. tmpQuaternion.y = -tmpQuaternion.y;
  9644. tmpQuaternion.z = -tmpQuaternion.z;
  9645. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9646. // Convert change in rotation to only y axis rotation
  9647. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9648. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9649. // Slowly move mesh to avoid jitter
  9650. var oldParent = pickedMesh.parent;
  9651. // Only rotate the mesh if it's parent has uniform scaling
  9652. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9653. pickedMesh.setParent(null);
  9654. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9655. pickedMesh.setParent(oldParent);
  9656. }
  9657. }
  9658. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9659. }
  9660. });
  9661. };
  9662. /**
  9663. * Detaches the behavior from the mesh
  9664. */
  9665. SixDofDragBehavior.prototype.detach = function () {
  9666. if (this._scene) {
  9667. this._scene.onPointerObservable.remove(this._pointerObserver);
  9668. }
  9669. if (this._ownerNode) {
  9670. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9671. }
  9672. if (this._virtualOriginMesh) {
  9673. this._virtualOriginMesh.dispose();
  9674. }
  9675. if (this._virtualDragMesh) {
  9676. this._virtualDragMesh.dispose();
  9677. }
  9678. this.onDragEndObservable.clear();
  9679. this.onDragStartObservable.clear();
  9680. };
  9681. return SixDofDragBehavior;
  9682. }());
  9683. /***/ }),
  9684. /***/ "./Behaviors/index.ts":
  9685. /*!****************************!*\
  9686. !*** ./Behaviors/index.ts ***!
  9687. \****************************/
  9688. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9690. "use strict";
  9691. __webpack_require__.r(__webpack_exports__);
  9692. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9696. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9702. /***/ }),
  9703. /***/ "./Bones/bone.ts":
  9704. /*!***********************!*\
  9705. !*** ./Bones/bone.ts ***!
  9706. \***********************/
  9707. /*! exports provided: Bone */
  9708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9709. "use strict";
  9710. __webpack_require__.r(__webpack_exports__);
  9711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9712. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9713. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9714. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9715. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9716. /**
  9717. * Class used to store bone information
  9718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9719. */
  9720. var Bone = /** @class */ (function (_super) {
  9721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9722. /**
  9723. * Create a new bone
  9724. * @param name defines the bone name
  9725. * @param skeleton defines the parent skeleton
  9726. * @param parentBone defines the parent (can be null if the bone is the root)
  9727. * @param localMatrix defines the local matrix
  9728. * @param restPose defines the rest pose matrix
  9729. * @param baseMatrix defines the base matrix
  9730. * @param index defines index of the bone in the hiearchy
  9731. */
  9732. function Bone(
  9733. /**
  9734. * defines the bone name
  9735. */
  9736. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9737. if (parentBone === void 0) { parentBone = null; }
  9738. if (localMatrix === void 0) { localMatrix = null; }
  9739. if (restPose === void 0) { restPose = null; }
  9740. if (baseMatrix === void 0) { baseMatrix = null; }
  9741. if (index === void 0) { index = null; }
  9742. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9743. _this.name = name;
  9744. /**
  9745. * Gets the list of child bones
  9746. */
  9747. _this.children = new Array();
  9748. /** Gets the animations associated with this bone */
  9749. _this.animations = new Array();
  9750. /**
  9751. * @hidden Internal only
  9752. * Set this value to map this bone to a different index in the transform matrices
  9753. * Set this value to -1 to exclude the bone from the transform matrices
  9754. */
  9755. _this._index = null;
  9756. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9757. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9758. _this._scalingDeterminant = 1;
  9759. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9760. _this._needToDecompose = true;
  9761. _this._needToCompose = false;
  9762. /** @hidden */
  9763. _this._linkedTransformNode = null;
  9764. _this._skeleton = skeleton;
  9765. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9766. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9767. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9768. _this._index = index;
  9769. skeleton.bones.push(_this);
  9770. _this.setParent(parentBone, false);
  9771. if (baseMatrix || localMatrix) {
  9772. _this._updateDifferenceMatrix();
  9773. }
  9774. return _this;
  9775. }
  9776. Object.defineProperty(Bone.prototype, "_matrix", {
  9777. /** @hidden */
  9778. get: function () {
  9779. this._compose();
  9780. return this._localMatrix;
  9781. },
  9782. /** @hidden */
  9783. set: function (value) {
  9784. this._localMatrix.copyFrom(value);
  9785. this._needToDecompose = true;
  9786. },
  9787. enumerable: true,
  9788. configurable: true
  9789. });
  9790. // Members
  9791. /**
  9792. * Gets the parent skeleton
  9793. * @returns a skeleton
  9794. */
  9795. Bone.prototype.getSkeleton = function () {
  9796. return this._skeleton;
  9797. };
  9798. /**
  9799. * Gets parent bone
  9800. * @returns a bone or null if the bone is the root of the bone hierarchy
  9801. */
  9802. Bone.prototype.getParent = function () {
  9803. return this._parent;
  9804. };
  9805. /**
  9806. * Sets the parent bone
  9807. * @param parent defines the parent (can be null if the bone is the root)
  9808. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9809. */
  9810. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9811. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9812. if (this._parent === parent) {
  9813. return;
  9814. }
  9815. if (this._parent) {
  9816. var index = this._parent.children.indexOf(this);
  9817. if (index !== -1) {
  9818. this._parent.children.splice(index, 1);
  9819. }
  9820. }
  9821. this._parent = parent;
  9822. if (this._parent) {
  9823. this._parent.children.push(this);
  9824. }
  9825. if (updateDifferenceMatrix) {
  9826. this._updateDifferenceMatrix();
  9827. }
  9828. this.markAsDirty();
  9829. };
  9830. /**
  9831. * Gets the local matrix
  9832. * @returns a matrix
  9833. */
  9834. Bone.prototype.getLocalMatrix = function () {
  9835. this._compose();
  9836. return this._localMatrix;
  9837. };
  9838. /**
  9839. * Gets the base matrix (initial matrix which remains unchanged)
  9840. * @returns a matrix
  9841. */
  9842. Bone.prototype.getBaseMatrix = function () {
  9843. return this._baseMatrix;
  9844. };
  9845. /**
  9846. * Gets the rest pose matrix
  9847. * @returns a matrix
  9848. */
  9849. Bone.prototype.getRestPose = function () {
  9850. return this._restPose;
  9851. };
  9852. /**
  9853. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9854. */
  9855. Bone.prototype.getWorldMatrix = function () {
  9856. return this._worldTransform;
  9857. };
  9858. /**
  9859. * Sets the local matrix to rest pose matrix
  9860. */
  9861. Bone.prototype.returnToRest = function () {
  9862. this.updateMatrix(this._restPose.clone());
  9863. };
  9864. /**
  9865. * Gets the inverse of the absolute transform matrix.
  9866. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9867. * @returns a matrix
  9868. */
  9869. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9870. return this._invertedAbsoluteTransform;
  9871. };
  9872. /**
  9873. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9874. * @returns a matrix
  9875. */
  9876. Bone.prototype.getAbsoluteTransform = function () {
  9877. return this._absoluteTransform;
  9878. };
  9879. /**
  9880. * Links with the given transform node.
  9881. * The local matrix of this bone is copied from the transform node every frame.
  9882. * @param transformNode defines the transform node to link to
  9883. */
  9884. Bone.prototype.linkTransformNode = function (transformNode) {
  9885. if (this._linkedTransformNode) {
  9886. this._skeleton._numBonesWithLinkedTransformNode--;
  9887. }
  9888. this._linkedTransformNode = transformNode;
  9889. if (this._linkedTransformNode) {
  9890. this._skeleton._numBonesWithLinkedTransformNode++;
  9891. }
  9892. };
  9893. Object.defineProperty(Bone.prototype, "position", {
  9894. // Properties (matches AbstractMesh properties)
  9895. /** Gets or sets current position (in local space) */
  9896. get: function () {
  9897. this._decompose();
  9898. return this._localPosition;
  9899. },
  9900. set: function (newPosition) {
  9901. this._decompose();
  9902. this._localPosition.copyFrom(newPosition);
  9903. this._markAsDirtyAndCompose();
  9904. },
  9905. enumerable: true,
  9906. configurable: true
  9907. });
  9908. Object.defineProperty(Bone.prototype, "rotation", {
  9909. /** Gets or sets current rotation (in local space) */
  9910. get: function () {
  9911. return this.getRotation();
  9912. },
  9913. set: function (newRotation) {
  9914. this.setRotation(newRotation);
  9915. },
  9916. enumerable: true,
  9917. configurable: true
  9918. });
  9919. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9920. /** Gets or sets current rotation quaternion (in local space) */
  9921. get: function () {
  9922. this._decompose();
  9923. return this._localRotation;
  9924. },
  9925. set: function (newRotation) {
  9926. this.setRotationQuaternion(newRotation);
  9927. },
  9928. enumerable: true,
  9929. configurable: true
  9930. });
  9931. Object.defineProperty(Bone.prototype, "scaling", {
  9932. /** Gets or sets current scaling (in local space) */
  9933. get: function () {
  9934. return this.getScale();
  9935. },
  9936. set: function (newScaling) {
  9937. this.setScale(newScaling);
  9938. },
  9939. enumerable: true,
  9940. configurable: true
  9941. });
  9942. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9943. /**
  9944. * Gets the animation properties override
  9945. */
  9946. get: function () {
  9947. return this._skeleton.animationPropertiesOverride;
  9948. },
  9949. enumerable: true,
  9950. configurable: true
  9951. });
  9952. // Methods
  9953. Bone.prototype._decompose = function () {
  9954. if (!this._needToDecompose) {
  9955. return;
  9956. }
  9957. this._needToDecompose = false;
  9958. if (!this._localScaling) {
  9959. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9960. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9961. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9962. }
  9963. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9964. };
  9965. Bone.prototype._compose = function () {
  9966. if (!this._needToCompose) {
  9967. return;
  9968. }
  9969. this._needToCompose = false;
  9970. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9971. };
  9972. /**
  9973. * Update the base and local matrices
  9974. * @param matrix defines the new base or local matrix
  9975. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9976. * @param updateLocalMatrix defines if the local matrix should be updated
  9977. */
  9978. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9979. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9980. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9981. this._baseMatrix.copyFrom(matrix);
  9982. if (updateDifferenceMatrix) {
  9983. this._updateDifferenceMatrix();
  9984. }
  9985. if (updateLocalMatrix) {
  9986. this._localMatrix.copyFrom(matrix);
  9987. this._markAsDirtyAndDecompose();
  9988. }
  9989. else {
  9990. this.markAsDirty();
  9991. }
  9992. };
  9993. /** @hidden */
  9994. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  9995. if (updateChildren === void 0) { updateChildren = true; }
  9996. if (!rootMatrix) {
  9997. rootMatrix = this._baseMatrix;
  9998. }
  9999. if (this._parent) {
  10000. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10001. }
  10002. else {
  10003. this._absoluteTransform.copyFrom(rootMatrix);
  10004. }
  10005. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10006. if (updateChildren) {
  10007. for (var index = 0; index < this.children.length; index++) {
  10008. this.children[index]._updateDifferenceMatrix();
  10009. }
  10010. }
  10011. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10012. };
  10013. /**
  10014. * Flag the bone as dirty (Forcing it to update everything)
  10015. */
  10016. Bone.prototype.markAsDirty = function () {
  10017. this._currentRenderId++;
  10018. this._childRenderId++;
  10019. this._skeleton._markAsDirty();
  10020. };
  10021. Bone.prototype._markAsDirtyAndCompose = function () {
  10022. this.markAsDirty();
  10023. this._needToCompose = true;
  10024. };
  10025. Bone.prototype._markAsDirtyAndDecompose = function () {
  10026. this.markAsDirty();
  10027. this._needToDecompose = true;
  10028. };
  10029. /**
  10030. * Translate the bone in local or world space
  10031. * @param vec The amount to translate the bone
  10032. * @param space The space that the translation is in
  10033. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10034. */
  10035. Bone.prototype.translate = function (vec, space, mesh) {
  10036. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10037. var lm = this.getLocalMatrix();
  10038. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10039. lm.addAtIndex(12, vec.x);
  10040. lm.addAtIndex(13, vec.y);
  10041. lm.addAtIndex(14, vec.z);
  10042. }
  10043. else {
  10044. var wm = null;
  10045. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10046. if (mesh) {
  10047. wm = mesh.getWorldMatrix();
  10048. }
  10049. this._skeleton.computeAbsoluteTransforms();
  10050. var tmat = Bone._tmpMats[0];
  10051. var tvec = Bone._tmpVecs[0];
  10052. if (this._parent) {
  10053. if (mesh && wm) {
  10054. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10055. tmat.multiplyToRef(wm, tmat);
  10056. }
  10057. else {
  10058. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10059. }
  10060. }
  10061. tmat.setTranslationFromFloats(0, 0, 0);
  10062. tmat.invert();
  10063. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10064. lm.addAtIndex(12, tvec.x);
  10065. lm.addAtIndex(13, tvec.y);
  10066. lm.addAtIndex(14, tvec.z);
  10067. }
  10068. this._markAsDirtyAndDecompose();
  10069. };
  10070. /**
  10071. * Set the postion of the bone in local or world space
  10072. * @param position The position to set the bone
  10073. * @param space The space that the position is in
  10074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10075. */
  10076. Bone.prototype.setPosition = function (position, space, mesh) {
  10077. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10078. var lm = this.getLocalMatrix();
  10079. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10080. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10081. }
  10082. else {
  10083. var wm = null;
  10084. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10085. if (mesh) {
  10086. wm = mesh.getWorldMatrix();
  10087. }
  10088. this._skeleton.computeAbsoluteTransforms();
  10089. var tmat = Bone._tmpMats[0];
  10090. var vec = Bone._tmpVecs[0];
  10091. if (this._parent) {
  10092. if (mesh && wm) {
  10093. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10094. tmat.multiplyToRef(wm, tmat);
  10095. }
  10096. else {
  10097. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10098. }
  10099. }
  10100. tmat.invert();
  10101. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10102. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10103. }
  10104. this._markAsDirtyAndDecompose();
  10105. };
  10106. /**
  10107. * Set the absolute position of the bone (world space)
  10108. * @param position The position to set the bone
  10109. * @param mesh The mesh that this bone is attached to
  10110. */
  10111. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10112. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10113. };
  10114. /**
  10115. * Scale the bone on the x, y and z axes (in local space)
  10116. * @param x The amount to scale the bone on the x axis
  10117. * @param y The amount to scale the bone on the y axis
  10118. * @param z The amount to scale the bone on the z axis
  10119. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10120. */
  10121. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10122. if (scaleChildren === void 0) { scaleChildren = false; }
  10123. var locMat = this.getLocalMatrix();
  10124. // Apply new scaling on top of current local matrix
  10125. var scaleMat = Bone._tmpMats[0];
  10126. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10127. scaleMat.multiplyToRef(locMat, locMat);
  10128. // Invert scaling matrix and apply the inverse to all children
  10129. scaleMat.invert();
  10130. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10131. var child = _a[_i];
  10132. var cm = child.getLocalMatrix();
  10133. cm.multiplyToRef(scaleMat, cm);
  10134. cm.multiplyAtIndex(12, x);
  10135. cm.multiplyAtIndex(13, y);
  10136. cm.multiplyAtIndex(14, z);
  10137. child._markAsDirtyAndDecompose();
  10138. }
  10139. this._markAsDirtyAndDecompose();
  10140. if (scaleChildren) {
  10141. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10142. var child = _c[_b];
  10143. child.scale(x, y, z, scaleChildren);
  10144. }
  10145. }
  10146. };
  10147. /**
  10148. * Set the bone scaling in local space
  10149. * @param scale defines the scaling vector
  10150. */
  10151. Bone.prototype.setScale = function (scale) {
  10152. this._decompose();
  10153. this._localScaling.copyFrom(scale);
  10154. this._markAsDirtyAndCompose();
  10155. };
  10156. /**
  10157. * Gets the current scaling in local space
  10158. * @returns the current scaling vector
  10159. */
  10160. Bone.prototype.getScale = function () {
  10161. this._decompose();
  10162. return this._localScaling;
  10163. };
  10164. /**
  10165. * Gets the current scaling in local space and stores it in a target vector
  10166. * @param result defines the target vector
  10167. */
  10168. Bone.prototype.getScaleToRef = function (result) {
  10169. this._decompose();
  10170. result.copyFrom(this._localScaling);
  10171. };
  10172. /**
  10173. * Set the yaw, pitch, and roll of the bone in local or world space
  10174. * @param yaw The rotation of the bone on the y axis
  10175. * @param pitch The rotation of the bone on the x axis
  10176. * @param roll The rotation of the bone on the z axis
  10177. * @param space The space that the axes of rotation are in
  10178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10179. */
  10180. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10181. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10182. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10183. var quat = Bone._tmpQuat;
  10184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10185. this.setRotationQuaternion(quat, space, mesh);
  10186. return;
  10187. }
  10188. var rotMatInv = Bone._tmpMats[0];
  10189. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10190. return;
  10191. }
  10192. var rotMat = Bone._tmpMats[1];
  10193. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10194. rotMatInv.multiplyToRef(rotMat, rotMat);
  10195. this._rotateWithMatrix(rotMat, space, mesh);
  10196. };
  10197. /**
  10198. * Add a rotation to the bone on an axis in local or world space
  10199. * @param axis The axis to rotate the bone on
  10200. * @param amount The amount to rotate the bone
  10201. * @param space The space that the axis is in
  10202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10203. */
  10204. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10205. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10206. var rmat = Bone._tmpMats[0];
  10207. rmat.setTranslationFromFloats(0, 0, 0);
  10208. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10209. this._rotateWithMatrix(rmat, space, mesh);
  10210. };
  10211. /**
  10212. * Set the rotation of the bone to a particular axis angle in local or world space
  10213. * @param axis The axis to rotate the bone on
  10214. * @param angle The angle that the bone should be rotated to
  10215. * @param space The space that the axis is in
  10216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10217. */
  10218. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10219. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10220. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10221. var quat = Bone._tmpQuat;
  10222. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10223. this.setRotationQuaternion(quat, space, mesh);
  10224. return;
  10225. }
  10226. var rotMatInv = Bone._tmpMats[0];
  10227. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10228. return;
  10229. }
  10230. var rotMat = Bone._tmpMats[1];
  10231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10232. rotMatInv.multiplyToRef(rotMat, rotMat);
  10233. this._rotateWithMatrix(rotMat, space, mesh);
  10234. };
  10235. /**
  10236. * Set the euler rotation of the bone in local of world space
  10237. * @param rotation The euler rotation that the bone should be set to
  10238. * @param space The space that the rotation is in
  10239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10240. */
  10241. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10242. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10243. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10244. };
  10245. /**
  10246. * Set the quaternion rotation of the bone in local of world space
  10247. * @param quat The quaternion rotation that the bone should be set to
  10248. * @param space The space that the rotation is in
  10249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10250. */
  10251. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10252. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10253. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10254. this._decompose();
  10255. this._localRotation.copyFrom(quat);
  10256. this._markAsDirtyAndCompose();
  10257. return;
  10258. }
  10259. var rotMatInv = Bone._tmpMats[0];
  10260. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10261. return;
  10262. }
  10263. var rotMat = Bone._tmpMats[1];
  10264. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10265. rotMatInv.multiplyToRef(rotMat, rotMat);
  10266. this._rotateWithMatrix(rotMat, space, mesh);
  10267. };
  10268. /**
  10269. * Set the rotation matrix of the bone in local of world space
  10270. * @param rotMat The rotation matrix that the bone should be set to
  10271. * @param space The space that the rotation is in
  10272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10273. */
  10274. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10275. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10276. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10277. var quat = Bone._tmpQuat;
  10278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10279. this.setRotationQuaternion(quat, space, mesh);
  10280. return;
  10281. }
  10282. var rotMatInv = Bone._tmpMats[0];
  10283. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10284. return;
  10285. }
  10286. var rotMat2 = Bone._tmpMats[1];
  10287. rotMat2.copyFrom(rotMat);
  10288. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10289. this._rotateWithMatrix(rotMat2, space, mesh);
  10290. };
  10291. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10292. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10293. var lmat = this.getLocalMatrix();
  10294. var lx = lmat.m[12];
  10295. var ly = lmat.m[13];
  10296. var lz = lmat.m[14];
  10297. var parent = this.getParent();
  10298. var parentScale = Bone._tmpMats[3];
  10299. var parentScaleInv = Bone._tmpMats[4];
  10300. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10301. if (mesh) {
  10302. parentScale.copyFrom(mesh.getWorldMatrix());
  10303. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10304. }
  10305. else {
  10306. parentScale.copyFrom(parent.getAbsoluteTransform());
  10307. }
  10308. parentScaleInv.copyFrom(parentScale);
  10309. parentScaleInv.invert();
  10310. lmat.multiplyToRef(parentScale, lmat);
  10311. lmat.multiplyToRef(rmat, lmat);
  10312. lmat.multiplyToRef(parentScaleInv, lmat);
  10313. }
  10314. else {
  10315. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10316. parentScale.copyFrom(mesh.getWorldMatrix());
  10317. parentScaleInv.copyFrom(parentScale);
  10318. parentScaleInv.invert();
  10319. lmat.multiplyToRef(parentScale, lmat);
  10320. lmat.multiplyToRef(rmat, lmat);
  10321. lmat.multiplyToRef(parentScaleInv, lmat);
  10322. }
  10323. else {
  10324. lmat.multiplyToRef(rmat, lmat);
  10325. }
  10326. }
  10327. lmat.setTranslationFromFloats(lx, ly, lz);
  10328. this.computeAbsoluteTransforms();
  10329. this._markAsDirtyAndDecompose();
  10330. };
  10331. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10332. var scaleMatrix = Bone._tmpMats[2];
  10333. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10334. if (mesh) {
  10335. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10337. }
  10338. rotMatInv.invert();
  10339. if (isNaN(rotMatInv.m[0])) {
  10340. // Matrix failed to invert.
  10341. // This can happen if scale is zero for example.
  10342. return false;
  10343. }
  10344. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10345. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10346. return true;
  10347. };
  10348. /**
  10349. * Get the position of the bone in local or world space
  10350. * @param space The space that the returned position is in
  10351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10352. * @returns The position of the bone
  10353. */
  10354. Bone.prototype.getPosition = function (space, mesh) {
  10355. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10356. if (mesh === void 0) { mesh = null; }
  10357. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10358. this.getPositionToRef(space, mesh, pos);
  10359. return pos;
  10360. };
  10361. /**
  10362. * Copy the position of the bone to a vector3 in local or world space
  10363. * @param space The space that the returned position is in
  10364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10365. * @param result The vector3 to copy the position to
  10366. */
  10367. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10368. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10369. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10370. var lm = this.getLocalMatrix();
  10371. result.x = lm.m[12];
  10372. result.y = lm.m[13];
  10373. result.z = lm.m[14];
  10374. }
  10375. else {
  10376. var wm = null;
  10377. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10378. if (mesh) {
  10379. wm = mesh.getWorldMatrix();
  10380. }
  10381. this._skeleton.computeAbsoluteTransforms();
  10382. var tmat = Bone._tmpMats[0];
  10383. if (mesh && wm) {
  10384. tmat.copyFrom(this.getAbsoluteTransform());
  10385. tmat.multiplyToRef(wm, tmat);
  10386. }
  10387. else {
  10388. tmat = this.getAbsoluteTransform();
  10389. }
  10390. result.x = tmat.m[12];
  10391. result.y = tmat.m[13];
  10392. result.z = tmat.m[14];
  10393. }
  10394. };
  10395. /**
  10396. * Get the absolute position of the bone (world space)
  10397. * @param mesh The mesh that this bone is attached to
  10398. * @returns The absolute position of the bone
  10399. */
  10400. Bone.prototype.getAbsolutePosition = function (mesh) {
  10401. if (mesh === void 0) { mesh = null; }
  10402. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10403. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10404. return pos;
  10405. };
  10406. /**
  10407. * Copy the absolute position of the bone (world space) to the result param
  10408. * @param mesh The mesh that this bone is attached to
  10409. * @param result The vector3 to copy the absolute position to
  10410. */
  10411. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10412. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10413. };
  10414. /**
  10415. * Compute the absolute transforms of this bone and its children
  10416. */
  10417. Bone.prototype.computeAbsoluteTransforms = function () {
  10418. this._compose();
  10419. if (this._parent) {
  10420. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10421. }
  10422. else {
  10423. this._absoluteTransform.copyFrom(this._localMatrix);
  10424. var poseMatrix = this._skeleton.getPoseMatrix();
  10425. if (poseMatrix) {
  10426. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10427. }
  10428. }
  10429. var children = this.children;
  10430. var len = children.length;
  10431. for (var i = 0; i < len; i++) {
  10432. children[i].computeAbsoluteTransforms();
  10433. }
  10434. };
  10435. /**
  10436. * Get the world direction from an axis that is in the local space of the bone
  10437. * @param localAxis The local direction that is used to compute the world direction
  10438. * @param mesh The mesh that this bone is attached to
  10439. * @returns The world direction
  10440. */
  10441. Bone.prototype.getDirection = function (localAxis, mesh) {
  10442. if (mesh === void 0) { mesh = null; }
  10443. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10444. this.getDirectionToRef(localAxis, mesh, result);
  10445. return result;
  10446. };
  10447. /**
  10448. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10449. * @param localAxis The local direction that is used to compute the world direction
  10450. * @param mesh The mesh that this bone is attached to
  10451. * @param result The vector3 that the world direction will be copied to
  10452. */
  10453. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10454. if (mesh === void 0) { mesh = null; }
  10455. var wm = null;
  10456. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10457. if (mesh) {
  10458. wm = mesh.getWorldMatrix();
  10459. }
  10460. this._skeleton.computeAbsoluteTransforms();
  10461. var mat = Bone._tmpMats[0];
  10462. mat.copyFrom(this.getAbsoluteTransform());
  10463. if (mesh && wm) {
  10464. mat.multiplyToRef(wm, mat);
  10465. }
  10466. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10467. result.normalize();
  10468. };
  10469. /**
  10470. * Get the euler rotation of the bone in local or world space
  10471. * @param space The space that the rotation should be in
  10472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10473. * @returns The euler rotation
  10474. */
  10475. Bone.prototype.getRotation = function (space, mesh) {
  10476. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10477. if (mesh === void 0) { mesh = null; }
  10478. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10479. this.getRotationToRef(space, mesh, result);
  10480. return result;
  10481. };
  10482. /**
  10483. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10484. * @param space The space that the rotation should be in
  10485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10486. * @param result The vector3 that the rotation should be copied to
  10487. */
  10488. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10489. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10490. if (mesh === void 0) { mesh = null; }
  10491. var quat = Bone._tmpQuat;
  10492. this.getRotationQuaternionToRef(space, mesh, quat);
  10493. quat.toEulerAnglesToRef(result);
  10494. };
  10495. /**
  10496. * Get the quaternion rotation of the bone in either local or world space
  10497. * @param space The space that the rotation should be in
  10498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10499. * @returns The quaternion rotation
  10500. */
  10501. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10502. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10503. if (mesh === void 0) { mesh = null; }
  10504. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10505. this.getRotationQuaternionToRef(space, mesh, result);
  10506. return result;
  10507. };
  10508. /**
  10509. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10510. * @param space The space that the rotation should be in
  10511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10512. * @param result The quaternion that the rotation should be copied to
  10513. */
  10514. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10515. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10516. if (mesh === void 0) { mesh = null; }
  10517. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10518. this._decompose();
  10519. result.copyFrom(this._localRotation);
  10520. }
  10521. else {
  10522. var mat = Bone._tmpMats[0];
  10523. var amat = this.getAbsoluteTransform();
  10524. if (mesh) {
  10525. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10526. }
  10527. else {
  10528. mat.copyFrom(amat);
  10529. }
  10530. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10531. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10532. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10533. mat.decompose(undefined, result, undefined);
  10534. }
  10535. };
  10536. /**
  10537. * Get the rotation matrix of the bone in local or world space
  10538. * @param space The space that the rotation should be in
  10539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10540. * @returns The rotation matrix
  10541. */
  10542. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10543. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10544. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10545. this.getRotationMatrixToRef(space, mesh, result);
  10546. return result;
  10547. };
  10548. /**
  10549. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10550. * @param space The space that the rotation should be in
  10551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10552. * @param result The quaternion that the rotation should be copied to
  10553. */
  10554. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10555. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10556. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10557. this.getLocalMatrix().getRotationMatrixToRef(result);
  10558. }
  10559. else {
  10560. var mat = Bone._tmpMats[0];
  10561. var amat = this.getAbsoluteTransform();
  10562. if (mesh) {
  10563. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10564. }
  10565. else {
  10566. mat.copyFrom(amat);
  10567. }
  10568. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10569. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10570. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10571. mat.getRotationMatrixToRef(result);
  10572. }
  10573. };
  10574. /**
  10575. * Get the world position of a point that is in the local space of the bone
  10576. * @param position The local position
  10577. * @param mesh The mesh that this bone is attached to
  10578. * @returns The world position
  10579. */
  10580. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10581. if (mesh === void 0) { mesh = null; }
  10582. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10583. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10584. return result;
  10585. };
  10586. /**
  10587. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10588. * @param position The local position
  10589. * @param mesh The mesh that this bone is attached to
  10590. * @param result The vector3 that the world position should be copied to
  10591. */
  10592. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10593. if (mesh === void 0) { mesh = null; }
  10594. var wm = null;
  10595. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10596. if (mesh) {
  10597. wm = mesh.getWorldMatrix();
  10598. }
  10599. this._skeleton.computeAbsoluteTransforms();
  10600. var tmat = Bone._tmpMats[0];
  10601. if (mesh && wm) {
  10602. tmat.copyFrom(this.getAbsoluteTransform());
  10603. tmat.multiplyToRef(wm, tmat);
  10604. }
  10605. else {
  10606. tmat = this.getAbsoluteTransform();
  10607. }
  10608. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10609. };
  10610. /**
  10611. * Get the local position of a point that is in world space
  10612. * @param position The world position
  10613. * @param mesh The mesh that this bone is attached to
  10614. * @returns The local position
  10615. */
  10616. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10617. if (mesh === void 0) { mesh = null; }
  10618. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10619. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10620. return result;
  10621. };
  10622. /**
  10623. * Get the local position of a point that is in world space and copy it to the result param
  10624. * @param position The world position
  10625. * @param mesh The mesh that this bone is attached to
  10626. * @param result The vector3 that the local position should be copied to
  10627. */
  10628. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10629. if (mesh === void 0) { mesh = null; }
  10630. var wm = null;
  10631. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10632. if (mesh) {
  10633. wm = mesh.getWorldMatrix();
  10634. }
  10635. this._skeleton.computeAbsoluteTransforms();
  10636. var tmat = Bone._tmpMats[0];
  10637. tmat.copyFrom(this.getAbsoluteTransform());
  10638. if (mesh && wm) {
  10639. tmat.multiplyToRef(wm, tmat);
  10640. }
  10641. tmat.invert();
  10642. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10643. };
  10644. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10645. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10646. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10647. return Bone;
  10648. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10649. /***/ }),
  10650. /***/ "./Bones/boneIKController.ts":
  10651. /*!***********************************!*\
  10652. !*** ./Bones/boneIKController.ts ***!
  10653. \***********************************/
  10654. /*! exports provided: BoneIKController */
  10655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10656. "use strict";
  10657. __webpack_require__.r(__webpack_exports__);
  10658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10659. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10660. /**
  10661. * Class used to apply inverse kinematics to bones
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10663. */
  10664. var BoneIKController = /** @class */ (function () {
  10665. /**
  10666. * Creates a new BoneIKController
  10667. * @param mesh defines the mesh to control
  10668. * @param bone defines the bone to control
  10669. * @param options defines options to set up the controller
  10670. */
  10671. function BoneIKController(mesh, bone, options) {
  10672. /**
  10673. * Gets or sets the target position
  10674. */
  10675. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10676. /**
  10677. * Gets or sets the pole target position
  10678. */
  10679. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10680. /**
  10681. * Gets or sets the pole target local offset
  10682. */
  10683. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10684. /**
  10685. * Gets or sets the pole angle
  10686. */
  10687. this.poleAngle = 0;
  10688. /**
  10689. * 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)
  10690. */
  10691. this.slerpAmount = 1;
  10692. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10693. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10694. this._bone2Ang = Math.PI;
  10695. this._maxAngle = Math.PI;
  10696. this._rightHandedSystem = false;
  10697. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10698. this._slerping = false;
  10699. this._adjustRoll = 0;
  10700. this._bone2 = bone;
  10701. this._bone1 = bone.getParent();
  10702. if (!this._bone1) {
  10703. return;
  10704. }
  10705. this.mesh = mesh;
  10706. var bonePos = bone.getPosition();
  10707. if (bone.getAbsoluteTransform().determinant() > 0) {
  10708. this._rightHandedSystem = true;
  10709. this._bendAxis.x = 0;
  10710. this._bendAxis.y = 0;
  10711. this._bendAxis.z = -1;
  10712. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10713. this._adjustRoll = Math.PI * .5;
  10714. this._bendAxis.z = 1;
  10715. }
  10716. }
  10717. if (this._bone1.length) {
  10718. var boneScale1 = this._bone1.getScale();
  10719. var boneScale2 = this._bone2.getScale();
  10720. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10721. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10722. }
  10723. else if (this._bone1.children[0]) {
  10724. mesh.computeWorldMatrix(true);
  10725. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10726. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10727. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10728. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10729. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10730. }
  10731. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10732. this.maxAngle = Math.PI;
  10733. if (options) {
  10734. if (options.targetMesh) {
  10735. this.targetMesh = options.targetMesh;
  10736. this.targetMesh.computeWorldMatrix(true);
  10737. }
  10738. if (options.poleTargetMesh) {
  10739. this.poleTargetMesh = options.poleTargetMesh;
  10740. this.poleTargetMesh.computeWorldMatrix(true);
  10741. }
  10742. else if (options.poleTargetBone) {
  10743. this.poleTargetBone = options.poleTargetBone;
  10744. }
  10745. else if (this._bone1.getParent()) {
  10746. this.poleTargetBone = this._bone1.getParent();
  10747. }
  10748. if (options.poleTargetLocalOffset) {
  10749. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10750. }
  10751. if (options.poleAngle) {
  10752. this.poleAngle = options.poleAngle;
  10753. }
  10754. if (options.bendAxis) {
  10755. this._bendAxis.copyFrom(options.bendAxis);
  10756. }
  10757. if (options.maxAngle) {
  10758. this.maxAngle = options.maxAngle;
  10759. }
  10760. if (options.slerpAmount) {
  10761. this.slerpAmount = options.slerpAmount;
  10762. }
  10763. }
  10764. }
  10765. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10766. /**
  10767. * Gets or sets maximum allowed angle
  10768. */
  10769. get: function () {
  10770. return this._maxAngle;
  10771. },
  10772. set: function (value) {
  10773. this._setMaxAngle(value);
  10774. },
  10775. enumerable: true,
  10776. configurable: true
  10777. });
  10778. BoneIKController.prototype._setMaxAngle = function (ang) {
  10779. if (ang < 0) {
  10780. ang = 0;
  10781. }
  10782. if (ang > Math.PI || ang == undefined) {
  10783. ang = Math.PI;
  10784. }
  10785. this._maxAngle = ang;
  10786. var a = this._bone1Length;
  10787. var b = this._bone2Length;
  10788. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10789. };
  10790. /**
  10791. * Force the controller to update the bones
  10792. */
  10793. BoneIKController.prototype.update = function () {
  10794. var bone1 = this._bone1;
  10795. if (!bone1) {
  10796. return;
  10797. }
  10798. var target = this.targetPosition;
  10799. var poleTarget = this.poleTargetPosition;
  10800. var mat1 = BoneIKController._tmpMats[0];
  10801. var mat2 = BoneIKController._tmpMats[1];
  10802. if (this.targetMesh) {
  10803. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10804. }
  10805. if (this.poleTargetBone) {
  10806. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10807. }
  10808. else if (this.poleTargetMesh) {
  10809. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10810. }
  10811. var bonePos = BoneIKController._tmpVecs[0];
  10812. var zaxis = BoneIKController._tmpVecs[1];
  10813. var xaxis = BoneIKController._tmpVecs[2];
  10814. var yaxis = BoneIKController._tmpVecs[3];
  10815. var upAxis = BoneIKController._tmpVecs[4];
  10816. var _tmpQuat = BoneIKController._tmpQuat;
  10817. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10818. poleTarget.subtractToRef(bonePos, upAxis);
  10819. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10820. upAxis.y = 1;
  10821. }
  10822. else {
  10823. upAxis.normalize();
  10824. }
  10825. target.subtractToRef(bonePos, yaxis);
  10826. yaxis.normalize();
  10827. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10828. zaxis.normalize();
  10829. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10830. xaxis.normalize();
  10831. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10832. var a = this._bone1Length;
  10833. var b = this._bone2Length;
  10834. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10835. if (this._maxReach > 0) {
  10836. c = Math.min(this._maxReach, c);
  10837. }
  10838. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10839. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10840. if (acosa > 1) {
  10841. acosa = 1;
  10842. }
  10843. if (acosb > 1) {
  10844. acosb = 1;
  10845. }
  10846. if (acosa < -1) {
  10847. acosa = -1;
  10848. }
  10849. if (acosb < -1) {
  10850. acosb = -1;
  10851. }
  10852. var angA = Math.acos(acosa);
  10853. var angB = Math.acos(acosb);
  10854. var angC = -angA - angB;
  10855. if (this._rightHandedSystem) {
  10856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10857. mat2.multiplyToRef(mat1, mat1);
  10858. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10859. mat2.multiplyToRef(mat1, mat1);
  10860. }
  10861. else {
  10862. var _tmpVec = BoneIKController._tmpVecs[5];
  10863. _tmpVec.copyFrom(this._bendAxis);
  10864. _tmpVec.x *= -1;
  10865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10866. mat2.multiplyToRef(mat1, mat1);
  10867. }
  10868. if (this.poleAngle) {
  10869. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10870. mat1.multiplyToRef(mat2, mat1);
  10871. }
  10872. if (this._bone1) {
  10873. if (this.slerpAmount < 1) {
  10874. if (!this._slerping) {
  10875. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10876. }
  10877. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10878. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10879. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10880. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10881. this._slerping = true;
  10882. }
  10883. else {
  10884. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10885. this._bone1Mat.copyFrom(mat1);
  10886. this._slerping = false;
  10887. }
  10888. }
  10889. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10890. this._bone2Ang = angC;
  10891. };
  10892. BoneIKController._tmpVecs = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  10893. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10894. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10895. return BoneIKController;
  10896. }());
  10897. /***/ }),
  10898. /***/ "./Bones/boneLookController.ts":
  10899. /*!*************************************!*\
  10900. !*** ./Bones/boneLookController.ts ***!
  10901. \*************************************/
  10902. /*! exports provided: BoneLookController */
  10903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10904. "use strict";
  10905. __webpack_require__.r(__webpack_exports__);
  10906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10907. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10908. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10909. /**
  10910. * Class used to make a bone look toward a point in space
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10912. */
  10913. var BoneLookController = /** @class */ (function () {
  10914. /**
  10915. * Create a BoneLookController
  10916. * @param mesh the mesh that the bone belongs to
  10917. * @param bone the bone that will be looking to the target
  10918. * @param target the target Vector3 to look at
  10919. * @param options optional settings:
  10920. * * maxYaw: the maximum angle the bone will yaw to
  10921. * * minYaw: the minimum angle the bone will yaw to
  10922. * * maxPitch: the maximum angle the bone will pitch to
  10923. * * minPitch: the minimum angle the bone will yaw to
  10924. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10925. * * upAxis: the up axis of the coordinate system
  10926. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10927. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10928. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10929. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10930. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10931. * * adjustRoll: used to make an adjustment to the roll of the bone
  10932. **/
  10933. function BoneLookController(mesh, bone, target, options) {
  10934. /**
  10935. * The up axis of the coordinate system that is used when the bone is rotated
  10936. */
  10937. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10938. /**
  10939. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10940. */
  10941. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10942. /**
  10943. * Used to make an adjustment to the yaw of the bone
  10944. */
  10945. this.adjustYaw = 0;
  10946. /**
  10947. * Used to make an adjustment to the pitch of the bone
  10948. */
  10949. this.adjustPitch = 0;
  10950. /**
  10951. * Used to make an adjustment to the roll of the bone
  10952. */
  10953. this.adjustRoll = 0;
  10954. /**
  10955. * 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)
  10956. */
  10957. this.slerpAmount = 1;
  10958. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10959. this._slerping = false;
  10960. this._firstFrameSkipped = false;
  10961. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10962. this.mesh = mesh;
  10963. this.bone = bone;
  10964. this.target = target;
  10965. if (options) {
  10966. if (options.adjustYaw) {
  10967. this.adjustYaw = options.adjustYaw;
  10968. }
  10969. if (options.adjustPitch) {
  10970. this.adjustPitch = options.adjustPitch;
  10971. }
  10972. if (options.adjustRoll) {
  10973. this.adjustRoll = options.adjustRoll;
  10974. }
  10975. if (options.maxYaw != null) {
  10976. this.maxYaw = options.maxYaw;
  10977. }
  10978. else {
  10979. this.maxYaw = Math.PI;
  10980. }
  10981. if (options.minYaw != null) {
  10982. this.minYaw = options.minYaw;
  10983. }
  10984. else {
  10985. this.minYaw = -Math.PI;
  10986. }
  10987. if (options.maxPitch != null) {
  10988. this.maxPitch = options.maxPitch;
  10989. }
  10990. else {
  10991. this.maxPitch = Math.PI;
  10992. }
  10993. if (options.minPitch != null) {
  10994. this.minPitch = options.minPitch;
  10995. }
  10996. else {
  10997. this.minPitch = -Math.PI;
  10998. }
  10999. if (options.slerpAmount != null) {
  11000. this.slerpAmount = options.slerpAmount;
  11001. }
  11002. if (options.upAxis != null) {
  11003. this.upAxis = options.upAxis;
  11004. }
  11005. if (options.upAxisSpace != null) {
  11006. this.upAxisSpace = options.upAxisSpace;
  11007. }
  11008. if (options.yawAxis != null || options.pitchAxis != null) {
  11009. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11010. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11011. if (options.yawAxis != null) {
  11012. newYawAxis = options.yawAxis.clone();
  11013. newYawAxis.normalize();
  11014. }
  11015. if (options.pitchAxis != null) {
  11016. newPitchAxis = options.pitchAxis.clone();
  11017. newPitchAxis.normalize();
  11018. }
  11019. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11020. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11021. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11022. this._transformYawPitchInv = this._transformYawPitch.clone();
  11023. this._transformYawPitch.invert();
  11024. }
  11025. }
  11026. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11027. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11028. }
  11029. }
  11030. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11031. /**
  11032. * Gets or sets the minimum yaw angle that the bone can look to
  11033. */
  11034. get: function () {
  11035. return this._minYaw;
  11036. },
  11037. set: function (value) {
  11038. this._minYaw = value;
  11039. this._minYawSin = Math.sin(value);
  11040. this._minYawCos = Math.cos(value);
  11041. if (this._maxYaw != null) {
  11042. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11043. this._yawRange = this._maxYaw - this._minYaw;
  11044. }
  11045. },
  11046. enumerable: true,
  11047. configurable: true
  11048. });
  11049. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11050. /**
  11051. * Gets or sets the maximum yaw angle that the bone can look to
  11052. */
  11053. get: function () {
  11054. return this._maxYaw;
  11055. },
  11056. set: function (value) {
  11057. this._maxYaw = value;
  11058. this._maxYawSin = Math.sin(value);
  11059. this._maxYawCos = Math.cos(value);
  11060. if (this._minYaw != null) {
  11061. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11062. this._yawRange = this._maxYaw - this._minYaw;
  11063. }
  11064. },
  11065. enumerable: true,
  11066. configurable: true
  11067. });
  11068. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11069. /**
  11070. * Gets or sets the minimum pitch angle that the bone can look to
  11071. */
  11072. get: function () {
  11073. return this._minPitch;
  11074. },
  11075. set: function (value) {
  11076. this._minPitch = value;
  11077. this._minPitchTan = Math.tan(value);
  11078. },
  11079. enumerable: true,
  11080. configurable: true
  11081. });
  11082. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11083. /**
  11084. * Gets or sets the maximum pitch angle that the bone can look to
  11085. */
  11086. get: function () {
  11087. return this._maxPitch;
  11088. },
  11089. set: function (value) {
  11090. this._maxPitch = value;
  11091. this._maxPitchTan = Math.tan(value);
  11092. },
  11093. enumerable: true,
  11094. configurable: true
  11095. });
  11096. /**
  11097. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11098. */
  11099. BoneLookController.prototype.update = function () {
  11100. //skip the first frame when slerping so that the mesh rotation is correct
  11101. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11102. this._firstFrameSkipped = true;
  11103. return;
  11104. }
  11105. var bone = this.bone;
  11106. var bonePos = BoneLookController._tmpVecs[0];
  11107. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11108. var target = this.target;
  11109. var _tmpMat1 = BoneLookController._tmpMats[0];
  11110. var _tmpMat2 = BoneLookController._tmpMats[1];
  11111. var mesh = this.mesh;
  11112. var parentBone = bone.getParent();
  11113. var upAxis = BoneLookController._tmpVecs[1];
  11114. upAxis.copyFrom(this.upAxis);
  11115. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11116. if (this._transformYawPitch) {
  11117. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11118. }
  11119. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11120. }
  11121. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11122. mesh.getDirectionToRef(upAxis, upAxis);
  11123. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11124. upAxis.normalize();
  11125. }
  11126. }
  11127. var checkYaw = false;
  11128. var checkPitch = false;
  11129. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11130. checkYaw = true;
  11131. }
  11132. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11133. checkPitch = true;
  11134. }
  11135. if (checkYaw || checkPitch) {
  11136. var spaceMat = BoneLookController._tmpMats[2];
  11137. var spaceMatInv = BoneLookController._tmpMats[3];
  11138. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11139. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11140. }
  11141. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11142. spaceMat.copyFrom(mesh.getWorldMatrix());
  11143. }
  11144. else {
  11145. var forwardAxis = BoneLookController._tmpVecs[2];
  11146. forwardAxis.copyFrom(this._fowardAxis);
  11147. if (this._transformYawPitch) {
  11148. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11149. }
  11150. if (parentBone) {
  11151. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11152. }
  11153. else {
  11154. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11155. }
  11156. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11157. rightAxis.normalize();
  11158. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11159. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11160. }
  11161. spaceMat.invertToRef(spaceMatInv);
  11162. var xzlen = null;
  11163. if (checkPitch) {
  11164. var localTarget = BoneLookController._tmpVecs[3];
  11165. target.subtractToRef(bonePos, localTarget);
  11166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11167. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11168. var pitch = Math.atan2(localTarget.y, xzlen);
  11169. var newPitch = pitch;
  11170. if (pitch > this._maxPitch) {
  11171. localTarget.y = this._maxPitchTan * xzlen;
  11172. newPitch = this._maxPitch;
  11173. }
  11174. else if (pitch < this._minPitch) {
  11175. localTarget.y = this._minPitchTan * xzlen;
  11176. newPitch = this._minPitch;
  11177. }
  11178. if (pitch != newPitch) {
  11179. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11180. localTarget.addInPlace(bonePos);
  11181. target = localTarget;
  11182. }
  11183. }
  11184. if (checkYaw) {
  11185. var localTarget = BoneLookController._tmpVecs[4];
  11186. target.subtractToRef(bonePos, localTarget);
  11187. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11188. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11189. var newYaw = yaw;
  11190. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11191. if (xzlen == null) {
  11192. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11193. }
  11194. if (this._yawRange > Math.PI) {
  11195. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11196. localTarget.z = this._maxYawCos * xzlen;
  11197. localTarget.x = this._maxYawSin * xzlen;
  11198. newYaw = this._maxYaw;
  11199. }
  11200. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11201. localTarget.z = this._minYawCos * xzlen;
  11202. localTarget.x = this._minYawSin * xzlen;
  11203. newYaw = this._minYaw;
  11204. }
  11205. }
  11206. else {
  11207. if (yaw > this._maxYaw) {
  11208. localTarget.z = this._maxYawCos * xzlen;
  11209. localTarget.x = this._maxYawSin * xzlen;
  11210. newYaw = this._maxYaw;
  11211. }
  11212. else if (yaw < this._minYaw) {
  11213. localTarget.z = this._minYawCos * xzlen;
  11214. localTarget.x = this._minYawSin * xzlen;
  11215. newYaw = this._minYaw;
  11216. }
  11217. }
  11218. }
  11219. if (this._slerping && this._yawRange > Math.PI) {
  11220. //are we going to be crossing into the min/max region?
  11221. var boneFwd = BoneLookController._tmpVecs[8];
  11222. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11223. if (this._transformYawPitch) {
  11224. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11225. }
  11226. var boneRotMat = BoneLookController._tmpMats[4];
  11227. this._boneQuat.toRotationMatrix(boneRotMat);
  11228. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11230. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11231. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11232. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11233. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11234. if (angBtwTar > angBtwMidYaw) {
  11235. if (xzlen == null) {
  11236. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11237. }
  11238. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11239. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11240. if (angBtwMin < angBtwMax) {
  11241. newYaw = boneYaw + Math.PI * .75;
  11242. localTarget.z = Math.cos(newYaw) * xzlen;
  11243. localTarget.x = Math.sin(newYaw) * xzlen;
  11244. }
  11245. else {
  11246. newYaw = boneYaw - Math.PI * .75;
  11247. localTarget.z = Math.cos(newYaw) * xzlen;
  11248. localTarget.x = Math.sin(newYaw) * xzlen;
  11249. }
  11250. }
  11251. }
  11252. if (yaw != newYaw) {
  11253. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11254. localTarget.addInPlace(bonePos);
  11255. target = localTarget;
  11256. }
  11257. }
  11258. }
  11259. var zaxis = BoneLookController._tmpVecs[5];
  11260. var xaxis = BoneLookController._tmpVecs[6];
  11261. var yaxis = BoneLookController._tmpVecs[7];
  11262. var _tmpQuat = BoneLookController._tmpQuat;
  11263. target.subtractToRef(bonePos, zaxis);
  11264. zaxis.normalize();
  11265. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11266. xaxis.normalize();
  11267. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11268. yaxis.normalize();
  11269. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11270. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11271. return;
  11272. }
  11273. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11274. return;
  11275. }
  11276. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11277. return;
  11278. }
  11279. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11281. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11282. }
  11283. if (this.slerpAmount < 1) {
  11284. if (!this._slerping) {
  11285. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11286. }
  11287. if (this._transformYawPitch) {
  11288. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11289. }
  11290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11292. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11293. this._slerping = true;
  11294. }
  11295. else {
  11296. if (this._transformYawPitch) {
  11297. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11298. }
  11299. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11300. this._slerping = false;
  11301. }
  11302. };
  11303. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11304. var angDiff = ang2 - ang1;
  11305. angDiff %= Math.PI * 2;
  11306. if (angDiff > Math.PI) {
  11307. angDiff -= Math.PI * 2;
  11308. }
  11309. else if (angDiff < -Math.PI) {
  11310. angDiff += Math.PI * 2;
  11311. }
  11312. return angDiff;
  11313. };
  11314. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11315. ang1 %= (2 * Math.PI);
  11316. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11317. ang2 %= (2 * Math.PI);
  11318. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11319. var ab = 0;
  11320. if (ang1 < ang2) {
  11321. ab = ang2 - ang1;
  11322. }
  11323. else {
  11324. ab = ang1 - ang2;
  11325. }
  11326. if (ab > Math.PI) {
  11327. ab = Math.PI * 2 - ab;
  11328. }
  11329. return ab;
  11330. };
  11331. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11332. ang %= (2 * Math.PI);
  11333. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11334. ang1 %= (2 * Math.PI);
  11335. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11336. ang2 %= (2 * Math.PI);
  11337. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11338. if (ang1 < ang2) {
  11339. if (ang > ang1 && ang < ang2) {
  11340. return true;
  11341. }
  11342. }
  11343. else {
  11344. if (ang > ang2 && ang < ang1) {
  11345. return true;
  11346. }
  11347. }
  11348. return false;
  11349. };
  11350. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11351. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11352. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11353. return BoneLookController;
  11354. }());
  11355. /***/ }),
  11356. /***/ "./Bones/index.ts":
  11357. /*!************************!*\
  11358. !*** ./Bones/index.ts ***!
  11359. \************************/
  11360. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11362. "use strict";
  11363. __webpack_require__.r(__webpack_exports__);
  11364. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11366. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11368. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11370. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11372. /***/ }),
  11373. /***/ "./Bones/skeleton.ts":
  11374. /*!***************************!*\
  11375. !*** ./Bones/skeleton.ts ***!
  11376. \***************************/
  11377. /*! exports provided: Skeleton */
  11378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11379. "use strict";
  11380. __webpack_require__.r(__webpack_exports__);
  11381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11382. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11383. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11384. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11385. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11386. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11387. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11388. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11389. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11390. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11391. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11392. /**
  11393. * Class used to handle skinning animations
  11394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11395. */
  11396. var Skeleton = /** @class */ (function () {
  11397. /**
  11398. * Creates a new skeleton
  11399. * @param name defines the skeleton name
  11400. * @param id defines the skeleton Id
  11401. * @param scene defines the hosting scene
  11402. */
  11403. function Skeleton(
  11404. /** defines the skeleton name */
  11405. name,
  11406. /** defines the skeleton Id */
  11407. id, scene) {
  11408. this.name = name;
  11409. this.id = id;
  11410. /**
  11411. * Defines the list of child bones
  11412. */
  11413. this.bones = new Array();
  11414. /**
  11415. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11416. */
  11417. this.needInitialSkinMatrix = false;
  11418. /**
  11419. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11420. */
  11421. this.overrideMesh = null;
  11422. this._isDirty = true;
  11423. this._meshesWithPoseMatrix = new Array();
  11424. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11425. this._ranges = {};
  11426. this._lastAbsoluteTransformsUpdateId = -1;
  11427. this._canUseTextureForBones = false;
  11428. /** @hidden */
  11429. this._numBonesWithLinkedTransformNode = 0;
  11430. /**
  11431. * Specifies if the skeleton should be serialized
  11432. */
  11433. this.doNotSerialize = false;
  11434. /**
  11435. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11436. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11437. */
  11438. this.useTextureToStoreBoneMatrices = true;
  11439. this._animationPropertiesOverride = null;
  11440. // Events
  11441. /**
  11442. * An observable triggered before computing the skeleton's matrices
  11443. */
  11444. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11445. this.bones = [];
  11446. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11447. this._scene.skeletons.push(this);
  11448. //make sure it will recalculate the matrix next time prepare is called.
  11449. this._isDirty = true;
  11450. var engineCaps = this._scene.getEngine().getCaps();
  11451. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11452. }
  11453. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11454. /**
  11455. * Gets or sets the animation properties override
  11456. */
  11457. get: function () {
  11458. if (!this._animationPropertiesOverride) {
  11459. return this._scene.animationPropertiesOverride;
  11460. }
  11461. return this._animationPropertiesOverride;
  11462. },
  11463. set: function (value) {
  11464. this._animationPropertiesOverride = value;
  11465. },
  11466. enumerable: true,
  11467. configurable: true
  11468. });
  11469. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11470. /**
  11471. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11472. */
  11473. get: function () {
  11474. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11475. },
  11476. enumerable: true,
  11477. configurable: true
  11478. });
  11479. // Members
  11480. /**
  11481. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11482. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11483. * @returns a Float32Array containing matrices data
  11484. */
  11485. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11486. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11487. return mesh._bonesTransformMatrices;
  11488. }
  11489. if (!this._transformMatrices) {
  11490. this.prepare();
  11491. }
  11492. return this._transformMatrices;
  11493. };
  11494. /**
  11495. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11496. * @returns a raw texture containing the data
  11497. */
  11498. Skeleton.prototype.getTransformMatrixTexture = function () {
  11499. return this._transformMatrixTexture;
  11500. };
  11501. /**
  11502. * Gets the current hosting scene
  11503. * @returns a scene object
  11504. */
  11505. Skeleton.prototype.getScene = function () {
  11506. return this._scene;
  11507. };
  11508. // Methods
  11509. /**
  11510. * Gets a string representing the current skeleton data
  11511. * @param fullDetails defines a boolean indicating if we want a verbose version
  11512. * @returns a string representing the current skeleton data
  11513. */
  11514. Skeleton.prototype.toString = function (fullDetails) {
  11515. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11516. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11517. if (fullDetails) {
  11518. ret += ", Ranges: {";
  11519. var first = true;
  11520. for (var name_1 in this._ranges) {
  11521. if (first) {
  11522. ret += ", ";
  11523. first = false;
  11524. }
  11525. ret += name_1;
  11526. }
  11527. ret += "}";
  11528. }
  11529. return ret;
  11530. };
  11531. /**
  11532. * Get bone's index searching by name
  11533. * @param name defines bone's name to search for
  11534. * @return the indice of the bone. Returns -1 if not found
  11535. */
  11536. Skeleton.prototype.getBoneIndexByName = function (name) {
  11537. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11538. if (this.bones[boneIndex].name === name) {
  11539. return boneIndex;
  11540. }
  11541. }
  11542. return -1;
  11543. };
  11544. /**
  11545. * Creater a new animation range
  11546. * @param name defines the name of the range
  11547. * @param from defines the start key
  11548. * @param to defines the end key
  11549. */
  11550. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11551. // check name not already in use
  11552. if (!this._ranges[name]) {
  11553. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11554. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11555. if (this.bones[i].animations[0]) {
  11556. this.bones[i].animations[0].createRange(name, from, to);
  11557. }
  11558. }
  11559. }
  11560. };
  11561. /**
  11562. * Delete a specific animation range
  11563. * @param name defines the name of the range
  11564. * @param deleteFrames defines if frames must be removed as well
  11565. */
  11566. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11567. if (deleteFrames === void 0) { deleteFrames = true; }
  11568. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11569. if (this.bones[i].animations[0]) {
  11570. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11571. }
  11572. }
  11573. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11574. };
  11575. /**
  11576. * Gets a specific animation range
  11577. * @param name defines the name of the range to look for
  11578. * @returns the requested animation range or null if not found
  11579. */
  11580. Skeleton.prototype.getAnimationRange = function (name) {
  11581. return this._ranges[name];
  11582. };
  11583. /**
  11584. * Gets the list of all animation ranges defined on this skeleton
  11585. * @returns an array
  11586. */
  11587. Skeleton.prototype.getAnimationRanges = function () {
  11588. var animationRanges = [];
  11589. var name;
  11590. var i = 0;
  11591. for (name in this._ranges) {
  11592. animationRanges[i] = this._ranges[name];
  11593. i++;
  11594. }
  11595. return animationRanges;
  11596. };
  11597. /**
  11598. * Copy animation range from a source skeleton.
  11599. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11600. * @param source defines the source skeleton
  11601. * @param name defines the name of the range to copy
  11602. * @param rescaleAsRequired defines if rescaling must be applied if required
  11603. * @returns true if operation was successful
  11604. */
  11605. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11606. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11607. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11608. return false;
  11609. }
  11610. var ret = true;
  11611. var frameOffset = this._getHighestAnimationFrame() + 1;
  11612. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11613. var boneDict = {};
  11614. var sourceBones = source.bones;
  11615. var nBones;
  11616. var i;
  11617. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11618. boneDict[sourceBones[i].name] = sourceBones[i];
  11619. }
  11620. if (this.bones.length !== sourceBones.length) {
  11621. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11622. ret = false;
  11623. }
  11624. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11625. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11626. var boneName = this.bones[i].name;
  11627. var sourceBone = boneDict[boneName];
  11628. if (sourceBone) {
  11629. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11630. }
  11631. else {
  11632. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11633. ret = false;
  11634. }
  11635. }
  11636. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11637. var range = source.getAnimationRange(name);
  11638. if (range) {
  11639. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11640. }
  11641. return ret;
  11642. };
  11643. /**
  11644. * Forces the skeleton to go to rest pose
  11645. */
  11646. Skeleton.prototype.returnToRest = function () {
  11647. for (var index = 0; index < this.bones.length; index++) {
  11648. this.bones[index].returnToRest();
  11649. }
  11650. };
  11651. Skeleton.prototype._getHighestAnimationFrame = function () {
  11652. var ret = 0;
  11653. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11654. if (this.bones[i].animations[0]) {
  11655. var highest = this.bones[i].animations[0].getHighestFrame();
  11656. if (ret < highest) {
  11657. ret = highest;
  11658. }
  11659. }
  11660. }
  11661. return ret;
  11662. };
  11663. /**
  11664. * Begin a specific animation range
  11665. * @param name defines the name of the range to start
  11666. * @param loop defines if looping must be turned on (false by default)
  11667. * @param speedRatio defines the speed ratio to apply (1 by default)
  11668. * @param onAnimationEnd defines a callback which will be called when animation will end
  11669. * @returns a new animatable
  11670. */
  11671. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11672. var range = this.getAnimationRange(name);
  11673. if (!range) {
  11674. return null;
  11675. }
  11676. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11677. };
  11678. /** @hidden */
  11679. Skeleton.prototype._markAsDirty = function () {
  11680. this._isDirty = true;
  11681. };
  11682. /** @hidden */
  11683. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11684. this._meshesWithPoseMatrix.push(mesh);
  11685. };
  11686. /** @hidden */
  11687. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11688. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11689. if (index > -1) {
  11690. this._meshesWithPoseMatrix.splice(index, 1);
  11691. }
  11692. };
  11693. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11694. this.onBeforeComputeObservable.notifyObservers(this);
  11695. for (var index = 0; index < this.bones.length; index++) {
  11696. var bone = this.bones[index];
  11697. var parentBone = bone.getParent();
  11698. if (parentBone) {
  11699. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11700. }
  11701. else {
  11702. if (initialSkinMatrix) {
  11703. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11704. }
  11705. else {
  11706. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11707. }
  11708. }
  11709. if (bone._index !== -1) {
  11710. var mappedIndex = bone._index === null ? index : bone._index;
  11711. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11712. }
  11713. }
  11714. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11715. };
  11716. /**
  11717. * Build all resources required to render a skeleton
  11718. */
  11719. Skeleton.prototype.prepare = function () {
  11720. // Update the local matrix of bones with linked transform nodes.
  11721. if (this._numBonesWithLinkedTransformNode > 0) {
  11722. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11723. var bone_1 = _a[_i];
  11724. if (bone_1._linkedTransformNode) {
  11725. // Computing the world matrix also computes the local matrix.
  11726. bone_1._linkedTransformNode.computeWorldMatrix();
  11727. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11728. bone_1.markAsDirty();
  11729. }
  11730. }
  11731. }
  11732. if (!this._isDirty) {
  11733. return;
  11734. }
  11735. if (this.needInitialSkinMatrix) {
  11736. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11737. var mesh = this._meshesWithPoseMatrix[index];
  11738. var poseMatrix = mesh.getPoseMatrix();
  11739. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11740. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11741. }
  11742. if (this._synchronizedWithMesh !== mesh) {
  11743. this._synchronizedWithMesh = mesh;
  11744. // Prepare bones
  11745. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11746. var bone = this.bones[boneIndex];
  11747. if (!bone.getParent()) {
  11748. var matrix = bone.getBaseMatrix();
  11749. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11750. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11751. }
  11752. }
  11753. }
  11754. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11755. }
  11756. }
  11757. else {
  11758. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11759. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11760. if (this.isUsingTextureForMatrices) {
  11761. if (this._transformMatrixTexture) {
  11762. this._transformMatrixTexture.dispose();
  11763. }
  11764. 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);
  11765. }
  11766. }
  11767. this._computeTransformMatrices(this._transformMatrices, null);
  11768. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11769. this._transformMatrixTexture.update(this._transformMatrices);
  11770. }
  11771. }
  11772. this._isDirty = false;
  11773. this._scene._activeBones.addCount(this.bones.length, false);
  11774. };
  11775. /**
  11776. * Gets the list of animatables currently running for this skeleton
  11777. * @returns an array of animatables
  11778. */
  11779. Skeleton.prototype.getAnimatables = function () {
  11780. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11781. this._animatables = [];
  11782. for (var index = 0; index < this.bones.length; index++) {
  11783. this._animatables.push(this.bones[index]);
  11784. }
  11785. }
  11786. return this._animatables;
  11787. };
  11788. /**
  11789. * Clone the current skeleton
  11790. * @param name defines the name of the new skeleton
  11791. * @param id defines the id of the enw skeleton
  11792. * @returns the new skeleton
  11793. */
  11794. Skeleton.prototype.clone = function (name, id) {
  11795. var result = new Skeleton(name, id || name, this._scene);
  11796. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11797. for (var index = 0; index < this.bones.length; index++) {
  11798. var source = this.bones[index];
  11799. var parentBone = null;
  11800. var parent_1 = source.getParent();
  11801. if (parent_1) {
  11802. var parentIndex = this.bones.indexOf(parent_1);
  11803. parentBone = result.bones[parentIndex];
  11804. }
  11805. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11806. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11807. }
  11808. if (this._ranges) {
  11809. result._ranges = {};
  11810. for (var rangeName in this._ranges) {
  11811. var range = this._ranges[rangeName];
  11812. if (range) {
  11813. result._ranges[rangeName] = range.clone();
  11814. }
  11815. }
  11816. }
  11817. this._isDirty = true;
  11818. return result;
  11819. };
  11820. /**
  11821. * Enable animation blending for this skeleton
  11822. * @param blendingSpeed defines the blending speed to apply
  11823. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11824. */
  11825. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11826. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11827. this.bones.forEach(function (bone) {
  11828. bone.animations.forEach(function (animation) {
  11829. animation.enableBlending = true;
  11830. animation.blendingSpeed = blendingSpeed;
  11831. });
  11832. });
  11833. };
  11834. /**
  11835. * Releases all resources associated with the current skeleton
  11836. */
  11837. Skeleton.prototype.dispose = function () {
  11838. this._meshesWithPoseMatrix = [];
  11839. // Animations
  11840. this.getScene().stopAnimation(this);
  11841. // Remove from scene
  11842. this.getScene().removeSkeleton(this);
  11843. if (this._transformMatrixTexture) {
  11844. this._transformMatrixTexture.dispose();
  11845. this._transformMatrixTexture = null;
  11846. }
  11847. };
  11848. /**
  11849. * Serialize the skeleton in a JSON object
  11850. * @returns a JSON object
  11851. */
  11852. Skeleton.prototype.serialize = function () {
  11853. var serializationObject = {};
  11854. serializationObject.name = this.name;
  11855. serializationObject.id = this.id;
  11856. if (this.dimensionsAtRest) {
  11857. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11858. }
  11859. serializationObject.bones = [];
  11860. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11861. for (var index = 0; index < this.bones.length; index++) {
  11862. var bone = this.bones[index];
  11863. var parent_2 = bone.getParent();
  11864. var serializedBone = {
  11865. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11866. name: bone.name,
  11867. matrix: bone.getBaseMatrix().toArray(),
  11868. rest: bone.getRestPose().toArray()
  11869. };
  11870. serializationObject.bones.push(serializedBone);
  11871. if (bone.length) {
  11872. serializedBone.length = bone.length;
  11873. }
  11874. if (bone.metadata) {
  11875. serializedBone.metadata = bone.metadata;
  11876. }
  11877. if (bone.animations && bone.animations.length > 0) {
  11878. serializedBone.animation = bone.animations[0].serialize();
  11879. }
  11880. serializationObject.ranges = [];
  11881. for (var name in this._ranges) {
  11882. var source = this._ranges[name];
  11883. if (!source) {
  11884. continue;
  11885. }
  11886. var range = {};
  11887. range.name = name;
  11888. range.from = source.from;
  11889. range.to = source.to;
  11890. serializationObject.ranges.push(range);
  11891. }
  11892. }
  11893. return serializationObject;
  11894. };
  11895. /**
  11896. * Creates a new skeleton from serialized data
  11897. * @param parsedSkeleton defines the serialized data
  11898. * @param scene defines the hosting scene
  11899. * @returns a new skeleton
  11900. */
  11901. Skeleton.Parse = function (parsedSkeleton, scene) {
  11902. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11903. if (parsedSkeleton.dimensionsAtRest) {
  11904. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11905. }
  11906. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11907. var index;
  11908. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11909. var parsedBone = parsedSkeleton.bones[index];
  11910. var parentBone = null;
  11911. if (parsedBone.parentBoneIndex > -1) {
  11912. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11913. }
  11914. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11915. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11916. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11917. bone.id = parsedBone.id;
  11918. }
  11919. if (parsedBone.length) {
  11920. bone.length = parsedBone.length;
  11921. }
  11922. if (parsedBone.metadata) {
  11923. bone.metadata = parsedBone.metadata;
  11924. }
  11925. if (parsedBone.animation) {
  11926. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11927. }
  11928. }
  11929. // placed after bones, so createAnimationRange can cascade down
  11930. if (parsedSkeleton.ranges) {
  11931. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11932. var data = parsedSkeleton.ranges[index];
  11933. skeleton.createAnimationRange(data.name, data.from, data.to);
  11934. }
  11935. }
  11936. return skeleton;
  11937. };
  11938. /**
  11939. * Compute all node absolute transforms
  11940. * @param forceUpdate defines if computation must be done even if cache is up to date
  11941. */
  11942. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11943. if (forceUpdate === void 0) { forceUpdate = false; }
  11944. var renderId = this._scene.getRenderId();
  11945. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11946. this.bones[0].computeAbsoluteTransforms();
  11947. this._lastAbsoluteTransformsUpdateId = renderId;
  11948. }
  11949. };
  11950. /**
  11951. * Gets the root pose matrix
  11952. * @returns a matrix
  11953. */
  11954. Skeleton.prototype.getPoseMatrix = function () {
  11955. var poseMatrix = null;
  11956. if (this._meshesWithPoseMatrix.length > 0) {
  11957. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11958. }
  11959. return poseMatrix;
  11960. };
  11961. /**
  11962. * Sorts bones per internal index
  11963. */
  11964. Skeleton.prototype.sortBones = function () {
  11965. var bones = new Array();
  11966. var visited = new Array(this.bones.length);
  11967. for (var index = 0; index < this.bones.length; index++) {
  11968. this._sortBones(index, bones, visited);
  11969. }
  11970. this.bones = bones;
  11971. };
  11972. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11973. if (visited[index]) {
  11974. return;
  11975. }
  11976. visited[index] = true;
  11977. var bone = this.bones[index];
  11978. if (bone._index === undefined) {
  11979. bone._index = index;
  11980. }
  11981. var parentBone = bone.getParent();
  11982. if (parentBone) {
  11983. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11984. }
  11985. bones.push(bone);
  11986. };
  11987. return Skeleton;
  11988. }());
  11989. /***/ }),
  11990. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11991. /*!*******************************************************!*\
  11992. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  11993. \*******************************************************/
  11994. /*! exports provided: ArcRotateCameraGamepadInput */
  11995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11996. "use strict";
  11997. __webpack_require__.r(__webpack_exports__);
  11998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  11999. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12000. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12001. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12002. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12003. /**
  12004. * Manage the gamepad inputs to control an arc rotate camera.
  12005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12006. */
  12007. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12008. function ArcRotateCameraGamepadInput() {
  12009. /**
  12010. * Defines the gamepad rotation sensiblity.
  12011. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12012. */
  12013. this.gamepadRotationSensibility = 80;
  12014. /**
  12015. * Defines the gamepad move sensiblity.
  12016. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12017. */
  12018. this.gamepadMoveSensibility = 40;
  12019. }
  12020. /**
  12021. * Attach the input controls to a specific dom element to get the input from.
  12022. * @param element Defines the element the controls should be listened from
  12023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12024. */
  12025. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12026. var _this = this;
  12027. var manager = this.camera.getScene().gamepadManager;
  12028. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12029. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12030. // prioritize XBOX gamepads.
  12031. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12032. _this.gamepad = gamepad;
  12033. }
  12034. }
  12035. });
  12036. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12037. if (_this.gamepad === gamepad) {
  12038. _this.gamepad = null;
  12039. }
  12040. });
  12041. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12042. };
  12043. /**
  12044. * Detach the current controls from the specified dom element.
  12045. * @param element Defines the element to stop listening the inputs from
  12046. */
  12047. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12048. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12049. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12050. this.gamepad = null;
  12051. };
  12052. /**
  12053. * Update the current camera state depending on the inputs that have been used this frame.
  12054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12055. */
  12056. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12057. if (this.gamepad) {
  12058. var camera = this.camera;
  12059. var RSValues = this.gamepad.rightStick;
  12060. if (RSValues) {
  12061. if (RSValues.x != 0) {
  12062. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12063. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12064. camera.inertialAlphaOffset += normalizedRX;
  12065. }
  12066. }
  12067. if (RSValues.y != 0) {
  12068. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12069. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12070. camera.inertialBetaOffset += normalizedRY;
  12071. }
  12072. }
  12073. }
  12074. var LSValues = this.gamepad.leftStick;
  12075. if (LSValues && LSValues.y != 0) {
  12076. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12077. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12078. this.camera.inertialRadiusOffset -= normalizedLY;
  12079. }
  12080. }
  12081. }
  12082. };
  12083. /**
  12084. * Gets the class name of the current intput.
  12085. * @returns the class name
  12086. */
  12087. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12088. return "ArcRotateCameraGamepadInput";
  12089. };
  12090. /**
  12091. * Get the friendly name associated with the input class.
  12092. * @returns the input friendly name
  12093. */
  12094. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12095. return "gamepad";
  12096. };
  12097. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12099. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12102. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12103. return ArcRotateCameraGamepadInput;
  12104. }());
  12105. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12106. /***/ }),
  12107. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12108. /*!************************************************************!*\
  12109. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12110. \************************************************************/
  12111. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12113. "use strict";
  12114. __webpack_require__.r(__webpack_exports__);
  12115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12117. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12118. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12119. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12120. /**
  12121. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12123. */
  12124. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12125. function ArcRotateCameraKeyboardMoveInput() {
  12126. /**
  12127. * Defines the list of key codes associated with the up action (increase alpha)
  12128. */
  12129. this.keysUp = [38];
  12130. /**
  12131. * Defines the list of key codes associated with the down action (decrease alpha)
  12132. */
  12133. this.keysDown = [40];
  12134. /**
  12135. * Defines the list of key codes associated with the left action (increase beta)
  12136. */
  12137. this.keysLeft = [37];
  12138. /**
  12139. * Defines the list of key codes associated with the right action (decrease beta)
  12140. */
  12141. this.keysRight = [39];
  12142. /**
  12143. * Defines the list of key codes associated with the reset action.
  12144. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12145. */
  12146. this.keysReset = [220];
  12147. /**
  12148. * Defines the panning sensibility of the inputs.
  12149. * (How fast is the camera paning)
  12150. */
  12151. this.panningSensibility = 50.0;
  12152. /**
  12153. * Defines the zooming sensibility of the inputs.
  12154. * (How fast is the camera zooming)
  12155. */
  12156. this.zoomingSensibility = 25.0;
  12157. /**
  12158. * Defines wether maintaining the alt key down switch the movement mode from
  12159. * orientation to zoom.
  12160. */
  12161. this.useAltToZoom = true;
  12162. /**
  12163. * Rotation speed of the camera
  12164. */
  12165. this.angularSpeed = 0.01;
  12166. this._keys = new Array();
  12167. }
  12168. /**
  12169. * Attach the input controls to a specific dom element to get the input from.
  12170. * @param element Defines the element the controls should be listened from
  12171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12172. */
  12173. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12174. var _this = this;
  12175. if (this._onCanvasBlurObserver) {
  12176. return;
  12177. }
  12178. this._scene = this.camera.getScene();
  12179. this._engine = this._scene.getEngine();
  12180. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12181. _this._keys = [];
  12182. });
  12183. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12184. var evt = info.event;
  12185. if (!evt.metaKey) {
  12186. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12187. _this._ctrlPressed = evt.ctrlKey;
  12188. _this._altPressed = evt.altKey;
  12189. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12190. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12191. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12192. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12193. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12194. var index = _this._keys.indexOf(evt.keyCode);
  12195. if (index === -1) {
  12196. _this._keys.push(evt.keyCode);
  12197. }
  12198. if (evt.preventDefault) {
  12199. if (!noPreventDefault) {
  12200. evt.preventDefault();
  12201. }
  12202. }
  12203. }
  12204. }
  12205. else {
  12206. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12207. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12208. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12209. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12210. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12211. var index = _this._keys.indexOf(evt.keyCode);
  12212. if (index >= 0) {
  12213. _this._keys.splice(index, 1);
  12214. }
  12215. if (evt.preventDefault) {
  12216. if (!noPreventDefault) {
  12217. evt.preventDefault();
  12218. }
  12219. }
  12220. }
  12221. }
  12222. }
  12223. });
  12224. };
  12225. /**
  12226. * Detach the current controls from the specified dom element.
  12227. * @param element Defines the element to stop listening the inputs from
  12228. */
  12229. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12230. if (this._scene) {
  12231. if (this._onKeyboardObserver) {
  12232. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12233. }
  12234. if (this._onCanvasBlurObserver) {
  12235. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12236. }
  12237. this._onKeyboardObserver = null;
  12238. this._onCanvasBlurObserver = null;
  12239. }
  12240. this._keys = [];
  12241. };
  12242. /**
  12243. * Update the current camera state depending on the inputs that have been used this frame.
  12244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12245. */
  12246. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12247. if (this._onKeyboardObserver) {
  12248. var camera = this.camera;
  12249. for (var index = 0; index < this._keys.length; index++) {
  12250. var keyCode = this._keys[index];
  12251. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12252. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12253. camera.inertialPanningX -= 1 / this.panningSensibility;
  12254. }
  12255. else {
  12256. camera.inertialAlphaOffset -= this.angularSpeed;
  12257. }
  12258. }
  12259. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12260. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12261. camera.inertialPanningY += 1 / this.panningSensibility;
  12262. }
  12263. else if (this._altPressed && this.useAltToZoom) {
  12264. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12265. }
  12266. else {
  12267. camera.inertialBetaOffset -= this.angularSpeed;
  12268. }
  12269. }
  12270. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12271. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12272. camera.inertialPanningX += 1 / this.panningSensibility;
  12273. }
  12274. else {
  12275. camera.inertialAlphaOffset += this.angularSpeed;
  12276. }
  12277. }
  12278. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12279. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12280. camera.inertialPanningY -= 1 / this.panningSensibility;
  12281. }
  12282. else if (this._altPressed && this.useAltToZoom) {
  12283. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12284. }
  12285. else {
  12286. camera.inertialBetaOffset += this.angularSpeed;
  12287. }
  12288. }
  12289. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12290. if (camera.useInputToRestoreState) {
  12291. camera.restoreState();
  12292. }
  12293. }
  12294. }
  12295. }
  12296. };
  12297. /**
  12298. * Gets the class name of the current intput.
  12299. * @returns the class name
  12300. */
  12301. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12302. return "ArcRotateCameraKeyboardMoveInput";
  12303. };
  12304. /**
  12305. * Get the friendly name associated with the input class.
  12306. * @returns the input friendly name
  12307. */
  12308. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12309. return "keyboard";
  12310. };
  12311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12313. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12316. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12319. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12322. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12325. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12328. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12331. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12334. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12337. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12338. return ArcRotateCameraKeyboardMoveInput;
  12339. }());
  12340. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12341. /***/ }),
  12342. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12343. /*!**********************************************************!*\
  12344. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12345. \**********************************************************/
  12346. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12348. "use strict";
  12349. __webpack_require__.r(__webpack_exports__);
  12350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12351. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12352. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12353. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12354. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12355. /**
  12356. * Manage the mouse wheel inputs to control an arc rotate camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12360. function ArcRotateCameraMouseWheelInput() {
  12361. /**
  12362. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12363. */
  12364. this.wheelPrecision = 3.0;
  12365. /**
  12366. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12367. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12368. */
  12369. this.wheelDeltaPercentage = 0;
  12370. }
  12371. /**
  12372. * Attach the input controls to a specific dom element to get the input from.
  12373. * @param element Defines the element the controls should be listened from
  12374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12375. */
  12376. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12377. var _this = this;
  12378. this._wheel = function (p, s) {
  12379. //sanity check - this should be a PointerWheel event.
  12380. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12381. return;
  12382. }
  12383. var event = p.event;
  12384. var delta = 0;
  12385. var mouseWheelLegacyEvent = event;
  12386. if (mouseWheelLegacyEvent.wheelDelta) {
  12387. if (_this.wheelDeltaPercentage) {
  12388. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12389. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12390. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12391. }
  12392. else {
  12393. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12394. }
  12395. }
  12396. else {
  12397. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12398. }
  12399. }
  12400. else {
  12401. var deltaValue = event.deltaY || event.detail;
  12402. delta = -deltaValue / _this.wheelPrecision;
  12403. }
  12404. if (delta) {
  12405. _this.camera.inertialRadiusOffset += delta;
  12406. }
  12407. if (event.preventDefault) {
  12408. if (!noPreventDefault) {
  12409. event.preventDefault();
  12410. }
  12411. }
  12412. };
  12413. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12414. };
  12415. /**
  12416. * Detach the current controls from the specified dom element.
  12417. * @param element Defines the element to stop listening the inputs from
  12418. */
  12419. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12420. if (this._observer && element) {
  12421. this.camera.getScene().onPointerObservable.remove(this._observer);
  12422. this._observer = null;
  12423. this._wheel = null;
  12424. }
  12425. };
  12426. /**
  12427. * Gets the class name of the current intput.
  12428. * @returns the class name
  12429. */
  12430. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12431. return "ArcRotateCameraMouseWheelInput";
  12432. };
  12433. /**
  12434. * Get the friendly name associated with the input class.
  12435. * @returns the input friendly name
  12436. */
  12437. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12438. return "mousewheel";
  12439. };
  12440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12442. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12445. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12446. return ArcRotateCameraMouseWheelInput;
  12447. }());
  12448. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12449. /***/ }),
  12450. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12451. /*!********************************************************!*\
  12452. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12453. \********************************************************/
  12454. /*! exports provided: ArcRotateCameraPointersInput */
  12455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12456. "use strict";
  12457. __webpack_require__.r(__webpack_exports__);
  12458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12460. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12461. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12462. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12463. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12464. /**
  12465. * Manage the pointers inputs to control an arc rotate camera.
  12466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12467. */
  12468. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12469. function ArcRotateCameraPointersInput() {
  12470. /**
  12471. * Defines the buttons associated with the input to handle camera move.
  12472. */
  12473. this.buttons = [0, 1, 2];
  12474. /**
  12475. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12476. */
  12477. this.angularSensibilityX = 1000.0;
  12478. /**
  12479. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12480. */
  12481. this.angularSensibilityY = 1000.0;
  12482. /**
  12483. * Defines the pointer pinch precision or how fast is the camera zooming.
  12484. */
  12485. this.pinchPrecision = 12.0;
  12486. /**
  12487. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12488. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12489. */
  12490. this.pinchDeltaPercentage = 0;
  12491. /**
  12492. * Defines the pointer panning sensibility or how fast is the camera moving.
  12493. */
  12494. this.panningSensibility = 1000.0;
  12495. /**
  12496. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12497. */
  12498. this.multiTouchPanning = true;
  12499. /**
  12500. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12501. */
  12502. this.multiTouchPanAndZoom = true;
  12503. /**
  12504. * Revers pinch action direction.
  12505. */
  12506. this.pinchInwards = true;
  12507. this._isPanClick = false;
  12508. }
  12509. /**
  12510. * Attach the input controls to a specific dom element to get the input from.
  12511. * @param element Defines the element the controls should be listened from
  12512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12513. */
  12514. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12515. var _this = this;
  12516. var engine = this.camera.getEngine();
  12517. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12518. var pointA = null;
  12519. var pointB = null;
  12520. var previousPinchSquaredDistance = 0;
  12521. var initialDistance = 0;
  12522. var twoFingerActivityCount = 0;
  12523. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12524. this._pointerInput = function (p, s) {
  12525. var evt = p.event;
  12526. var isTouch = p.event.pointerType === "touch";
  12527. if (engine.isInVRExclusivePointerMode) {
  12528. return;
  12529. }
  12530. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12531. return;
  12532. }
  12533. var srcElement = (evt.srcElement || evt.target);
  12534. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12535. try {
  12536. srcElement.setPointerCapture(evt.pointerId);
  12537. }
  12538. catch (e) {
  12539. //Nothing to do with the error. Execution will continue.
  12540. }
  12541. // Manage panning with pan button click
  12542. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12543. // manage pointers
  12544. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12545. if (pointA === null) {
  12546. pointA = cacheSoloPointer;
  12547. }
  12548. else if (pointB === null) {
  12549. pointB = cacheSoloPointer;
  12550. }
  12551. if (!noPreventDefault) {
  12552. evt.preventDefault();
  12553. element.focus();
  12554. }
  12555. }
  12556. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12557. if (_this.camera.useInputToRestoreState) {
  12558. _this.camera.restoreState();
  12559. }
  12560. }
  12561. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12562. try {
  12563. srcElement.releasePointerCapture(evt.pointerId);
  12564. }
  12565. catch (e) {
  12566. //Nothing to do with the error.
  12567. }
  12568. cacheSoloPointer = null;
  12569. previousPinchSquaredDistance = 0;
  12570. previousMultiTouchPanPosition.isPaning = false;
  12571. previousMultiTouchPanPosition.isPinching = false;
  12572. twoFingerActivityCount = 0;
  12573. initialDistance = 0;
  12574. if (!isTouch) {
  12575. pointB = null; // Mouse and pen are mono pointer
  12576. }
  12577. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12578. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12579. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12580. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12581. if (engine._badOS) {
  12582. pointA = pointB = null;
  12583. }
  12584. else {
  12585. //only remove the impacted pointer in case of multitouch allowing on most
  12586. //platforms switching from rotate to zoom and pan seamlessly.
  12587. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12588. pointA = pointB;
  12589. pointB = null;
  12590. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12591. }
  12592. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12593. pointB = null;
  12594. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12595. }
  12596. else {
  12597. pointA = pointB = null;
  12598. }
  12599. }
  12600. if (!noPreventDefault) {
  12601. evt.preventDefault();
  12602. }
  12603. }
  12604. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12605. if (!noPreventDefault) {
  12606. evt.preventDefault();
  12607. }
  12608. // One button down
  12609. if (pointA && pointB === null && cacheSoloPointer) {
  12610. if (_this.panningSensibility !== 0 &&
  12611. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12612. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12613. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12614. }
  12615. else {
  12616. var offsetX = evt.clientX - cacheSoloPointer.x;
  12617. var offsetY = evt.clientY - cacheSoloPointer.y;
  12618. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12619. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12620. }
  12621. cacheSoloPointer.x = evt.clientX;
  12622. cacheSoloPointer.y = evt.clientY;
  12623. }
  12624. // Two buttons down: pinch/pan
  12625. else if (pointA && pointB) {
  12626. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12627. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12628. ed.x = evt.clientX;
  12629. ed.y = evt.clientY;
  12630. var direction = _this.pinchInwards ? 1 : -1;
  12631. var distX = pointA.x - pointB.x;
  12632. var distY = pointA.y - pointB.y;
  12633. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12634. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12635. if (previousPinchSquaredDistance === 0) {
  12636. initialDistance = pinchDistance;
  12637. previousPinchSquaredDistance = pinchSquaredDistance;
  12638. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12639. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12640. return;
  12641. }
  12642. if (_this.multiTouchPanAndZoom) {
  12643. if (_this.pinchDeltaPercentage) {
  12644. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12645. }
  12646. else {
  12647. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12648. (_this.pinchPrecision *
  12649. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12650. direction);
  12651. }
  12652. if (_this.panningSensibility !== 0) {
  12653. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12654. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12655. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12656. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12657. previousMultiTouchPanPosition.x = pointersCenterX;
  12658. previousMultiTouchPanPosition.y = pointersCenterY;
  12659. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12660. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12661. }
  12662. }
  12663. else {
  12664. twoFingerActivityCount++;
  12665. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12666. if (_this.pinchDeltaPercentage) {
  12667. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12668. }
  12669. else {
  12670. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12671. (_this.pinchPrecision *
  12672. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12673. direction);
  12674. }
  12675. previousMultiTouchPanPosition.isPaning = false;
  12676. previousMultiTouchPanPosition.isPinching = true;
  12677. }
  12678. else {
  12679. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12680. if (!previousMultiTouchPanPosition.isPaning) {
  12681. previousMultiTouchPanPosition.isPaning = true;
  12682. previousMultiTouchPanPosition.isPinching = false;
  12683. previousMultiTouchPanPosition.x = ed.x;
  12684. previousMultiTouchPanPosition.y = ed.y;
  12685. return;
  12686. }
  12687. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12688. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12689. }
  12690. }
  12691. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12692. previousMultiTouchPanPosition.x = ed.x;
  12693. previousMultiTouchPanPosition.y = ed.y;
  12694. }
  12695. }
  12696. previousPinchSquaredDistance = pinchSquaredDistance;
  12697. }
  12698. }
  12699. };
  12700. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12701. this._onContextMenu = function (evt) {
  12702. evt.preventDefault();
  12703. };
  12704. if (!this.camera._useCtrlForPanning) {
  12705. element.addEventListener("contextmenu", this._onContextMenu, false);
  12706. }
  12707. this._onLostFocus = function () {
  12708. //this._keys = [];
  12709. pointA = pointB = null;
  12710. previousPinchSquaredDistance = 0;
  12711. previousMultiTouchPanPosition.isPaning = false;
  12712. previousMultiTouchPanPosition.isPinching = false;
  12713. twoFingerActivityCount = 0;
  12714. cacheSoloPointer = null;
  12715. initialDistance = 0;
  12716. };
  12717. this._onMouseMove = function (evt) {
  12718. if (!engine.isPointerLock) {
  12719. return;
  12720. }
  12721. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12722. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12723. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12724. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12725. if (!noPreventDefault) {
  12726. evt.preventDefault();
  12727. }
  12728. };
  12729. this._onGestureStart = function (e) {
  12730. if (window.MSGesture === undefined) {
  12731. return;
  12732. }
  12733. if (!_this._MSGestureHandler) {
  12734. _this._MSGestureHandler = new MSGesture();
  12735. _this._MSGestureHandler.target = element;
  12736. }
  12737. _this._MSGestureHandler.addPointer(e.pointerId);
  12738. };
  12739. this._onGesture = function (e) {
  12740. _this.camera.radius *= e.scale;
  12741. if (e.preventDefault) {
  12742. if (!noPreventDefault) {
  12743. e.stopPropagation();
  12744. e.preventDefault();
  12745. }
  12746. }
  12747. };
  12748. element.addEventListener("mousemove", this._onMouseMove, false);
  12749. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12750. element.addEventListener("MSGestureChange", this._onGesture, false);
  12751. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12752. { name: "blur", handler: this._onLostFocus }
  12753. ]);
  12754. };
  12755. /**
  12756. * Detach the current controls from the specified dom element.
  12757. * @param element Defines the element to stop listening the inputs from
  12758. */
  12759. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12760. if (this._onLostFocus) {
  12761. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12762. { name: "blur", handler: this._onLostFocus }
  12763. ]);
  12764. }
  12765. if (element && this._observer) {
  12766. this.camera.getScene().onPointerObservable.remove(this._observer);
  12767. this._observer = null;
  12768. if (this._onContextMenu) {
  12769. element.removeEventListener("contextmenu", this._onContextMenu);
  12770. }
  12771. if (this._onMouseMove) {
  12772. element.removeEventListener("mousemove", this._onMouseMove);
  12773. }
  12774. if (this._onGestureStart) {
  12775. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12776. }
  12777. if (this._onGesture) {
  12778. element.removeEventListener("MSGestureChange", this._onGesture);
  12779. }
  12780. this._isPanClick = false;
  12781. this.pinchInwards = true;
  12782. this._onMouseMove = null;
  12783. this._onGestureStart = null;
  12784. this._onGesture = null;
  12785. this._MSGestureHandler = null;
  12786. this._onLostFocus = null;
  12787. this._onContextMenu = null;
  12788. }
  12789. };
  12790. /**
  12791. * Gets the class name of the current intput.
  12792. * @returns the class name
  12793. */
  12794. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12795. return "ArcRotateCameraPointersInput";
  12796. };
  12797. /**
  12798. * Get the friendly name associated with the input class.
  12799. * @returns the input friendly name
  12800. */
  12801. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12802. return "pointers";
  12803. };
  12804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12806. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12809. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12812. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12815. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12818. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12821. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12824. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12827. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12828. return ArcRotateCameraPointersInput;
  12829. }());
  12830. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12831. /***/ }),
  12832. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12833. /*!*******************************************************************!*\
  12834. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12835. \*******************************************************************/
  12836. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12838. "use strict";
  12839. __webpack_require__.r(__webpack_exports__);
  12840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12841. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12842. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12843. /**
  12844. * Add orientation input support to the input manager.
  12845. * @returns the current input manager
  12846. */
  12847. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12848. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12849. return this;
  12850. };
  12851. /**
  12852. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12854. */
  12855. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12856. /**
  12857. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12858. */
  12859. function ArcRotateCameraVRDeviceOrientationInput() {
  12860. /**
  12861. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12862. */
  12863. this.alphaCorrection = 1;
  12864. /**
  12865. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12866. */
  12867. this.gammaCorrection = 1;
  12868. this._alpha = 0;
  12869. this._gamma = 0;
  12870. this._dirty = false;
  12871. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12872. }
  12873. /**
  12874. * Attach the input controls to a specific dom element to get the input from.
  12875. * @param element Defines the element the controls should be listened from
  12876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12877. */
  12878. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12879. this.camera.attachControl(element, noPreventDefault);
  12880. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12881. };
  12882. /** @hidden */
  12883. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12884. if (evt.alpha !== null) {
  12885. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12886. }
  12887. if (evt.gamma !== null) {
  12888. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12889. }
  12890. this._dirty = true;
  12891. };
  12892. /**
  12893. * Update the current camera state depending on the inputs that have been used this frame.
  12894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12895. */
  12896. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12897. if (this._dirty) {
  12898. this._dirty = false;
  12899. if (this._gamma < 0) {
  12900. this._gamma = 180 + this._gamma;
  12901. }
  12902. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12903. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12904. }
  12905. };
  12906. /**
  12907. * Detach the current controls from the specified dom element.
  12908. * @param element Defines the element to stop listening the inputs from
  12909. */
  12910. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12911. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12912. };
  12913. /**
  12914. * Gets the class name of the current intput.
  12915. * @returns the class name
  12916. */
  12917. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12918. return "ArcRotateCameraVRDeviceOrientationInput";
  12919. };
  12920. /**
  12921. * Get the friendly name associated with the input class.
  12922. * @returns the input friendly name
  12923. */
  12924. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12925. return "VRDeviceOrientation";
  12926. };
  12927. return ArcRotateCameraVRDeviceOrientationInput;
  12928. }());
  12929. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12930. /***/ }),
  12931. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12932. /*!**************************************************!*\
  12933. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12934. \**************************************************/
  12935. /*! exports provided: FlyCameraKeyboardInput */
  12936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12937. "use strict";
  12938. __webpack_require__.r(__webpack_exports__);
  12939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12940. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12941. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12942. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12943. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12944. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12945. /**
  12946. * Listen to keyboard events to control the camera.
  12947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12948. */
  12949. var FlyCameraKeyboardInput = /** @class */ (function () {
  12950. function FlyCameraKeyboardInput() {
  12951. /**
  12952. * The list of keyboard keys used to control the forward move of the camera.
  12953. */
  12954. this.keysForward = [87];
  12955. /**
  12956. * The list of keyboard keys used to control the backward move of the camera.
  12957. */
  12958. this.keysBackward = [83];
  12959. /**
  12960. * The list of keyboard keys used to control the forward move of the camera.
  12961. */
  12962. this.keysUp = [69];
  12963. /**
  12964. * The list of keyboard keys used to control the backward move of the camera.
  12965. */
  12966. this.keysDown = [81];
  12967. /**
  12968. * The list of keyboard keys used to control the right strafe move of the camera.
  12969. */
  12970. this.keysRight = [68];
  12971. /**
  12972. * The list of keyboard keys used to control the left strafe move of the camera.
  12973. */
  12974. this.keysLeft = [65];
  12975. this._keys = new Array();
  12976. }
  12977. /**
  12978. * Attach the input controls to a specific dom element to get the input from.
  12979. * @param element Defines the element the controls should be listened from
  12980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12981. */
  12982. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12983. var _this = this;
  12984. if (this._onCanvasBlurObserver) {
  12985. return;
  12986. }
  12987. this._scene = this.camera.getScene();
  12988. this._engine = this._scene.getEngine();
  12989. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12990. _this._keys = [];
  12991. });
  12992. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12993. var evt = info.event;
  12994. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12995. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12996. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12997. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12998. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12999. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13000. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13001. var index = _this._keys.indexOf(evt.keyCode);
  13002. if (index === -1) {
  13003. _this._keys.push(evt.keyCode);
  13004. }
  13005. if (!noPreventDefault) {
  13006. evt.preventDefault();
  13007. }
  13008. }
  13009. }
  13010. else {
  13011. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13012. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13013. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13014. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13015. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13016. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13017. var index = _this._keys.indexOf(evt.keyCode);
  13018. if (index >= 0) {
  13019. _this._keys.splice(index, 1);
  13020. }
  13021. if (!noPreventDefault) {
  13022. evt.preventDefault();
  13023. }
  13024. }
  13025. }
  13026. });
  13027. };
  13028. /**
  13029. * Detach the current controls from the specified dom element.
  13030. * @param element Defines the element to stop listening the inputs from
  13031. */
  13032. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13033. if (this._scene) {
  13034. if (this._onKeyboardObserver) {
  13035. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13036. }
  13037. if (this._onCanvasBlurObserver) {
  13038. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13039. }
  13040. this._onKeyboardObserver = null;
  13041. this._onCanvasBlurObserver = null;
  13042. }
  13043. this._keys = [];
  13044. };
  13045. /**
  13046. * Gets the class name of the current intput.
  13047. * @returns the class name
  13048. */
  13049. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13050. return "FlyCameraKeyboardInput";
  13051. };
  13052. /** @hidden */
  13053. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13054. this._keys = [];
  13055. };
  13056. /**
  13057. * Get the friendly name associated with the input class.
  13058. * @returns the input friendly name
  13059. */
  13060. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13061. return "keyboard";
  13062. };
  13063. /**
  13064. * Update the current camera state depending on the inputs that have been used this frame.
  13065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13066. */
  13067. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13068. if (this._onKeyboardObserver) {
  13069. var camera = this.camera;
  13070. // Keyboard
  13071. for (var index = 0; index < this._keys.length; index++) {
  13072. var keyCode = this._keys[index];
  13073. var speed = camera._computeLocalCameraSpeed();
  13074. if (this.keysForward.indexOf(keyCode) !== -1) {
  13075. camera._localDirection.copyFromFloats(0, 0, speed);
  13076. }
  13077. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13078. camera._localDirection.copyFromFloats(0, 0, -speed);
  13079. }
  13080. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13081. camera._localDirection.copyFromFloats(0, speed, 0);
  13082. }
  13083. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13084. camera._localDirection.copyFromFloats(0, -speed, 0);
  13085. }
  13086. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13087. camera._localDirection.copyFromFloats(speed, 0, 0);
  13088. }
  13089. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13090. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13091. }
  13092. if (camera.getScene().useRightHandedSystem) {
  13093. camera._localDirection.z *= -1;
  13094. }
  13095. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13096. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13097. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13098. }
  13099. }
  13100. };
  13101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13103. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13106. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13109. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13112. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13115. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13118. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13119. return FlyCameraKeyboardInput;
  13120. }());
  13121. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13122. /***/ }),
  13123. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13124. /*!***********************************************!*\
  13125. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13126. \***********************************************/
  13127. /*! exports provided: FlyCameraMouseInput */
  13128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13129. "use strict";
  13130. __webpack_require__.r(__webpack_exports__);
  13131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13133. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13134. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13135. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13137. /**
  13138. * Listen to mouse events to control the camera.
  13139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13140. */
  13141. var FlyCameraMouseInput = /** @class */ (function () {
  13142. /**
  13143. * Listen to mouse events to control the camera.
  13144. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13146. */
  13147. function FlyCameraMouseInput(touchEnabled) {
  13148. if (touchEnabled === void 0) { touchEnabled = true; }
  13149. /**
  13150. * Defines the buttons associated with the input to handle camera rotation.
  13151. */
  13152. this.buttons = [0, 1, 2];
  13153. /**
  13154. * Assign buttons for Yaw control.
  13155. */
  13156. this.buttonsYaw = [-1, 0, 1];
  13157. /**
  13158. * Assign buttons for Pitch control.
  13159. */
  13160. this.buttonsPitch = [-1, 0, 1];
  13161. /**
  13162. * Assign buttons for Roll control.
  13163. */
  13164. this.buttonsRoll = [2];
  13165. /**
  13166. * Detect if any button is being pressed while mouse is moved.
  13167. * -1 = Mouse locked.
  13168. * 0 = Left button.
  13169. * 1 = Middle Button.
  13170. * 2 = Right Button.
  13171. */
  13172. this.activeButton = -1;
  13173. /**
  13174. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13175. * Higher values reduce its sensitivity.
  13176. */
  13177. this.angularSensibility = 1000.0;
  13178. this.previousPosition = null;
  13179. }
  13180. /**
  13181. * Attach the mouse control to the HTML DOM element.
  13182. * @param element Defines the element that listens to the input events.
  13183. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13184. */
  13185. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13186. var _this = this;
  13187. this.element = element;
  13188. this.noPreventDefault = noPreventDefault;
  13189. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13190. _this._pointerInput(p, s);
  13191. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13192. // Correct Roll by rate, if enabled.
  13193. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13194. if (_this.camera.rollCorrect) {
  13195. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13196. }
  13197. });
  13198. // Helper function to keep 'this'.
  13199. this._mousemoveCallback = function (e) {
  13200. _this._onMouseMove(e);
  13201. };
  13202. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13203. };
  13204. /**
  13205. * Detach the current controls from the specified dom element.
  13206. * @param element Defines the element to stop listening the inputs from
  13207. */
  13208. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13209. if (this._observer && element) {
  13210. this.camera.getScene().onPointerObservable.remove(this._observer);
  13211. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13212. if (this._mousemoveCallback) {
  13213. element.removeEventListener("mousemove", this._mousemoveCallback);
  13214. }
  13215. this._observer = null;
  13216. this._rollObserver = null;
  13217. this.previousPosition = null;
  13218. this.noPreventDefault = undefined;
  13219. }
  13220. };
  13221. /**
  13222. * Gets the class name of the current input.
  13223. * @returns the class name.
  13224. */
  13225. FlyCameraMouseInput.prototype.getClassName = function () {
  13226. return "FlyCameraMouseInput";
  13227. };
  13228. /**
  13229. * Get the friendly name associated with the input class.
  13230. * @returns the input's friendly name.
  13231. */
  13232. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13233. return "mouse";
  13234. };
  13235. // Track mouse movement, when the pointer is not locked.
  13236. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13237. var e = p.event;
  13238. var camera = this.camera;
  13239. var engine = camera.getEngine();
  13240. if (engine.isInVRExclusivePointerMode) {
  13241. return;
  13242. }
  13243. if (!this.touchEnabled && e.pointerType === "touch") {
  13244. return;
  13245. }
  13246. // Mouse is moved but an unknown mouse button is pressed.
  13247. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13248. return;
  13249. }
  13250. var srcElement = (e.srcElement || e.target);
  13251. // Mouse down.
  13252. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13253. try {
  13254. srcElement.setPointerCapture(e.pointerId);
  13255. }
  13256. catch (e) {
  13257. // Nothing to do with the error. Execution continues.
  13258. }
  13259. this.previousPosition = {
  13260. x: e.clientX,
  13261. y: e.clientY
  13262. };
  13263. this.activeButton = e.button;
  13264. if (!this.noPreventDefault) {
  13265. e.preventDefault();
  13266. this.element.focus();
  13267. }
  13268. }
  13269. else
  13270. // Mouse up.
  13271. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13272. try {
  13273. srcElement.releasePointerCapture(e.pointerId);
  13274. }
  13275. catch (e) {
  13276. // Nothing to do with the error. Execution continues.
  13277. }
  13278. this.activeButton = -1;
  13279. this.previousPosition = null;
  13280. if (!this.noPreventDefault) {
  13281. e.preventDefault();
  13282. }
  13283. }
  13284. else
  13285. // Mouse move.
  13286. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13287. if (!this.previousPosition || engine.isPointerLock) {
  13288. return;
  13289. }
  13290. var offsetX = e.clientX - this.previousPosition.x;
  13291. var offsetY = e.clientY - this.previousPosition.y;
  13292. this.rotateCamera(offsetX, offsetY);
  13293. this.previousPosition = {
  13294. x: e.clientX,
  13295. y: e.clientY
  13296. };
  13297. if (!this.noPreventDefault) {
  13298. e.preventDefault();
  13299. }
  13300. }
  13301. };
  13302. // Track mouse movement, when pointer is locked.
  13303. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13304. var camera = this.camera;
  13305. var engine = camera.getEngine();
  13306. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13307. return;
  13308. }
  13309. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13310. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13311. this.rotateCamera(offsetX, offsetY);
  13312. this.previousPosition = null;
  13313. if (!this.noPreventDefault) {
  13314. e.preventDefault();
  13315. }
  13316. };
  13317. /**
  13318. * Rotate camera by mouse offset.
  13319. */
  13320. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13321. var _this = this;
  13322. var camera = this.camera;
  13323. var scene = this.camera.getScene();
  13324. if (scene.useRightHandedSystem) {
  13325. offsetX *= -1;
  13326. }
  13327. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13328. offsetX *= -1;
  13329. }
  13330. var x = offsetX / this.angularSensibility;
  13331. var y = offsetY / this.angularSensibility;
  13332. // Initialize to current rotation.
  13333. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13334. var rotationChange;
  13335. // Pitch.
  13336. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13337. // Apply change in Radians to vector Angle.
  13338. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13339. // Apply Pitch to quaternion.
  13340. currentRotation.multiplyInPlace(rotationChange);
  13341. }
  13342. // Yaw.
  13343. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13344. // Apply change in Radians to vector Angle.
  13345. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13346. // Apply Yaw to quaternion.
  13347. currentRotation.multiplyInPlace(rotationChange);
  13348. // Add Roll, if banked turning is enabled, within Roll limit.
  13349. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13350. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13351. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13352. // Apply change in Radians to vector Angle.
  13353. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13354. // Apply Yaw to quaternion.
  13355. currentRotation.multiplyInPlace(rotationChange);
  13356. }
  13357. }
  13358. // Roll.
  13359. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13360. // Apply change in Radians to vector Angle.
  13361. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13362. // Track Rolling.
  13363. camera._trackRoll -= x;
  13364. // Apply Pitch to quaternion.
  13365. currentRotation.multiplyInPlace(rotationChange);
  13366. }
  13367. // Apply rotationQuaternion to Euler camera.rotation.
  13368. currentRotation.toEulerAnglesToRef(camera.rotation);
  13369. };
  13370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13372. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13375. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13376. return FlyCameraMouseInput;
  13377. }());
  13378. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13379. /***/ }),
  13380. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13381. /*!*********************************************************!*\
  13382. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13383. \*********************************************************/
  13384. /*! exports provided: FollowCameraKeyboardMoveInput */
  13385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13386. "use strict";
  13387. __webpack_require__.r(__webpack_exports__);
  13388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13389. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13390. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13391. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13392. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13393. /**
  13394. * Manage the keyboard inputs to control the movement of a follow camera.
  13395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13396. */
  13397. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13398. function FollowCameraKeyboardMoveInput() {
  13399. /**
  13400. * Defines the list of key codes associated with the up action (increase heightOffset)
  13401. */
  13402. this.keysHeightOffsetIncr = [38];
  13403. /**
  13404. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13405. */
  13406. this.keysHeightOffsetDecr = [40];
  13407. /**
  13408. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13409. */
  13410. this.keysHeightOffsetModifierAlt = false;
  13411. /**
  13412. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13413. */
  13414. this.keysHeightOffsetModifierCtrl = false;
  13415. /**
  13416. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13417. */
  13418. this.keysHeightOffsetModifierShift = false;
  13419. /**
  13420. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13421. */
  13422. this.keysRotationOffsetIncr = [37];
  13423. /**
  13424. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13425. */
  13426. this.keysRotationOffsetDecr = [39];
  13427. /**
  13428. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13429. */
  13430. this.keysRotationOffsetModifierAlt = false;
  13431. /**
  13432. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13433. */
  13434. this.keysRotationOffsetModifierCtrl = false;
  13435. /**
  13436. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13437. */
  13438. this.keysRotationOffsetModifierShift = false;
  13439. /**
  13440. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13441. */
  13442. this.keysRadiusIncr = [40];
  13443. /**
  13444. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13445. */
  13446. this.keysRadiusDecr = [38];
  13447. /**
  13448. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13449. */
  13450. this.keysRadiusModifierAlt = true;
  13451. /**
  13452. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13453. */
  13454. this.keysRadiusModifierCtrl = false;
  13455. /**
  13456. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13457. */
  13458. this.keysRadiusModifierShift = false;
  13459. /**
  13460. * Defines the rate of change of heightOffset.
  13461. */
  13462. this.heightSensibility = 1;
  13463. /**
  13464. * Defines the rate of change of rotationOffset.
  13465. */
  13466. this.rotationSensibility = 1;
  13467. /**
  13468. * Defines the rate of change of radius.
  13469. */
  13470. this.radiusSensibility = 1;
  13471. this._keys = new Array();
  13472. }
  13473. /**
  13474. * Attach the input controls to a specific dom element to get the input from.
  13475. * @param element Defines the element the controls should be listened from
  13476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13477. */
  13478. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13479. var _this = this;
  13480. if (this._onCanvasBlurObserver) {
  13481. return;
  13482. }
  13483. this._scene = this.camera.getScene();
  13484. this._engine = this._scene.getEngine();
  13485. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13486. _this._keys = [];
  13487. });
  13488. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13489. var evt = info.event;
  13490. if (!evt.metaKey) {
  13491. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13492. _this._ctrlPressed = evt.ctrlKey;
  13493. _this._altPressed = evt.altKey;
  13494. _this._shiftPressed = evt.shiftKey;
  13495. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13496. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13497. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13498. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13499. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13500. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13501. var index = _this._keys.indexOf(evt.keyCode);
  13502. if (index === -1) {
  13503. _this._keys.push(evt.keyCode);
  13504. }
  13505. if (evt.preventDefault) {
  13506. if (!noPreventDefault) {
  13507. evt.preventDefault();
  13508. }
  13509. }
  13510. }
  13511. }
  13512. else {
  13513. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13514. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13515. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13516. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13517. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13518. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13519. var index = _this._keys.indexOf(evt.keyCode);
  13520. if (index >= 0) {
  13521. _this._keys.splice(index, 1);
  13522. }
  13523. if (evt.preventDefault) {
  13524. if (!noPreventDefault) {
  13525. evt.preventDefault();
  13526. }
  13527. }
  13528. }
  13529. }
  13530. }
  13531. });
  13532. };
  13533. /**
  13534. * Detach the current controls from the specified dom element.
  13535. * @param element Defines the element to stop listening the inputs from
  13536. */
  13537. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13538. if (this._scene) {
  13539. if (this._onKeyboardObserver) {
  13540. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13541. }
  13542. if (this._onCanvasBlurObserver) {
  13543. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13544. }
  13545. this._onKeyboardObserver = null;
  13546. this._onCanvasBlurObserver = null;
  13547. }
  13548. this._keys = [];
  13549. };
  13550. /**
  13551. * Update the current camera state depending on the inputs that have been used this frame.
  13552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13553. */
  13554. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13555. var _this = this;
  13556. if (this._onKeyboardObserver) {
  13557. this._keys.forEach(function (keyCode) {
  13558. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13559. _this._modifierHeightOffset()) {
  13560. _this.camera.heightOffset += _this.heightSensibility;
  13561. }
  13562. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13563. _this._modifierHeightOffset()) {
  13564. _this.camera.heightOffset -= _this.heightSensibility;
  13565. }
  13566. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13567. _this._modifierRotationOffset()) {
  13568. _this.camera.rotationOffset += _this.rotationSensibility;
  13569. _this.camera.rotationOffset %= 360;
  13570. }
  13571. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13572. _this._modifierRotationOffset()) {
  13573. _this.camera.rotationOffset -= _this.rotationSensibility;
  13574. _this.camera.rotationOffset %= 360;
  13575. }
  13576. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13577. _this._modifierRadius()) {
  13578. _this.camera.radius += _this.radiusSensibility;
  13579. }
  13580. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13581. _this._modifierRadius()) {
  13582. _this.camera.radius -= _this.radiusSensibility;
  13583. }
  13584. });
  13585. }
  13586. };
  13587. /**
  13588. * Gets the class name of the current input.
  13589. * @returns the class name
  13590. */
  13591. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13592. return "FollowCameraKeyboardMoveInput";
  13593. };
  13594. /**
  13595. * Get the friendly name associated with the input class.
  13596. * @returns the input friendly name
  13597. */
  13598. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13599. return "keyboard";
  13600. };
  13601. /**
  13602. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13603. * allow modification of the heightOffset value.
  13604. */
  13605. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13606. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13607. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13608. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13609. };
  13610. /**
  13611. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13612. * allow modification of the rotationOffset value.
  13613. */
  13614. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13615. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13616. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13617. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13618. };
  13619. /**
  13620. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13621. * allow modification of the radius value.
  13622. */
  13623. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13624. return (this.keysRadiusModifierAlt === this._altPressed &&
  13625. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13626. this.keysRadiusModifierShift === this._shiftPressed);
  13627. };
  13628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13630. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13633. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13636. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13639. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13642. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13645. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13648. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13651. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13654. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13657. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13660. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13663. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13666. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13669. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13672. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13675. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13678. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13681. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13682. return FollowCameraKeyboardMoveInput;
  13683. }());
  13684. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13685. /***/ }),
  13686. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13687. /*!*******************************************************!*\
  13688. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13689. \*******************************************************/
  13690. /*! exports provided: FollowCameraMouseWheelInput */
  13691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13692. "use strict";
  13693. __webpack_require__.r(__webpack_exports__);
  13694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13695. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13696. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13697. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13698. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13699. /**
  13700. * Manage the mouse wheel inputs to control a follow camera.
  13701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13702. */
  13703. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13704. function FollowCameraMouseWheelInput() {
  13705. /**
  13706. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13707. */
  13708. this.axisControlRadius = true;
  13709. /**
  13710. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13711. */
  13712. this.axisControlHeight = false;
  13713. /**
  13714. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13715. */
  13716. this.axisControlRotation = false;
  13717. /**
  13718. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13719. * relation to mouseWheel events.
  13720. */
  13721. this.wheelPrecision = 3.0;
  13722. /**
  13723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13725. */
  13726. this.wheelDeltaPercentage = 0;
  13727. }
  13728. /**
  13729. * Attach the input controls to a specific dom element to get the input from.
  13730. * @param element Defines the element the controls should be listened from
  13731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13732. */
  13733. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13734. var _this = this;
  13735. this._wheel = function (p, s) {
  13736. // sanity check - this should be a PointerWheel event.
  13737. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13738. return;
  13739. }
  13740. var event = p.event;
  13741. var delta = 0;
  13742. // Chrome, Safari: event.deltaY
  13743. // IE: event.wheelDelta
  13744. // Firefox: event.detail (inverted)
  13745. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13746. if (_this.wheelDeltaPercentage) {
  13747. console.assert((_this.axisControlRadius +
  13748. _this.axisControlHeight +
  13749. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13750. "controlls ONE axis. " +
  13751. "Currently enabled: " +
  13752. "axisControlRadius: " + _this.axisControlRadius +
  13753. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13754. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13755. if (_this.axisControlRadius) {
  13756. delta =
  13757. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13758. _this.camera.radius;
  13759. }
  13760. else if (_this.axisControlHeight) {
  13761. delta =
  13762. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13763. _this.camera.heightOffset;
  13764. }
  13765. else if (_this.axisControlRotation) {
  13766. delta =
  13767. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13768. _this.camera.rotationOffset;
  13769. }
  13770. }
  13771. else {
  13772. delta = wheelDelta * _this.wheelPrecision;
  13773. }
  13774. if (delta) {
  13775. if (_this.axisControlRadius) {
  13776. _this.camera.radius += delta;
  13777. }
  13778. else if (_this.axisControlHeight) {
  13779. _this.camera.heightOffset -= delta;
  13780. }
  13781. else if (_this.axisControlRotation) {
  13782. _this.camera.rotationOffset -= delta;
  13783. }
  13784. }
  13785. if (event.preventDefault) {
  13786. if (!noPreventDefault) {
  13787. event.preventDefault();
  13788. }
  13789. }
  13790. };
  13791. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13792. };
  13793. /**
  13794. * Detach the current controls from the specified dom element.
  13795. * @param element Defines the element to stop listening the inputs from
  13796. */
  13797. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13798. if (this._observer && element) {
  13799. this.camera.getScene().onPointerObservable.remove(this._observer);
  13800. this._observer = null;
  13801. this._wheel = null;
  13802. }
  13803. };
  13804. /**
  13805. * Gets the class name of the current intput.
  13806. * @returns the class name
  13807. */
  13808. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13809. return "ArcRotateCameraMouseWheelInput";
  13810. };
  13811. /**
  13812. * Get the friendly name associated with the input class.
  13813. * @returns the input friendly name
  13814. */
  13815. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13816. return "mousewheel";
  13817. };
  13818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13820. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13823. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13826. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13829. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13832. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13833. return FollowCameraMouseWheelInput;
  13834. }());
  13835. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13836. /***/ }),
  13837. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13838. /*!************************************************************!*\
  13839. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13840. \************************************************************/
  13841. /*! exports provided: FreeCameraDeviceOrientationInput */
  13842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13843. "use strict";
  13844. __webpack_require__.r(__webpack_exports__);
  13845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13846. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13848. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13849. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13850. /**
  13851. * Add orientation input support to the input manager.
  13852. * @returns the current input manager
  13853. */
  13854. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13855. this.add(new FreeCameraDeviceOrientationInput());
  13856. return this;
  13857. };
  13858. /**
  13859. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13860. * Screen rotation is taken into account.
  13861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13862. */
  13863. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13864. /**
  13865. * Instantiates a new input
  13866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13867. */
  13868. function FreeCameraDeviceOrientationInput() {
  13869. var _this = this;
  13870. this._screenOrientationAngle = 0;
  13871. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13872. this._alpha = 0;
  13873. this._beta = 0;
  13874. this._gamma = 0;
  13875. this._orientationChanged = function () {
  13876. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13877. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13878. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13879. };
  13880. this._deviceOrientation = function (evt) {
  13881. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13882. _this._beta = evt.beta !== null ? evt.beta : 0;
  13883. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13884. };
  13885. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13886. this._orientationChanged();
  13887. }
  13888. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13889. /**
  13890. * Define the camera controlled by the input.
  13891. */
  13892. get: function () {
  13893. return this._camera;
  13894. },
  13895. set: function (camera) {
  13896. this._camera = camera;
  13897. if (this._camera != null && !this._camera.rotationQuaternion) {
  13898. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13899. }
  13900. },
  13901. enumerable: true,
  13902. configurable: true
  13903. });
  13904. /**
  13905. * Attach the input controls to a specific dom element to get the input from.
  13906. * @param element Defines the element the controls should be listened from
  13907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13908. */
  13909. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13910. window.addEventListener("orientationchange", this._orientationChanged);
  13911. window.addEventListener("deviceorientation", this._deviceOrientation);
  13912. //In certain cases, the attach control is called AFTER orientation was changed,
  13913. //So this is needed.
  13914. this._orientationChanged();
  13915. };
  13916. /**
  13917. * Detach the current controls from the specified dom element.
  13918. * @param element Defines the element to stop listening the inputs from
  13919. */
  13920. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13921. window.removeEventListener("orientationchange", this._orientationChanged);
  13922. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13923. };
  13924. /**
  13925. * Update the current camera state depending on the inputs that have been used this frame.
  13926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13927. */
  13928. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13929. //if no device orientation provided, don't update the rotation.
  13930. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13931. if (!this._alpha) {
  13932. return;
  13933. }
  13934. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._alpha), _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._beta), -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._gamma), this.camera.rotationQuaternion);
  13935. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13936. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13937. //Mirror on XY Plane
  13938. this._camera.rotationQuaternion.z *= -1;
  13939. this._camera.rotationQuaternion.w *= -1;
  13940. };
  13941. /**
  13942. * Gets the class name of the current intput.
  13943. * @returns the class name
  13944. */
  13945. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13946. return "FreeCameraDeviceOrientationInput";
  13947. };
  13948. /**
  13949. * Get the friendly name associated with the input class.
  13950. * @returns the input friendly name
  13951. */
  13952. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13953. return "deviceOrientation";
  13954. };
  13955. return FreeCameraDeviceOrientationInput;
  13956. }());
  13957. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13958. /***/ }),
  13959. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13960. /*!**************************************************!*\
  13961. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13962. \**************************************************/
  13963. /*! exports provided: FreeCameraGamepadInput */
  13964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13965. "use strict";
  13966. __webpack_require__.r(__webpack_exports__);
  13967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13968. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13969. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13970. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13971. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13972. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13973. /**
  13974. * Manage the gamepad inputs to control a free camera.
  13975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13976. */
  13977. var FreeCameraGamepadInput = /** @class */ (function () {
  13978. function FreeCameraGamepadInput() {
  13979. /**
  13980. * Defines the gamepad rotation sensiblity.
  13981. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13982. */
  13983. this.gamepadAngularSensibility = 200;
  13984. /**
  13985. * Defines the gamepad move sensiblity.
  13986. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13987. */
  13988. this.gamepadMoveSensibility = 40;
  13989. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13990. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13991. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13992. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  13993. }
  13994. /**
  13995. * Attach the input controls to a specific dom element to get the input from.
  13996. * @param element Defines the element the controls should be listened from
  13997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13998. */
  13999. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14000. var _this = this;
  14001. var manager = this.camera.getScene().gamepadManager;
  14002. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14003. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14004. // prioritize XBOX gamepads.
  14005. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14006. _this.gamepad = gamepad;
  14007. }
  14008. }
  14009. });
  14010. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14011. if (_this.gamepad === gamepad) {
  14012. _this.gamepad = null;
  14013. }
  14014. });
  14015. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14016. };
  14017. /**
  14018. * Detach the current controls from the specified dom element.
  14019. * @param element Defines the element to stop listening the inputs from
  14020. */
  14021. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14022. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14023. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14024. this.gamepad = null;
  14025. };
  14026. /**
  14027. * Update the current camera state depending on the inputs that have been used this frame.
  14028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14029. */
  14030. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14031. if (this.gamepad && this.gamepad.leftStick) {
  14032. var camera = this.camera;
  14033. var LSValues = this.gamepad.leftStick;
  14034. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14035. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14036. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14037. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14038. var RSValues = this.gamepad.rightStick;
  14039. if (RSValues) {
  14040. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14041. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14042. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14043. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14044. }
  14045. else {
  14046. RSValues = { x: 0, y: 0 };
  14047. }
  14048. if (!camera.rotationQuaternion) {
  14049. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14050. }
  14051. else {
  14052. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14053. }
  14054. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14055. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14056. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14057. camera.cameraDirection.addInPlace(this._deltaTransform);
  14058. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14059. camera.cameraRotation.addInPlace(this._vector2);
  14060. }
  14061. };
  14062. /**
  14063. * Gets the class name of the current intput.
  14064. * @returns the class name
  14065. */
  14066. FreeCameraGamepadInput.prototype.getClassName = function () {
  14067. return "FreeCameraGamepadInput";
  14068. };
  14069. /**
  14070. * Get the friendly name associated with the input class.
  14071. * @returns the input friendly name
  14072. */
  14073. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14074. return "gamepad";
  14075. };
  14076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14078. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14081. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14082. return FreeCameraGamepadInput;
  14083. }());
  14084. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14085. /***/ }),
  14086. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14087. /*!*******************************************************!*\
  14088. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14089. \*******************************************************/
  14090. /*! exports provided: FreeCameraKeyboardMoveInput */
  14091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14092. "use strict";
  14093. __webpack_require__.r(__webpack_exports__);
  14094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14096. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14097. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14098. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14099. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14100. /**
  14101. * Manage the keyboard inputs to control the movement of a free camera.
  14102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14103. */
  14104. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14105. function FreeCameraKeyboardMoveInput() {
  14106. /**
  14107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14108. */
  14109. this.keysUp = [38];
  14110. /**
  14111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14112. */
  14113. this.keysDown = [40];
  14114. /**
  14115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14116. */
  14117. this.keysLeft = [37];
  14118. /**
  14119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14120. */
  14121. this.keysRight = [39];
  14122. this._keys = new Array();
  14123. }
  14124. /**
  14125. * Attach the input controls to a specific dom element to get the input from.
  14126. * @param element Defines the element the controls should be listened from
  14127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14128. */
  14129. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14130. var _this = this;
  14131. if (this._onCanvasBlurObserver) {
  14132. return;
  14133. }
  14134. this._scene = this.camera.getScene();
  14135. this._engine = this._scene.getEngine();
  14136. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14137. _this._keys = [];
  14138. });
  14139. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14140. var evt = info.event;
  14141. if (!evt.metaKey) {
  14142. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14143. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14144. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14145. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14146. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14147. var index = _this._keys.indexOf(evt.keyCode);
  14148. if (index === -1) {
  14149. _this._keys.push(evt.keyCode);
  14150. }
  14151. if (!noPreventDefault) {
  14152. evt.preventDefault();
  14153. }
  14154. }
  14155. }
  14156. else {
  14157. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14158. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14159. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14160. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14161. var index = _this._keys.indexOf(evt.keyCode);
  14162. if (index >= 0) {
  14163. _this._keys.splice(index, 1);
  14164. }
  14165. if (!noPreventDefault) {
  14166. evt.preventDefault();
  14167. }
  14168. }
  14169. }
  14170. }
  14171. });
  14172. };
  14173. /**
  14174. * Detach the current controls from the specified dom element.
  14175. * @param element Defines the element to stop listening the inputs from
  14176. */
  14177. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14178. if (this._scene) {
  14179. if (this._onKeyboardObserver) {
  14180. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14181. }
  14182. if (this._onCanvasBlurObserver) {
  14183. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14184. }
  14185. this._onKeyboardObserver = null;
  14186. this._onCanvasBlurObserver = null;
  14187. }
  14188. this._keys = [];
  14189. };
  14190. /**
  14191. * Update the current camera state depending on the inputs that have been used this frame.
  14192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14193. */
  14194. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14195. if (this._onKeyboardObserver) {
  14196. var camera = this.camera;
  14197. // Keyboard
  14198. for (var index = 0; index < this._keys.length; index++) {
  14199. var keyCode = this._keys[index];
  14200. var speed = camera._computeLocalCameraSpeed();
  14201. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14202. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14203. }
  14204. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14205. camera._localDirection.copyFromFloats(0, 0, speed);
  14206. }
  14207. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14208. camera._localDirection.copyFromFloats(speed, 0, 0);
  14209. }
  14210. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14211. camera._localDirection.copyFromFloats(0, 0, -speed);
  14212. }
  14213. if (camera.getScene().useRightHandedSystem) {
  14214. camera._localDirection.z *= -1;
  14215. }
  14216. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14217. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14218. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14219. }
  14220. }
  14221. };
  14222. /**
  14223. * Gets the class name of the current intput.
  14224. * @returns the class name
  14225. */
  14226. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14227. return "FreeCameraKeyboardMoveInput";
  14228. };
  14229. /** @hidden */
  14230. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14231. this._keys = [];
  14232. };
  14233. /**
  14234. * Get the friendly name associated with the input class.
  14235. * @returns the input friendly name
  14236. */
  14237. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14238. return "keyboard";
  14239. };
  14240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14242. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14245. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14248. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14251. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14252. return FreeCameraKeyboardMoveInput;
  14253. }());
  14254. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14255. /***/ }),
  14256. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14257. /*!************************************************!*\
  14258. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14259. \************************************************/
  14260. /*! exports provided: FreeCameraMouseInput */
  14261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14262. "use strict";
  14263. __webpack_require__.r(__webpack_exports__);
  14264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14265. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14266. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14267. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14268. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14269. /**
  14270. * Manage the mouse inputs to control the movement of a free camera.
  14271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14272. */
  14273. var FreeCameraMouseInput = /** @class */ (function () {
  14274. /**
  14275. * Manage the mouse inputs to control the movement of a free camera.
  14276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14277. * @param touchEnabled Defines if touch is enabled or not
  14278. */
  14279. function FreeCameraMouseInput(
  14280. /**
  14281. * Define if touch is enabled in the mouse input
  14282. */
  14283. touchEnabled) {
  14284. if (touchEnabled === void 0) { touchEnabled = true; }
  14285. this.touchEnabled = touchEnabled;
  14286. /**
  14287. * Defines the buttons associated with the input to handle camera move.
  14288. */
  14289. this.buttons = [0, 1, 2];
  14290. /**
  14291. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14292. */
  14293. this.angularSensibility = 2000.0;
  14294. this.previousPosition = null;
  14295. }
  14296. /**
  14297. * Attach the input controls to a specific dom element to get the input from.
  14298. * @param element Defines the element the controls should be listened from
  14299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14300. */
  14301. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14302. var _this = this;
  14303. var engine = this.camera.getEngine();
  14304. if (!this._pointerInput) {
  14305. this._pointerInput = function (p) {
  14306. var evt = p.event;
  14307. if (engine.isInVRExclusivePointerMode) {
  14308. return;
  14309. }
  14310. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14311. return;
  14312. }
  14313. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14314. return;
  14315. }
  14316. var srcElement = (evt.srcElement || evt.target);
  14317. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14318. try {
  14319. srcElement.setPointerCapture(evt.pointerId);
  14320. }
  14321. catch (e) {
  14322. //Nothing to do with the error. Execution will continue.
  14323. }
  14324. _this.previousPosition = {
  14325. x: evt.clientX,
  14326. y: evt.clientY
  14327. };
  14328. if (!noPreventDefault) {
  14329. evt.preventDefault();
  14330. element.focus();
  14331. }
  14332. }
  14333. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14334. try {
  14335. srcElement.releasePointerCapture(evt.pointerId);
  14336. }
  14337. catch (e) {
  14338. //Nothing to do with the error.
  14339. }
  14340. _this.previousPosition = null;
  14341. if (!noPreventDefault) {
  14342. evt.preventDefault();
  14343. }
  14344. }
  14345. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14346. if (!_this.previousPosition || engine.isPointerLock) {
  14347. return;
  14348. }
  14349. var offsetX = evt.clientX - _this.previousPosition.x;
  14350. if (_this.camera.getScene().useRightHandedSystem) {
  14351. offsetX *= -1;
  14352. }
  14353. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14354. offsetX *= -1;
  14355. }
  14356. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14357. var offsetY = evt.clientY - _this.previousPosition.y;
  14358. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14359. _this.previousPosition = {
  14360. x: evt.clientX,
  14361. y: evt.clientY
  14362. };
  14363. if (!noPreventDefault) {
  14364. evt.preventDefault();
  14365. }
  14366. }
  14367. };
  14368. }
  14369. this._onMouseMove = function (evt) {
  14370. if (!engine.isPointerLock) {
  14371. return;
  14372. }
  14373. if (engine.isInVRExclusivePointerMode) {
  14374. return;
  14375. }
  14376. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14377. if (_this.camera.getScene().useRightHandedSystem) {
  14378. offsetX *= -1;
  14379. }
  14380. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14381. offsetX *= -1;
  14382. }
  14383. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14384. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14385. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14386. _this.previousPosition = null;
  14387. if (!noPreventDefault) {
  14388. evt.preventDefault();
  14389. }
  14390. };
  14391. 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);
  14392. element.addEventListener("mousemove", this._onMouseMove, false);
  14393. };
  14394. /**
  14395. * Detach the current controls from the specified dom element.
  14396. * @param element Defines the element to stop listening the inputs from
  14397. */
  14398. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14399. if (this._observer && element) {
  14400. this.camera.getScene().onPointerObservable.remove(this._observer);
  14401. if (this._onMouseMove) {
  14402. element.removeEventListener("mousemove", this._onMouseMove);
  14403. }
  14404. this._observer = null;
  14405. this._onMouseMove = null;
  14406. this.previousPosition = null;
  14407. }
  14408. };
  14409. /**
  14410. * Gets the class name of the current intput.
  14411. * @returns the class name
  14412. */
  14413. FreeCameraMouseInput.prototype.getClassName = function () {
  14414. return "FreeCameraMouseInput";
  14415. };
  14416. /**
  14417. * Get the friendly name associated with the input class.
  14418. * @returns the input friendly name
  14419. */
  14420. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14421. return "mouse";
  14422. };
  14423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14425. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14428. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14429. return FreeCameraMouseInput;
  14430. }());
  14431. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14432. /***/ }),
  14433. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14434. /*!************************************************!*\
  14435. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14436. \************************************************/
  14437. /*! exports provided: FreeCameraTouchInput */
  14438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14439. "use strict";
  14440. __webpack_require__.r(__webpack_exports__);
  14441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14443. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14444. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14445. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14447. /**
  14448. * Manage the touch inputs to control the movement of a free camera.
  14449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14450. */
  14451. var FreeCameraTouchInput = /** @class */ (function () {
  14452. function FreeCameraTouchInput() {
  14453. /**
  14454. * Defines the touch sensibility for rotation.
  14455. * The higher the faster.
  14456. */
  14457. this.touchAngularSensibility = 200000.0;
  14458. /**
  14459. * Defines the touch sensibility for move.
  14460. * The higher the faster.
  14461. */
  14462. this.touchMoveSensibility = 250.0;
  14463. this._offsetX = null;
  14464. this._offsetY = null;
  14465. this._pointerPressed = new Array();
  14466. }
  14467. /**
  14468. * Attach the input controls to a specific dom element to get the input from.
  14469. * @param element Defines the element the controls should be listened from
  14470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14471. */
  14472. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14473. var _this = this;
  14474. var previousPosition = null;
  14475. if (this._pointerInput === undefined) {
  14476. this._onLostFocus = function () {
  14477. _this._offsetX = null;
  14478. _this._offsetY = null;
  14479. };
  14480. this._pointerInput = function (p) {
  14481. var evt = p.event;
  14482. if (evt.pointerType === "mouse") {
  14483. return;
  14484. }
  14485. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14486. if (!noPreventDefault) {
  14487. evt.preventDefault();
  14488. }
  14489. _this._pointerPressed.push(evt.pointerId);
  14490. if (_this._pointerPressed.length !== 1) {
  14491. return;
  14492. }
  14493. previousPosition = {
  14494. x: evt.clientX,
  14495. y: evt.clientY
  14496. };
  14497. }
  14498. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14499. if (!noPreventDefault) {
  14500. evt.preventDefault();
  14501. }
  14502. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14503. if (index === -1) {
  14504. return;
  14505. }
  14506. _this._pointerPressed.splice(index, 1);
  14507. if (index != 0) {
  14508. return;
  14509. }
  14510. previousPosition = null;
  14511. _this._offsetX = null;
  14512. _this._offsetY = null;
  14513. }
  14514. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14515. if (!noPreventDefault) {
  14516. evt.preventDefault();
  14517. }
  14518. if (!previousPosition) {
  14519. return;
  14520. }
  14521. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14522. if (index != 0) {
  14523. return;
  14524. }
  14525. _this._offsetX = evt.clientX - previousPosition.x;
  14526. _this._offsetY = -(evt.clientY - previousPosition.y);
  14527. }
  14528. };
  14529. }
  14530. 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);
  14531. if (this._onLostFocus) {
  14532. element.addEventListener("blur", this._onLostFocus);
  14533. }
  14534. };
  14535. /**
  14536. * Detach the current controls from the specified dom element.
  14537. * @param element Defines the element to stop listening the inputs from
  14538. */
  14539. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14540. if (this._pointerInput && element) {
  14541. if (this._observer) {
  14542. this.camera.getScene().onPointerObservable.remove(this._observer);
  14543. this._observer = null;
  14544. }
  14545. if (this._onLostFocus) {
  14546. element.removeEventListener("blur", this._onLostFocus);
  14547. this._onLostFocus = null;
  14548. }
  14549. this._pointerPressed = [];
  14550. this._offsetX = null;
  14551. this._offsetY = null;
  14552. }
  14553. };
  14554. /**
  14555. * Update the current camera state depending on the inputs that have been used this frame.
  14556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14557. */
  14558. FreeCameraTouchInput.prototype.checkInputs = function () {
  14559. if (this._offsetX && this._offsetY) {
  14560. var camera = this.camera;
  14561. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14562. if (this._pointerPressed.length > 1) {
  14563. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14564. }
  14565. else {
  14566. var speed = camera._computeLocalCameraSpeed();
  14567. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14568. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14569. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14570. }
  14571. }
  14572. };
  14573. /**
  14574. * Gets the class name of the current intput.
  14575. * @returns the class name
  14576. */
  14577. FreeCameraTouchInput.prototype.getClassName = function () {
  14578. return "FreeCameraTouchInput";
  14579. };
  14580. /**
  14581. * Get the friendly name associated with the input class.
  14582. * @returns the input friendly name
  14583. */
  14584. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14585. return "touch";
  14586. };
  14587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14589. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14592. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14593. return FreeCameraTouchInput;
  14594. }());
  14595. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14596. /***/ }),
  14597. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14598. /*!**********************************************************!*\
  14599. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14600. \**********************************************************/
  14601. /*! exports provided: FreeCameraVirtualJoystickInput */
  14602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14603. "use strict";
  14604. __webpack_require__.r(__webpack_exports__);
  14605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14606. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14607. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14608. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14609. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14610. /**
  14611. * Add virtual joystick input support to the input manager.
  14612. * @returns the current input manager
  14613. */
  14614. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14615. this.add(new FreeCameraVirtualJoystickInput());
  14616. return this;
  14617. };
  14618. /**
  14619. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14621. */
  14622. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14623. function FreeCameraVirtualJoystickInput() {
  14624. }
  14625. /**
  14626. * Gets the left stick of the virtual joystick.
  14627. * @returns The virtual Joystick
  14628. */
  14629. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14630. return this._leftjoystick;
  14631. };
  14632. /**
  14633. * Gets the right stick of the virtual joystick.
  14634. * @returns The virtual Joystick
  14635. */
  14636. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14637. return this._rightjoystick;
  14638. };
  14639. /**
  14640. * Update the current camera state depending on the inputs that have been used this frame.
  14641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14642. */
  14643. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14644. if (this._leftjoystick) {
  14645. var camera = this.camera;
  14646. var speed = camera._computeLocalCameraSpeed() * 50;
  14647. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14648. var deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._leftjoystick.deltaPosition.x * speed, this._leftjoystick.deltaPosition.y * speed, this._leftjoystick.deltaPosition.z * speed), cameraTransform);
  14649. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14650. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14651. if (!this._leftjoystick.pressed) {
  14652. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14653. }
  14654. if (!this._rightjoystick.pressed) {
  14655. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14656. }
  14657. }
  14658. };
  14659. /**
  14660. * Attach the input controls to a specific dom element to get the input from.
  14661. * @param element Defines the element the controls should be listened from
  14662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14663. */
  14664. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14665. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14666. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14667. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14668. this._leftjoystick.setJoystickSensibility(0.15);
  14669. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14670. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14671. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14672. this._rightjoystick.reverseUpDown = true;
  14673. this._rightjoystick.setJoystickSensibility(0.05);
  14674. this._rightjoystick.setJoystickColor("yellow");
  14675. };
  14676. /**
  14677. * Detach the current controls from the specified dom element.
  14678. * @param element Defines the element to stop listening the inputs from
  14679. */
  14680. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14681. this._leftjoystick.releaseCanvas();
  14682. this._rightjoystick.releaseCanvas();
  14683. };
  14684. /**
  14685. * Gets the class name of the current intput.
  14686. * @returns the class name
  14687. */
  14688. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14689. return "FreeCameraVirtualJoystickInput";
  14690. };
  14691. /**
  14692. * Get the friendly name associated with the input class.
  14693. * @returns the input friendly name
  14694. */
  14695. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14696. return "virtualJoystick";
  14697. };
  14698. return FreeCameraVirtualJoystickInput;
  14699. }());
  14700. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14701. /***/ }),
  14702. /***/ "./Cameras/Inputs/index.ts":
  14703. /*!*********************************!*\
  14704. !*** ./Cameras/Inputs/index.ts ***!
  14705. \*********************************/
  14706. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14708. "use strict";
  14709. __webpack_require__.r(__webpack_exports__);
  14710. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14712. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14714. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14716. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14718. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14720. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14722. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14724. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14726. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14728. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14730. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14732. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14734. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14736. /***/ }),
  14737. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14738. /*!*********************************************************!*\
  14739. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14740. \*********************************************************/
  14741. /*! no exports provided */
  14742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14743. "use strict";
  14744. __webpack_require__.r(__webpack_exports__);
  14745. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14746. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14747. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14748. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14749. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14750. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14751. };
  14752. /***/ }),
  14753. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14754. /*!*************************************************!*\
  14755. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14756. \*************************************************/
  14757. /*! no exports provided */
  14758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14759. "use strict";
  14760. __webpack_require__.r(__webpack_exports__);
  14761. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14762. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14763. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14764. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14765. 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;
  14766. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14767. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14768. };
  14769. /***/ }),
  14770. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14771. /*!***************************************!*\
  14772. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14773. \***************************************/
  14774. /*! no exports provided */
  14775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14776. "use strict";
  14777. __webpack_require__.r(__webpack_exports__);
  14778. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14779. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14780. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14781. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14782. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14783. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14784. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14785. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14786. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14787. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14788. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14789. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14790. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14791. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14792. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14793. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14794. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14795. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14796. if (metrics.compensateDistortion) {
  14797. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14798. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14799. }
  14800. };
  14801. /***/ }),
  14802. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14803. /*!******************************************!*\
  14804. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14805. \******************************************/
  14806. /*! no exports provided */
  14807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14808. "use strict";
  14809. __webpack_require__.r(__webpack_exports__);
  14810. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14812. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14813. if (rigParams.vrDisplay) {
  14814. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14815. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14816. //Left eye
  14817. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14818. camera._rigCameras[0].setCameraRigParameter("left", true);
  14819. //leaving this for future reference
  14820. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14821. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14822. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14823. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14824. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14825. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14826. camera._rigCameras[0].parent = camera;
  14827. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14828. //Right eye
  14829. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14830. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14831. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14832. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14833. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14834. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14835. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14836. camera._rigCameras[1].parent = camera;
  14837. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14838. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14839. camera._rigCameras[1]._skipRendering = true;
  14840. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14841. }
  14842. }
  14843. };
  14844. /***/ }),
  14845. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14846. /*!*********************************************************!*\
  14847. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14848. \*********************************************************/
  14849. /*! exports provided: AnaglyphArcRotateCamera */
  14850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14851. "use strict";
  14852. __webpack_require__.r(__webpack_exports__);
  14853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14854. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14855. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14856. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14857. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14858. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14859. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14860. // Side effect import to define the stereoscopic mode.
  14861. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14862. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14863. });
  14864. /**
  14865. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14866. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14867. */
  14868. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14869. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14870. /**
  14871. * Creates a new AnaglyphArcRotateCamera
  14872. * @param name defines camera name
  14873. * @param alpha defines alpha angle (in radians)
  14874. * @param beta defines beta angle (in radians)
  14875. * @param radius defines radius
  14876. * @param target defines camera target
  14877. * @param interaxialDistance defines distance between each color axis
  14878. * @param scene defines the hosting scene
  14879. */
  14880. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14881. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14882. _this.interaxialDistance = interaxialDistance;
  14883. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14884. return _this;
  14885. }
  14886. /**
  14887. * Gets camera class name
  14888. * @returns AnaglyphArcRotateCamera
  14889. */
  14890. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14891. return "AnaglyphArcRotateCamera";
  14892. };
  14893. return AnaglyphArcRotateCamera;
  14894. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14895. /***/ }),
  14896. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14897. /*!****************************************************!*\
  14898. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14899. \****************************************************/
  14900. /*! exports provided: AnaglyphFreeCamera */
  14901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14902. "use strict";
  14903. __webpack_require__.r(__webpack_exports__);
  14904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14905. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14906. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14907. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14908. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14909. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14910. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14911. // Side effect import to define the stereoscopic mode.
  14912. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14913. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14914. });
  14915. /**
  14916. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14917. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14918. */
  14919. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14921. /**
  14922. * Creates a new AnaglyphFreeCamera
  14923. * @param name defines camera name
  14924. * @param position defines initial position
  14925. * @param interaxialDistance defines distance between each color axis
  14926. * @param scene defines the hosting scene
  14927. */
  14928. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14929. var _this = _super.call(this, name, position, scene) || this;
  14930. _this.interaxialDistance = interaxialDistance;
  14931. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14932. return _this;
  14933. }
  14934. /**
  14935. * Gets camera class name
  14936. * @returns AnaglyphFreeCamera
  14937. */
  14938. AnaglyphFreeCamera.prototype.getClassName = function () {
  14939. return "AnaglyphFreeCamera";
  14940. };
  14941. return AnaglyphFreeCamera;
  14942. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14943. /***/ }),
  14944. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14945. /*!*******************************************************!*\
  14946. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14947. \*******************************************************/
  14948. /*! exports provided: AnaglyphGamepadCamera */
  14949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14950. "use strict";
  14951. __webpack_require__.r(__webpack_exports__);
  14952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14953. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14954. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14955. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14956. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14957. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14958. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14959. // Side effect import to define the stereoscopic mode.
  14960. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14961. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14962. });
  14963. /**
  14964. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14965. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14966. */
  14967. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14969. /**
  14970. * Creates a new AnaglyphGamepadCamera
  14971. * @param name defines camera name
  14972. * @param position defines initial position
  14973. * @param interaxialDistance defines distance between each color axis
  14974. * @param scene defines the hosting scene
  14975. */
  14976. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14977. var _this = _super.call(this, name, position, scene) || this;
  14978. _this.interaxialDistance = interaxialDistance;
  14979. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14980. return _this;
  14981. }
  14982. /**
  14983. * Gets camera class name
  14984. * @returns AnaglyphGamepadCamera
  14985. */
  14986. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14987. return "AnaglyphGamepadCamera";
  14988. };
  14989. return AnaglyphGamepadCamera;
  14990. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14991. /***/ }),
  14992. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  14993. /*!*********************************************************!*\
  14994. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  14995. \*********************************************************/
  14996. /*! exports provided: AnaglyphUniversalCamera */
  14997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14998. "use strict";
  14999. __webpack_require__.r(__webpack_exports__);
  15000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15002. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15003. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15005. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15006. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15007. // Side effect import to define the stereoscopic mode.
  15008. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15009. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15010. });
  15011. /**
  15012. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15013. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15014. */
  15015. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15016. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15017. /**
  15018. * Creates a new AnaglyphUniversalCamera
  15019. * @param name defines camera name
  15020. * @param position defines initial position
  15021. * @param interaxialDistance defines distance between each color axis
  15022. * @param scene defines the hosting scene
  15023. */
  15024. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15025. var _this = _super.call(this, name, position, scene) || this;
  15026. _this.interaxialDistance = interaxialDistance;
  15027. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15028. return _this;
  15029. }
  15030. /**
  15031. * Gets camera class name
  15032. * @returns AnaglyphUniversalCamera
  15033. */
  15034. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15035. return "AnaglyphUniversalCamera";
  15036. };
  15037. return AnaglyphUniversalCamera;
  15038. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15039. /***/ }),
  15040. /***/ "./Cameras/Stereoscopic/index.ts":
  15041. /*!***************************************!*\
  15042. !*** ./Cameras/Stereoscopic/index.ts ***!
  15043. \***************************************/
  15044. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15046. "use strict";
  15047. __webpack_require__.r(__webpack_exports__);
  15048. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15050. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15052. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15054. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15056. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15058. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15060. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15062. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15064. /***/ }),
  15065. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15066. /*!*************************************************************!*\
  15067. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15068. \*************************************************************/
  15069. /*! exports provided: StereoscopicArcRotateCamera */
  15070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15071. "use strict";
  15072. __webpack_require__.r(__webpack_exports__);
  15073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15074. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15075. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15076. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15077. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15078. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15079. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15080. // Side effect import to define the stereoscopic mode.
  15081. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15082. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15083. });
  15084. /**
  15085. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15086. * @see http://doc.babylonjs.com/features/cameras
  15087. */
  15088. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15089. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15090. /**
  15091. * Creates a new StereoscopicArcRotateCamera
  15092. * @param name defines camera name
  15093. * @param alpha defines alpha angle (in radians)
  15094. * @param beta defines beta angle (in radians)
  15095. * @param radius defines radius
  15096. * @param target defines camera target
  15097. * @param interaxialDistance defines distance between each color axis
  15098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15099. * @param scene defines the hosting scene
  15100. */
  15101. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15102. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15103. _this.interaxialDistance = interaxialDistance;
  15104. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15105. _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 });
  15106. return _this;
  15107. }
  15108. /**
  15109. * Gets camera class name
  15110. * @returns StereoscopicArcRotateCamera
  15111. */
  15112. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15113. return "StereoscopicArcRotateCamera";
  15114. };
  15115. return StereoscopicArcRotateCamera;
  15116. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15117. /***/ }),
  15118. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15119. /*!********************************************************!*\
  15120. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15121. \********************************************************/
  15122. /*! exports provided: StereoscopicFreeCamera */
  15123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15124. "use strict";
  15125. __webpack_require__.r(__webpack_exports__);
  15126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15128. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15129. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15130. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15131. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15132. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15133. // Side effect import to define the stereoscopic mode.
  15134. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15135. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15136. });
  15137. /**
  15138. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15139. * @see http://doc.babylonjs.com/features/cameras
  15140. */
  15141. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15143. /**
  15144. * Creates a new StereoscopicFreeCamera
  15145. * @param name defines camera name
  15146. * @param position defines initial position
  15147. * @param interaxialDistance defines distance between each color axis
  15148. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15149. * @param scene defines the hosting scene
  15150. */
  15151. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15152. var _this = _super.call(this, name, position, scene) || this;
  15153. _this.interaxialDistance = interaxialDistance;
  15154. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15155. _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 });
  15156. return _this;
  15157. }
  15158. /**
  15159. * Gets camera class name
  15160. * @returns StereoscopicFreeCamera
  15161. */
  15162. StereoscopicFreeCamera.prototype.getClassName = function () {
  15163. return "StereoscopicFreeCamera";
  15164. };
  15165. return StereoscopicFreeCamera;
  15166. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15167. /***/ }),
  15168. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15169. /*!***********************************************************!*\
  15170. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15171. \***********************************************************/
  15172. /*! exports provided: StereoscopicGamepadCamera */
  15173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15174. "use strict";
  15175. __webpack_require__.r(__webpack_exports__);
  15176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15178. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15179. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15181. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15182. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15183. // Side effect import to define the stereoscopic mode.
  15184. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15185. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15186. });
  15187. /**
  15188. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15189. * @see http://doc.babylonjs.com/features/cameras
  15190. */
  15191. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15192. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15193. /**
  15194. * Creates a new StereoscopicGamepadCamera
  15195. * @param name defines camera name
  15196. * @param position defines initial position
  15197. * @param interaxialDistance defines distance between each color axis
  15198. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15199. * @param scene defines the hosting scene
  15200. */
  15201. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15202. var _this = _super.call(this, name, position, scene) || this;
  15203. _this.interaxialDistance = interaxialDistance;
  15204. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15205. _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 });
  15206. return _this;
  15207. }
  15208. /**
  15209. * Gets camera class name
  15210. * @returns StereoscopicGamepadCamera
  15211. */
  15212. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15213. return "StereoscopicGamepadCamera";
  15214. };
  15215. return StereoscopicGamepadCamera;
  15216. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15217. /***/ }),
  15218. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15219. /*!*************************************************************!*\
  15220. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15221. \*************************************************************/
  15222. /*! exports provided: StereoscopicUniversalCamera */
  15223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15224. "use strict";
  15225. __webpack_require__.r(__webpack_exports__);
  15226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15228. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15229. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15231. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15232. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15233. // Side effect import to define the stereoscopic mode.
  15234. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15235. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15236. });
  15237. /**
  15238. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15239. * @see http://doc.babylonjs.com/features/cameras
  15240. */
  15241. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15243. /**
  15244. * Creates a new StereoscopicUniversalCamera
  15245. * @param name defines camera name
  15246. * @param position defines initial position
  15247. * @param interaxialDistance defines distance between each color axis
  15248. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15249. * @param scene defines the hosting scene
  15250. */
  15251. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15252. var _this = _super.call(this, name, position, scene) || this;
  15253. _this.interaxialDistance = interaxialDistance;
  15254. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15255. _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 });
  15256. return _this;
  15257. }
  15258. /**
  15259. * Gets camera class name
  15260. * @returns StereoscopicUniversalCamera
  15261. */
  15262. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15263. return "StereoscopicUniversalCamera";
  15264. };
  15265. return StereoscopicUniversalCamera;
  15266. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15267. /***/ }),
  15268. /***/ "./Cameras/VR/index.ts":
  15269. /*!*****************************!*\
  15270. !*** ./Cameras/VR/index.ts ***!
  15271. \*****************************/
  15272. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15274. "use strict";
  15275. __webpack_require__.r(__webpack_exports__);
  15276. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15278. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15280. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15282. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15284. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15286. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15288. /***/ }),
  15289. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15290. /*!***************************************!*\
  15291. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15292. \***************************************/
  15293. /*! exports provided: VRCameraMetrics */
  15294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15295. "use strict";
  15296. __webpack_require__.r(__webpack_exports__);
  15297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15299. /**
  15300. * This represents all the required metrics to create a VR camera.
  15301. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15302. */
  15303. var VRCameraMetrics = /** @class */ (function () {
  15304. function VRCameraMetrics() {
  15305. /**
  15306. * Define if the current vr camera should compensate the distortion of the lense or not.
  15307. */
  15308. this.compensateDistortion = true;
  15309. }
  15310. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15311. /**
  15312. * Gets the rendering aspect ratio based on the provided resolutions.
  15313. */
  15314. get: function () {
  15315. return this.hResolution / (2 * this.vResolution);
  15316. },
  15317. enumerable: true,
  15318. configurable: true
  15319. });
  15320. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15321. /**
  15322. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15323. */
  15324. get: function () {
  15325. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15326. },
  15327. enumerable: true,
  15328. configurable: true
  15329. });
  15330. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15331. /**
  15332. * @hidden
  15333. */
  15334. get: function () {
  15335. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15336. var h = (4 * meters) / this.hScreenSize;
  15337. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15338. },
  15339. enumerable: true,
  15340. configurable: true
  15341. });
  15342. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15343. /**
  15344. * @hidden
  15345. */
  15346. get: function () {
  15347. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15348. var h = (4 * meters) / this.hScreenSize;
  15349. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15350. },
  15351. enumerable: true,
  15352. configurable: true
  15353. });
  15354. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15355. /**
  15356. * @hidden
  15357. */
  15358. get: function () {
  15359. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15360. },
  15361. enumerable: true,
  15362. configurable: true
  15363. });
  15364. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15365. /**
  15366. * @hidden
  15367. */
  15368. get: function () {
  15369. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15370. },
  15371. enumerable: true,
  15372. configurable: true
  15373. });
  15374. /**
  15375. * Get the default VRMetrics based on the most generic setup.
  15376. * @returns the default vr metrics
  15377. */
  15378. VRCameraMetrics.GetDefault = function () {
  15379. var result = new VRCameraMetrics();
  15380. result.hResolution = 1280;
  15381. result.vResolution = 800;
  15382. result.hScreenSize = 0.149759993;
  15383. result.vScreenSize = 0.0935999975;
  15384. result.vScreenCenter = 0.0467999987;
  15385. result.eyeToScreenDistance = 0.0410000011;
  15386. result.lensSeparationDistance = 0.0635000020;
  15387. result.interpupillaryDistance = 0.0640000030;
  15388. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15389. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15390. result.postProcessScaleFactor = 1.714605507808412;
  15391. result.lensCenterOffset = 0.151976421;
  15392. return result;
  15393. };
  15394. return VRCameraMetrics;
  15395. }());
  15396. /***/ }),
  15397. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15398. /*!**********************************************************!*\
  15399. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15400. \**********************************************************/
  15401. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15403. "use strict";
  15404. __webpack_require__.r(__webpack_exports__);
  15405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15406. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15407. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15408. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15409. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15410. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15411. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15412. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15413. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15414. // Side effect import to define the stereoscopic mode.
  15415. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15416. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15417. });
  15418. /**
  15419. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15420. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15421. */
  15422. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15423. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15424. /**
  15425. * Creates a new VRDeviceOrientationArcRotateCamera
  15426. * @param name defines camera name
  15427. * @param alpha defines the camera rotation along the logitudinal axis
  15428. * @param beta defines the camera rotation along the latitudinal axis
  15429. * @param radius defines the camera distance from its target
  15430. * @param target defines the camera target
  15431. * @param scene defines the scene the camera belongs to
  15432. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15433. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15434. */
  15435. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15436. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15437. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15438. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15439. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15440. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15441. _this.inputs.addVRDeviceOrientation();
  15442. return _this;
  15443. }
  15444. /**
  15445. * Gets camera class name
  15446. * @returns VRDeviceOrientationArcRotateCamera
  15447. */
  15448. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15449. return "VRDeviceOrientationArcRotateCamera";
  15450. };
  15451. return VRDeviceOrientationArcRotateCamera;
  15452. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15453. /***/ }),
  15454. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15455. /*!*****************************************************!*\
  15456. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15457. \*****************************************************/
  15458. /*! exports provided: VRDeviceOrientationFreeCamera */
  15459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15460. "use strict";
  15461. __webpack_require__.r(__webpack_exports__);
  15462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15463. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15464. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15465. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15466. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15468. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15469. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15470. // Side effect import to define the stereoscopic mode.
  15471. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15472. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15473. });
  15474. /**
  15475. * Camera used to simulate VR rendering (based on FreeCamera)
  15476. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15477. */
  15478. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15480. /**
  15481. * Creates a new VRDeviceOrientationFreeCamera
  15482. * @param name defines camera name
  15483. * @param position defines the start position of the camera
  15484. * @param scene defines the scene the camera belongs to
  15485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15487. */
  15488. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15489. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15490. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15491. var _this = _super.call(this, name, position, scene) || this;
  15492. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15493. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15494. return _this;
  15495. }
  15496. /**
  15497. * Gets camera class name
  15498. * @returns VRDeviceOrientationFreeCamera
  15499. */
  15500. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15501. return "VRDeviceOrientationFreeCamera";
  15502. };
  15503. return VRDeviceOrientationFreeCamera;
  15504. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15505. /***/ }),
  15506. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15507. /*!********************************************************!*\
  15508. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15509. \********************************************************/
  15510. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15512. "use strict";
  15513. __webpack_require__.r(__webpack_exports__);
  15514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15516. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15517. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15518. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15519. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15520. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15521. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15522. });
  15523. /**
  15524. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15525. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15526. */
  15527. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15528. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15529. /**
  15530. * Creates a new VRDeviceOrientationGamepadCamera
  15531. * @param name defines camera name
  15532. * @param position defines the start position of the camera
  15533. * @param scene defines the scene the camera belongs to
  15534. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15535. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15536. */
  15537. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15538. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15539. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15540. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15541. _this.inputs.addGamepad();
  15542. return _this;
  15543. }
  15544. /**
  15545. * Gets camera class name
  15546. * @returns VRDeviceOrientationGamepadCamera
  15547. */
  15548. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15549. return "VRDeviceOrientationGamepadCamera";
  15550. };
  15551. return VRDeviceOrientationGamepadCamera;
  15552. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15553. /***/ }),
  15554. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15555. /*!******************************************!*\
  15556. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15557. \******************************************/
  15558. /*! exports provided: VRExperienceHelper */
  15559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15560. "use strict";
  15561. __webpack_require__.r(__webpack_exports__);
  15562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15564. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15565. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15566. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15567. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15568. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15569. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15570. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15571. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15572. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15573. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15574. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15575. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15576. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15577. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15578. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15579. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15580. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15581. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15582. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15583. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15584. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15585. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15586. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15587. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15588. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15589. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15590. var VRExperienceHelperGazer = /** @class */ (function () {
  15591. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15592. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15593. this.scene = scene;
  15594. /** @hidden */
  15595. this._pointerDownOnMeshAsked = false;
  15596. /** @hidden */
  15597. this._isActionableMesh = false;
  15598. /** @hidden */
  15599. this._teleportationRequestInitiated = false;
  15600. /** @hidden */
  15601. this._teleportationBackRequestInitiated = false;
  15602. /** @hidden */
  15603. this._rotationRightAsked = false;
  15604. /** @hidden */
  15605. this._rotationLeftAsked = false;
  15606. /** @hidden */
  15607. this._dpadPressed = true;
  15608. /** @hidden */
  15609. this._activePointer = false;
  15610. this._id = VRExperienceHelperGazer._idCounter++;
  15611. // Gaze tracker
  15612. if (!gazeTrackerToClone) {
  15613. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15614. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15615. this._gazeTracker.isPickable = false;
  15616. this._gazeTracker.isVisible = false;
  15617. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15618. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15619. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15620. targetMat.backFaceCulling = false;
  15621. this._gazeTracker.material = targetMat;
  15622. }
  15623. else {
  15624. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15625. }
  15626. }
  15627. /** @hidden */
  15628. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15629. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, length));
  15630. };
  15631. /** @hidden */
  15632. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15633. this._pointerDownOnMeshAsked = true;
  15634. if (this._currentHit) {
  15635. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15636. }
  15637. };
  15638. /** @hidden */
  15639. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15640. if (this._currentHit) {
  15641. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15642. }
  15643. this._pointerDownOnMeshAsked = false;
  15644. };
  15645. /** @hidden */
  15646. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15647. this._activePointer = true;
  15648. };
  15649. /** @hidden */
  15650. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15651. this._activePointer = false;
  15652. };
  15653. /** @hidden */
  15654. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15655. if (distance === void 0) { distance = 100; }
  15656. };
  15657. VRExperienceHelperGazer.prototype.dispose = function () {
  15658. this._interactionsEnabled = false;
  15659. this._teleportationEnabled = false;
  15660. if (this._gazeTracker) {
  15661. this._gazeTracker.dispose();
  15662. }
  15663. };
  15664. VRExperienceHelperGazer._idCounter = 0;
  15665. return VRExperienceHelperGazer;
  15666. }());
  15667. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15668. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15669. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15670. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15671. _this.webVRController = webVRController;
  15672. // Laser pointer
  15673. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15674. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15675. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15676. laserPointerMaterial.alpha = 0.6;
  15677. _this._laserPointer.material = laserPointerMaterial;
  15678. _this._laserPointer.rotation.x = Math.PI / 2;
  15679. _this._laserPointer.position.z = -0.5;
  15680. _this._laserPointer.isVisible = false;
  15681. _this._laserPointer.isPickable = false;
  15682. if (!webVRController.mesh) {
  15683. // Create an empty mesh that is used prior to loading the high quality model
  15684. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15685. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15686. preloadPointerPose.rotation.x = -0.7;
  15687. preloadMesh.addChild(preloadPointerPose);
  15688. webVRController.attachToMesh(preloadMesh);
  15689. }
  15690. _this._setLaserPointerParent(webVRController.mesh);
  15691. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15692. _this._setLaserPointerParent(mesh);
  15693. });
  15694. return _this;
  15695. }
  15696. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15697. return this.webVRController.getForwardRay(length);
  15698. };
  15699. /** @hidden */
  15700. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15701. _super.prototype._activatePointer.call(this);
  15702. this._laserPointer.isVisible = true;
  15703. };
  15704. /** @hidden */
  15705. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15706. _super.prototype._deactivatePointer.call(this);
  15707. this._laserPointer.isVisible = false;
  15708. };
  15709. /** @hidden */
  15710. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15711. this._laserPointer.material.emissiveColor = color;
  15712. };
  15713. /** @hidden */
  15714. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15715. var makeNotPick = function (root) {
  15716. root.isPickable = false;
  15717. root.getChildMeshes().forEach(function (c) {
  15718. makeNotPick(c);
  15719. });
  15720. };
  15721. makeNotPick(mesh);
  15722. var meshChildren = mesh.getChildren(undefined, false);
  15723. var laserParent = mesh;
  15724. this.webVRController._pointingPoseNode = null;
  15725. for (var i = 0; i < meshChildren.length; i++) {
  15726. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15727. laserParent = meshChildren[i];
  15728. this.webVRController._pointingPoseNode = laserParent;
  15729. break;
  15730. }
  15731. }
  15732. this._laserPointer.parent = laserParent;
  15733. };
  15734. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15735. if (distance === void 0) { distance = 100; }
  15736. this._laserPointer.scaling.y = distance;
  15737. this._laserPointer.position.z = -distance / 2;
  15738. };
  15739. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15740. _super.prototype.dispose.call(this);
  15741. this._laserPointer.dispose();
  15742. if (this._meshAttachedObserver) {
  15743. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15744. }
  15745. };
  15746. return VRExperienceHelperControllerGazer;
  15747. }(VRExperienceHelperGazer));
  15748. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15750. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15751. var _this = _super.call(this, scene) || this;
  15752. _this.getCamera = getCamera;
  15753. return _this;
  15754. }
  15755. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15756. var camera = this.getCamera();
  15757. if (camera) {
  15758. return camera.getForwardRay(length);
  15759. }
  15760. else {
  15761. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Forward());
  15762. }
  15763. };
  15764. return VRExperienceHelperCameraGazer;
  15765. }(VRExperienceHelperGazer));
  15766. /**
  15767. * Helps to quickly add VR support to an existing scene.
  15768. * See http://doc.babylonjs.com/how_to/webvr_helper
  15769. */
  15770. var VRExperienceHelper = /** @class */ (function () {
  15771. /**
  15772. * Instantiates a VRExperienceHelper.
  15773. * Helps to quickly add VR support to an existing scene.
  15774. * @param scene The scene the VRExperienceHelper belongs to.
  15775. * @param webVROptions Options to modify the vr experience helper's behavior.
  15776. */
  15777. function VRExperienceHelper(scene,
  15778. /** Options to modify the vr experience helper's behavior. */
  15779. webVROptions) {
  15780. if (webVROptions === void 0) { webVROptions = {}; }
  15781. var _this = this;
  15782. this.webVROptions = webVROptions;
  15783. // Can the system support WebVR, even if a headset isn't plugged in?
  15784. this._webVRsupported = false;
  15785. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15786. this._webVRready = false;
  15787. // Are we waiting for the requestPresent callback to complete?
  15788. this._webVRrequesting = false;
  15789. // Are we presenting to the headset right now? (this is the vrDevice state)
  15790. this._webVRpresenting = false;
  15791. // Are we presenting in the fullscreen fallback?
  15792. this._fullscreenVRpresenting = false;
  15793. /**
  15794. * Observable raised when entering VR.
  15795. */
  15796. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15797. /**
  15798. * Observable raised when exiting VR.
  15799. */
  15800. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15801. /**
  15802. * Observable raised when controller mesh is loaded.
  15803. */
  15804. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15805. this._useCustomVRButton = false;
  15806. this._teleportationRequested = false;
  15807. this._teleportActive = false;
  15808. this._floorMeshesCollection = [];
  15809. this._rotationAllowed = true;
  15810. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15811. this._isDefaultTeleportationTarget = true;
  15812. this._teleportationFillColor = "#444444";
  15813. this._teleportationBorderColor = "#FFFFFF";
  15814. this._rotationAngle = 0;
  15815. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15816. this._padSensibilityUp = 0.65;
  15817. this._padSensibilityDown = 0.35;
  15818. this._leftController = null;
  15819. this._rightController = null;
  15820. /**
  15821. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15822. */
  15823. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15824. /**
  15825. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15826. */
  15827. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15828. /**
  15829. * Observable raised before camera teleportation
  15830. */
  15831. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15832. /**
  15833. * Observable raised after camera teleportation
  15834. */
  15835. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15836. /**
  15837. * Observable raised when current selected mesh gets unselected
  15838. */
  15839. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15840. /**
  15841. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15842. */
  15843. this.teleportationEnabled = true;
  15844. this._teleportationInitialized = false;
  15845. this._interactionsEnabled = false;
  15846. this._interactionsRequested = false;
  15847. this._displayGaze = true;
  15848. this._displayLaserPointer = true;
  15849. /**
  15850. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15851. */
  15852. this.updateGazeTrackerScale = true;
  15853. /**
  15854. * If the gaze trackers color should be updated when selecting meshes
  15855. */
  15856. this.updateGazeTrackerColor = true;
  15857. this._onResize = function () {
  15858. _this.moveButtonToBottomRight();
  15859. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15860. _this.exitVR();
  15861. }
  15862. };
  15863. this._onFullscreenChange = function () {
  15864. if (document.fullscreen !== undefined) {
  15865. _this._fullscreenVRpresenting = document.fullscreen;
  15866. }
  15867. else if (document.mozFullScreen !== undefined) {
  15868. _this._fullscreenVRpresenting = document.mozFullScreen;
  15869. }
  15870. else if (document.webkitIsFullScreen !== undefined) {
  15871. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15872. }
  15873. else if (document.msIsFullScreen !== undefined) {
  15874. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15875. }
  15876. else if (document.msFullscreenElement !== undefined) {
  15877. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15878. }
  15879. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15880. _this.exitVR();
  15881. if (!_this._useCustomVRButton) {
  15882. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15883. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15884. }
  15885. }
  15886. };
  15887. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15888. this.beforeRender = function () {
  15889. if (_this._leftController && _this._leftController._activePointer) {
  15890. _this._castRayAndSelectObject(_this._leftController);
  15891. }
  15892. if (_this._rightController && _this._rightController._activePointer) {
  15893. _this._castRayAndSelectObject(_this._rightController);
  15894. }
  15895. if (_this._noControllerIsActive) {
  15896. _this._castRayAndSelectObject(_this._cameraGazer);
  15897. }
  15898. else {
  15899. _this._cameraGazer._gazeTracker.isVisible = false;
  15900. }
  15901. };
  15902. this._onNewGamepadConnected = function (gamepad) {
  15903. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15904. if (gamepad.leftStick) {
  15905. gamepad.onleftstickchanged(function (stickValues) {
  15906. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15907. // Listening to classic/xbox gamepad only if no VR controller is active
  15908. if ((!_this._leftController && !_this._rightController) ||
  15909. ((_this._leftController && !_this._leftController._activePointer) &&
  15910. (_this._rightController && !_this._rightController._activePointer))) {
  15911. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15912. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15913. }
  15914. }
  15915. });
  15916. }
  15917. if (gamepad.rightStick) {
  15918. gamepad.onrightstickchanged(function (stickValues) {
  15919. if (_this._teleportationInitialized) {
  15920. _this._checkRotate(stickValues, _this._cameraGazer);
  15921. }
  15922. });
  15923. }
  15924. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15925. gamepad.onbuttondown(function (buttonPressed) {
  15926. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15927. _this._cameraGazer._selectionPointerDown();
  15928. }
  15929. });
  15930. gamepad.onbuttonup(function (buttonPressed) {
  15931. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15932. _this._cameraGazer._selectionPointerUp();
  15933. }
  15934. });
  15935. }
  15936. }
  15937. else {
  15938. var webVRController = gamepad;
  15939. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15940. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15941. _this._rightController = controller;
  15942. }
  15943. else {
  15944. _this._leftController = controller;
  15945. }
  15946. _this._tryEnableInteractionOnController(controller);
  15947. }
  15948. };
  15949. // 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
  15950. this._tryEnableInteractionOnController = function (controller) {
  15951. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15952. _this._enableInteractionOnController(controller);
  15953. }
  15954. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15955. _this._enableTeleportationOnController(controller);
  15956. }
  15957. };
  15958. this._onNewGamepadDisconnected = function (gamepad) {
  15959. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15960. if (gamepad.hand === "left" && _this._leftController != null) {
  15961. _this._leftController.dispose();
  15962. _this._leftController = null;
  15963. }
  15964. if (gamepad.hand === "right" && _this._rightController != null) {
  15965. _this._rightController.dispose();
  15966. _this._rightController = null;
  15967. }
  15968. }
  15969. };
  15970. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15971. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15972. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15973. this._scene = scene;
  15974. this._canvas = scene.getEngine().getRenderingCanvas();
  15975. // Parse options
  15976. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15977. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15978. }
  15979. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15980. webVROptions.createDeviceOrientationCamera = true;
  15981. }
  15982. if (webVROptions.laserToggle === undefined) {
  15983. webVROptions.laserToggle = true;
  15984. }
  15985. if (webVROptions.defaultHeight === undefined) {
  15986. webVROptions.defaultHeight = 1.7;
  15987. }
  15988. if (webVROptions.useCustomVRButton) {
  15989. this._useCustomVRButton = true;
  15990. if (webVROptions.customVRButton) {
  15991. this._btnVR = webVROptions.customVRButton;
  15992. }
  15993. }
  15994. if (webVROptions.rayLength) {
  15995. this._rayLength = webVROptions.rayLength;
  15996. }
  15997. this._defaultHeight = webVROptions.defaultHeight;
  15998. if (webVROptions.positionScale) {
  15999. this._rayLength *= webVROptions.positionScale;
  16000. this._defaultHeight *= webVROptions.positionScale;
  16001. }
  16002. this._hasEnteredVR = false;
  16003. // Set position
  16004. if (this._scene.activeCamera) {
  16005. this._position = this._scene.activeCamera.position.clone();
  16006. }
  16007. else {
  16008. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16009. }
  16010. // Set non-vr camera
  16011. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16012. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16013. // Copy data from existing camera
  16014. if (this._scene.activeCamera) {
  16015. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16016. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16017. // Set rotation from previous camera
  16018. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16019. var targetCamera = this._scene.activeCamera;
  16020. if (targetCamera.rotationQuaternion) {
  16021. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16022. }
  16023. else {
  16024. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16025. }
  16026. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16027. }
  16028. }
  16029. this._scene.activeCamera = this._deviceOrientationCamera;
  16030. if (this._canvas) {
  16031. this._scene.activeCamera.attachControl(this._canvas);
  16032. }
  16033. }
  16034. else {
  16035. this._existingCamera = this._scene.activeCamera;
  16036. }
  16037. // Create VR cameras
  16038. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16039. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16040. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16041. }
  16042. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16043. this._webVRCamera.useStandingMatrix();
  16044. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16045. // Create default button
  16046. if (!this._useCustomVRButton) {
  16047. this._btnVR = document.createElement("BUTTON");
  16048. this._btnVR.className = "babylonVRicon";
  16049. this._btnVR.id = "babylonVRiconbtn";
  16050. this._btnVR.title = "Click to switch to VR";
  16051. 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) }";
  16052. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16053. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16054. // css += ".babylonVRicon.vrdisplaysupported { }";
  16055. // css += ".babylonVRicon.vrdisplayready { }";
  16056. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16057. var style = document.createElement('style');
  16058. style.appendChild(document.createTextNode(css));
  16059. document.getElementsByTagName('head')[0].appendChild(style);
  16060. this.moveButtonToBottomRight();
  16061. }
  16062. // VR button click event
  16063. if (this._btnVR) {
  16064. this._btnVR.addEventListener("click", function () {
  16065. if (!_this.isInVRMode) {
  16066. _this.enterVR();
  16067. }
  16068. else {
  16069. _this.exitVR();
  16070. }
  16071. });
  16072. }
  16073. // Window events
  16074. window.addEventListener("resize", this._onResize);
  16075. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16076. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16077. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16078. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16079. document.onmsfullscreenchange = this._onFullscreenChange;
  16080. // Display vr button when headset is connected
  16081. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16082. this.displayVRButton();
  16083. }
  16084. else {
  16085. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16086. if (e.vrDisplay) {
  16087. _this.displayVRButton();
  16088. }
  16089. });
  16090. }
  16091. // Exiting VR mode using 'ESC' key on desktop
  16092. this._onKeyDown = function (event) {
  16093. if (event.keyCode === 27 && _this.isInVRMode) {
  16094. _this.exitVR();
  16095. }
  16096. };
  16097. document.addEventListener("keydown", this._onKeyDown);
  16098. // Exiting VR mode double tapping the touch screen
  16099. this._scene.onPrePointerObservable.add(function () {
  16100. if (_this.isInVRMode) {
  16101. _this.exitVR();
  16102. if (_this._fullscreenVRpresenting) {
  16103. _this._scene.getEngine().switchFullscreen(true);
  16104. }
  16105. }
  16106. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16107. // Listen for WebVR display changes
  16108. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16109. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16110. this._onVRRequestPresentStart = function () {
  16111. _this._webVRrequesting = true;
  16112. _this.updateButtonVisibility();
  16113. };
  16114. this._onVRRequestPresentComplete = function () {
  16115. _this._webVRrequesting = false;
  16116. _this.updateButtonVisibility();
  16117. };
  16118. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16119. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16120. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16121. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16122. scene.onDisposeObservable.add(function () {
  16123. _this.dispose();
  16124. });
  16125. // Gamepad connection events
  16126. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16127. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16128. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16129. this.updateButtonVisibility();
  16130. //create easing functions
  16131. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16132. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16133. if (this.webVROptions.floorMeshes) {
  16134. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16135. }
  16136. }
  16137. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16138. /** Return this.onEnteringVRObservable
  16139. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16140. */
  16141. get: function () {
  16142. return this.onEnteringVRObservable;
  16143. },
  16144. enumerable: true,
  16145. configurable: true
  16146. });
  16147. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16148. /** Return this.onExitingVRObservable
  16149. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16150. */
  16151. get: function () {
  16152. return this.onExitingVRObservable;
  16153. },
  16154. enumerable: true,
  16155. configurable: true
  16156. });
  16157. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16158. /** Return this.onControllerMeshLoadedObservable
  16159. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16160. */
  16161. get: function () {
  16162. return this.onControllerMeshLoadedObservable;
  16163. },
  16164. enumerable: true,
  16165. configurable: true
  16166. });
  16167. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16168. /**
  16169. * The mesh used to display where the user is going to teleport.
  16170. */
  16171. get: function () {
  16172. return this._teleportationTarget;
  16173. },
  16174. /**
  16175. * Sets the mesh to be used to display where the user is going to teleport.
  16176. */
  16177. set: function (value) {
  16178. if (value) {
  16179. value.name = "teleportationTarget";
  16180. this._isDefaultTeleportationTarget = false;
  16181. this._teleportationTarget = value;
  16182. }
  16183. },
  16184. enumerable: true,
  16185. configurable: true
  16186. });
  16187. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16188. /**
  16189. * 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
  16190. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16191. * See http://doc.babylonjs.com/resources/baking_transformations
  16192. */
  16193. get: function () {
  16194. return this._cameraGazer._gazeTracker;
  16195. },
  16196. set: function (value) {
  16197. if (value) {
  16198. // Dispose of existing meshes
  16199. if (this._cameraGazer._gazeTracker) {
  16200. this._cameraGazer._gazeTracker.dispose();
  16201. }
  16202. if (this._leftController && this._leftController._gazeTracker) {
  16203. this._leftController._gazeTracker.dispose();
  16204. }
  16205. if (this._rightController && this._rightController._gazeTracker) {
  16206. this._rightController._gazeTracker.dispose();
  16207. }
  16208. // Set and create gaze trackers on head and controllers
  16209. this._cameraGazer._gazeTracker = value;
  16210. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16211. this._cameraGazer._gazeTracker.isPickable = false;
  16212. this._cameraGazer._gazeTracker.isVisible = false;
  16213. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16214. if (this._leftController) {
  16215. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16216. }
  16217. if (this._rightController) {
  16218. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16219. }
  16220. }
  16221. },
  16222. enumerable: true,
  16223. configurable: true
  16224. });
  16225. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16226. /**
  16227. * The gaze tracking mesh corresponding to the left controller
  16228. */
  16229. get: function () {
  16230. if (this._leftController) {
  16231. return this._leftController._gazeTracker;
  16232. }
  16233. return null;
  16234. },
  16235. enumerable: true,
  16236. configurable: true
  16237. });
  16238. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16239. /**
  16240. * The gaze tracking mesh corresponding to the right controller
  16241. */
  16242. get: function () {
  16243. if (this._rightController) {
  16244. return this._rightController._gazeTracker;
  16245. }
  16246. return null;
  16247. },
  16248. enumerable: true,
  16249. configurable: true
  16250. });
  16251. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16252. /**
  16253. * If the ray of the gaze should be displayed.
  16254. */
  16255. get: function () {
  16256. return this._displayGaze;
  16257. },
  16258. /**
  16259. * Sets if the ray of the gaze should be displayed.
  16260. */
  16261. set: function (value) {
  16262. this._displayGaze = value;
  16263. if (!value) {
  16264. this._cameraGazer._gazeTracker.isVisible = false;
  16265. if (this._leftController) {
  16266. this._leftController._gazeTracker.isVisible = false;
  16267. }
  16268. if (this._rightController) {
  16269. this._rightController._gazeTracker.isVisible = false;
  16270. }
  16271. }
  16272. },
  16273. enumerable: true,
  16274. configurable: true
  16275. });
  16276. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16277. /**
  16278. * If the ray of the LaserPointer should be displayed.
  16279. */
  16280. get: function () {
  16281. return this._displayLaserPointer;
  16282. },
  16283. /**
  16284. * Sets if the ray of the LaserPointer should be displayed.
  16285. */
  16286. set: function (value) {
  16287. this._displayLaserPointer = value;
  16288. if (!value) {
  16289. if (this._rightController) {
  16290. this._rightController._deactivatePointer();
  16291. this._rightController._gazeTracker.isVisible = false;
  16292. }
  16293. if (this._leftController) {
  16294. this._leftController._deactivatePointer();
  16295. this._leftController._gazeTracker.isVisible = false;
  16296. }
  16297. }
  16298. else {
  16299. if (this._rightController) {
  16300. this._rightController._activatePointer();
  16301. }
  16302. if (this._leftController) {
  16303. this._leftController._activatePointer();
  16304. }
  16305. }
  16306. },
  16307. enumerable: true,
  16308. configurable: true
  16309. });
  16310. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16311. /**
  16312. * The deviceOrientationCamera used as the camera when not in VR.
  16313. */
  16314. get: function () {
  16315. return this._deviceOrientationCamera;
  16316. },
  16317. enumerable: true,
  16318. configurable: true
  16319. });
  16320. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16321. /**
  16322. * Based on the current WebVR support, returns the current VR camera used.
  16323. */
  16324. get: function () {
  16325. if (this._webVRready) {
  16326. return this._webVRCamera;
  16327. }
  16328. else {
  16329. return this._scene.activeCamera;
  16330. }
  16331. },
  16332. enumerable: true,
  16333. configurable: true
  16334. });
  16335. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16336. /**
  16337. * The webVRCamera which is used when in VR.
  16338. */
  16339. get: function () {
  16340. return this._webVRCamera;
  16341. },
  16342. enumerable: true,
  16343. configurable: true
  16344. });
  16345. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16346. /**
  16347. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16348. */
  16349. get: function () {
  16350. return this._vrDeviceOrientationCamera;
  16351. },
  16352. enumerable: true,
  16353. configurable: true
  16354. });
  16355. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16356. get: function () {
  16357. var result = this._cameraGazer._teleportationRequestInitiated
  16358. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16359. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16360. return result;
  16361. },
  16362. enumerable: true,
  16363. configurable: true
  16364. });
  16365. // Raised when one of the controller has loaded successfully its associated default mesh
  16366. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16367. if (this._leftController && this._leftController.webVRController == webVRController) {
  16368. if (webVRController.mesh) {
  16369. this._leftController._setLaserPointerParent(webVRController.mesh);
  16370. }
  16371. }
  16372. if (this._rightController && this._rightController.webVRController == webVRController) {
  16373. if (webVRController.mesh) {
  16374. this._rightController._setLaserPointerParent(webVRController.mesh);
  16375. }
  16376. }
  16377. try {
  16378. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16379. }
  16380. catch (err) {
  16381. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16382. }
  16383. };
  16384. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16385. /**
  16386. * Gets a value indicating if we are currently in VR mode.
  16387. */
  16388. get: function () {
  16389. return this._webVRpresenting || this._fullscreenVRpresenting;
  16390. },
  16391. enumerable: true,
  16392. configurable: true
  16393. });
  16394. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16395. var vrDisplay = this._scene.getEngine().getVRDevice();
  16396. if (vrDisplay) {
  16397. var wasPresenting = this._webVRpresenting;
  16398. this._webVRpresenting = vrDisplay.isPresenting;
  16399. if (wasPresenting && !this._webVRpresenting) {
  16400. this.exitVR();
  16401. }
  16402. }
  16403. else {
  16404. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16405. }
  16406. this.updateButtonVisibility();
  16407. };
  16408. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16409. this._webVRsupported = eventArgs.vrSupported;
  16410. this._webVRready = !!eventArgs.vrDisplay;
  16411. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16412. this.updateButtonVisibility();
  16413. };
  16414. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16415. if (this._canvas && !this._useCustomVRButton) {
  16416. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16417. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16418. }
  16419. };
  16420. VRExperienceHelper.prototype.displayVRButton = function () {
  16421. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16422. document.body.appendChild(this._btnVR);
  16423. this._btnVRDisplayed = true;
  16424. }
  16425. };
  16426. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16427. if (!this._btnVR || this._useCustomVRButton) {
  16428. return;
  16429. }
  16430. this._btnVR.className = "babylonVRicon";
  16431. if (this.isInVRMode) {
  16432. this._btnVR.className += " vrdisplaypresenting";
  16433. }
  16434. else {
  16435. if (this._webVRready) {
  16436. this._btnVR.className += " vrdisplayready";
  16437. }
  16438. if (this._webVRsupported) {
  16439. this._btnVR.className += " vrdisplaysupported";
  16440. }
  16441. if (this._webVRrequesting) {
  16442. this._btnVR.className += " vrdisplayrequesting";
  16443. }
  16444. }
  16445. };
  16446. /**
  16447. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16448. * Otherwise, will use the fullscreen API.
  16449. */
  16450. VRExperienceHelper.prototype.enterVR = function () {
  16451. if (this.onEnteringVRObservable) {
  16452. try {
  16453. this.onEnteringVRObservable.notifyObservers(this);
  16454. }
  16455. catch (err) {
  16456. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16457. }
  16458. }
  16459. if (this._scene.activeCamera) {
  16460. this._position = this._scene.activeCamera.position.clone();
  16461. if (this.vrDeviceOrientationCamera) {
  16462. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16463. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16464. }
  16465. if (this.webVRCamera) {
  16466. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16467. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16468. var delta = desiredYRotation - currentYRotation;
  16469. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16470. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16471. }
  16472. // make sure that we return to the last active camera
  16473. this._existingCamera = this._scene.activeCamera;
  16474. // Remove and cache angular sensability to avoid camera rotation when in VR
  16475. if (this._existingCamera.angularSensibilityX) {
  16476. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16477. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16478. }
  16479. if (this._existingCamera.angularSensibilityY) {
  16480. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16481. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16482. }
  16483. if (this._existingCamera.angularSensibility) {
  16484. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16485. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16486. }
  16487. }
  16488. if (this._webVRrequesting) {
  16489. return;
  16490. }
  16491. // If WebVR is supported and a headset is connected
  16492. if (this._webVRready) {
  16493. if (!this._webVRpresenting) {
  16494. this._webVRCamera.position = this._position;
  16495. this._scene.activeCamera = this._webVRCamera;
  16496. }
  16497. }
  16498. else if (this._vrDeviceOrientationCamera) {
  16499. this._vrDeviceOrientationCamera.position = this._position;
  16500. if (this._scene.activeCamera) {
  16501. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16502. }
  16503. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16504. this._scene.getEngine().switchFullscreen(true);
  16505. this.updateButtonVisibility();
  16506. }
  16507. if (this._scene.activeCamera && this._canvas) {
  16508. this._scene.activeCamera.attachControl(this._canvas);
  16509. }
  16510. if (this._interactionsEnabled) {
  16511. this._scene.registerBeforeRender(this.beforeRender);
  16512. }
  16513. if (this._displayLaserPointer) {
  16514. [this._leftController, this._rightController].forEach(function (controller) {
  16515. if (controller) {
  16516. controller._activatePointer();
  16517. }
  16518. });
  16519. }
  16520. this._hasEnteredVR = true;
  16521. };
  16522. /**
  16523. * Attempt to exit VR, or fullscreen.
  16524. */
  16525. VRExperienceHelper.prototype.exitVR = function () {
  16526. if (this._hasEnteredVR) {
  16527. if (this.onExitingVRObservable) {
  16528. try {
  16529. this.onExitingVRObservable.notifyObservers(this);
  16530. }
  16531. catch (err) {
  16532. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16533. }
  16534. }
  16535. if (this._webVRpresenting) {
  16536. this._scene.getEngine().disableVR();
  16537. }
  16538. if (this._scene.activeCamera) {
  16539. this._position = this._scene.activeCamera.position.clone();
  16540. }
  16541. if (this.vrDeviceOrientationCamera) {
  16542. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16543. }
  16544. if (this._deviceOrientationCamera) {
  16545. this._deviceOrientationCamera.position = this._position;
  16546. this._scene.activeCamera = this._deviceOrientationCamera;
  16547. if (this._canvas) {
  16548. this._scene.activeCamera.attachControl(this._canvas);
  16549. }
  16550. // Restore angular sensibility
  16551. if (this._cachedAngularSensibility.angularSensibilityX) {
  16552. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16553. this._cachedAngularSensibility.angularSensibilityX = null;
  16554. }
  16555. if (this._cachedAngularSensibility.angularSensibilityY) {
  16556. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16557. this._cachedAngularSensibility.angularSensibilityY = null;
  16558. }
  16559. if (this._cachedAngularSensibility.angularSensibility) {
  16560. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16561. this._cachedAngularSensibility.angularSensibility = null;
  16562. }
  16563. }
  16564. else if (this._existingCamera) {
  16565. this._existingCamera.position = this._position;
  16566. this._scene.activeCamera = this._existingCamera;
  16567. // Restore angular sensibility
  16568. if (this._cachedAngularSensibility.angularSensibilityX) {
  16569. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16570. this._cachedAngularSensibility.angularSensibilityX = null;
  16571. }
  16572. if (this._cachedAngularSensibility.angularSensibilityY) {
  16573. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16574. this._cachedAngularSensibility.angularSensibilityY = null;
  16575. }
  16576. if (this._cachedAngularSensibility.angularSensibility) {
  16577. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16578. this._cachedAngularSensibility.angularSensibility = null;
  16579. }
  16580. }
  16581. this.updateButtonVisibility();
  16582. if (this._interactionsEnabled) {
  16583. this._scene.unregisterBeforeRender(this.beforeRender);
  16584. this._cameraGazer._gazeTracker.isVisible = false;
  16585. if (this._leftController) {
  16586. this._leftController._gazeTracker.isVisible = false;
  16587. }
  16588. if (this._rightController) {
  16589. this._rightController._gazeTracker.isVisible = false;
  16590. }
  16591. }
  16592. // resize to update width and height when exiting vr exits fullscreen
  16593. this._scene.getEngine().resize();
  16594. [this._leftController, this._rightController].forEach(function (controller) {
  16595. if (controller) {
  16596. controller._deactivatePointer();
  16597. }
  16598. });
  16599. this._hasEnteredVR = false;
  16600. }
  16601. };
  16602. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16603. /**
  16604. * The position of the vr experience helper.
  16605. */
  16606. get: function () {
  16607. return this._position;
  16608. },
  16609. /**
  16610. * Sets the position of the vr experience helper.
  16611. */
  16612. set: function (value) {
  16613. this._position = value;
  16614. if (this._scene.activeCamera) {
  16615. this._scene.activeCamera.position = value;
  16616. }
  16617. },
  16618. enumerable: true,
  16619. configurable: true
  16620. });
  16621. /**
  16622. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16623. */
  16624. VRExperienceHelper.prototype.enableInteractions = function () {
  16625. var _this = this;
  16626. if (!this._interactionsEnabled) {
  16627. this._interactionsRequested = true;
  16628. if (this._leftController) {
  16629. this._enableInteractionOnController(this._leftController);
  16630. }
  16631. if (this._rightController) {
  16632. this._enableInteractionOnController(this._rightController);
  16633. }
  16634. this.raySelectionPredicate = function (mesh) {
  16635. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16636. };
  16637. this.meshSelectionPredicate = function () {
  16638. return true;
  16639. };
  16640. this._raySelectionPredicate = function (mesh) {
  16641. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16642. && mesh.name.indexOf("teleportationTarget") === -1
  16643. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16644. return _this.raySelectionPredicate(mesh);
  16645. }
  16646. return false;
  16647. };
  16648. this._interactionsEnabled = true;
  16649. }
  16650. };
  16651. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16652. get: function () {
  16653. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16654. },
  16655. enumerable: true,
  16656. configurable: true
  16657. });
  16658. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16659. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16660. if (this._floorMeshesCollection[i].id === mesh.id) {
  16661. return true;
  16662. }
  16663. }
  16664. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16665. return true;
  16666. }
  16667. return false;
  16668. };
  16669. /**
  16670. * Adds a floor mesh to be used for teleportation.
  16671. * @param floorMesh the mesh to be used for teleportation.
  16672. */
  16673. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16674. if (!this._floorMeshesCollection) {
  16675. return;
  16676. }
  16677. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16678. return;
  16679. }
  16680. this._floorMeshesCollection.push(floorMesh);
  16681. };
  16682. /**
  16683. * Removes a floor mesh from being used for teleportation.
  16684. * @param floorMesh the mesh to be removed.
  16685. */
  16686. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16687. if (!this._floorMeshesCollection) {
  16688. return;
  16689. }
  16690. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16691. if (meshIndex !== -1) {
  16692. this._floorMeshesCollection.splice(meshIndex, 1);
  16693. }
  16694. };
  16695. /**
  16696. * Enables interactions and teleportation using the VR controllers and gaze.
  16697. * @param vrTeleportationOptions options to modify teleportation behavior.
  16698. */
  16699. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16700. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16701. if (!this._teleportationInitialized) {
  16702. this._teleportationRequested = true;
  16703. this.enableInteractions();
  16704. if (vrTeleportationOptions.floorMeshName) {
  16705. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16706. }
  16707. if (vrTeleportationOptions.floorMeshes) {
  16708. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16709. }
  16710. if (this._leftController != null) {
  16711. this._enableTeleportationOnController(this._leftController);
  16712. }
  16713. if (this._rightController != null) {
  16714. this._enableTeleportationOnController(this._rightController);
  16715. }
  16716. // Creates an image processing post process for the vignette not relying
  16717. // on the main scene configuration for image processing to reduce setup and spaces
  16718. // (gamma/linear) conflicts.
  16719. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16720. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16721. imageProcessingConfiguration.vignetteEnabled = true;
  16722. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16723. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16724. this._teleportationInitialized = true;
  16725. if (this._isDefaultTeleportationTarget) {
  16726. this._createTeleportationCircles();
  16727. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16728. }
  16729. }
  16730. };
  16731. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16732. var _this = this;
  16733. var controllerMesh = controller.webVRController.mesh;
  16734. if (controllerMesh) {
  16735. controller._interactionsEnabled = true;
  16736. if (this.isInVRMode && this._displayLaserPointer) {
  16737. controller._activatePointer();
  16738. }
  16739. if (this.webVROptions.laserToggle) {
  16740. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16741. // Enabling / disabling laserPointer
  16742. if (_this._displayLaserPointer && stateObject.value === 1) {
  16743. if (controller._activePointer) {
  16744. controller._deactivatePointer();
  16745. }
  16746. else {
  16747. controller._activatePointer();
  16748. }
  16749. if (_this.displayGaze) {
  16750. controller._gazeTracker.isVisible = controller._activePointer;
  16751. }
  16752. }
  16753. });
  16754. }
  16755. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16756. var gazer = controller;
  16757. if (_this._noControllerIsActive) {
  16758. gazer = _this._cameraGazer;
  16759. }
  16760. if (!gazer._pointerDownOnMeshAsked) {
  16761. if (stateObject.value > _this._padSensibilityUp) {
  16762. gazer._selectionPointerDown();
  16763. }
  16764. }
  16765. else if (stateObject.value < _this._padSensibilityDown) {
  16766. gazer._selectionPointerUp();
  16767. }
  16768. });
  16769. }
  16770. };
  16771. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16772. // Dont teleport if another gaze already requested teleportation
  16773. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16774. return;
  16775. }
  16776. if (!gazer._teleportationRequestInitiated) {
  16777. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16778. gazer._activatePointer();
  16779. gazer._teleportationRequestInitiated = true;
  16780. }
  16781. }
  16782. else {
  16783. // Listening to the proper controller values changes to confirm teleportation
  16784. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16785. if (this._teleportActive) {
  16786. this.teleportCamera(this._haloCenter);
  16787. }
  16788. gazer._teleportationRequestInitiated = false;
  16789. }
  16790. }
  16791. };
  16792. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16793. // Only rotate when user is not currently selecting a teleportation location
  16794. if (gazer._teleportationRequestInitiated) {
  16795. return;
  16796. }
  16797. if (!gazer._rotationLeftAsked) {
  16798. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16799. gazer._rotationLeftAsked = true;
  16800. if (this._rotationAllowed) {
  16801. this._rotateCamera(false);
  16802. }
  16803. }
  16804. }
  16805. else {
  16806. if (stateObject.x > -this._padSensibilityDown) {
  16807. gazer._rotationLeftAsked = false;
  16808. }
  16809. }
  16810. if (!gazer._rotationRightAsked) {
  16811. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16812. gazer._rotationRightAsked = true;
  16813. if (this._rotationAllowed) {
  16814. this._rotateCamera(true);
  16815. }
  16816. }
  16817. }
  16818. else {
  16819. if (stateObject.x < this._padSensibilityDown) {
  16820. gazer._rotationRightAsked = false;
  16821. }
  16822. }
  16823. };
  16824. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16825. // Only teleport backwards when user is not currently selecting a teleportation location
  16826. if (gazer._teleportationRequestInitiated) {
  16827. return;
  16828. }
  16829. // Teleport backwards
  16830. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16831. if (!gazer._teleportationBackRequestInitiated) {
  16832. if (!this.currentVRCamera) {
  16833. return;
  16834. }
  16835. // Get rotation and position of the current camera
  16836. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16837. var position = this.currentVRCamera.position;
  16838. // If the camera has device position, use that instead
  16839. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16840. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16841. position = this.currentVRCamera.devicePosition;
  16842. }
  16843. // Get matrix with only the y rotation of the device rotation
  16844. rotation.toEulerAnglesToRef(this._workingVector);
  16845. this._workingVector.z = 0;
  16846. this._workingVector.x = 0;
  16847. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16848. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16849. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16850. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16851. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16852. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16853. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16854. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16855. this.teleportCamera(hit.pickedPoint);
  16856. }
  16857. gazer._teleportationBackRequestInitiated = true;
  16858. }
  16859. }
  16860. else {
  16861. gazer._teleportationBackRequestInitiated = false;
  16862. }
  16863. };
  16864. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16865. var _this = this;
  16866. var controllerMesh = controller.webVRController.mesh;
  16867. if (controllerMesh) {
  16868. if (!controller._interactionsEnabled) {
  16869. this._enableInteractionOnController(controller);
  16870. }
  16871. controller._interactionsEnabled = true;
  16872. controller._teleportationEnabled = true;
  16873. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16874. controller._dpadPressed = false;
  16875. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16876. controller._dpadPressed = stateObject.pressed;
  16877. if (!controller._dpadPressed) {
  16878. controller._rotationLeftAsked = false;
  16879. controller._rotationRightAsked = false;
  16880. controller._teleportationBackRequestInitiated = false;
  16881. }
  16882. });
  16883. }
  16884. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16885. if (_this.teleportationEnabled) {
  16886. _this._checkTeleportBackwards(stateObject, controller);
  16887. _this._checkTeleportWithRay(stateObject, controller);
  16888. }
  16889. _this._checkRotate(stateObject, controller);
  16890. });
  16891. }
  16892. };
  16893. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16894. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16895. this._teleportationTarget.isPickable = false;
  16896. var length = 512;
  16897. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16898. dynamicTexture.hasAlpha = true;
  16899. var context = dynamicTexture.getContext();
  16900. var centerX = length / 2;
  16901. var centerY = length / 2;
  16902. var radius = 200;
  16903. context.beginPath();
  16904. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16905. context.fillStyle = this._teleportationFillColor;
  16906. context.fill();
  16907. context.lineWidth = 10;
  16908. context.strokeStyle = this._teleportationBorderColor;
  16909. context.stroke();
  16910. context.closePath();
  16911. dynamicTexture.update();
  16912. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16913. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16914. this._teleportationTarget.material = teleportationCircleMaterial;
  16915. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16916. torus.isPickable = false;
  16917. torus.parent = this._teleportationTarget;
  16918. var animationInnerCircle = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationInnerCircle", "position.y", 30, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  16919. var keys = [];
  16920. keys.push({
  16921. frame: 0,
  16922. value: 0
  16923. });
  16924. keys.push({
  16925. frame: 30,
  16926. value: 0.4
  16927. });
  16928. keys.push({
  16929. frame: 60,
  16930. value: 0
  16931. });
  16932. animationInnerCircle.setKeys(keys);
  16933. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16934. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16935. animationInnerCircle.setEasingFunction(easingFunction);
  16936. torus.animations = [];
  16937. torus.animations.push(animationInnerCircle);
  16938. this._scene.beginAnimation(torus, 0, 60, true);
  16939. this._hideTeleportationTarget();
  16940. };
  16941. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16942. this._teleportActive = true;
  16943. if (this._teleportationInitialized) {
  16944. this._teleportationTarget.isVisible = true;
  16945. if (this._isDefaultTeleportationTarget) {
  16946. this._teleportationTarget.getChildren()[0].isVisible = true;
  16947. }
  16948. }
  16949. };
  16950. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16951. this._teleportActive = false;
  16952. if (this._teleportationInitialized) {
  16953. this._teleportationTarget.isVisible = false;
  16954. if (this._isDefaultTeleportationTarget) {
  16955. this._teleportationTarget.getChildren()[0].isVisible = false;
  16956. }
  16957. }
  16958. };
  16959. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16960. var _this = this;
  16961. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16962. return;
  16963. }
  16964. if (right) {
  16965. this._rotationAngle++;
  16966. }
  16967. else {
  16968. this._rotationAngle--;
  16969. }
  16970. this.currentVRCamera.animations = [];
  16971. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16972. var animationRotation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationRotation", "rotationQuaternion", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_QUATERNION, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  16973. var animationRotationKeys = [];
  16974. animationRotationKeys.push({
  16975. frame: 0,
  16976. value: this.currentVRCamera.rotationQuaternion
  16977. });
  16978. animationRotationKeys.push({
  16979. frame: 6,
  16980. value: target
  16981. });
  16982. animationRotation.setKeys(animationRotationKeys);
  16983. animationRotation.setEasingFunction(this._circleEase);
  16984. this.currentVRCamera.animations.push(animationRotation);
  16985. this._postProcessMove.animations = [];
  16986. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  16987. var vignetteWeightKeys = [];
  16988. vignetteWeightKeys.push({
  16989. frame: 0,
  16990. value: 0
  16991. });
  16992. vignetteWeightKeys.push({
  16993. frame: 3,
  16994. value: 4
  16995. });
  16996. vignetteWeightKeys.push({
  16997. frame: 6,
  16998. value: 0
  16999. });
  17000. animationPP.setKeys(vignetteWeightKeys);
  17001. animationPP.setEasingFunction(this._circleEase);
  17002. this._postProcessMove.animations.push(animationPP);
  17003. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17004. var vignetteStretchKeys = [];
  17005. vignetteStretchKeys.push({
  17006. frame: 0,
  17007. value: 0
  17008. });
  17009. vignetteStretchKeys.push({
  17010. frame: 3,
  17011. value: 10
  17012. });
  17013. vignetteStretchKeys.push({
  17014. frame: 6,
  17015. value: 0
  17016. });
  17017. animationPP2.setKeys(vignetteStretchKeys);
  17018. animationPP2.setEasingFunction(this._circleEase);
  17019. this._postProcessMove.animations.push(animationPP2);
  17020. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17021. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17022. this._postProcessMove.samples = 4;
  17023. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17024. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17025. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17026. });
  17027. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17028. };
  17029. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17030. if (hit.pickedPoint) {
  17031. if (gazer._teleportationRequestInitiated) {
  17032. this._displayTeleportationTarget();
  17033. this._haloCenter.copyFrom(hit.pickedPoint);
  17034. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17035. }
  17036. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17037. if (pickNormal) {
  17038. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17039. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17040. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17041. }
  17042. this._teleportationTarget.position.y += 0.1;
  17043. }
  17044. };
  17045. /**
  17046. * Teleports the users feet to the desired location
  17047. * @param location The location where the user's feet should be placed
  17048. */
  17049. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17050. var _this = this;
  17051. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17052. return;
  17053. }
  17054. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17055. // offset of the headset from the anchor.
  17056. if (this.webVRCamera.leftCamera) {
  17057. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17058. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17059. location.subtractToRef(this._workingVector, this._workingVector);
  17060. }
  17061. else {
  17062. this._workingVector.copyFrom(location);
  17063. }
  17064. // Add height to account for user's height offset
  17065. if (this.isInVRMode) {
  17066. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17067. }
  17068. else {
  17069. this._workingVector.y += this._defaultHeight;
  17070. }
  17071. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17072. // Create animation from the camera's position to the new location
  17073. this.currentVRCamera.animations = [];
  17074. var animationCameraTeleportation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationCameraTeleportation", "position", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_VECTOR3, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17075. var animationCameraTeleportationKeys = [{
  17076. frame: 0,
  17077. value: this.currentVRCamera.position
  17078. },
  17079. {
  17080. frame: 11,
  17081. value: this._workingVector
  17082. }
  17083. ];
  17084. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17085. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17086. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17087. this._postProcessMove.animations = [];
  17088. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17089. var vignetteWeightKeys = [];
  17090. vignetteWeightKeys.push({
  17091. frame: 0,
  17092. value: 0
  17093. });
  17094. vignetteWeightKeys.push({
  17095. frame: 5,
  17096. value: 8
  17097. });
  17098. vignetteWeightKeys.push({
  17099. frame: 11,
  17100. value: 0
  17101. });
  17102. animationPP.setKeys(vignetteWeightKeys);
  17103. this._postProcessMove.animations.push(animationPP);
  17104. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17105. var vignetteStretchKeys = [];
  17106. vignetteStretchKeys.push({
  17107. frame: 0,
  17108. value: 0
  17109. });
  17110. vignetteStretchKeys.push({
  17111. frame: 5,
  17112. value: 10
  17113. });
  17114. vignetteStretchKeys.push({
  17115. frame: 11,
  17116. value: 0
  17117. });
  17118. animationPP2.setKeys(vignetteStretchKeys);
  17119. this._postProcessMove.animations.push(animationPP2);
  17120. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17121. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17122. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17123. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17124. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17125. });
  17126. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17127. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17128. });
  17129. this._hideTeleportationTarget();
  17130. };
  17131. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17132. if (normal) {
  17133. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17134. if (angle < Math.PI / 2) {
  17135. normal.scaleInPlace(-1);
  17136. }
  17137. }
  17138. return normal;
  17139. };
  17140. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17141. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17142. return;
  17143. }
  17144. var ray = gazer._getForwardRay(this._rayLength);
  17145. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17146. if (hit) {
  17147. // Populate the contrllers mesh that can be used for drag/drop
  17148. if (gazer._laserPointer) {
  17149. hit.originMesh = gazer._laserPointer.parent;
  17150. }
  17151. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17152. }
  17153. gazer._currentHit = hit;
  17154. // Moving the gazeTracker on the mesh face targetted
  17155. if (hit && hit.pickedPoint) {
  17156. if (this._displayGaze) {
  17157. var multiplier = 1;
  17158. gazer._gazeTracker.isVisible = true;
  17159. if (gazer._isActionableMesh) {
  17160. multiplier = 3;
  17161. }
  17162. if (this.updateGazeTrackerScale) {
  17163. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17164. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17165. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17166. }
  17167. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17168. // To avoid z-fighting
  17169. var deltaFighting = 0.002;
  17170. if (pickNormal) {
  17171. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17172. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17173. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17174. }
  17175. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17176. if (gazer._gazeTracker.position.x < 0) {
  17177. gazer._gazeTracker.position.x += deltaFighting;
  17178. }
  17179. else {
  17180. gazer._gazeTracker.position.x -= deltaFighting;
  17181. }
  17182. if (gazer._gazeTracker.position.y < 0) {
  17183. gazer._gazeTracker.position.y += deltaFighting;
  17184. }
  17185. else {
  17186. gazer._gazeTracker.position.y -= deltaFighting;
  17187. }
  17188. if (gazer._gazeTracker.position.z < 0) {
  17189. gazer._gazeTracker.position.z += deltaFighting;
  17190. }
  17191. else {
  17192. gazer._gazeTracker.position.z -= deltaFighting;
  17193. }
  17194. }
  17195. // Changing the size of the laser pointer based on the distance from the targetted point
  17196. gazer._updatePointerDistance(hit.distance);
  17197. }
  17198. else {
  17199. gazer._updatePointerDistance();
  17200. gazer._gazeTracker.isVisible = false;
  17201. }
  17202. if (hit && hit.pickedMesh) {
  17203. // The object selected is the floor, we're in a teleportation scenario
  17204. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17205. // Moving the teleportation area to this targetted point
  17206. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17207. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17208. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17209. }
  17210. gazer._currentMeshSelected = null;
  17211. if (gazer._teleportationRequestInitiated) {
  17212. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17213. }
  17214. return;
  17215. }
  17216. // If not, we're in a selection scenario
  17217. //this._teleportationAllowed = false;
  17218. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17219. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17220. this.onNewMeshPicked.notifyObservers(hit);
  17221. gazer._currentMeshSelected = hit.pickedMesh;
  17222. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17223. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17224. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17225. gazer._isActionableMesh = true;
  17226. }
  17227. else {
  17228. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17229. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17230. gazer._isActionableMesh = false;
  17231. }
  17232. try {
  17233. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17234. }
  17235. catch (err) {
  17236. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17237. }
  17238. }
  17239. else {
  17240. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17241. gazer._currentMeshSelected = null;
  17242. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17243. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17244. }
  17245. }
  17246. }
  17247. else {
  17248. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17249. gazer._currentMeshSelected = null;
  17250. //this._teleportationAllowed = false;
  17251. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17252. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17253. }
  17254. };
  17255. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17256. if (mesh) {
  17257. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17258. }
  17259. };
  17260. /**
  17261. * Sets the color of the laser ray from the vr controllers.
  17262. * @param color new color for the ray.
  17263. */
  17264. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17265. if (this._leftController) {
  17266. this._leftController._setLaserPointerColor(color);
  17267. }
  17268. if (this._rightController) {
  17269. this._rightController._setLaserPointerColor(color);
  17270. }
  17271. };
  17272. /**
  17273. * Sets the color of the ray from the vr headsets gaze.
  17274. * @param color new color for the ray.
  17275. */
  17276. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17277. if (!this.updateGazeTrackerColor) {
  17278. return;
  17279. }
  17280. if (!this._cameraGazer._gazeTracker.material) {
  17281. return;
  17282. }
  17283. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17284. if (this._leftController) {
  17285. this._leftController._gazeTracker.material.emissiveColor = color;
  17286. }
  17287. if (this._rightController) {
  17288. this._rightController._gazeTracker.material.emissiveColor = color;
  17289. }
  17290. };
  17291. /**
  17292. * Exits VR and disposes of the vr experience helper
  17293. */
  17294. VRExperienceHelper.prototype.dispose = function () {
  17295. if (this.isInVRMode) {
  17296. this.exitVR();
  17297. }
  17298. if (this._postProcessMove) {
  17299. this._postProcessMove.dispose();
  17300. }
  17301. if (this._webVRCamera) {
  17302. this._webVRCamera.dispose();
  17303. }
  17304. if (this._vrDeviceOrientationCamera) {
  17305. this._vrDeviceOrientationCamera.dispose();
  17306. }
  17307. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17308. document.body.removeChild(this._btnVR);
  17309. }
  17310. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17311. this._deviceOrientationCamera.dispose();
  17312. }
  17313. if (this._cameraGazer) {
  17314. this._cameraGazer.dispose();
  17315. }
  17316. if (this._leftController) {
  17317. this._leftController.dispose();
  17318. }
  17319. if (this._rightController) {
  17320. this._rightController.dispose();
  17321. }
  17322. if (this._teleportationTarget) {
  17323. this._teleportationTarget.dispose();
  17324. }
  17325. this._floorMeshesCollection = [];
  17326. document.removeEventListener("keydown", this._onKeyDown);
  17327. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17328. window.removeEventListener("resize", this._onResize);
  17329. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17330. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17331. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17332. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17333. document.onmsfullscreenchange = null;
  17334. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17335. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17336. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17337. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17338. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17339. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17340. this._scene.unregisterBeforeRender(this.beforeRender);
  17341. };
  17342. /**
  17343. * Gets the name of the VRExperienceHelper class
  17344. * @returns "VRExperienceHelper"
  17345. */
  17346. VRExperienceHelper.prototype.getClassName = function () {
  17347. return "VRExperienceHelper";
  17348. };
  17349. return VRExperienceHelper;
  17350. }());
  17351. /***/ }),
  17352. /***/ "./Cameras/VR/webVRCamera.ts":
  17353. /*!***********************************!*\
  17354. !*** ./Cameras/VR/webVRCamera.ts ***!
  17355. \***********************************/
  17356. /*! exports provided: WebVRFreeCamera */
  17357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17358. "use strict";
  17359. __webpack_require__.r(__webpack_exports__);
  17360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17362. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17363. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17364. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17365. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17366. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17367. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17368. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17369. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17370. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17371. // Side effect import to define the stereoscopic mode.
  17372. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17373. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17374. });
  17375. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17376. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17377. });
  17378. /**
  17379. * This represents a WebVR camera.
  17380. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17381. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17382. */
  17383. var WebVRFreeCamera = /** @class */ (function (_super) {
  17384. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17385. /**
  17386. * Instantiates a WebVRFreeCamera.
  17387. * @param name The name of the WebVRFreeCamera
  17388. * @param position The starting anchor position for the camera
  17389. * @param scene The scene the camera belongs to
  17390. * @param webVROptions a set of customizable options for the webVRCamera
  17391. */
  17392. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17393. if (webVROptions === void 0) { webVROptions = {}; }
  17394. var _this = _super.call(this, name, position, scene) || this;
  17395. _this.webVROptions = webVROptions;
  17396. /**
  17397. * @hidden
  17398. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17399. */
  17400. _this._vrDevice = null;
  17401. /**
  17402. * The rawPose of the vrDevice.
  17403. */
  17404. _this.rawPose = null;
  17405. _this._specsVersion = "1.1";
  17406. _this._attached = false;
  17407. _this._descendants = [];
  17408. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17409. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17410. /** @hidden */
  17411. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17412. _this._standingMatrix = null;
  17413. /**
  17414. * Represents device position in babylon space.
  17415. */
  17416. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17417. /**
  17418. * Represents device rotation in babylon space.
  17419. */
  17420. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17421. /**
  17422. * The scale of the device to be used when translating from device space to babylon space.
  17423. */
  17424. _this.deviceScaleFactor = 1;
  17425. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17426. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17427. /**
  17428. * References to the webVR controllers for the vrDevice.
  17429. */
  17430. _this.controllers = [];
  17431. /**
  17432. * Emits an event when a controller is attached.
  17433. */
  17434. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17435. /**
  17436. * Emits an event when a controller's mesh has been loaded;
  17437. */
  17438. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17439. /**
  17440. * Emits an event when the HMD's pose has been updated.
  17441. */
  17442. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17443. _this._poseSet = false;
  17444. /**
  17445. * If the rig cameras be used as parent instead of this camera.
  17446. */
  17447. _this.rigParenting = true;
  17448. _this._defaultHeight = undefined;
  17449. _this._htmlElementAttached = null;
  17450. _this._detachIfAttached = function () {
  17451. var vrDisplay = _this.getEngine().getVRDevice();
  17452. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17453. _this.detachControl(_this._htmlElementAttached);
  17454. }
  17455. };
  17456. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17457. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17458. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17459. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17460. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17461. if (webVROptions.defaultHeight) {
  17462. _this._defaultHeight = webVROptions.defaultHeight;
  17463. _this.position.y = _this._defaultHeight;
  17464. }
  17465. _this.minZ = 0.1;
  17466. //legacy support - the compensation boolean was removed.
  17467. if (arguments.length === 5) {
  17468. _this.webVROptions = arguments[4];
  17469. }
  17470. // default webVR options
  17471. if (_this.webVROptions.trackPosition == undefined) {
  17472. _this.webVROptions.trackPosition = true;
  17473. }
  17474. if (_this.webVROptions.controllerMeshes == undefined) {
  17475. _this.webVROptions.controllerMeshes = true;
  17476. }
  17477. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17478. _this.webVROptions.defaultLightingOnControllers = true;
  17479. }
  17480. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17481. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17482. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17483. }
  17484. //enable VR
  17485. var engine = _this.getEngine();
  17486. _this._onVREnabled = function (success) { if (success) {
  17487. _this.initControllers();
  17488. } };
  17489. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17490. engine.initWebVR().add(function (event) {
  17491. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17492. return;
  17493. }
  17494. _this._vrDevice = event.vrDisplay;
  17495. //reset the rig parameters.
  17496. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17497. if (_this._attached) {
  17498. _this.getEngine().enableVR();
  17499. }
  17500. });
  17501. if (typeof (VRFrameData) !== "undefined") {
  17502. _this._frameData = new VRFrameData();
  17503. }
  17504. /**
  17505. * The idea behind the following lines:
  17506. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17507. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17508. * the second will not show it correctly.
  17509. *
  17510. * To solve this - each object that has the camera as parent will be added to a protected array.
  17511. * When the rig camera renders, it will take this array and set all of those to be its children.
  17512. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17513. * Amazing!
  17514. */
  17515. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17516. if (camera.parent === _this && _this.rigParenting) {
  17517. _this._descendants = _this.getDescendants(true, function (n) {
  17518. // don't take the cameras or the controllers!
  17519. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17520. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17521. return !isController && !isRigCamera;
  17522. });
  17523. _this._descendants.forEach(function (node) {
  17524. node.parent = camera;
  17525. });
  17526. }
  17527. });
  17528. scene.onAfterCameraRenderObservable.add(function (camera) {
  17529. if (camera.parent === _this && _this.rigParenting) {
  17530. _this._descendants.forEach(function (node) {
  17531. node.parent = _this;
  17532. });
  17533. }
  17534. });
  17535. return _this;
  17536. }
  17537. /**
  17538. * Gets the device distance from the ground in meters.
  17539. * @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.
  17540. */
  17541. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17542. if (this._standingMatrix) {
  17543. // Add standing matrix offset to get real offset from ground in room
  17544. this._standingMatrix.getTranslationToRef(this._workingVector);
  17545. return this._deviceRoomPosition.y + this._workingVector.y;
  17546. }
  17547. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17548. return this._defaultHeight || 0;
  17549. };
  17550. /**
  17551. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17552. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17553. */
  17554. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17555. var _this = this;
  17556. if (callback === void 0) { callback = function (bool) { }; }
  17557. // Use standing matrix if available
  17558. this.getEngine().initWebVRAsync().then(function (result) {
  17559. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17560. callback(false);
  17561. }
  17562. else {
  17563. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17564. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17565. if (!_this.getScene().useRightHandedSystem) {
  17566. if (_this._standingMatrix) {
  17567. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17568. }
  17569. }
  17570. callback(true);
  17571. }
  17572. });
  17573. };
  17574. /**
  17575. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17576. * @returns A promise with a boolean set to if the standing matrix is supported.
  17577. */
  17578. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17579. var _this = this;
  17580. return new Promise(function (res) {
  17581. _this.useStandingMatrix(function (supported) {
  17582. res(supported);
  17583. });
  17584. });
  17585. };
  17586. /**
  17587. * Disposes the camera
  17588. */
  17589. WebVRFreeCamera.prototype.dispose = function () {
  17590. this._detachIfAttached();
  17591. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17592. if (this._updateCacheWhenTrackingDisabledObserver) {
  17593. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17594. }
  17595. _super.prototype.dispose.call(this);
  17596. };
  17597. /**
  17598. * Gets a vrController by name.
  17599. * @param name The name of the controller to retreive
  17600. * @returns the controller matching the name specified or null if not found
  17601. */
  17602. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17603. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17604. var gp = _a[_i];
  17605. if (gp.hand === name) {
  17606. return gp;
  17607. }
  17608. }
  17609. return null;
  17610. };
  17611. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17612. /**
  17613. * The controller corrisponding to the users left hand.
  17614. */
  17615. get: function () {
  17616. if (!this._leftController) {
  17617. this._leftController = this.getControllerByName("left");
  17618. }
  17619. return this._leftController;
  17620. },
  17621. enumerable: true,
  17622. configurable: true
  17623. });
  17624. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17625. /**
  17626. * The controller corrisponding to the users right hand.
  17627. */
  17628. get: function () {
  17629. if (!this._rightController) {
  17630. this._rightController = this.getControllerByName("right");
  17631. }
  17632. return this._rightController;
  17633. },
  17634. enumerable: true,
  17635. configurable: true
  17636. });
  17637. /**
  17638. * Casts a ray forward from the vrCamera's gaze.
  17639. * @param length Length of the ray (default: 100)
  17640. * @returns the ray corrisponding to the gaze
  17641. */
  17642. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17643. if (length === void 0) { length = 100; }
  17644. if (this.leftCamera) {
  17645. // Use left eye to avoid computation to compute center on every call
  17646. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17647. }
  17648. else {
  17649. return _super.prototype.getForwardRay.call(this, length);
  17650. }
  17651. };
  17652. /**
  17653. * @hidden
  17654. * Updates the camera based on device's frame data
  17655. */
  17656. WebVRFreeCamera.prototype._checkInputs = function () {
  17657. if (this._vrDevice && this._vrDevice.isPresenting) {
  17658. this._vrDevice.getFrameData(this._frameData);
  17659. this.updateFromDevice(this._frameData.pose);
  17660. }
  17661. _super.prototype._checkInputs.call(this);
  17662. };
  17663. /**
  17664. * Updates the poseControlled values based on the input device pose.
  17665. * @param poseData Pose coming from the device
  17666. */
  17667. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17668. if (poseData && poseData.orientation) {
  17669. this.rawPose = poseData;
  17670. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17671. if (this.getScene().useRightHandedSystem) {
  17672. this._deviceRoomRotationQuaternion.z *= -1;
  17673. this._deviceRoomRotationQuaternion.w *= -1;
  17674. }
  17675. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17676. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17677. if (this.getScene().useRightHandedSystem) {
  17678. this._deviceRoomPosition.z *= -1;
  17679. }
  17680. }
  17681. this._poseSet = true;
  17682. }
  17683. };
  17684. /**
  17685. * WebVR's attach control will start broadcasting frames to the device.
  17686. * Note that in certain browsers (chrome for example) this function must be called
  17687. * within a user-interaction callback. Example:
  17688. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17689. *
  17690. * @param element html element to attach the vrDevice to
  17691. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17692. */
  17693. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17694. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17695. this._attached = true;
  17696. this._htmlElementAttached = element;
  17697. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17698. if (this._vrDevice) {
  17699. this.getEngine().enableVR();
  17700. }
  17701. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17702. };
  17703. /**
  17704. * Detaches the camera from the html element and disables VR
  17705. *
  17706. * @param element html element to detach from
  17707. */
  17708. WebVRFreeCamera.prototype.detachControl = function (element) {
  17709. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17710. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17711. _super.prototype.detachControl.call(this, element);
  17712. this._attached = false;
  17713. this.getEngine().disableVR();
  17714. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17715. };
  17716. /**
  17717. * @returns the name of this class
  17718. */
  17719. WebVRFreeCamera.prototype.getClassName = function () {
  17720. return "WebVRFreeCamera";
  17721. };
  17722. /**
  17723. * Calls resetPose on the vrDisplay
  17724. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17725. */
  17726. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17727. //uses the vrDisplay's "resetPose()".
  17728. //pitch and roll won't be affected.
  17729. this._vrDevice.resetPose();
  17730. };
  17731. /**
  17732. * @hidden
  17733. * Updates the rig cameras (left and right eye)
  17734. */
  17735. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17736. var camLeft = this._rigCameras[0];
  17737. var camRight = this._rigCameras[1];
  17738. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17739. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17740. camLeft.position.copyFrom(this._deviceRoomPosition);
  17741. camRight.position.copyFrom(this._deviceRoomPosition);
  17742. };
  17743. // Remove translation from 6dof headset if trackposition is set to false
  17744. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17745. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17746. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17747. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17748. if (!isViewMatrix) {
  17749. this._tmpMatrix.invert();
  17750. }
  17751. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17752. }
  17753. };
  17754. /**
  17755. * @hidden
  17756. * Updates the cached values of the camera
  17757. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17758. */
  17759. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17760. var _this = this;
  17761. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17762. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17763. if (!this.updateCacheCalled) {
  17764. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17765. this.updateCacheCalled = true;
  17766. this.update();
  17767. }
  17768. // Set working vector to the device position in room space rotated by the new rotation
  17769. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17770. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17771. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17772. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17773. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17774. // Add translation from anchor position
  17775. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17776. this._workingVector.addInPlace(this.position);
  17777. this._workingVector.subtractInPlace(this._cache.position);
  17778. this._deviceToWorld.setTranslation(this._workingVector);
  17779. // Set an inverted matrix to be used when updating the camera
  17780. this._deviceToWorld.invertToRef(this._worldToDevice);
  17781. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17782. this.controllers.forEach(function (controller) {
  17783. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17784. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17785. controller.update();
  17786. });
  17787. }
  17788. if (!ignoreParentClass) {
  17789. _super.prototype._updateCache.call(this);
  17790. }
  17791. this.updateCacheCalled = false;
  17792. };
  17793. /**
  17794. * @hidden
  17795. * Get current device position in babylon world
  17796. */
  17797. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17798. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17799. };
  17800. /**
  17801. * Updates the current device position and rotation in the babylon world
  17802. */
  17803. WebVRFreeCamera.prototype.update = function () {
  17804. this._computeDevicePosition();
  17805. // Get current device rotation in babylon world
  17806. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17807. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17808. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17809. if (this._poseSet) {
  17810. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17811. }
  17812. _super.prototype.update.call(this);
  17813. };
  17814. /**
  17815. * @hidden
  17816. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17817. * @returns an identity matrix
  17818. */
  17819. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17820. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17821. };
  17822. /**
  17823. * This function is called by the two RIG cameras.
  17824. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17825. * @hidden
  17826. */
  17827. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17828. // Update the parent camera prior to using a child camera to avoid desynchronization
  17829. var parentCamera = this._cameraRigParams["parentCamera"];
  17830. parentCamera._updateCache();
  17831. //WebVR 1.1
  17832. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17833. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17834. if (!this.getScene().useRightHandedSystem) {
  17835. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17836. }
  17837. // update the camera rotation matrix
  17838. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17839. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17840. // Computing target and final matrix
  17841. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17842. // should the view matrix be updated with scale and position offset?
  17843. if (parentCamera.deviceScaleFactor !== 1) {
  17844. this._webvrViewMatrix.invert();
  17845. // scale the position, if set
  17846. if (parentCamera.deviceScaleFactor) {
  17847. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17848. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17849. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17850. }
  17851. this._webvrViewMatrix.invert();
  17852. }
  17853. // Remove translation from 6dof headset if trackposition is set to false
  17854. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17855. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17856. // Compute global position
  17857. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17858. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17859. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17860. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17861. this._markSyncedWithParent();
  17862. return this._webvrViewMatrix;
  17863. };
  17864. /** @hidden */
  17865. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17866. var parentCamera = this.parent;
  17867. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17868. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17869. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17871. //babylon compatible matrix
  17872. if (!this.getScene().useRightHandedSystem) {
  17873. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17874. }
  17875. return this._projectionMatrix;
  17876. };
  17877. /**
  17878. * Initializes the controllers and their meshes
  17879. */
  17880. WebVRFreeCamera.prototype.initControllers = function () {
  17881. var _this = this;
  17882. this.controllers = [];
  17883. var manager = this.getScene().gamepadManager;
  17884. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17885. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17886. var webVrController = gamepad;
  17887. if (webVrController.defaultModel) {
  17888. webVrController.defaultModel.setEnabled(false);
  17889. }
  17890. if (webVrController.hand === "right") {
  17891. _this._rightController = null;
  17892. }
  17893. if (webVrController.hand === "left") {
  17894. _this._leftController = null;
  17895. }
  17896. var controllerIndex = _this.controllers.indexOf(webVrController);
  17897. if (controllerIndex !== -1) {
  17898. _this.controllers.splice(controllerIndex, 1);
  17899. }
  17900. }
  17901. });
  17902. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17903. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17904. var webVrController_1 = gamepad;
  17905. if (!_this.webVROptions.trackPosition) {
  17906. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17907. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17908. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17909. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17910. _this._updateCache();
  17911. });
  17912. }
  17913. }
  17914. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17915. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17916. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17917. if (_this.webVROptions.controllerMeshes) {
  17918. if (webVrController_1.defaultModel) {
  17919. webVrController_1.defaultModel.setEnabled(true);
  17920. }
  17921. else {
  17922. // Load the meshes
  17923. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17924. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17925. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17926. if (_this.webVROptions.defaultLightingOnControllers) {
  17927. if (!_this._lightOnControllers) {
  17928. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17929. }
  17930. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17931. var children = mesh.getChildren();
  17932. if (children && children.length !== 0) {
  17933. children.forEach(function (mesh) {
  17934. light.includedOnlyMeshes.push(mesh);
  17935. activateLightOnSubMeshes_1(mesh, light);
  17936. });
  17937. }
  17938. };
  17939. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17940. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17941. }
  17942. });
  17943. }
  17944. }
  17945. webVrController_1.attachToPoseControlledCamera(_this);
  17946. // since this is async - sanity check. Is the controller already stored?
  17947. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17948. //add to the controllers array
  17949. _this.controllers.push(webVrController_1);
  17950. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17951. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17952. // So we're overriding setting left & right manually to be sure
  17953. var firstViveWandDetected = false;
  17954. for (var i = 0; i < _this.controllers.length; i++) {
  17955. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17956. if (!firstViveWandDetected) {
  17957. firstViveWandDetected = true;
  17958. _this.controllers[i].hand = "left";
  17959. }
  17960. else {
  17961. _this.controllers[i].hand = "right";
  17962. }
  17963. }
  17964. }
  17965. //did we find enough controllers? Great! let the developer know.
  17966. if (_this.controllers.length >= 2) {
  17967. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17968. }
  17969. }
  17970. }
  17971. });
  17972. };
  17973. return WebVRFreeCamera;
  17974. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17975. /***/ }),
  17976. /***/ "./Cameras/XR/index.ts":
  17977. /*!*****************************!*\
  17978. !*** ./Cameras/XR/index.ts ***!
  17979. \*****************************/
  17980. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17982. "use strict";
  17983. __webpack_require__.r(__webpack_exports__);
  17984. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17986. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  17988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  17989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  17990. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  17992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  17993. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  17994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  17995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  17996. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  17997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  17998. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18000. /***/ }),
  18001. /***/ "./Cameras/XR/webXRCamera.ts":
  18002. /*!***********************************!*\
  18003. !*** ./Cameras/XR/webXRCamera.ts ***!
  18004. \***********************************/
  18005. /*! exports provided: WebXRCamera */
  18006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18007. "use strict";
  18008. __webpack_require__.r(__webpack_exports__);
  18009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18011. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18012. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18013. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18014. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18015. /**
  18016. * WebXR Camera which holds the views for the xrSession
  18017. * @see https://doc.babylonjs.com/how_to/webxr
  18018. */
  18019. var WebXRCamera = /** @class */ (function (_super) {
  18020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18021. /**
  18022. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18023. * @param name the name of the camera
  18024. * @param scene the scene to add the camera to
  18025. */
  18026. function WebXRCamera(name, scene) {
  18027. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18028. // Initial camera configuration
  18029. _this.minZ = 0;
  18030. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18031. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18032. _this.updateUpVectorFromRotation = true;
  18033. _this._updateNumberOfRigCameras(1);
  18034. return _this;
  18035. }
  18036. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18037. if (viewCount === void 0) { viewCount = 1; }
  18038. while (this.rigCameras.length < viewCount) {
  18039. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18040. newCamera.minZ = 0;
  18041. newCamera.parent = this;
  18042. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18043. newCamera.updateUpVectorFromRotation = true;
  18044. this.rigCameras.push(newCamera);
  18045. }
  18046. while (this.rigCameras.length > viewCount) {
  18047. var removedCamera = this.rigCameras.pop();
  18048. if (removedCamera) {
  18049. removedCamera.dispose();
  18050. }
  18051. }
  18052. };
  18053. /** @hidden */
  18054. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18055. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18056. // Create initial camera rigs
  18057. this._updateNumberOfRigCameras(2);
  18058. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18059. this.rigCameras[0].position.x = -pupilDistance / 2;
  18060. this.rigCameras[0].outputRenderTarget = null;
  18061. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18062. this.rigCameras[1].position.x = pupilDistance / 2;
  18063. this.rigCameras[1].outputRenderTarget = null;
  18064. };
  18065. /**
  18066. * Updates the cameras position from the current pose information of the XR session
  18067. * @param xrSessionManager the session containing pose information
  18068. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18069. */
  18070. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18071. var _this = this;
  18072. // Ensure all frame data is available
  18073. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18074. return false;
  18075. }
  18076. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18077. if (!pose || !pose.poseModelMatrix) {
  18078. return false;
  18079. }
  18080. // Update the parent cameras matrix
  18081. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18082. if (!this._scene.useRightHandedSystem) {
  18083. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18084. }
  18085. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18086. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18087. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18088. this.computeWorldMatrix();
  18089. // Update camera rigs
  18090. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18091. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18092. // Update view/projection matrix
  18093. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18094. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18095. if (!_this._scene.useRightHandedSystem) {
  18096. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18097. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18098. }
  18099. // Update viewport
  18100. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18101. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18102. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18103. _this.rigCameras[i].viewport.width = viewport.width / width;
  18104. _this.rigCameras[i].viewport.height = viewport.height / height;
  18105. _this.rigCameras[i].viewport.x = viewport.x / width;
  18106. _this.rigCameras[i].viewport.y = viewport.y / height;
  18107. // Set cameras to render to the session's render target
  18108. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18109. });
  18110. return true;
  18111. };
  18112. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18113. return WebXRCamera;
  18114. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18115. /***/ }),
  18116. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18117. /*!****************************************!*\
  18118. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18119. \****************************************/
  18120. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18122. "use strict";
  18123. __webpack_require__.r(__webpack_exports__);
  18124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18128. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18129. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18130. /**
  18131. * Button which can be used to enter a different mode of XR
  18132. */
  18133. var WebXREnterExitUIButton = /** @class */ (function () {
  18134. /**
  18135. * Creates a WebXREnterExitUIButton
  18136. * @param element button element
  18137. * @param initializationOptions XR initialization options for the button
  18138. */
  18139. function WebXREnterExitUIButton(
  18140. /** button element */
  18141. element,
  18142. /** XR initialization options for the button */
  18143. initializationOptions) {
  18144. this.element = element;
  18145. this.initializationOptions = initializationOptions;
  18146. }
  18147. /**
  18148. * Overwritable function which can be used to update the button's visuals when the state changes
  18149. * @param activeButton the current active button in the UI
  18150. */
  18151. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18152. };
  18153. return WebXREnterExitUIButton;
  18154. }());
  18155. /**
  18156. * Options to create the webXR UI
  18157. */
  18158. var WebXREnterExitUIOptions = /** @class */ (function () {
  18159. function WebXREnterExitUIOptions() {
  18160. }
  18161. return WebXREnterExitUIOptions;
  18162. }());
  18163. /**
  18164. * UI to allow the user to enter/exit XR mode
  18165. */
  18166. var WebXREnterExitUI = /** @class */ (function () {
  18167. function WebXREnterExitUI(scene, options) {
  18168. var _this = this;
  18169. this.scene = scene;
  18170. this._buttons = [];
  18171. this._activeButton = null;
  18172. /**
  18173. * Fired every time the active button is changed.
  18174. *
  18175. * When xr is entered via a button that launches xr that button will be the callback parameter
  18176. *
  18177. * When exiting xr the callback parameter will be null)
  18178. */
  18179. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18180. this._overlay = document.createElement("div");
  18181. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18182. if (options.customButtons) {
  18183. this._buttons = options.customButtons;
  18184. }
  18185. else {
  18186. var hmdBtn = document.createElement("button");
  18187. 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;";
  18188. hmdBtn.innerText = "HMD";
  18189. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18190. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18191. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18192. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18193. };
  18194. var windowBtn = document.createElement("button");
  18195. windowBtn.style.cssText = hmdBtn.style.cssText;
  18196. windowBtn.innerText = "Window";
  18197. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18198. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18199. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18200. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18201. };
  18202. this._updateButtons(null);
  18203. }
  18204. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18205. if (renderCanvas && renderCanvas.parentNode) {
  18206. renderCanvas.parentNode.appendChild(this._overlay);
  18207. scene.onDisposeObservable.addOnce(function () {
  18208. _this.dispose();
  18209. });
  18210. }
  18211. }
  18212. /**
  18213. * Creates UI to allow the user to enter/exit XR mode
  18214. * @param scene the scene to add the ui to
  18215. * @param helper the xr experience helper to enter/exit xr with
  18216. * @param options options to configure the UI
  18217. * @returns the created ui
  18218. */
  18219. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18220. var _this = this;
  18221. var ui = new WebXREnterExitUI(scene, options);
  18222. var supportedPromises = ui._buttons.map(function (btn) {
  18223. return helper.supportsSessionAsync(btn.initializationOptions);
  18224. });
  18225. helper.onStateChangedObservable.add(function (state) {
  18226. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18227. ui._updateButtons(null);
  18228. }
  18229. });
  18230. return Promise.all(supportedPromises).then(function (results) {
  18231. results.forEach(function (supported, i) {
  18232. if (supported) {
  18233. ui._overlay.appendChild(ui._buttons[i].element);
  18234. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18235. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18236. switch (_a.label) {
  18237. case 0:
  18238. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18239. ui._updateButtons(null);
  18240. return [4 /*yield*/, helper.exitXRAsync()];
  18241. case 1:
  18242. _a.sent();
  18243. return [2 /*return*/];
  18244. case 2:
  18245. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18246. ui._updateButtons(ui._buttons[i]);
  18247. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18248. case 3:
  18249. _a.sent();
  18250. _a.label = 4;
  18251. case 4: return [2 /*return*/];
  18252. }
  18253. });
  18254. }); };
  18255. }
  18256. });
  18257. return ui;
  18258. });
  18259. };
  18260. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18261. var _this = this;
  18262. this._activeButton = activeButton;
  18263. this._buttons.forEach(function (b) {
  18264. b.update(_this._activeButton);
  18265. });
  18266. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18267. };
  18268. /**
  18269. * Disposes of the object
  18270. */
  18271. WebXREnterExitUI.prototype.dispose = function () {
  18272. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18273. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18274. renderCanvas.parentNode.removeChild(this._overlay);
  18275. }
  18276. this.activeButtonChangedObservable.clear();
  18277. };
  18278. return WebXREnterExitUI;
  18279. }());
  18280. /***/ }),
  18281. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18282. /*!*********************************************!*\
  18283. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18284. \*********************************************/
  18285. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18287. "use strict";
  18288. __webpack_require__.r(__webpack_exports__);
  18289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18291. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18292. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18293. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18294. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18295. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18296. /**
  18297. * States of the webXR experience
  18298. */
  18299. var WebXRState;
  18300. (function (WebXRState) {
  18301. /**
  18302. * Transitioning to being in XR mode
  18303. */
  18304. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18305. /**
  18306. * Transitioning to non XR mode
  18307. */
  18308. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18309. /**
  18310. * In XR mode and presenting
  18311. */
  18312. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18313. /**
  18314. * Not entered XR mode
  18315. */
  18316. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18317. })(WebXRState || (WebXRState = {}));
  18318. /**
  18319. * Helper class used to enable XR
  18320. * @see https://doc.babylonjs.com/how_to/webxr
  18321. */
  18322. var WebXRExperienceHelper = /** @class */ (function () {
  18323. /**
  18324. * Creates a WebXRExperienceHelper
  18325. * @param scene The scene the helper should be created in
  18326. */
  18327. function WebXRExperienceHelper(scene) {
  18328. this.scene = scene;
  18329. /**
  18330. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18331. */
  18332. this.state = WebXRState.NOT_IN_XR;
  18333. /**
  18334. * Fires when the state of the experience helper has changed
  18335. */
  18336. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18337. this._nonVRCamera = null;
  18338. this._originalSceneAutoClear = true;
  18339. this._supported = false;
  18340. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18341. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18342. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18343. this.camera.parent = this.container;
  18344. }
  18345. WebXRExperienceHelper.prototype._setState = function (val) {
  18346. this.state = val;
  18347. this.onStateChangedObservable.notifyObservers(this.state);
  18348. };
  18349. /**
  18350. * Creates the experience helper
  18351. * @param scene the scene to attach the experience helper to
  18352. * @returns a promise for the experience helper
  18353. */
  18354. WebXRExperienceHelper.CreateAsync = function (scene) {
  18355. var helper = new WebXRExperienceHelper(scene);
  18356. return helper._sessionManager.initializeAsync().then(function () {
  18357. helper._supported = true;
  18358. return helper;
  18359. }).catch(function () {
  18360. return helper;
  18361. });
  18362. };
  18363. /**
  18364. * Exits XR mode and returns the scene to its original state
  18365. * @returns promise that resolves after xr mode has exited
  18366. */
  18367. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18368. this._setState(WebXRState.EXITING_XR);
  18369. return this._sessionManager.exitXRAsync();
  18370. };
  18371. /**
  18372. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18373. * @param sessionCreationOptions options for the XR session
  18374. * @param frameOfReference frame of reference of the XR session
  18375. * @returns promise that resolves after xr mode has entered
  18376. */
  18377. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18378. var _this = this;
  18379. if (!this._supported) {
  18380. throw "XR session not supported by this browser";
  18381. }
  18382. this._setState(WebXRState.ENTERING_XR);
  18383. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18384. // Cache pre xr scene settings
  18385. _this._originalSceneAutoClear = _this.scene.autoClear;
  18386. _this._nonVRCamera = _this.scene.activeCamera;
  18387. // Overwrite current scene settings
  18388. _this.scene.autoClear = false;
  18389. _this.scene.activeCamera = _this.camera;
  18390. _this._sessionManager.onXRFrameObservable.add(function () {
  18391. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18392. });
  18393. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18394. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18395. _this.camera.rigCameras.forEach(function (c) {
  18396. c.outputRenderTarget = null;
  18397. });
  18398. // Restore scene settings
  18399. _this.scene.autoClear = _this._originalSceneAutoClear;
  18400. _this.scene.activeCamera = _this._nonVRCamera;
  18401. _this._sessionManager.onXRFrameObservable.clear();
  18402. _this._setState(WebXRState.NOT_IN_XR);
  18403. });
  18404. _this._setState(WebXRState.IN_XR);
  18405. });
  18406. };
  18407. /**
  18408. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18409. * @param ray ray to cast into the environment
  18410. * @returns Promise which resolves with a collision point in the environment if it exists
  18411. */
  18412. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18413. return this._sessionManager.environmentPointHitTestAsync(ray);
  18414. };
  18415. /**
  18416. * Updates the global position of the camera by moving the camera's container
  18417. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18418. * @param position The desired global position of the camera
  18419. */
  18420. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18421. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18422. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18423. };
  18424. /**
  18425. * Rotates the xr camera by rotating the camera's container around the camera's position
  18426. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18427. * @param rotation the desired quaternion rotation to apply to the camera
  18428. */
  18429. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18430. if (!this.container.rotationQuaternion) {
  18431. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18432. }
  18433. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18434. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18435. };
  18436. /**
  18437. * Checks if the creation options are supported by the xr session
  18438. * @param options creation options
  18439. * @returns true if supported
  18440. */
  18441. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18442. if (!this._supported) {
  18443. return Promise.resolve(false);
  18444. }
  18445. return this._sessionManager.supportsSessionAsync(options);
  18446. };
  18447. /**
  18448. * Disposes of the experience helper
  18449. */
  18450. WebXRExperienceHelper.prototype.dispose = function () {
  18451. this.camera.dispose();
  18452. this.container.dispose();
  18453. this.onStateChangedObservable.clear();
  18454. this._sessionManager.dispose();
  18455. };
  18456. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18457. return WebXRExperienceHelper;
  18458. }());
  18459. /***/ }),
  18460. /***/ "./Cameras/XR/webXRInput.ts":
  18461. /*!**********************************!*\
  18462. !*** ./Cameras/XR/webXRInput.ts ***!
  18463. \**********************************/
  18464. /*! exports provided: WebXRController, WebXRInput */
  18465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18466. "use strict";
  18467. __webpack_require__.r(__webpack_exports__);
  18468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18471. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18472. /**
  18473. * Represents an XR input
  18474. */
  18475. var WebXRController = /** @class */ (function () {
  18476. /**
  18477. * Creates the controller
  18478. * @see https://doc.babylonjs.com/how_to/webxr
  18479. * @param scene the scene which the controller should be associated to
  18480. */
  18481. function WebXRController(scene) {
  18482. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18483. }
  18484. /**
  18485. * Disposes of the object
  18486. */
  18487. WebXRController.prototype.dispose = function () {
  18488. if (this.grip) {
  18489. this.grip.dispose();
  18490. }
  18491. this.pointer.dispose();
  18492. };
  18493. return WebXRController;
  18494. }());
  18495. /**
  18496. * XR input used to track XR inputs such as controllers/rays
  18497. */
  18498. var WebXRInput = /** @class */ (function () {
  18499. /**
  18500. * Initializes the WebXRInput
  18501. * @param helper experience helper which the input should be created for
  18502. */
  18503. function WebXRInput(helper) {
  18504. var _this = this;
  18505. this.helper = helper;
  18506. /**
  18507. * XR controllers being tracked
  18508. */
  18509. this.controllers = [];
  18510. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18511. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18512. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18513. return;
  18514. }
  18515. var xrFrame = helper._sessionManager._currentXRFrame;
  18516. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18517. inputSources.forEach(function (input, i) {
  18518. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18519. if (inputPose) {
  18520. if (_this.controllers.length <= i) {
  18521. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18522. }
  18523. var controller = _this.controllers[i];
  18524. // Manage the grip if it exists
  18525. if (inputPose.gripMatrix) {
  18526. if (!controller.grip) {
  18527. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18528. }
  18529. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18530. if (!controller.grip.getScene().useRightHandedSystem) {
  18531. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18532. }
  18533. if (!controller.grip.rotationQuaternion) {
  18534. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18535. }
  18536. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18537. }
  18538. // Manager pointer of controller
  18539. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18540. if (!controller.pointer.getScene().useRightHandedSystem) {
  18541. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18542. }
  18543. if (!controller.pointer.rotationQuaternion) {
  18544. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18545. }
  18546. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18547. }
  18548. });
  18549. });
  18550. }
  18551. /**
  18552. * Disposes of the object
  18553. */
  18554. WebXRInput.prototype.dispose = function () {
  18555. this.controllers.forEach(function (c) {
  18556. c.dispose();
  18557. });
  18558. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18559. };
  18560. return WebXRInput;
  18561. }());
  18562. /***/ }),
  18563. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18564. /*!************************************************!*\
  18565. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18566. \************************************************/
  18567. /*! exports provided: WebXRManagedOutputCanvas */
  18568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18569. "use strict";
  18570. __webpack_require__.r(__webpack_exports__);
  18571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18572. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18573. /**
  18574. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18575. */
  18576. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18577. /**
  18578. * Initializes the canvas to be added/removed upon entering/exiting xr
  18579. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18580. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18581. */
  18582. function WebXRManagedOutputCanvas(helper, canvas) {
  18583. var _this = this;
  18584. this._canvas = null;
  18585. /**
  18586. * xrpresent context of the canvas which can be used to display/mirror xr content
  18587. */
  18588. this.canvasContext = null;
  18589. if (!canvas) {
  18590. canvas = document.createElement('canvas');
  18591. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18592. }
  18593. this._setManagedOutputCanvas(canvas);
  18594. helper.onStateChangedObservable.add(function (stateInfo) {
  18595. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18596. // 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
  18597. _this._addCanvas();
  18598. }
  18599. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18600. _this._removeCanvas();
  18601. }
  18602. });
  18603. }
  18604. /**
  18605. * Disposes of the object
  18606. */
  18607. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18608. this._removeCanvas();
  18609. this._setManagedOutputCanvas(null);
  18610. };
  18611. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18612. this._removeCanvas();
  18613. if (!canvas) {
  18614. this._canvas = null;
  18615. this.canvasContext = null;
  18616. }
  18617. else {
  18618. this._canvas = canvas;
  18619. this.canvasContext = this._canvas.getContext('xrpresent');
  18620. }
  18621. };
  18622. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18623. if (this._canvas) {
  18624. document.body.appendChild(this._canvas);
  18625. }
  18626. };
  18627. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18628. if (this._canvas && document.body.contains(this._canvas)) {
  18629. document.body.removeChild(this._canvas);
  18630. }
  18631. };
  18632. return WebXRManagedOutputCanvas;
  18633. }());
  18634. /***/ }),
  18635. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18636. /*!*******************************************!*\
  18637. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18638. \*******************************************/
  18639. /*! exports provided: WebXRSessionManager */
  18640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18641. "use strict";
  18642. __webpack_require__.r(__webpack_exports__);
  18643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18644. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18645. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18646. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18647. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18648. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18649. /**
  18650. * Manages an XRSession
  18651. * @see https://doc.babylonjs.com/how_to/webxr
  18652. */
  18653. var WebXRSessionManager = /** @class */ (function () {
  18654. /**
  18655. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18656. * @param scene The scene which the session should be created for
  18657. */
  18658. function WebXRSessionManager(scene) {
  18659. this.scene = scene;
  18660. /**
  18661. * Fires every time a new xrFrame arrives which can be used to update the camera
  18662. */
  18663. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18664. /**
  18665. * Fires when the xr session is ended either by the device or manually done
  18666. */
  18667. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18668. /** @hidden */
  18669. this._sessionRenderTargetTexture = null;
  18670. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18671. }
  18672. /**
  18673. * Initializes the manager
  18674. * After initialization enterXR can be called to start an XR session
  18675. * @returns Promise which resolves after it is initialized
  18676. */
  18677. WebXRSessionManager.prototype.initializeAsync = function () {
  18678. var _this = this;
  18679. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18680. // Check if the browser supports webXR
  18681. this._xrNavigator = navigator;
  18682. if (!this._xrNavigator.xr) {
  18683. return Promise.reject("webXR not supported by this browser");
  18684. }
  18685. // Request the webXR device
  18686. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18687. _this._xrDevice = device;
  18688. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18689. });
  18690. };
  18691. /**
  18692. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18693. * @param sessionCreationOptions xr options to create the session with
  18694. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18695. * @returns Promise which resolves after it enters XR
  18696. */
  18697. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18698. var _this = this;
  18699. // initialize session
  18700. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18701. _this._xrSession = session;
  18702. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18703. _this._xrSession.addEventListener("end", function () {
  18704. // Remove render target texture and notify frame obervers
  18705. _this._sessionRenderTargetTexture = null;
  18706. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18707. _this.scene.getEngine().restoreDefaultFramebuffer();
  18708. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18709. _this.scene.getEngine().customAnimationFrameRequester = null;
  18710. _this.onXRSessionEnded.notifyObservers(null);
  18711. _this.scene.getEngine()._renderLoop();
  18712. }, { once: true });
  18713. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18714. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18715. }).then(function (frameOfRef) {
  18716. _this._frameOfReference = frameOfRef;
  18717. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18718. _this.scene.getEngine().customAnimationFrameRequester = {
  18719. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18720. renderFunction: function (timestamp, xrFrame) {
  18721. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18722. _this._currentXRFrame = xrFrame;
  18723. _this.onXRFrameObservable.notifyObservers(null);
  18724. _this.scene.getEngine()._renderLoop();
  18725. }
  18726. };
  18727. // Create render target texture from xr's webgl render target
  18728. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18729. // Stop window's animation frame and trigger sessions animation frame
  18730. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18731. _this.scene.getEngine()._renderLoop();
  18732. });
  18733. };
  18734. /**
  18735. * Stops the xrSession and restores the renderloop
  18736. * @returns Promise which resolves after it exits XR
  18737. */
  18738. WebXRSessionManager.prototype.exitXRAsync = function () {
  18739. return this._xrSession.end();
  18740. };
  18741. /**
  18742. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18743. * @param ray ray to cast into the environment
  18744. * @returns Promise which resolves with a collision point in the environment if it exists
  18745. */
  18746. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18747. var _this = this;
  18748. return new Promise(function (res) {
  18749. // Compute left handed inputs to request hit test
  18750. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18751. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18752. if (!_this.scene.useRightHandedSystem) {
  18753. origin[2] *= -1;
  18754. direction[2] *= -1;
  18755. }
  18756. // Fire hittest
  18757. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18758. .then(function (hits) {
  18759. if (hits.length > 0) {
  18760. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18761. var hitPoint = _this._tmpMatrix.getTranslation();
  18762. if (!_this.scene.useRightHandedSystem) {
  18763. hitPoint.z *= -1;
  18764. }
  18765. res(hitPoint);
  18766. }
  18767. else {
  18768. res(null);
  18769. }
  18770. }).catch(function () {
  18771. res(null);
  18772. });
  18773. });
  18774. };
  18775. /**
  18776. * Checks if a session would be supported for the creation options specified
  18777. * @param options creation options to check if they are supported
  18778. * @returns true if supported
  18779. */
  18780. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18781. return this._xrDevice.supportsSession(options).then(function () {
  18782. return true;
  18783. }).catch(function () {
  18784. return false;
  18785. });
  18786. };
  18787. /**
  18788. * @hidden
  18789. * Converts the render layer of xrSession to a render target
  18790. * @param session session to create render target for
  18791. * @param scene scene the new render target should be created for
  18792. */
  18793. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18794. // Create internal texture
  18795. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18796. internalTexture.width = session.baseLayer.framebufferWidth;
  18797. internalTexture.height = session.baseLayer.framebufferHeight;
  18798. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18799. // Create render target texture from the internal texture
  18800. var renderTargetTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__["RenderTargetTexture"]("XR renderTargetTexture", { width: internalTexture.width, height: internalTexture.height }, scene, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);
  18801. renderTargetTexture._texture = internalTexture;
  18802. return renderTargetTexture;
  18803. };
  18804. /**
  18805. * Disposes of the session manager
  18806. */
  18807. WebXRSessionManager.prototype.dispose = function () {
  18808. this.onXRFrameObservable.clear();
  18809. this.onXRSessionEnded.clear();
  18810. };
  18811. return WebXRSessionManager;
  18812. }());
  18813. /***/ }),
  18814. /***/ "./Cameras/arcRotateCamera.ts":
  18815. /*!************************************!*\
  18816. !*** ./Cameras/arcRotateCamera.ts ***!
  18817. \************************************/
  18818. /*! exports provided: ArcRotateCamera */
  18819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18820. "use strict";
  18821. __webpack_require__.r(__webpack_exports__);
  18822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18823. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18824. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18825. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18826. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18827. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18828. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18829. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18830. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18831. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18832. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18833. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18834. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18835. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18836. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18837. });
  18838. /**
  18839. * This represents an orbital type of camera.
  18840. *
  18841. * 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.
  18842. * 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.
  18843. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18844. */
  18845. var ArcRotateCamera = /** @class */ (function (_super) {
  18846. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18847. /**
  18848. * Instantiates a new ArcRotateCamera in a given scene
  18849. * @param name Defines the name of the camera
  18850. * @param alpha Defines the camera rotation along the logitudinal axis
  18851. * @param beta Defines the camera rotation along the latitudinal axis
  18852. * @param radius Defines the camera distance from its target
  18853. * @param target Defines the camera target
  18854. * @param scene Defines the scene the camera belongs to
  18855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18856. */
  18857. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18858. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18859. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18860. /**
  18861. * Current inertia value on the longitudinal axis.
  18862. * The bigger this number the longer it will take for the camera to stop.
  18863. */
  18864. _this.inertialAlphaOffset = 0;
  18865. /**
  18866. * Current inertia value on the latitudinal axis.
  18867. * The bigger this number the longer it will take for the camera to stop.
  18868. */
  18869. _this.inertialBetaOffset = 0;
  18870. /**
  18871. * Current inertia value on the radius axis.
  18872. * The bigger this number the longer it will take for the camera to stop.
  18873. */
  18874. _this.inertialRadiusOffset = 0;
  18875. /**
  18876. * Minimum allowed angle on the longitudinal axis.
  18877. * This can help limiting how the Camera is able to move in the scene.
  18878. */
  18879. _this.lowerAlphaLimit = null;
  18880. /**
  18881. * Maximum allowed angle on the longitudinal axis.
  18882. * This can help limiting how the Camera is able to move in the scene.
  18883. */
  18884. _this.upperAlphaLimit = null;
  18885. /**
  18886. * Minimum allowed angle on the latitudinal axis.
  18887. * This can help limiting how the Camera is able to move in the scene.
  18888. */
  18889. _this.lowerBetaLimit = 0.01;
  18890. /**
  18891. * Maximum allowed angle on the latitudinal axis.
  18892. * This can help limiting how the Camera is able to move in the scene.
  18893. */
  18894. _this.upperBetaLimit = Math.PI - 0.01;
  18895. /**
  18896. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18897. * This can help limiting how the Camera is able to move in the scene.
  18898. */
  18899. _this.lowerRadiusLimit = null;
  18900. /**
  18901. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18902. * This can help limiting how the Camera is able to move in the scene.
  18903. */
  18904. _this.upperRadiusLimit = null;
  18905. /**
  18906. * Defines the current inertia value used during panning of the camera along the X axis.
  18907. */
  18908. _this.inertialPanningX = 0;
  18909. /**
  18910. * Defines the current inertia value used during panning of the camera along the Y axis.
  18911. */
  18912. _this.inertialPanningY = 0;
  18913. /**
  18914. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18915. * Basically if your fingers moves away from more than this distance you will be considered
  18916. * in pinch mode.
  18917. */
  18918. _this.pinchToPanMaxDistance = 20;
  18919. /**
  18920. * Defines the maximum distance the camera can pan.
  18921. * This could help keeping the cammera always in your scene.
  18922. */
  18923. _this.panningDistanceLimit = null;
  18924. /**
  18925. * Defines the target of the camera before paning.
  18926. */
  18927. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18928. /**
  18929. * Defines the value of the inertia used during panning.
  18930. * 0 would mean stop inertia and one would mean no decelleration at all.
  18931. */
  18932. _this.panningInertia = 0.9;
  18933. //-- end properties for backward compatibility for inputs
  18934. /**
  18935. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18936. */
  18937. _this.zoomOnFactor = 1;
  18938. /**
  18939. * Defines a screen offset for the camera position.
  18940. */
  18941. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18942. /**
  18943. * Allows the camera to be completely reversed.
  18944. * If false the camera can not arrive upside down.
  18945. */
  18946. _this.allowUpsideDown = true;
  18947. /**
  18948. * Define if double tap/click is used to restore the previously saved state of the camera.
  18949. */
  18950. _this.useInputToRestoreState = true;
  18951. /** @hidden */
  18952. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18953. /**
  18954. * Defines the allowed panning axis.
  18955. */
  18956. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18957. /**
  18958. * Observable triggered when the mesh target has been changed on the camera.
  18959. */
  18960. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18961. /**
  18962. * Defines whether the camera should check collision with the objects oh the scene.
  18963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18964. */
  18965. _this.checkCollisions = false;
  18966. /**
  18967. * Defines the collision radius of the camera.
  18968. * This simulates a sphere around the camera.
  18969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18970. */
  18971. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18972. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18973. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18974. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18975. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18976. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18977. if (collidedMesh === void 0) { collidedMesh = null; }
  18978. if (!collidedMesh) {
  18979. _this._previousPosition.copyFrom(_this.position);
  18980. }
  18981. else {
  18982. _this.setPosition(newPosition);
  18983. if (_this.onCollide) {
  18984. _this.onCollide(collidedMesh);
  18985. }
  18986. }
  18987. // Recompute because of constraints
  18988. var cosa = Math.cos(_this.alpha);
  18989. var sina = Math.sin(_this.alpha);
  18990. var cosb = Math.cos(_this.beta);
  18991. var sinb = Math.sin(_this.beta);
  18992. if (sinb === 0) {
  18993. sinb = 0.0001;
  18994. }
  18995. var target = _this._getTargetPosition();
  18996. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  18997. target.addToRef(_this._computationVector, _this._newPosition);
  18998. _this.position.copyFrom(_this._newPosition);
  18999. var up = _this.upVector;
  19000. if (_this.allowUpsideDown && _this.beta < 0) {
  19001. up = up.clone();
  19002. up = up.negate();
  19003. }
  19004. _this._computeViewMatrix(_this.position, target, up);
  19005. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19006. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19007. _this._collisionTriggered = false;
  19008. };
  19009. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19010. if (target) {
  19011. _this.setTarget(target);
  19012. }
  19013. _this.alpha = alpha;
  19014. _this.beta = beta;
  19015. _this.radius = radius;
  19016. _this.getViewMatrix();
  19017. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19018. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19019. return _this;
  19020. }
  19021. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19022. /**
  19023. * Defines the target point of the camera.
  19024. * The camera looks towards it form the radius distance.
  19025. */
  19026. get: function () {
  19027. return this._target;
  19028. },
  19029. set: function (value) {
  19030. this.setTarget(value);
  19031. },
  19032. enumerable: true,
  19033. configurable: true
  19034. });
  19035. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19036. //-- begin properties for backward compatibility for inputs
  19037. /**
  19038. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19039. */
  19040. get: function () {
  19041. var pointers = this.inputs.attached["pointers"];
  19042. if (pointers) {
  19043. return pointers.angularSensibilityX;
  19044. }
  19045. return 0;
  19046. },
  19047. set: function (value) {
  19048. var pointers = this.inputs.attached["pointers"];
  19049. if (pointers) {
  19050. pointers.angularSensibilityX = value;
  19051. }
  19052. },
  19053. enumerable: true,
  19054. configurable: true
  19055. });
  19056. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19057. /**
  19058. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19059. */
  19060. get: function () {
  19061. var pointers = this.inputs.attached["pointers"];
  19062. if (pointers) {
  19063. return pointers.angularSensibilityY;
  19064. }
  19065. return 0;
  19066. },
  19067. set: function (value) {
  19068. var pointers = this.inputs.attached["pointers"];
  19069. if (pointers) {
  19070. pointers.angularSensibilityY = value;
  19071. }
  19072. },
  19073. enumerable: true,
  19074. configurable: true
  19075. });
  19076. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19077. /**
  19078. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19079. */
  19080. get: function () {
  19081. var pointers = this.inputs.attached["pointers"];
  19082. if (pointers) {
  19083. return pointers.pinchPrecision;
  19084. }
  19085. return 0;
  19086. },
  19087. set: function (value) {
  19088. var pointers = this.inputs.attached["pointers"];
  19089. if (pointers) {
  19090. pointers.pinchPrecision = value;
  19091. }
  19092. },
  19093. enumerable: true,
  19094. configurable: true
  19095. });
  19096. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19097. /**
  19098. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19099. * It will be used instead of pinchDeltaPrecision if different from 0.
  19100. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19101. */
  19102. get: function () {
  19103. var pointers = this.inputs.attached["pointers"];
  19104. if (pointers) {
  19105. return pointers.pinchDeltaPercentage;
  19106. }
  19107. return 0;
  19108. },
  19109. set: function (value) {
  19110. var pointers = this.inputs.attached["pointers"];
  19111. if (pointers) {
  19112. pointers.pinchDeltaPercentage = value;
  19113. }
  19114. },
  19115. enumerable: true,
  19116. configurable: true
  19117. });
  19118. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19119. /**
  19120. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19121. */
  19122. get: function () {
  19123. var pointers = this.inputs.attached["pointers"];
  19124. if (pointers) {
  19125. return pointers.panningSensibility;
  19126. }
  19127. return 0;
  19128. },
  19129. set: function (value) {
  19130. var pointers = this.inputs.attached["pointers"];
  19131. if (pointers) {
  19132. pointers.panningSensibility = value;
  19133. }
  19134. },
  19135. enumerable: true,
  19136. configurable: true
  19137. });
  19138. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19139. /**
  19140. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19141. */
  19142. get: function () {
  19143. var keyboard = this.inputs.attached["keyboard"];
  19144. if (keyboard) {
  19145. return keyboard.keysUp;
  19146. }
  19147. return [];
  19148. },
  19149. set: function (value) {
  19150. var keyboard = this.inputs.attached["keyboard"];
  19151. if (keyboard) {
  19152. keyboard.keysUp = value;
  19153. }
  19154. },
  19155. enumerable: true,
  19156. configurable: true
  19157. });
  19158. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19159. /**
  19160. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19161. */
  19162. get: function () {
  19163. var keyboard = this.inputs.attached["keyboard"];
  19164. if (keyboard) {
  19165. return keyboard.keysDown;
  19166. }
  19167. return [];
  19168. },
  19169. set: function (value) {
  19170. var keyboard = this.inputs.attached["keyboard"];
  19171. if (keyboard) {
  19172. keyboard.keysDown = value;
  19173. }
  19174. },
  19175. enumerable: true,
  19176. configurable: true
  19177. });
  19178. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19179. /**
  19180. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19181. */
  19182. get: function () {
  19183. var keyboard = this.inputs.attached["keyboard"];
  19184. if (keyboard) {
  19185. return keyboard.keysLeft;
  19186. }
  19187. return [];
  19188. },
  19189. set: function (value) {
  19190. var keyboard = this.inputs.attached["keyboard"];
  19191. if (keyboard) {
  19192. keyboard.keysLeft = value;
  19193. }
  19194. },
  19195. enumerable: true,
  19196. configurable: true
  19197. });
  19198. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19199. /**
  19200. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19201. */
  19202. get: function () {
  19203. var keyboard = this.inputs.attached["keyboard"];
  19204. if (keyboard) {
  19205. return keyboard.keysRight;
  19206. }
  19207. return [];
  19208. },
  19209. set: function (value) {
  19210. var keyboard = this.inputs.attached["keyboard"];
  19211. if (keyboard) {
  19212. keyboard.keysRight = value;
  19213. }
  19214. },
  19215. enumerable: true,
  19216. configurable: true
  19217. });
  19218. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19219. /**
  19220. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19221. */
  19222. get: function () {
  19223. var mousewheel = this.inputs.attached["mousewheel"];
  19224. if (mousewheel) {
  19225. return mousewheel.wheelPrecision;
  19226. }
  19227. return 0;
  19228. },
  19229. set: function (value) {
  19230. var mousewheel = this.inputs.attached["mousewheel"];
  19231. if (mousewheel) {
  19232. mousewheel.wheelPrecision = value;
  19233. }
  19234. },
  19235. enumerable: true,
  19236. configurable: true
  19237. });
  19238. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19239. /**
  19240. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19241. * It will be used instead of pinchDeltaPrecision if different from 0.
  19242. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19243. */
  19244. get: function () {
  19245. var mousewheel = this.inputs.attached["mousewheel"];
  19246. if (mousewheel) {
  19247. return mousewheel.wheelDeltaPercentage;
  19248. }
  19249. return 0;
  19250. },
  19251. set: function (value) {
  19252. var mousewheel = this.inputs.attached["mousewheel"];
  19253. if (mousewheel) {
  19254. mousewheel.wheelDeltaPercentage = value;
  19255. }
  19256. },
  19257. enumerable: true,
  19258. configurable: true
  19259. });
  19260. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19261. /**
  19262. * Gets the bouncing behavior of the camera if it has been enabled.
  19263. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19264. */
  19265. get: function () {
  19266. return this._bouncingBehavior;
  19267. },
  19268. enumerable: true,
  19269. configurable: true
  19270. });
  19271. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19272. /**
  19273. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19275. */
  19276. get: function () {
  19277. return this._bouncingBehavior != null;
  19278. },
  19279. set: function (value) {
  19280. if (value === this.useBouncingBehavior) {
  19281. return;
  19282. }
  19283. if (value) {
  19284. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19285. this.addBehavior(this._bouncingBehavior);
  19286. }
  19287. else if (this._bouncingBehavior) {
  19288. this.removeBehavior(this._bouncingBehavior);
  19289. this._bouncingBehavior = null;
  19290. }
  19291. },
  19292. enumerable: true,
  19293. configurable: true
  19294. });
  19295. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19296. /**
  19297. * Gets the framing behavior of the camera if it has been enabled.
  19298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19299. */
  19300. get: function () {
  19301. return this._framingBehavior;
  19302. },
  19303. enumerable: true,
  19304. configurable: true
  19305. });
  19306. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19307. /**
  19308. * Defines if the framing behavior of the camera is enabled on the camera.
  19309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19310. */
  19311. get: function () {
  19312. return this._framingBehavior != null;
  19313. },
  19314. set: function (value) {
  19315. if (value === this.useFramingBehavior) {
  19316. return;
  19317. }
  19318. if (value) {
  19319. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19320. this.addBehavior(this._framingBehavior);
  19321. }
  19322. else if (this._framingBehavior) {
  19323. this.removeBehavior(this._framingBehavior);
  19324. this._framingBehavior = null;
  19325. }
  19326. },
  19327. enumerable: true,
  19328. configurable: true
  19329. });
  19330. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19331. /**
  19332. * Gets the auto rotation behavior of the camera if it has been enabled.
  19333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19334. */
  19335. get: function () {
  19336. return this._autoRotationBehavior;
  19337. },
  19338. enumerable: true,
  19339. configurable: true
  19340. });
  19341. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19342. /**
  19343. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19345. */
  19346. get: function () {
  19347. return this._autoRotationBehavior != null;
  19348. },
  19349. set: function (value) {
  19350. if (value === this.useAutoRotationBehavior) {
  19351. return;
  19352. }
  19353. if (value) {
  19354. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19355. this.addBehavior(this._autoRotationBehavior);
  19356. }
  19357. else if (this._autoRotationBehavior) {
  19358. this.removeBehavior(this._autoRotationBehavior);
  19359. this._autoRotationBehavior = null;
  19360. }
  19361. },
  19362. enumerable: true,
  19363. configurable: true
  19364. });
  19365. // Cache
  19366. /** @hidden */
  19367. ArcRotateCamera.prototype._initCache = function () {
  19368. _super.prototype._initCache.call(this);
  19369. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19370. this._cache.alpha = undefined;
  19371. this._cache.beta = undefined;
  19372. this._cache.radius = undefined;
  19373. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19374. };
  19375. /** @hidden */
  19376. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19377. if (!ignoreParentClass) {
  19378. _super.prototype._updateCache.call(this);
  19379. }
  19380. this._cache._target.copyFrom(this._getTargetPosition());
  19381. this._cache.alpha = this.alpha;
  19382. this._cache.beta = this.beta;
  19383. this._cache.radius = this.radius;
  19384. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19385. };
  19386. ArcRotateCamera.prototype._getTargetPosition = function () {
  19387. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19388. var pos = this._targetHost.absolutePosition;
  19389. if (this._targetBoundingCenter) {
  19390. pos.addToRef(this._targetBoundingCenter, this._target);
  19391. }
  19392. else {
  19393. this._target.copyFrom(pos);
  19394. }
  19395. }
  19396. var lockedTargetPosition = this._getLockedTargetPosition();
  19397. if (lockedTargetPosition) {
  19398. return lockedTargetPosition;
  19399. }
  19400. return this._target;
  19401. };
  19402. /**
  19403. * Stores the current state of the camera (alpha, beta, radius and target)
  19404. * @returns the camera itself
  19405. */
  19406. ArcRotateCamera.prototype.storeState = function () {
  19407. this._storedAlpha = this.alpha;
  19408. this._storedBeta = this.beta;
  19409. this._storedRadius = this.radius;
  19410. this._storedTarget = this._getTargetPosition().clone();
  19411. return _super.prototype.storeState.call(this);
  19412. };
  19413. /**
  19414. * @hidden
  19415. * Restored camera state. You must call storeState() first
  19416. */
  19417. ArcRotateCamera.prototype._restoreStateValues = function () {
  19418. if (!_super.prototype._restoreStateValues.call(this)) {
  19419. return false;
  19420. }
  19421. this.alpha = this._storedAlpha;
  19422. this.beta = this._storedBeta;
  19423. this.radius = this._storedRadius;
  19424. this.setTarget(this._storedTarget.clone());
  19425. this.inertialAlphaOffset = 0;
  19426. this.inertialBetaOffset = 0;
  19427. this.inertialRadiusOffset = 0;
  19428. this.inertialPanningX = 0;
  19429. this.inertialPanningY = 0;
  19430. return true;
  19431. };
  19432. // Synchronized
  19433. /** @hidden */
  19434. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19435. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19436. return false;
  19437. }
  19438. return this._cache._target.equals(this._getTargetPosition())
  19439. && this._cache.alpha === this.alpha
  19440. && this._cache.beta === this.beta
  19441. && this._cache.radius === this.radius
  19442. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19443. };
  19444. /**
  19445. * Attached controls to the current camera.
  19446. * @param element Defines the element the controls should be listened from
  19447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19448. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19449. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19450. */
  19451. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19452. var _this = this;
  19453. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19454. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19455. this._useCtrlForPanning = useCtrlForPanning;
  19456. this._panningMouseButton = panningMouseButton;
  19457. this.inputs.attachElement(element, noPreventDefault);
  19458. this._reset = function () {
  19459. _this.inertialAlphaOffset = 0;
  19460. _this.inertialBetaOffset = 0;
  19461. _this.inertialRadiusOffset = 0;
  19462. _this.inertialPanningX = 0;
  19463. _this.inertialPanningY = 0;
  19464. };
  19465. };
  19466. /**
  19467. * Detach the current controls from the camera.
  19468. * The camera will stop reacting to inputs.
  19469. * @param element Defines the element to stop listening the inputs from
  19470. */
  19471. ArcRotateCamera.prototype.detachControl = function (element) {
  19472. this.inputs.detachElement(element);
  19473. if (this._reset) {
  19474. this._reset();
  19475. }
  19476. };
  19477. /** @hidden */
  19478. ArcRotateCamera.prototype._checkInputs = function () {
  19479. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19480. if (this._collisionTriggered) {
  19481. return;
  19482. }
  19483. this.inputs.checkInputs();
  19484. // Inertia
  19485. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19486. var inertialAlphaOffset = this.inertialAlphaOffset;
  19487. if (this.beta <= 0) {
  19488. inertialAlphaOffset *= -1;
  19489. }
  19490. if (this.getScene().useRightHandedSystem) {
  19491. inertialAlphaOffset *= -1;
  19492. }
  19493. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19494. inertialAlphaOffset *= -1;
  19495. }
  19496. this.alpha += inertialAlphaOffset;
  19497. this.beta += this.inertialBetaOffset;
  19498. this.radius -= this.inertialRadiusOffset;
  19499. this.inertialAlphaOffset *= this.inertia;
  19500. this.inertialBetaOffset *= this.inertia;
  19501. this.inertialRadiusOffset *= this.inertia;
  19502. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19503. this.inertialAlphaOffset = 0;
  19504. }
  19505. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19506. this.inertialBetaOffset = 0;
  19507. }
  19508. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19509. this.inertialRadiusOffset = 0;
  19510. }
  19511. }
  19512. // Panning inertia
  19513. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19514. if (!this._localDirection) {
  19515. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19516. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19517. }
  19518. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19519. this._localDirection.multiplyInPlace(this.panningAxis);
  19520. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19521. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19522. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19523. if (!this.panningAxis.y) {
  19524. this._transformedDirection.y = 0;
  19525. }
  19526. if (!this._targetHost) {
  19527. if (this.panningDistanceLimit) {
  19528. this._transformedDirection.addInPlace(this._target);
  19529. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19530. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19531. this._target.copyFrom(this._transformedDirection);
  19532. }
  19533. }
  19534. else {
  19535. this._target.addInPlace(this._transformedDirection);
  19536. }
  19537. }
  19538. this.inertialPanningX *= this.panningInertia;
  19539. this.inertialPanningY *= this.panningInertia;
  19540. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19541. this.inertialPanningX = 0;
  19542. }
  19543. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19544. this.inertialPanningY = 0;
  19545. }
  19546. }
  19547. // Limits
  19548. this._checkLimits();
  19549. _super.prototype._checkInputs.call(this);
  19550. };
  19551. ArcRotateCamera.prototype._checkLimits = function () {
  19552. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19553. if (this.allowUpsideDown && this.beta > Math.PI) {
  19554. this.beta = this.beta - (2 * Math.PI);
  19555. }
  19556. }
  19557. else {
  19558. if (this.beta < this.lowerBetaLimit) {
  19559. this.beta = this.lowerBetaLimit;
  19560. }
  19561. }
  19562. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19563. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19564. this.beta = this.beta + (2 * Math.PI);
  19565. }
  19566. }
  19567. else {
  19568. if (this.beta > this.upperBetaLimit) {
  19569. this.beta = this.upperBetaLimit;
  19570. }
  19571. }
  19572. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19573. this.alpha = this.lowerAlphaLimit;
  19574. }
  19575. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19576. this.alpha = this.upperAlphaLimit;
  19577. }
  19578. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19579. this.radius = this.lowerRadiusLimit;
  19580. this.inertialRadiusOffset = 0;
  19581. }
  19582. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19583. this.radius = this.upperRadiusLimit;
  19584. this.inertialRadiusOffset = 0;
  19585. }
  19586. };
  19587. /**
  19588. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19589. */
  19590. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19591. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19592. this.radius = this._computationVector.length();
  19593. if (this.radius === 0) {
  19594. this.radius = 0.0001; // Just to avoid division by zero
  19595. }
  19596. // Alpha
  19597. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19598. if (this._computationVector.z < 0) {
  19599. this.alpha = 2 * Math.PI - this.alpha;
  19600. }
  19601. // Beta
  19602. this.beta = Math.acos(this._computationVector.y / this.radius);
  19603. this._checkLimits();
  19604. };
  19605. /**
  19606. * Use a position to define the current camera related information like aplha, beta and radius
  19607. * @param position Defines the position to set the camera at
  19608. */
  19609. ArcRotateCamera.prototype.setPosition = function (position) {
  19610. if (this.position.equals(position)) {
  19611. return;
  19612. }
  19613. this.position.copyFrom(position);
  19614. this.rebuildAnglesAndRadius();
  19615. };
  19616. /**
  19617. * Defines the target the camera should look at.
  19618. * This will automatically adapt alpha beta and radius to fit within the new target.
  19619. * @param target Defines the new target as a Vector or a mesh
  19620. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19621. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19622. */
  19623. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19624. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19625. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19626. if (target.getBoundingInfo) {
  19627. if (toBoundingCenter) {
  19628. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19629. }
  19630. else {
  19631. this._targetBoundingCenter = null;
  19632. }
  19633. this._targetHost = target;
  19634. this._target = this._getTargetPosition();
  19635. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19636. }
  19637. else {
  19638. var newTarget = target;
  19639. var currentTarget = this._getTargetPosition();
  19640. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19641. return;
  19642. }
  19643. this._targetHost = null;
  19644. this._target = newTarget;
  19645. this._targetBoundingCenter = null;
  19646. this.onMeshTargetChangedObservable.notifyObservers(null);
  19647. }
  19648. this.rebuildAnglesAndRadius();
  19649. };
  19650. /** @hidden */
  19651. ArcRotateCamera.prototype._getViewMatrix = function () {
  19652. // Compute
  19653. var cosa = Math.cos(this.alpha);
  19654. var sina = Math.sin(this.alpha);
  19655. var cosb = Math.cos(this.beta);
  19656. var sinb = Math.sin(this.beta);
  19657. if (sinb === 0) {
  19658. sinb = 0.0001;
  19659. }
  19660. var target = this._getTargetPosition();
  19661. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19662. // Rotate according to up vector
  19663. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19664. if (!this._tempAxisVector) {
  19665. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19666. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19667. }
  19668. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19669. this._tempAxisVector.normalize();
  19670. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19671. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19672. this._tempAxisVector.copyFrom(this._computationVector);
  19673. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19674. }
  19675. target.addToRef(this._computationVector, this._newPosition);
  19676. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19677. var coordinator = this.getScene().collisionCoordinator;
  19678. if (!this._collider) {
  19679. this._collider = coordinator.createCollider();
  19680. }
  19681. this._collider._radius = this.collisionRadius;
  19682. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19683. this._collisionTriggered = true;
  19684. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19685. }
  19686. else {
  19687. this.position.copyFrom(this._newPosition);
  19688. var up = this.upVector;
  19689. if (this.allowUpsideDown && sinb < 0) {
  19690. up = up.clone();
  19691. up = up.negate();
  19692. }
  19693. this._computeViewMatrix(this.position, target, up);
  19694. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19695. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19696. }
  19697. this._currentTarget = target;
  19698. return this._viewMatrix;
  19699. };
  19700. /**
  19701. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19702. * @param meshes Defines the mesh to zoom on
  19703. * @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)
  19704. */
  19705. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19706. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19707. meshes = meshes || this.getScene().meshes;
  19708. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19709. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19710. this.radius = distance * this.zoomOnFactor;
  19711. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19712. };
  19713. /**
  19714. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19715. * The target will be changed but the radius
  19716. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19717. * @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)
  19718. */
  19719. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19720. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19721. var meshesOrMinMaxVector;
  19722. var distance;
  19723. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19724. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19725. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19726. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19727. }
  19728. else { //minMaxVector and distance
  19729. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19730. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19731. distance = minMaxVectorAndDistance.distance;
  19732. }
  19733. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19734. if (!doNotUpdateMaxZ) {
  19735. this.maxZ = distance * 2;
  19736. }
  19737. };
  19738. /**
  19739. * @override
  19740. * Override Camera.createRigCamera
  19741. */
  19742. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19743. var alphaShift = 0;
  19744. switch (this.cameraRigMode) {
  19745. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19746. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19747. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19748. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19749. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19750. break;
  19751. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19752. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19753. break;
  19754. }
  19755. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19756. rigCam._cameraRigParams = {};
  19757. return rigCam;
  19758. };
  19759. /**
  19760. * @hidden
  19761. * @override
  19762. * Override Camera._updateRigCameras
  19763. */
  19764. ArcRotateCamera.prototype._updateRigCameras = function () {
  19765. var camLeft = this._rigCameras[0];
  19766. var camRight = this._rigCameras[1];
  19767. camLeft.beta = camRight.beta = this.beta;
  19768. switch (this.cameraRigMode) {
  19769. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19770. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19771. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19772. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19773. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19774. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19775. break;
  19776. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19777. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19778. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19779. break;
  19780. }
  19781. _super.prototype._updateRigCameras.call(this);
  19782. };
  19783. /**
  19784. * Destroy the camera and release the current resources hold by it.
  19785. */
  19786. ArcRotateCamera.prototype.dispose = function () {
  19787. this.inputs.clear();
  19788. _super.prototype.dispose.call(this);
  19789. };
  19790. /**
  19791. * Gets the current object class name.
  19792. * @return the class name
  19793. */
  19794. ArcRotateCamera.prototype.getClassName = function () {
  19795. return "ArcRotateCamera";
  19796. };
  19797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19799. ], ArcRotateCamera.prototype, "alpha", void 0);
  19800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19802. ], ArcRotateCamera.prototype, "beta", void 0);
  19803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19805. ], ArcRotateCamera.prototype, "radius", void 0);
  19806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19808. ], ArcRotateCamera.prototype, "_target", void 0);
  19809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19811. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19814. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19817. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19820. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19829. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19847. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19850. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19862. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19865. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19866. return ArcRotateCamera;
  19867. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19868. /***/ }),
  19869. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19870. /*!*************************************************!*\
  19871. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19872. \*************************************************/
  19873. /*! exports provided: ArcRotateCameraInputsManager */
  19874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19875. "use strict";
  19876. __webpack_require__.r(__webpack_exports__);
  19877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19879. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19880. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19881. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19882. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19883. /**
  19884. * Default Inputs manager for the ArcRotateCamera.
  19885. * It groups all the default supported inputs for ease of use.
  19886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19887. */
  19888. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19889. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19890. /**
  19891. * Instantiates a new ArcRotateCameraInputsManager.
  19892. * @param camera Defines the camera the inputs belong to
  19893. */
  19894. function ArcRotateCameraInputsManager(camera) {
  19895. return _super.call(this, camera) || this;
  19896. }
  19897. /**
  19898. * Add mouse wheel input support to the input manager.
  19899. * @returns the current input manager
  19900. */
  19901. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19902. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19903. return this;
  19904. };
  19905. /**
  19906. * Add pointers input support to the input manager.
  19907. * @returns the current input manager
  19908. */
  19909. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19910. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19911. return this;
  19912. };
  19913. /**
  19914. * Add keyboard input support to the input manager.
  19915. * @returns the current input manager
  19916. */
  19917. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19918. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19919. return this;
  19920. };
  19921. return ArcRotateCameraInputsManager;
  19922. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19923. /***/ }),
  19924. /***/ "./Cameras/camera.ts":
  19925. /*!***************************!*\
  19926. !*** ./Cameras/camera.ts ***!
  19927. \***************************/
  19928. /*! exports provided: Camera */
  19929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19930. "use strict";
  19931. __webpack_require__.r(__webpack_exports__);
  19932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19934. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19935. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19936. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19937. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19938. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19939. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19940. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19941. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19942. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  19943. /**
  19944. * This is the base class of all the camera used in the application.
  19945. * @see http://doc.babylonjs.com/features/cameras
  19946. */
  19947. var Camera = /** @class */ (function (_super) {
  19948. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19949. /**
  19950. * Instantiates a new camera object.
  19951. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19952. * @see http://doc.babylonjs.com/features/cameras
  19953. * @param name Defines the name of the camera in the scene
  19954. * @param position Defines the position of the camera
  19955. * @param scene Defines the scene the camera belongs too
  19956. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19957. */
  19958. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19959. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19960. var _this = _super.call(this, name, scene) || this;
  19961. /**
  19962. * The vector the camera should consider as up.
  19963. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19964. */
  19965. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19966. /**
  19967. * Define the current limit on the left side for an orthographic camera
  19968. * In scene unit
  19969. */
  19970. _this.orthoLeft = null;
  19971. /**
  19972. * Define the current limit on the right side for an orthographic camera
  19973. * In scene unit
  19974. */
  19975. _this.orthoRight = null;
  19976. /**
  19977. * Define the current limit on the bottom side for an orthographic camera
  19978. * In scene unit
  19979. */
  19980. _this.orthoBottom = null;
  19981. /**
  19982. * Define the current limit on the top side for an orthographic camera
  19983. * In scene unit
  19984. */
  19985. _this.orthoTop = null;
  19986. /**
  19987. * Field Of View is set in Radians. (default is 0.8)
  19988. */
  19989. _this.fov = 0.8;
  19990. /**
  19991. * Define the minimum distance the camera can see from.
  19992. * This is important to note that the depth buffer are not infinite and the closer it starts
  19993. * the more your scene might encounter depth fighting issue.
  19994. */
  19995. _this.minZ = 1;
  19996. /**
  19997. * Define the maximum distance the camera can see to.
  19998. * This is important to note that the depth buffer are not infinite and the further it end
  19999. * the more your scene might encounter depth fighting issue.
  20000. */
  20001. _this.maxZ = 10000.0;
  20002. /**
  20003. * Define the default inertia of the camera.
  20004. * This helps giving a smooth feeling to the camera movement.
  20005. */
  20006. _this.inertia = 0.9;
  20007. /**
  20008. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20009. */
  20010. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20011. /**
  20012. * Define wether the camera is intermediate.
  20013. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20014. */
  20015. _this.isIntermediate = false;
  20016. /**
  20017. * Define the viewport of the camera.
  20018. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20019. */
  20020. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20021. /**
  20022. * Restricts the camera to viewing objects with the same layerMask.
  20023. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20024. */
  20025. _this.layerMask = 0x0FFFFFFF;
  20026. /**
  20027. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20028. */
  20029. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20030. /**
  20031. * Rig mode of the camera.
  20032. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20033. * This is normally controlled byt the camera themselves as internal use.
  20034. */
  20035. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20036. /**
  20037. * 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
  20038. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20039. * else in the scene.
  20040. */
  20041. _this.customRenderTargets = new Array();
  20042. /**
  20043. * When set, the camera will render to this render target instead of the default canvas
  20044. */
  20045. _this.outputRenderTarget = null;
  20046. /**
  20047. * Observable triggered when the camera view matrix has changed.
  20048. */
  20049. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20050. /**
  20051. * Observable triggered when the camera Projection matrix has changed.
  20052. */
  20053. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20054. /**
  20055. * Observable triggered when the inputs have been processed.
  20056. */
  20057. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20058. /**
  20059. * Observable triggered when reset has been called and applied to the camera.
  20060. */
  20061. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20062. /** @hidden */
  20063. _this._rigCameras = new Array();
  20064. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20065. /** @hidden */
  20066. _this._skipRendering = false;
  20067. /** @hidden */
  20068. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20069. /** @hidden */
  20070. _this._postProcesses = new Array();
  20071. /** @hidden */
  20072. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20073. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20074. /** hidden */
  20075. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20076. _this._doNotComputeProjectionMatrix = false;
  20077. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20078. _this._refreshFrustumPlanes = true;
  20079. /** @hidden */
  20080. _this._isCamera = true;
  20081. _this.getScene().addCamera(_this);
  20082. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20083. _this.getScene().activeCamera = _this;
  20084. }
  20085. _this.position = position;
  20086. return _this;
  20087. }
  20088. /**
  20089. * Store current camera state (fov, position, etc..)
  20090. * @returns the camera
  20091. */
  20092. Camera.prototype.storeState = function () {
  20093. this._stateStored = true;
  20094. this._storedFov = this.fov;
  20095. return this;
  20096. };
  20097. /**
  20098. * Restores the camera state values if it has been stored. You must call storeState() first
  20099. */
  20100. Camera.prototype._restoreStateValues = function () {
  20101. if (!this._stateStored) {
  20102. return false;
  20103. }
  20104. this.fov = this._storedFov;
  20105. return true;
  20106. };
  20107. /**
  20108. * Restored camera state. You must call storeState() first.
  20109. * @returns true if restored and false otherwise
  20110. */
  20111. Camera.prototype.restoreState = function () {
  20112. if (this._restoreStateValues()) {
  20113. this.onRestoreStateObservable.notifyObservers(this);
  20114. return true;
  20115. }
  20116. return false;
  20117. };
  20118. /**
  20119. * Gets the class name of the camera.
  20120. * @returns the class name
  20121. */
  20122. Camera.prototype.getClassName = function () {
  20123. return "Camera";
  20124. };
  20125. /**
  20126. * Gets a string representation of the camera useful for debug purpose.
  20127. * @param fullDetails Defines that a more verboe level of logging is required
  20128. * @returns the string representation
  20129. */
  20130. Camera.prototype.toString = function (fullDetails) {
  20131. var ret = "Name: " + this.name;
  20132. ret += ", type: " + this.getClassName();
  20133. if (this.animations) {
  20134. for (var i = 0; i < this.animations.length; i++) {
  20135. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20136. }
  20137. }
  20138. if (fullDetails) {
  20139. }
  20140. return ret;
  20141. };
  20142. Object.defineProperty(Camera.prototype, "globalPosition", {
  20143. /**
  20144. * Gets the current world space position of the camera.
  20145. */
  20146. get: function () {
  20147. return this._globalPosition;
  20148. },
  20149. enumerable: true,
  20150. configurable: true
  20151. });
  20152. /**
  20153. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20154. * @returns the active meshe list
  20155. */
  20156. Camera.prototype.getActiveMeshes = function () {
  20157. return this._activeMeshes;
  20158. };
  20159. /**
  20160. * Check wether a mesh is part of the current active mesh list of the camera
  20161. * @param mesh Defines the mesh to check
  20162. * @returns true if active, false otherwise
  20163. */
  20164. Camera.prototype.isActiveMesh = function (mesh) {
  20165. return (this._activeMeshes.indexOf(mesh) !== -1);
  20166. };
  20167. /**
  20168. * Is this camera ready to be used/rendered
  20169. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20170. * @return true if the camera is ready
  20171. */
  20172. Camera.prototype.isReady = function (completeCheck) {
  20173. if (completeCheck === void 0) { completeCheck = false; }
  20174. if (completeCheck) {
  20175. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20176. var pp = _a[_i];
  20177. if (pp && !pp.isReady()) {
  20178. return false;
  20179. }
  20180. }
  20181. }
  20182. return _super.prototype.isReady.call(this, completeCheck);
  20183. };
  20184. /** @hidden */
  20185. Camera.prototype._initCache = function () {
  20186. _super.prototype._initCache.call(this);
  20187. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20188. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20189. this._cache.mode = undefined;
  20190. this._cache.minZ = undefined;
  20191. this._cache.maxZ = undefined;
  20192. this._cache.fov = undefined;
  20193. this._cache.fovMode = undefined;
  20194. this._cache.aspectRatio = undefined;
  20195. this._cache.orthoLeft = undefined;
  20196. this._cache.orthoRight = undefined;
  20197. this._cache.orthoBottom = undefined;
  20198. this._cache.orthoTop = undefined;
  20199. this._cache.renderWidth = undefined;
  20200. this._cache.renderHeight = undefined;
  20201. };
  20202. /** @hidden */
  20203. Camera.prototype._updateCache = function (ignoreParentClass) {
  20204. if (!ignoreParentClass) {
  20205. _super.prototype._updateCache.call(this);
  20206. }
  20207. this._cache.position.copyFrom(this.position);
  20208. this._cache.upVector.copyFrom(this.upVector);
  20209. };
  20210. /** @hidden */
  20211. Camera.prototype._isSynchronized = function () {
  20212. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20213. };
  20214. /** @hidden */
  20215. Camera.prototype._isSynchronizedViewMatrix = function () {
  20216. if (!_super.prototype._isSynchronized.call(this)) {
  20217. return false;
  20218. }
  20219. return this._cache.position.equals(this.position)
  20220. && this._cache.upVector.equals(this.upVector)
  20221. && this.isSynchronizedWithParent();
  20222. };
  20223. /** @hidden */
  20224. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20225. var check = this._cache.mode === this.mode
  20226. && this._cache.minZ === this.minZ
  20227. && this._cache.maxZ === this.maxZ;
  20228. if (!check) {
  20229. return false;
  20230. }
  20231. var engine = this.getEngine();
  20232. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20233. check = this._cache.fov === this.fov
  20234. && this._cache.fovMode === this.fovMode
  20235. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20236. }
  20237. else {
  20238. check = this._cache.orthoLeft === this.orthoLeft
  20239. && this._cache.orthoRight === this.orthoRight
  20240. && this._cache.orthoBottom === this.orthoBottom
  20241. && this._cache.orthoTop === this.orthoTop
  20242. && this._cache.renderWidth === engine.getRenderWidth()
  20243. && this._cache.renderHeight === engine.getRenderHeight();
  20244. }
  20245. return check;
  20246. };
  20247. /**
  20248. * Attach the input controls to a specific dom element to get the input from.
  20249. * @param element Defines the element the controls should be listened from
  20250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20251. */
  20252. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20253. };
  20254. /**
  20255. * Detach the current controls from the specified dom element.
  20256. * @param element Defines the element to stop listening the inputs from
  20257. */
  20258. Camera.prototype.detachControl = function (element) {
  20259. };
  20260. /**
  20261. * Update the camera state according to the different inputs gathered during the frame.
  20262. */
  20263. Camera.prototype.update = function () {
  20264. this._checkInputs();
  20265. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20266. this._updateRigCameras();
  20267. }
  20268. };
  20269. /** @hidden */
  20270. Camera.prototype._checkInputs = function () {
  20271. this.onAfterCheckInputsObservable.notifyObservers(this);
  20272. };
  20273. Object.defineProperty(Camera.prototype, "rigCameras", {
  20274. /** @hidden */
  20275. get: function () {
  20276. return this._rigCameras;
  20277. },
  20278. enumerable: true,
  20279. configurable: true
  20280. });
  20281. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20282. /**
  20283. * Gets the post process used by the rig cameras
  20284. */
  20285. get: function () {
  20286. return this._rigPostProcess;
  20287. },
  20288. enumerable: true,
  20289. configurable: true
  20290. });
  20291. /**
  20292. * Internal, gets the first post proces.
  20293. * @returns the first post process to be run on this camera.
  20294. */
  20295. Camera.prototype._getFirstPostProcess = function () {
  20296. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20297. if (this._postProcesses[ppIndex] !== null) {
  20298. return this._postProcesses[ppIndex];
  20299. }
  20300. }
  20301. return null;
  20302. };
  20303. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20304. // invalidate framebuffer
  20305. var firstPostProcess = this._getFirstPostProcess();
  20306. if (firstPostProcess) {
  20307. firstPostProcess.markTextureDirty();
  20308. }
  20309. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20310. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20311. var cam = this._rigCameras[i];
  20312. var rigPostProcess = cam._rigPostProcess;
  20313. // for VR rig, there does not have to be a post process
  20314. if (rigPostProcess) {
  20315. var isPass = rigPostProcess.getEffectName() === "pass";
  20316. if (isPass) {
  20317. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20318. cam.isIntermediate = this._postProcesses.length === 0;
  20319. }
  20320. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20321. rigPostProcess.markTextureDirty();
  20322. }
  20323. else {
  20324. cam._postProcesses = this._postProcesses.slice(0);
  20325. }
  20326. }
  20327. };
  20328. /**
  20329. * Attach a post process to the camera.
  20330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20331. * @param postProcess The post process to attach to the camera
  20332. * @param insertAt The position of the post process in case several of them are in use in the scene
  20333. * @returns the position the post process has been inserted at
  20334. */
  20335. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20336. if (insertAt === void 0) { insertAt = null; }
  20337. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20338. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20339. return 0;
  20340. }
  20341. if (insertAt == null || insertAt < 0) {
  20342. this._postProcesses.push(postProcess);
  20343. }
  20344. else if (this._postProcesses[insertAt] === null) {
  20345. this._postProcesses[insertAt] = postProcess;
  20346. }
  20347. else {
  20348. this._postProcesses.splice(insertAt, 0, postProcess);
  20349. }
  20350. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20351. return this._postProcesses.indexOf(postProcess);
  20352. };
  20353. /**
  20354. * Detach a post process to the camera.
  20355. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20356. * @param postProcess The post process to detach from the camera
  20357. */
  20358. Camera.prototype.detachPostProcess = function (postProcess) {
  20359. var idx = this._postProcesses.indexOf(postProcess);
  20360. if (idx !== -1) {
  20361. this._postProcesses[idx] = null;
  20362. }
  20363. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20364. };
  20365. /**
  20366. * Gets the current world matrix of the camera
  20367. */
  20368. Camera.prototype.getWorldMatrix = function () {
  20369. if (this._isSynchronizedViewMatrix()) {
  20370. return this._worldMatrix;
  20371. }
  20372. // Getting the the view matrix will also compute the world matrix.
  20373. this.getViewMatrix();
  20374. return this._worldMatrix;
  20375. };
  20376. /** @hidden */
  20377. Camera.prototype._getViewMatrix = function () {
  20378. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20379. };
  20380. /**
  20381. * Gets the current view matrix of the camera.
  20382. * @param force forces the camera to recompute the matrix without looking at the cached state
  20383. * @returns the view matrix
  20384. */
  20385. Camera.prototype.getViewMatrix = function (force) {
  20386. if (!force && this._isSynchronizedViewMatrix()) {
  20387. return this._computedViewMatrix;
  20388. }
  20389. this.updateCache();
  20390. this._computedViewMatrix = this._getViewMatrix();
  20391. this._currentRenderId = this.getScene().getRenderId();
  20392. this._childRenderId = this._currentRenderId;
  20393. this._refreshFrustumPlanes = true;
  20394. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20395. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20396. }
  20397. this.onViewMatrixChangedObservable.notifyObservers(this);
  20398. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20399. return this._computedViewMatrix;
  20400. };
  20401. /**
  20402. * Freeze the projection matrix.
  20403. * It will prevent the cache check of the camera projection compute and can speed up perf
  20404. * if no parameter of the camera are meant to change
  20405. * @param projection Defines manually a projection if necessary
  20406. */
  20407. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20408. this._doNotComputeProjectionMatrix = true;
  20409. if (projection !== undefined) {
  20410. this._projectionMatrix = projection;
  20411. }
  20412. };
  20413. /**
  20414. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20415. */
  20416. Camera.prototype.unfreezeProjectionMatrix = function () {
  20417. this._doNotComputeProjectionMatrix = false;
  20418. };
  20419. /**
  20420. * Gets the current projection matrix of the camera.
  20421. * @param force forces the camera to recompute the matrix without looking at the cached state
  20422. * @returns the projection matrix
  20423. */
  20424. Camera.prototype.getProjectionMatrix = function (force) {
  20425. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20426. return this._projectionMatrix;
  20427. }
  20428. // Cache
  20429. this._cache.mode = this.mode;
  20430. this._cache.minZ = this.minZ;
  20431. this._cache.maxZ = this.maxZ;
  20432. // Matrix
  20433. this._refreshFrustumPlanes = true;
  20434. var engine = this.getEngine();
  20435. var scene = this.getScene();
  20436. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20437. this._cache.fov = this.fov;
  20438. this._cache.fovMode = this.fovMode;
  20439. this._cache.aspectRatio = engine.getAspectRatio(this);
  20440. if (this.minZ <= 0) {
  20441. this.minZ = 0.1;
  20442. }
  20443. if (scene.useRightHandedSystem) {
  20444. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovRHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  20445. }
  20446. else {
  20447. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  20448. }
  20449. }
  20450. else {
  20451. var halfWidth = engine.getRenderWidth() / 2.0;
  20452. var halfHeight = engine.getRenderHeight() / 2.0;
  20453. if (scene.useRightHandedSystem) {
  20454. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterRHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  20455. }
  20456. else {
  20457. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  20458. }
  20459. this._cache.orthoLeft = this.orthoLeft;
  20460. this._cache.orthoRight = this.orthoRight;
  20461. this._cache.orthoBottom = this.orthoBottom;
  20462. this._cache.orthoTop = this.orthoTop;
  20463. this._cache.renderWidth = engine.getRenderWidth();
  20464. this._cache.renderHeight = engine.getRenderHeight();
  20465. }
  20466. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20467. return this._projectionMatrix;
  20468. };
  20469. /**
  20470. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20471. * @returns a Matrix
  20472. */
  20473. Camera.prototype.getTransformationMatrix = function () {
  20474. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20475. return this._transformMatrix;
  20476. };
  20477. Camera.prototype._updateFrustumPlanes = function () {
  20478. if (!this._refreshFrustumPlanes) {
  20479. return;
  20480. }
  20481. this.getTransformationMatrix();
  20482. if (!this._frustumPlanes) {
  20483. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20484. }
  20485. else {
  20486. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20487. }
  20488. this._refreshFrustumPlanes = false;
  20489. };
  20490. /**
  20491. * Checks if a cullable object (mesh...) is in the camera frustum
  20492. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20493. * @param target The object to check
  20494. * @returns true if the object is in frustum otherwise false
  20495. */
  20496. Camera.prototype.isInFrustum = function (target) {
  20497. this._updateFrustumPlanes();
  20498. return target.isInFrustum(this._frustumPlanes);
  20499. };
  20500. /**
  20501. * Checks if a cullable object (mesh...) is in the camera frustum
  20502. * Unlike isInFrustum this cheks the full bounding box
  20503. * @param target The object to check
  20504. * @returns true if the object is in frustum otherwise false
  20505. */
  20506. Camera.prototype.isCompletelyInFrustum = function (target) {
  20507. this._updateFrustumPlanes();
  20508. return target.isCompletelyInFrustum(this._frustumPlanes);
  20509. };
  20510. /**
  20511. * Gets a ray in the forward direction from the camera.
  20512. * @param length Defines the length of the ray to create
  20513. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20514. * @param origin Defines the start point of the ray which defaults to the camera position
  20515. * @returns the forward ray
  20516. */
  20517. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20518. if (length === void 0) { length = 100; }
  20519. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20520. };
  20521. /**
  20522. * Releases resources associated with this node.
  20523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20525. */
  20526. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20527. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20528. // Observables
  20529. this.onViewMatrixChangedObservable.clear();
  20530. this.onProjectionMatrixChangedObservable.clear();
  20531. this.onAfterCheckInputsObservable.clear();
  20532. this.onRestoreStateObservable.clear();
  20533. // Inputs
  20534. if (this.inputs) {
  20535. this.inputs.clear();
  20536. }
  20537. // Animations
  20538. this.getScene().stopAnimation(this);
  20539. // Remove from scene
  20540. this.getScene().removeCamera(this);
  20541. while (this._rigCameras.length > 0) {
  20542. var camera = this._rigCameras.pop();
  20543. if (camera) {
  20544. camera.dispose();
  20545. }
  20546. }
  20547. // Postprocesses
  20548. if (this._rigPostProcess) {
  20549. this._rigPostProcess.dispose(this);
  20550. this._rigPostProcess = null;
  20551. this._postProcesses = [];
  20552. }
  20553. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20554. this._rigPostProcess = null;
  20555. this._postProcesses = [];
  20556. }
  20557. else {
  20558. var i = this._postProcesses.length;
  20559. while (--i >= 0) {
  20560. var postProcess = this._postProcesses[i];
  20561. if (postProcess) {
  20562. postProcess.dispose(this);
  20563. }
  20564. }
  20565. }
  20566. // Render targets
  20567. var i = this.customRenderTargets.length;
  20568. while (--i >= 0) {
  20569. this.customRenderTargets[i].dispose();
  20570. }
  20571. this.customRenderTargets = [];
  20572. // Active Meshes
  20573. this._activeMeshes.dispose();
  20574. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20575. };
  20576. Object.defineProperty(Camera.prototype, "leftCamera", {
  20577. /**
  20578. * Gets the left camera of a rig setup in case of Rigged Camera
  20579. */
  20580. get: function () {
  20581. if (this._rigCameras.length < 1) {
  20582. return null;
  20583. }
  20584. return this._rigCameras[0];
  20585. },
  20586. enumerable: true,
  20587. configurable: true
  20588. });
  20589. Object.defineProperty(Camera.prototype, "rightCamera", {
  20590. /**
  20591. * Gets the right camera of a rig setup in case of Rigged Camera
  20592. */
  20593. get: function () {
  20594. if (this._rigCameras.length < 2) {
  20595. return null;
  20596. }
  20597. return this._rigCameras[1];
  20598. },
  20599. enumerable: true,
  20600. configurable: true
  20601. });
  20602. /**
  20603. * Gets the left camera target of a rig setup in case of Rigged Camera
  20604. * @returns the target position
  20605. */
  20606. Camera.prototype.getLeftTarget = function () {
  20607. if (this._rigCameras.length < 1) {
  20608. return null;
  20609. }
  20610. return this._rigCameras[0].getTarget();
  20611. };
  20612. /**
  20613. * Gets the right camera target of a rig setup in case of Rigged Camera
  20614. * @returns the target position
  20615. */
  20616. Camera.prototype.getRightTarget = function () {
  20617. if (this._rigCameras.length < 2) {
  20618. return null;
  20619. }
  20620. return this._rigCameras[1].getTarget();
  20621. };
  20622. /**
  20623. * @hidden
  20624. */
  20625. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20626. if (this.cameraRigMode === mode) {
  20627. return;
  20628. }
  20629. while (this._rigCameras.length > 0) {
  20630. var camera = this._rigCameras.pop();
  20631. if (camera) {
  20632. camera.dispose();
  20633. }
  20634. }
  20635. this.cameraRigMode = mode;
  20636. this._cameraRigParams = {};
  20637. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20638. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20639. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20640. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20641. // create the rig cameras, unless none
  20642. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20643. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20644. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20645. if (leftCamera && rightCamera) {
  20646. this._rigCameras.push(leftCamera);
  20647. this._rigCameras.push(rightCamera);
  20648. }
  20649. }
  20650. switch (this.cameraRigMode) {
  20651. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20652. Camera._setStereoscopicAnaglyphRigMode(this);
  20653. break;
  20654. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20655. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20656. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20657. Camera._setStereoscopicRigMode(this);
  20658. break;
  20659. case Camera.RIG_MODE_VR:
  20660. Camera._setVRRigMode(this, rigParams);
  20661. break;
  20662. case Camera.RIG_MODE_WEBVR:
  20663. Camera._setWebVRRigMode(this, rigParams);
  20664. break;
  20665. }
  20666. this._cascadePostProcessesToRigCams();
  20667. this.update();
  20668. };
  20669. /** @hidden */
  20670. Camera._setStereoscopicRigMode = function (camera) {
  20671. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20672. };
  20673. /** @hidden */
  20674. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20675. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20676. };
  20677. /** @hidden */
  20678. Camera._setVRRigMode = function (camera, rigParams) {
  20679. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20680. };
  20681. /** @hidden */
  20682. Camera._setWebVRRigMode = function (camera, rigParams) {
  20683. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20684. };
  20685. /** @hidden */
  20686. Camera.prototype._getVRProjectionMatrix = function () {
  20687. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20688. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20689. return this._projectionMatrix;
  20690. };
  20691. Camera.prototype._updateCameraRotationMatrix = function () {
  20692. //Here for WebVR
  20693. };
  20694. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20695. //Here for WebVR
  20696. };
  20697. /**
  20698. * This function MUST be overwritten by the different WebVR cameras available.
  20699. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20700. * @hidden
  20701. */
  20702. Camera.prototype._getWebVRProjectionMatrix = function () {
  20703. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20704. };
  20705. /**
  20706. * This function MUST be overwritten by the different WebVR cameras available.
  20707. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20708. * @hidden
  20709. */
  20710. Camera.prototype._getWebVRViewMatrix = function () {
  20711. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20712. };
  20713. /** @hidden */
  20714. Camera.prototype.setCameraRigParameter = function (name, value) {
  20715. if (!this._cameraRigParams) {
  20716. this._cameraRigParams = {};
  20717. }
  20718. this._cameraRigParams[name] = value;
  20719. //provisionnally:
  20720. if (name === "interaxialDistance") {
  20721. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20722. }
  20723. };
  20724. /**
  20725. * needs to be overridden by children so sub has required properties to be copied
  20726. * @hidden
  20727. */
  20728. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20729. return null;
  20730. };
  20731. /**
  20732. * May need to be overridden by children
  20733. * @hidden
  20734. */
  20735. Camera.prototype._updateRigCameras = function () {
  20736. for (var i = 0; i < this._rigCameras.length; i++) {
  20737. this._rigCameras[i].minZ = this.minZ;
  20738. this._rigCameras[i].maxZ = this.maxZ;
  20739. this._rigCameras[i].fov = this.fov;
  20740. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20741. }
  20742. // only update viewport when ANAGLYPH
  20743. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20744. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20745. }
  20746. };
  20747. /** @hidden */
  20748. Camera.prototype._setupInputs = function () {
  20749. };
  20750. /**
  20751. * Serialiaze the camera setup to a json represention
  20752. * @returns the JSON representation
  20753. */
  20754. Camera.prototype.serialize = function () {
  20755. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20756. // Type
  20757. serializationObject.type = this.getClassName();
  20758. // Parent
  20759. if (this.parent) {
  20760. serializationObject.parentId = this.parent.id;
  20761. }
  20762. if (this.inputs) {
  20763. this.inputs.serialize(serializationObject);
  20764. }
  20765. // Animations
  20766. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20767. serializationObject.ranges = this.serializeAnimationRanges();
  20768. return serializationObject;
  20769. };
  20770. /**
  20771. * Clones the current camera.
  20772. * @param name The cloned camera name
  20773. * @returns the cloned camera
  20774. */
  20775. Camera.prototype.clone = function (name) {
  20776. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20777. };
  20778. /**
  20779. * Gets the direction of the camera relative to a given local axis.
  20780. * @param localAxis Defines the reference axis to provide a relative direction.
  20781. * @return the direction
  20782. */
  20783. Camera.prototype.getDirection = function (localAxis) {
  20784. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20785. this.getDirectionToRef(localAxis, result);
  20786. return result;
  20787. };
  20788. /**
  20789. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20790. * @param localAxis Defines the reference axis to provide a relative direction.
  20791. * @param result Defines the vector to store the result in
  20792. */
  20793. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20794. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20795. };
  20796. /**
  20797. * Gets a camera constructor for a given camera type
  20798. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20799. * @param name The name of the camera the result will be able to instantiate
  20800. * @param scene The scene the result will construct the camera in
  20801. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20802. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20803. * @returns a factory method to construc the camera
  20804. */
  20805. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20806. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20807. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20808. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20809. interaxial_distance: interaxial_distance,
  20810. isStereoscopicSideBySide: isStereoscopicSideBySide
  20811. });
  20812. if (constructorFunc) {
  20813. return constructorFunc;
  20814. }
  20815. // Default to universal camera
  20816. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20817. };
  20818. /**
  20819. * Compute the world matrix of the camera.
  20820. * @returns the camera workd matrix
  20821. */
  20822. Camera.prototype.computeWorldMatrix = function () {
  20823. return this.getWorldMatrix();
  20824. };
  20825. /**
  20826. * Parse a JSON and creates the camera from the parsed information
  20827. * @param parsedCamera The JSON to parse
  20828. * @param scene The scene to instantiate the camera in
  20829. * @returns the newly constructed camera
  20830. */
  20831. Camera.Parse = function (parsedCamera, scene) {
  20832. var type = parsedCamera.type;
  20833. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20834. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20835. // Parent
  20836. if (parsedCamera.parentId) {
  20837. camera._waitingParentId = parsedCamera.parentId;
  20838. }
  20839. //If camera has an input manager, let it parse inputs settings
  20840. if (camera.inputs) {
  20841. camera.inputs.parse(parsedCamera);
  20842. camera._setupInputs();
  20843. }
  20844. if (camera.setPosition) { // need to force position
  20845. camera.position.copyFromFloats(0, 0, 0);
  20846. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20847. }
  20848. // Target
  20849. if (parsedCamera.target) {
  20850. if (camera.setTarget) {
  20851. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20852. }
  20853. }
  20854. // Apply 3d rig, when found
  20855. if (parsedCamera.cameraRigMode) {
  20856. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20857. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20858. }
  20859. // Animations
  20860. if (parsedCamera.animations) {
  20861. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20862. var parsedAnimation = parsedCamera.animations[animationIndex];
  20863. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  20864. if (internalClass) {
  20865. camera.animations.push(internalClass.Parse(parsedAnimation));
  20866. }
  20867. }
  20868. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20869. }
  20870. if (parsedCamera.autoAnimate) {
  20871. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20872. }
  20873. return camera;
  20874. };
  20875. /** @hidden */
  20876. Camera._createDefaultParsedCamera = function (name, scene) {
  20877. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  20878. };
  20879. /**
  20880. * This is the default projection mode used by the cameras.
  20881. * It helps recreating a feeling of perspective and better appreciate depth.
  20882. * This is the best way to simulate real life cameras.
  20883. */
  20884. Camera.PERSPECTIVE_CAMERA = 0;
  20885. /**
  20886. * This helps creating camera with an orthographic mode.
  20887. * 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.
  20888. */
  20889. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20890. /**
  20891. * This is the default FOV mode for perspective cameras.
  20892. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20893. */
  20894. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20895. /**
  20896. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20897. */
  20898. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20899. /**
  20900. * This specifies ther is no need for a camera rig.
  20901. * Basically only one eye is rendered corresponding to the camera.
  20902. */
  20903. Camera.RIG_MODE_NONE = 0;
  20904. /**
  20905. * Simulates a camera Rig with one blue eye and one red eye.
  20906. * This can be use with 3d blue and red glasses.
  20907. */
  20908. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20909. /**
  20910. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20911. */
  20912. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20913. /**
  20914. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20915. */
  20916. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20917. /**
  20918. * Defines that both eyes of the camera will be rendered over under each other.
  20919. */
  20920. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20921. /**
  20922. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20923. */
  20924. Camera.RIG_MODE_VR = 20;
  20925. /**
  20926. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20927. */
  20928. Camera.RIG_MODE_WEBVR = 21;
  20929. /**
  20930. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20931. */
  20932. Camera.RIG_MODE_CUSTOM = 22;
  20933. /**
  20934. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20935. */
  20936. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20937. /**
  20938. * @hidden
  20939. * Might be removed once multiview will be a thing
  20940. */
  20941. Camera.UseAlternateWebVRRendering = false;
  20942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20944. ], Camera.prototype, "position", void 0);
  20945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20947. ], Camera.prototype, "upVector", void 0);
  20948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20950. ], Camera.prototype, "orthoLeft", void 0);
  20951. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20953. ], Camera.prototype, "orthoRight", void 0);
  20954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20956. ], Camera.prototype, "orthoBottom", void 0);
  20957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20959. ], Camera.prototype, "orthoTop", void 0);
  20960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20962. ], Camera.prototype, "fov", void 0);
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20965. ], Camera.prototype, "minZ", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20968. ], Camera.prototype, "maxZ", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "inertia", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "mode", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "layerMask", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "fovMode", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "cameraRigMode", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "interaxialDistance", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  20990. return Camera;
  20991. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  20992. /***/ }),
  20993. /***/ "./Cameras/cameraInputsManager.ts":
  20994. /*!****************************************!*\
  20995. !*** ./Cameras/cameraInputsManager.ts ***!
  20996. \****************************************/
  20997. /*! exports provided: CameraInputTypes, CameraInputsManager */
  20998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20999. "use strict";
  21000. __webpack_require__.r(__webpack_exports__);
  21001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21003. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21004. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21005. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21006. /**
  21007. * @ignore
  21008. * This is a list of all the different input types that are available in the application.
  21009. * Fo instance: ArcRotateCameraGamepadInput...
  21010. */
  21011. var CameraInputTypes = {};
  21012. /**
  21013. * This represents the input manager used within a camera.
  21014. * It helps dealing with all the different kind of input attached to a camera.
  21015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21016. */
  21017. var CameraInputsManager = /** @class */ (function () {
  21018. /**
  21019. * Instantiate a new Camera Input Manager.
  21020. * @param camera Defines the camera the input manager blongs to
  21021. */
  21022. function CameraInputsManager(camera) {
  21023. this.attached = {};
  21024. this.camera = camera;
  21025. this.checkInputs = function () { };
  21026. }
  21027. /**
  21028. * Add an input method to a camera
  21029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21030. * @param input camera input method
  21031. */
  21032. CameraInputsManager.prototype.add = function (input) {
  21033. var type = input.getSimpleName();
  21034. if (this.attached[type]) {
  21035. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21036. return;
  21037. }
  21038. this.attached[type] = input;
  21039. input.camera = this.camera;
  21040. //for checkInputs, we are dynamically creating a function
  21041. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21042. if (input.checkInputs) {
  21043. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21044. }
  21045. if (this.attachedElement) {
  21046. input.attachControl(this.attachedElement);
  21047. }
  21048. };
  21049. /**
  21050. * Remove a specific input method from a camera
  21051. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21052. * @param inputToRemove camera input method
  21053. */
  21054. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21055. for (var cam in this.attached) {
  21056. var input = this.attached[cam];
  21057. if (input === inputToRemove) {
  21058. input.detachControl(this.attachedElement);
  21059. input.camera = null;
  21060. delete this.attached[cam];
  21061. this.rebuildInputCheck();
  21062. }
  21063. }
  21064. };
  21065. /**
  21066. * Remove a specific input type from a camera
  21067. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21068. * @param inputType the type of the input to remove
  21069. */
  21070. CameraInputsManager.prototype.removeByType = function (inputType) {
  21071. for (var cam in this.attached) {
  21072. var input = this.attached[cam];
  21073. if (input.getClassName() === inputType) {
  21074. input.detachControl(this.attachedElement);
  21075. input.camera = null;
  21076. delete this.attached[cam];
  21077. this.rebuildInputCheck();
  21078. }
  21079. }
  21080. };
  21081. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21082. var current = this.checkInputs;
  21083. return function () {
  21084. current();
  21085. fn();
  21086. };
  21087. };
  21088. /**
  21089. * Attach the input controls to the currently attached dom element to listen the events from.
  21090. * @param input Defines the input to attach
  21091. */
  21092. CameraInputsManager.prototype.attachInput = function (input) {
  21093. if (this.attachedElement) {
  21094. input.attachControl(this.attachedElement, this.noPreventDefault);
  21095. }
  21096. };
  21097. /**
  21098. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21099. * @param element Defines the dom element to collect the events from
  21100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21101. */
  21102. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21103. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21104. if (this.attachedElement) {
  21105. return;
  21106. }
  21107. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21108. this.attachedElement = element;
  21109. this.noPreventDefault = noPreventDefault;
  21110. for (var cam in this.attached) {
  21111. this.attached[cam].attachControl(element, noPreventDefault);
  21112. }
  21113. };
  21114. /**
  21115. * Detach the current manager inputs controls from a specific dom element.
  21116. * @param element Defines the dom element to collect the events from
  21117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21118. */
  21119. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21120. if (disconnect === void 0) { disconnect = false; }
  21121. if (this.attachedElement !== element) {
  21122. return;
  21123. }
  21124. for (var cam in this.attached) {
  21125. this.attached[cam].detachControl(element);
  21126. if (disconnect) {
  21127. this.attached[cam].camera = null;
  21128. }
  21129. }
  21130. this.attachedElement = null;
  21131. };
  21132. /**
  21133. * Rebuild the dynamic inputCheck function from the current list of
  21134. * defined inputs in the manager.
  21135. */
  21136. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21137. this.checkInputs = function () { };
  21138. for (var cam in this.attached) {
  21139. var input = this.attached[cam];
  21140. if (input.checkInputs) {
  21141. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21142. }
  21143. }
  21144. };
  21145. /**
  21146. * Remove all attached input methods from a camera
  21147. */
  21148. CameraInputsManager.prototype.clear = function () {
  21149. if (this.attachedElement) {
  21150. this.detachElement(this.attachedElement, true);
  21151. }
  21152. this.attached = {};
  21153. this.attachedElement = null;
  21154. this.checkInputs = function () { };
  21155. };
  21156. /**
  21157. * Serialize the current input manager attached to a camera.
  21158. * This ensures than once parsed,
  21159. * the input associated to the camera will be identical to the current ones
  21160. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21161. */
  21162. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21163. var inputs = {};
  21164. for (var cam in this.attached) {
  21165. var input = this.attached[cam];
  21166. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21167. inputs[input.getClassName()] = res;
  21168. }
  21169. serializedCamera.inputsmgr = inputs;
  21170. };
  21171. /**
  21172. * Parses an input manager serialized JSON to restore the previous list of inputs
  21173. * and states associated to a camera.
  21174. * @param parsedCamera Defines the JSON to parse
  21175. */
  21176. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21177. var parsedInputs = parsedCamera.inputsmgr;
  21178. if (parsedInputs) {
  21179. this.clear();
  21180. for (var n in parsedInputs) {
  21181. var construct = CameraInputTypes[n];
  21182. if (construct) {
  21183. var parsedinput = parsedInputs[n];
  21184. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21185. this.add(input);
  21186. }
  21187. }
  21188. }
  21189. else {
  21190. //2016-03-08 this part is for managing backward compatibility
  21191. for (var n in this.attached) {
  21192. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21193. if (construct) {
  21194. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21195. this.remove(this.attached[n]);
  21196. this.add(input);
  21197. }
  21198. }
  21199. }
  21200. };
  21201. return CameraInputsManager;
  21202. }());
  21203. /***/ }),
  21204. /***/ "./Cameras/deviceOrientationCamera.ts":
  21205. /*!********************************************!*\
  21206. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21207. \********************************************/
  21208. /*! exports provided: DeviceOrientationCamera */
  21209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21210. "use strict";
  21211. __webpack_require__.r(__webpack_exports__);
  21212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21213. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21214. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21215. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21216. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21217. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21218. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21219. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21220. });
  21221. // We're mainly based on the logic defined into the FreeCamera code
  21222. /**
  21223. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21224. * being tilted forward or back and left or right.
  21225. */
  21226. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21227. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21228. /**
  21229. * Creates a new device orientation camera
  21230. * @param name The name of the camera
  21231. * @param position The start position camera
  21232. * @param scene The scene the camera belongs to
  21233. */
  21234. function DeviceOrientationCamera(name, position, scene) {
  21235. var _this = _super.call(this, name, position, scene) || this;
  21236. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21237. _this.inputs.addDeviceOrientation();
  21238. return _this;
  21239. }
  21240. /**
  21241. * Gets the current instance class name ("DeviceOrientationCamera").
  21242. * This helps avoiding instanceof at run time.
  21243. * @returns the class name
  21244. */
  21245. DeviceOrientationCamera.prototype.getClassName = function () {
  21246. return "DeviceOrientationCamera";
  21247. };
  21248. /**
  21249. * @hidden
  21250. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21251. */
  21252. DeviceOrientationCamera.prototype._checkInputs = function () {
  21253. _super.prototype._checkInputs.call(this);
  21254. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21255. if (this._initialQuaternion) {
  21256. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21257. }
  21258. };
  21259. /**
  21260. * Reset the camera to its default orientation on the specified axis only.
  21261. * @param axis The axis to reset
  21262. */
  21263. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21264. var _this = this;
  21265. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21266. //can only work if this camera has a rotation quaternion already.
  21267. if (!this.rotationQuaternion) {
  21268. return;
  21269. }
  21270. if (!this._initialQuaternion) {
  21271. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21272. }
  21273. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21274. ['x', 'y', 'z'].forEach(function (axisName) {
  21275. if (!axis[axisName]) {
  21276. _this._initialQuaternion[axisName] = 0;
  21277. }
  21278. else {
  21279. _this._initialQuaternion[axisName] *= -1;
  21280. }
  21281. });
  21282. this._initialQuaternion.normalize();
  21283. //force rotation update
  21284. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21285. };
  21286. return DeviceOrientationCamera;
  21287. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21288. /***/ }),
  21289. /***/ "./Cameras/flyCamera.ts":
  21290. /*!******************************!*\
  21291. !*** ./Cameras/flyCamera.ts ***!
  21292. \******************************/
  21293. /*! exports provided: FlyCamera */
  21294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21295. "use strict";
  21296. __webpack_require__.r(__webpack_exports__);
  21297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21299. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21300. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21301. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21302. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21303. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21304. /**
  21305. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21306. * such as in a 3D Space Shooter or a Flight Simulator.
  21307. */
  21308. var FlyCamera = /** @class */ (function (_super) {
  21309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21310. /**
  21311. * Instantiates a FlyCamera.
  21312. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21313. * such as in a 3D Space Shooter or a Flight Simulator.
  21314. * @param name Define the name of the camera in the scene.
  21315. * @param position Define the starting position of the camera in the scene.
  21316. * @param scene Define the scene the camera belongs to.
  21317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21318. */
  21319. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21320. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21321. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21322. /**
  21323. * Define the collision ellipsoid of the camera.
  21324. * This is helpful for simulating a camera body, like a player's body.
  21325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21326. */
  21327. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21328. /**
  21329. * Define an offset for the position of the ellipsoid around the camera.
  21330. * This can be helpful if the camera is attached away from the player's body center,
  21331. * such as at its head.
  21332. */
  21333. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21334. /**
  21335. * Enable or disable collisions of the camera with the rest of the scene objects.
  21336. */
  21337. _this.checkCollisions = false;
  21338. /**
  21339. * Enable or disable gravity on the camera.
  21340. */
  21341. _this.applyGravity = false;
  21342. /**
  21343. * Define the current direction the camera is moving to.
  21344. */
  21345. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21346. /**
  21347. * Track Roll to maintain the wanted Rolling when looking around.
  21348. */
  21349. _this._trackRoll = 0;
  21350. /**
  21351. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21352. */
  21353. _this.rollCorrect = 100;
  21354. /**
  21355. * Mimic a banked turn, Rolling the camera when Yawing.
  21356. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21357. */
  21358. _this.bankedTurn = false;
  21359. /**
  21360. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21361. */
  21362. _this.bankedTurnLimit = Math.PI / 2;
  21363. /**
  21364. * Value of 0 disables the banked Roll.
  21365. * Value of 1 is equal to the Yaw angle in radians.
  21366. */
  21367. _this.bankedTurnMultiplier = 1;
  21368. _this._needMoveForGravity = false;
  21369. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21370. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21371. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21372. // Collisions.
  21373. _this._collisionMask = -1;
  21374. /** @hidden */
  21375. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21376. if (collidedMesh === void 0) { collidedMesh = null; }
  21377. var updatePosition = function (newPos) {
  21378. _this._newPosition.copyFrom(newPos);
  21379. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21380. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21381. _this.position.addInPlace(_this._diffPosition);
  21382. if (_this.onCollide && collidedMesh) {
  21383. _this.onCollide(collidedMesh);
  21384. }
  21385. }
  21386. };
  21387. updatePosition(newPosition);
  21388. };
  21389. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21390. _this.inputs.addKeyboard().addMouse();
  21391. return _this;
  21392. }
  21393. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21394. /**
  21395. * Gets the input sensibility for mouse input.
  21396. * Higher values reduce sensitivity.
  21397. */
  21398. get: function () {
  21399. var mouse = this.inputs.attached["mouse"];
  21400. if (mouse) {
  21401. return mouse.angularSensibility;
  21402. }
  21403. return 0;
  21404. },
  21405. /**
  21406. * Sets the input sensibility for a mouse input.
  21407. * Higher values reduce sensitivity.
  21408. */
  21409. set: function (value) {
  21410. var mouse = this.inputs.attached["mouse"];
  21411. if (mouse) {
  21412. mouse.angularSensibility = value;
  21413. }
  21414. },
  21415. enumerable: true,
  21416. configurable: true
  21417. });
  21418. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21419. /**
  21420. * Get the keys for camera movement forward.
  21421. */
  21422. get: function () {
  21423. var keyboard = this.inputs.attached["keyboard"];
  21424. if (keyboard) {
  21425. return keyboard.keysForward;
  21426. }
  21427. return [];
  21428. },
  21429. /**
  21430. * Set the keys for camera movement forward.
  21431. */
  21432. set: function (value) {
  21433. var keyboard = this.inputs.attached["keyboard"];
  21434. if (keyboard) {
  21435. keyboard.keysForward = value;
  21436. }
  21437. },
  21438. enumerable: true,
  21439. configurable: true
  21440. });
  21441. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21442. /**
  21443. * Get the keys for camera movement backward.
  21444. */
  21445. get: function () {
  21446. var keyboard = this.inputs.attached["keyboard"];
  21447. if (keyboard) {
  21448. return keyboard.keysBackward;
  21449. }
  21450. return [];
  21451. },
  21452. set: function (value) {
  21453. var keyboard = this.inputs.attached["keyboard"];
  21454. if (keyboard) {
  21455. keyboard.keysBackward = value;
  21456. }
  21457. },
  21458. enumerable: true,
  21459. configurable: true
  21460. });
  21461. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21462. /**
  21463. * Get the keys for camera movement up.
  21464. */
  21465. get: function () {
  21466. var keyboard = this.inputs.attached["keyboard"];
  21467. if (keyboard) {
  21468. return keyboard.keysUp;
  21469. }
  21470. return [];
  21471. },
  21472. /**
  21473. * Set the keys for camera movement up.
  21474. */
  21475. set: function (value) {
  21476. var keyboard = this.inputs.attached["keyboard"];
  21477. if (keyboard) {
  21478. keyboard.keysUp = value;
  21479. }
  21480. },
  21481. enumerable: true,
  21482. configurable: true
  21483. });
  21484. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21485. /**
  21486. * Get the keys for camera movement down.
  21487. */
  21488. get: function () {
  21489. var keyboard = this.inputs.attached["keyboard"];
  21490. if (keyboard) {
  21491. return keyboard.keysDown;
  21492. }
  21493. return [];
  21494. },
  21495. /**
  21496. * Set the keys for camera movement down.
  21497. */
  21498. set: function (value) {
  21499. var keyboard = this.inputs.attached["keyboard"];
  21500. if (keyboard) {
  21501. keyboard.keysDown = value;
  21502. }
  21503. },
  21504. enumerable: true,
  21505. configurable: true
  21506. });
  21507. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21508. /**
  21509. * Get the keys for camera movement left.
  21510. */
  21511. get: function () {
  21512. var keyboard = this.inputs.attached["keyboard"];
  21513. if (keyboard) {
  21514. return keyboard.keysLeft;
  21515. }
  21516. return [];
  21517. },
  21518. /**
  21519. * Set the keys for camera movement left.
  21520. */
  21521. set: function (value) {
  21522. var keyboard = this.inputs.attached["keyboard"];
  21523. if (keyboard) {
  21524. keyboard.keysLeft = value;
  21525. }
  21526. },
  21527. enumerable: true,
  21528. configurable: true
  21529. });
  21530. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21531. /**
  21532. * Set the keys for camera movement right.
  21533. */
  21534. get: function () {
  21535. var keyboard = this.inputs.attached["keyboard"];
  21536. if (keyboard) {
  21537. return keyboard.keysRight;
  21538. }
  21539. return [];
  21540. },
  21541. /**
  21542. * Set the keys for camera movement right.
  21543. */
  21544. set: function (value) {
  21545. var keyboard = this.inputs.attached["keyboard"];
  21546. if (keyboard) {
  21547. keyboard.keysRight = value;
  21548. }
  21549. },
  21550. enumerable: true,
  21551. configurable: true
  21552. });
  21553. /**
  21554. * Attach a control to the HTML DOM element.
  21555. * @param element Defines the element that listens to the input events.
  21556. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21557. */
  21558. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21559. this.inputs.attachElement(element, noPreventDefault);
  21560. };
  21561. /**
  21562. * Detach a control from the HTML DOM element.
  21563. * The camera will stop reacting to that input.
  21564. * @param element Defines the element that listens to the input events.
  21565. */
  21566. FlyCamera.prototype.detachControl = function (element) {
  21567. this.inputs.detachElement(element);
  21568. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21569. };
  21570. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21571. /**
  21572. * Get the mask that the camera ignores in collision events.
  21573. */
  21574. get: function () {
  21575. return this._collisionMask;
  21576. },
  21577. /**
  21578. * Set the mask that the camera ignores in collision events.
  21579. */
  21580. set: function (mask) {
  21581. this._collisionMask = !isNaN(mask) ? mask : -1;
  21582. },
  21583. enumerable: true,
  21584. configurable: true
  21585. });
  21586. /** @hidden */
  21587. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21588. var globalPosition;
  21589. if (this.parent) {
  21590. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21591. }
  21592. else {
  21593. globalPosition = this.position;
  21594. }
  21595. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21596. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21597. var coordinator = this.getScene().collisionCoordinator;
  21598. if (!this._collider) {
  21599. this._collider = coordinator.createCollider();
  21600. }
  21601. this._collider._radius = this.ellipsoid;
  21602. this._collider.collisionMask = this._collisionMask;
  21603. // No need for clone, as long as gravity is not on.
  21604. var actualDisplacement = displacement;
  21605. // Add gravity to direction to prevent dual-collision checking.
  21606. if (this.applyGravity) {
  21607. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21608. actualDisplacement = displacement.add(this.getScene().gravity);
  21609. }
  21610. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21611. };
  21612. /** @hidden */
  21613. FlyCamera.prototype._checkInputs = function () {
  21614. if (!this._localDirection) {
  21615. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21616. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21617. }
  21618. this.inputs.checkInputs();
  21619. _super.prototype._checkInputs.call(this);
  21620. };
  21621. /** @hidden */
  21622. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21623. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21624. };
  21625. /** @hidden */
  21626. FlyCamera.prototype._updatePosition = function () {
  21627. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21628. this._collideWithWorld(this.cameraDirection);
  21629. }
  21630. else {
  21631. _super.prototype._updatePosition.call(this);
  21632. }
  21633. };
  21634. /**
  21635. * Restore the Roll to its target value at the rate specified.
  21636. * @param rate - Higher means slower restoring.
  21637. * @hidden
  21638. */
  21639. FlyCamera.prototype.restoreRoll = function (rate) {
  21640. var limit = this._trackRoll; // Target Roll.
  21641. var z = this.rotation.z; // Current Roll.
  21642. var delta = limit - z; // Difference in Roll.
  21643. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21644. // If the difference is noticable, restore the Roll.
  21645. if (Math.abs(delta) >= minRad) {
  21646. // Change Z rotation towards the target Roll.
  21647. this.rotation.z += delta / rate;
  21648. // Match when near enough.
  21649. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21650. this.rotation.z = limit;
  21651. }
  21652. }
  21653. };
  21654. /**
  21655. * Destroy the camera and release the current resources held by it.
  21656. */
  21657. FlyCamera.prototype.dispose = function () {
  21658. this.inputs.clear();
  21659. _super.prototype.dispose.call(this);
  21660. };
  21661. /**
  21662. * Get the current object class name.
  21663. * @returns the class name.
  21664. */
  21665. FlyCamera.prototype.getClassName = function () {
  21666. return "FlyCamera";
  21667. };
  21668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21670. ], FlyCamera.prototype, "ellipsoid", void 0);
  21671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21673. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21676. ], FlyCamera.prototype, "checkCollisions", void 0);
  21677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21679. ], FlyCamera.prototype, "applyGravity", void 0);
  21680. return FlyCamera;
  21681. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21682. /***/ }),
  21683. /***/ "./Cameras/flyCameraInputsManager.ts":
  21684. /*!*******************************************!*\
  21685. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21686. \*******************************************/
  21687. /*! exports provided: FlyCameraInputsManager */
  21688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21689. "use strict";
  21690. __webpack_require__.r(__webpack_exports__);
  21691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21692. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21693. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21694. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21695. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21696. /**
  21697. * Default Inputs manager for the FlyCamera.
  21698. * It groups all the default supported inputs for ease of use.
  21699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21700. */
  21701. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21702. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21703. /**
  21704. * Instantiates a new FlyCameraInputsManager.
  21705. * @param camera Defines the camera the inputs belong to.
  21706. */
  21707. function FlyCameraInputsManager(camera) {
  21708. return _super.call(this, camera) || this;
  21709. }
  21710. /**
  21711. * Add keyboard input support to the input manager.
  21712. * @returns the new FlyCameraKeyboardMoveInput().
  21713. */
  21714. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21715. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21716. return this;
  21717. };
  21718. /**
  21719. * Add mouse input support to the input manager.
  21720. * @param touchEnabled Enable touch screen support.
  21721. * @returns the new FlyCameraMouseInput().
  21722. */
  21723. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21724. if (touchEnabled === void 0) { touchEnabled = true; }
  21725. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21726. return this;
  21727. };
  21728. return FlyCameraInputsManager;
  21729. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21730. /***/ }),
  21731. /***/ "./Cameras/followCamera.ts":
  21732. /*!*********************************!*\
  21733. !*** ./Cameras/followCamera.ts ***!
  21734. \*********************************/
  21735. /*! exports provided: FollowCamera, ArcFollowCamera */
  21736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21737. "use strict";
  21738. __webpack_require__.r(__webpack_exports__);
  21739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21741. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21742. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21743. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21744. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21745. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21746. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21747. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21748. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21749. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21750. });
  21751. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21752. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21753. });
  21754. /**
  21755. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21756. * an arc rotate version arcFollowCamera are available.
  21757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21758. */
  21759. var FollowCamera = /** @class */ (function (_super) {
  21760. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21761. /**
  21762. * Instantiates the follow camera.
  21763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21764. * @param name Define the name of the camera in the scene
  21765. * @param position Define the position of the camera
  21766. * @param scene Define the scene the camera belong to
  21767. * @param lockedTarget Define the target of the camera
  21768. */
  21769. function FollowCamera(name, position, scene, lockedTarget) {
  21770. if (lockedTarget === void 0) { lockedTarget = null; }
  21771. var _this = _super.call(this, name, position, scene) || this;
  21772. /**
  21773. * Distance the follow camera should follow an object at
  21774. */
  21775. _this.radius = 12;
  21776. /**
  21777. * Minimum allowed distance of the camera to the axis of rotation
  21778. * (The camera can not get closer).
  21779. * This can help limiting how the Camera is able to move in the scene.
  21780. */
  21781. _this.lowerRadiusLimit = null;
  21782. /**
  21783. * Maximum allowed distance of the camera to the axis of rotation
  21784. * (The camera can not get further).
  21785. * This can help limiting how the Camera is able to move in the scene.
  21786. */
  21787. _this.upperRadiusLimit = null;
  21788. /**
  21789. * Define a rotation offset between the camera and the object it follows
  21790. */
  21791. _this.rotationOffset = 0;
  21792. /**
  21793. * Minimum allowed angle to camera position relative to target object.
  21794. * This can help limiting how the Camera is able to move in the scene.
  21795. */
  21796. _this.lowerRotationOffsetLimit = null;
  21797. /**
  21798. * Maximum allowed angle to camera position relative to target object.
  21799. * This can help limiting how the Camera is able to move in the scene.
  21800. */
  21801. _this.upperRotationOffsetLimit = null;
  21802. /**
  21803. * Define a height offset between the camera and the object it follows.
  21804. * It can help following an object from the top (like a car chaing a plane)
  21805. */
  21806. _this.heightOffset = 4;
  21807. /**
  21808. * Minimum allowed height of camera position relative to target object.
  21809. * This can help limiting how the Camera is able to move in the scene.
  21810. */
  21811. _this.lowerHeightOffsetLimit = null;
  21812. /**
  21813. * Maximum allowed height of camera position relative to target object.
  21814. * This can help limiting how the Camera is able to move in the scene.
  21815. */
  21816. _this.upperHeightOffsetLimit = null;
  21817. /**
  21818. * Define how fast the camera can accelerate to follow it s target.
  21819. */
  21820. _this.cameraAcceleration = 0.05;
  21821. /**
  21822. * Define the speed limit of the camera following an object.
  21823. */
  21824. _this.maxCameraSpeed = 20;
  21825. _this.lockedTarget = lockedTarget;
  21826. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21827. _this.inputs.addKeyboard().addMouseWheel();
  21828. return _this;
  21829. // Uncomment the following line when the relevant handlers have been implemented.
  21830. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21831. }
  21832. FollowCamera.prototype._follow = function (cameraTarget) {
  21833. if (!cameraTarget) {
  21834. return;
  21835. }
  21836. var yRotation;
  21837. if (cameraTarget.rotationQuaternion) {
  21838. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21839. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21840. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21841. }
  21842. else {
  21843. yRotation = cameraTarget.rotation.y;
  21844. }
  21845. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21846. var targetPosition = cameraTarget.getAbsolutePosition();
  21847. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21848. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21849. var dx = targetX - this.position.x;
  21850. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21851. var dz = (targetZ) - this.position.z;
  21852. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21853. var vy = dy * this.cameraAcceleration;
  21854. var vz = dz * this.cameraAcceleration * 2;
  21855. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21856. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21857. }
  21858. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21859. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21860. }
  21861. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21862. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21863. }
  21864. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21865. this.setTarget(targetPosition);
  21866. };
  21867. /**
  21868. * Attached controls to the current camera.
  21869. * @param element Defines the element the controls should be listened from
  21870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21871. */
  21872. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21873. this.inputs.attachElement(element, noPreventDefault);
  21874. this._reset = function () {
  21875. };
  21876. };
  21877. /**
  21878. * Detach the current controls from the camera.
  21879. * The camera will stop reacting to inputs.
  21880. * @param element Defines the element to stop listening the inputs from
  21881. */
  21882. FollowCamera.prototype.detachControl = function (element) {
  21883. this.inputs.detachElement(element);
  21884. if (this._reset) {
  21885. this._reset();
  21886. }
  21887. };
  21888. /** @hidden */
  21889. FollowCamera.prototype._checkInputs = function () {
  21890. this.inputs.checkInputs();
  21891. this._checkLimits();
  21892. _super.prototype._checkInputs.call(this);
  21893. if (this.lockedTarget) {
  21894. this._follow(this.lockedTarget);
  21895. }
  21896. };
  21897. FollowCamera.prototype._checkLimits = function () {
  21898. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21899. this.radius = this.lowerRadiusLimit;
  21900. }
  21901. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21902. this.radius = this.upperRadiusLimit;
  21903. }
  21904. if (this.lowerHeightOffsetLimit !== null &&
  21905. this.heightOffset < this.lowerHeightOffsetLimit) {
  21906. this.heightOffset = this.lowerHeightOffsetLimit;
  21907. }
  21908. if (this.upperHeightOffsetLimit !== null &&
  21909. this.heightOffset > this.upperHeightOffsetLimit) {
  21910. this.heightOffset = this.upperHeightOffsetLimit;
  21911. }
  21912. if (this.lowerRotationOffsetLimit !== null &&
  21913. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21914. this.rotationOffset = this.lowerRotationOffsetLimit;
  21915. }
  21916. if (this.upperRotationOffsetLimit !== null &&
  21917. this.rotationOffset > this.upperRotationOffsetLimit) {
  21918. this.rotationOffset = this.upperRotationOffsetLimit;
  21919. }
  21920. };
  21921. /**
  21922. * Gets the camera class name.
  21923. * @returns the class name
  21924. */
  21925. FollowCamera.prototype.getClassName = function () {
  21926. return "FollowCamera";
  21927. };
  21928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21930. ], FollowCamera.prototype, "radius", void 0);
  21931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21933. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21936. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21939. ], FollowCamera.prototype, "rotationOffset", void 0);
  21940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21942. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21945. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21948. ], FollowCamera.prototype, "heightOffset", void 0);
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21963. ], FollowCamera.prototype, "lockedTarget", void 0);
  21964. return FollowCamera;
  21965. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21966. /**
  21967. * Arc Rotate version of the follow camera.
  21968. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21969. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21970. */
  21971. var ArcFollowCamera = /** @class */ (function (_super) {
  21972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21973. /**
  21974. * Instantiates a new ArcFollowCamera
  21975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21976. * @param name Define the name of the camera
  21977. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21978. * @param beta Define the rotation angle of the camera around the elevation axis
  21979. * @param radius Define the radius of the camera from its target point
  21980. * @param target Define the target of the camera
  21981. * @param scene Define the scene the camera belongs to
  21982. */
  21983. function ArcFollowCamera(name,
  21984. /** The longitudinal angle of the camera */
  21985. alpha,
  21986. /** The latitudinal angle of the camera */
  21987. beta,
  21988. /** The radius of the camera from its target */
  21989. radius,
  21990. /** Define the camera target (the messh it should follow) */
  21991. target, scene) {
  21992. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  21993. _this.alpha = alpha;
  21994. _this.beta = beta;
  21995. _this.radius = radius;
  21996. _this.target = target;
  21997. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  21998. _this._follow();
  21999. return _this;
  22000. }
  22001. ArcFollowCamera.prototype._follow = function () {
  22002. if (!this.target) {
  22003. return;
  22004. }
  22005. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22006. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22007. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22008. var targetPosition = this.target.getAbsolutePosition();
  22009. this.position = targetPosition.add(this._cartesianCoordinates);
  22010. this.setTarget(targetPosition);
  22011. };
  22012. /** @hidden */
  22013. ArcFollowCamera.prototype._checkInputs = function () {
  22014. _super.prototype._checkInputs.call(this);
  22015. this._follow();
  22016. };
  22017. /**
  22018. * Returns the class name of the object.
  22019. * It is mostly used internally for serialization purposes.
  22020. */
  22021. ArcFollowCamera.prototype.getClassName = function () {
  22022. return "ArcFollowCamera";
  22023. };
  22024. return ArcFollowCamera;
  22025. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22026. /***/ }),
  22027. /***/ "./Cameras/followCameraInputsManager.ts":
  22028. /*!**********************************************!*\
  22029. !*** ./Cameras/followCameraInputsManager.ts ***!
  22030. \**********************************************/
  22031. /*! exports provided: FollowCameraInputsManager */
  22032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22033. "use strict";
  22034. __webpack_require__.r(__webpack_exports__);
  22035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22036. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22037. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22038. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22039. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22040. /**
  22041. * Default Inputs manager for the FollowCamera.
  22042. * It groups all the default supported inputs for ease of use.
  22043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22044. */
  22045. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22047. /**
  22048. * Instantiates a new FollowCameraInputsManager.
  22049. * @param camera Defines the camera the inputs belong to
  22050. */
  22051. function FollowCameraInputsManager(camera) {
  22052. return _super.call(this, camera) || this;
  22053. }
  22054. /**
  22055. * Add keyboard input support to the input manager.
  22056. * @returns the current input manager
  22057. */
  22058. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22059. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22060. return this;
  22061. };
  22062. /**
  22063. * Add mouse wheel input support to the input manager.
  22064. * @returns the current input manager
  22065. */
  22066. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22067. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22068. return this;
  22069. };
  22070. /**
  22071. * Add pointers input support to the input manager.
  22072. * @returns the current input manager
  22073. */
  22074. FollowCameraInputsManager.prototype.addPointers = function () {
  22075. console.warn("Pointer support not yet implemented for FollowCamera.");
  22076. return this;
  22077. };
  22078. /**
  22079. * Add orientation input support to the input manager.
  22080. * @returns the current input manager
  22081. */
  22082. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22083. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22084. return this;
  22085. };
  22086. return FollowCameraInputsManager;
  22087. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22088. /***/ }),
  22089. /***/ "./Cameras/freeCamera.ts":
  22090. /*!*******************************!*\
  22091. !*** ./Cameras/freeCamera.ts ***!
  22092. \*******************************/
  22093. /*! exports provided: FreeCamera */
  22094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22095. "use strict";
  22096. __webpack_require__.r(__webpack_exports__);
  22097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22099. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22100. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22101. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22102. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22103. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22104. /**
  22105. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22106. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22107. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22108. */
  22109. var FreeCamera = /** @class */ (function (_super) {
  22110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22111. /**
  22112. * Instantiates a Free Camera.
  22113. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22114. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22115. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22116. * @param name Define the name of the camera in the scene
  22117. * @param position Define the start position of the camera in the scene
  22118. * @param scene Define the scene the camera belongs to
  22119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22120. */
  22121. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22122. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22123. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22124. /**
  22125. * Define the collision ellipsoid of the camera.
  22126. * This is helpful to simulate a camera body like the player body around the camera
  22127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22128. */
  22129. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22130. /**
  22131. * Define an offset for the position of the ellipsoid around the camera.
  22132. * This can be helpful to determine the center of the body near the gravity center of the body
  22133. * instead of its head.
  22134. */
  22135. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22136. /**
  22137. * Enable or disable collisions of the camera with the rest of the scene objects.
  22138. */
  22139. _this.checkCollisions = false;
  22140. /**
  22141. * Enable or disable gravity on the camera.
  22142. */
  22143. _this.applyGravity = false;
  22144. _this._needMoveForGravity = false;
  22145. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22146. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22147. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22148. // Collisions
  22149. _this._collisionMask = -1;
  22150. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22151. if (collidedMesh === void 0) { collidedMesh = null; }
  22152. var updatePosition = function (newPos) {
  22153. _this._newPosition.copyFrom(newPos);
  22154. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22155. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22156. _this.position.addInPlace(_this._diffPosition);
  22157. if (_this.onCollide && collidedMesh) {
  22158. _this.onCollide(collidedMesh);
  22159. }
  22160. }
  22161. };
  22162. updatePosition(newPosition);
  22163. };
  22164. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22165. _this.inputs.addKeyboard().addMouse();
  22166. return _this;
  22167. }
  22168. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22169. /**
  22170. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22171. * Higher values reduce sensitivity.
  22172. */
  22173. get: function () {
  22174. var mouse = this.inputs.attached["mouse"];
  22175. if (mouse) {
  22176. return mouse.angularSensibility;
  22177. }
  22178. return 0;
  22179. },
  22180. /**
  22181. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22182. * Higher values reduce sensitivity.
  22183. */
  22184. set: function (value) {
  22185. var mouse = this.inputs.attached["mouse"];
  22186. if (mouse) {
  22187. mouse.angularSensibility = value;
  22188. }
  22189. },
  22190. enumerable: true,
  22191. configurable: true
  22192. });
  22193. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22194. /**
  22195. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22196. */
  22197. get: function () {
  22198. var keyboard = this.inputs.attached["keyboard"];
  22199. if (keyboard) {
  22200. return keyboard.keysUp;
  22201. }
  22202. return [];
  22203. },
  22204. set: function (value) {
  22205. var keyboard = this.inputs.attached["keyboard"];
  22206. if (keyboard) {
  22207. keyboard.keysUp = value;
  22208. }
  22209. },
  22210. enumerable: true,
  22211. configurable: true
  22212. });
  22213. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22214. /**
  22215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22216. */
  22217. get: function () {
  22218. var keyboard = this.inputs.attached["keyboard"];
  22219. if (keyboard) {
  22220. return keyboard.keysDown;
  22221. }
  22222. return [];
  22223. },
  22224. set: function (value) {
  22225. var keyboard = this.inputs.attached["keyboard"];
  22226. if (keyboard) {
  22227. keyboard.keysDown = value;
  22228. }
  22229. },
  22230. enumerable: true,
  22231. configurable: true
  22232. });
  22233. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22234. /**
  22235. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22236. */
  22237. get: function () {
  22238. var keyboard = this.inputs.attached["keyboard"];
  22239. if (keyboard) {
  22240. return keyboard.keysLeft;
  22241. }
  22242. return [];
  22243. },
  22244. set: function (value) {
  22245. var keyboard = this.inputs.attached["keyboard"];
  22246. if (keyboard) {
  22247. keyboard.keysLeft = value;
  22248. }
  22249. },
  22250. enumerable: true,
  22251. configurable: true
  22252. });
  22253. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22254. /**
  22255. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22256. */
  22257. get: function () {
  22258. var keyboard = this.inputs.attached["keyboard"];
  22259. if (keyboard) {
  22260. return keyboard.keysRight;
  22261. }
  22262. return [];
  22263. },
  22264. set: function (value) {
  22265. var keyboard = this.inputs.attached["keyboard"];
  22266. if (keyboard) {
  22267. keyboard.keysRight = value;
  22268. }
  22269. },
  22270. enumerable: true,
  22271. configurable: true
  22272. });
  22273. /**
  22274. * Attached controls to the current camera.
  22275. * @param element Defines the element the controls should be listened from
  22276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22277. */
  22278. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22279. this.inputs.attachElement(element, noPreventDefault);
  22280. };
  22281. /**
  22282. * Detach the current controls from the camera.
  22283. * The camera will stop reacting to inputs.
  22284. * @param element Defines the element to stop listening the inputs from
  22285. */
  22286. FreeCamera.prototype.detachControl = function (element) {
  22287. this.inputs.detachElement(element);
  22288. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22289. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22290. };
  22291. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22292. /**
  22293. * Define a collision mask to limit the list of object the camera can collide with
  22294. */
  22295. get: function () {
  22296. return this._collisionMask;
  22297. },
  22298. set: function (mask) {
  22299. this._collisionMask = !isNaN(mask) ? mask : -1;
  22300. },
  22301. enumerable: true,
  22302. configurable: true
  22303. });
  22304. /** @hidden */
  22305. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22306. var globalPosition;
  22307. if (this.parent) {
  22308. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22309. }
  22310. else {
  22311. globalPosition = this.position;
  22312. }
  22313. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22314. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22315. var coordinator = this.getScene().collisionCoordinator;
  22316. if (!this._collider) {
  22317. this._collider = coordinator.createCollider();
  22318. }
  22319. this._collider._radius = this.ellipsoid;
  22320. this._collider.collisionMask = this._collisionMask;
  22321. //no need for clone, as long as gravity is not on.
  22322. var actualDisplacement = displacement;
  22323. //add gravity to the direction to prevent the dual-collision checking
  22324. if (this.applyGravity) {
  22325. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22326. actualDisplacement = displacement.add(this.getScene().gravity);
  22327. }
  22328. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22329. };
  22330. /** @hidden */
  22331. FreeCamera.prototype._checkInputs = function () {
  22332. if (!this._localDirection) {
  22333. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22334. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22335. }
  22336. this.inputs.checkInputs();
  22337. _super.prototype._checkInputs.call(this);
  22338. };
  22339. /** @hidden */
  22340. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22341. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22342. };
  22343. /** @hidden */
  22344. FreeCamera.prototype._updatePosition = function () {
  22345. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22346. this._collideWithWorld(this.cameraDirection);
  22347. }
  22348. else {
  22349. _super.prototype._updatePosition.call(this);
  22350. }
  22351. };
  22352. /**
  22353. * Destroy the camera and release the current resources hold by it.
  22354. */
  22355. FreeCamera.prototype.dispose = function () {
  22356. this.inputs.clear();
  22357. _super.prototype.dispose.call(this);
  22358. };
  22359. /**
  22360. * Gets the current object class name.
  22361. * @return the class name
  22362. */
  22363. FreeCamera.prototype.getClassName = function () {
  22364. return "FreeCamera";
  22365. };
  22366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22368. ], FreeCamera.prototype, "ellipsoid", void 0);
  22369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22371. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22374. ], FreeCamera.prototype, "checkCollisions", void 0);
  22375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22377. ], FreeCamera.prototype, "applyGravity", void 0);
  22378. return FreeCamera;
  22379. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22380. /***/ }),
  22381. /***/ "./Cameras/freeCameraInputsManager.ts":
  22382. /*!********************************************!*\
  22383. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22384. \********************************************/
  22385. /*! exports provided: FreeCameraInputsManager */
  22386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22387. "use strict";
  22388. __webpack_require__.r(__webpack_exports__);
  22389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22390. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22391. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22392. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22393. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22394. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22395. /**
  22396. * Default Inputs manager for the FreeCamera.
  22397. * It groups all the default supported inputs for ease of use.
  22398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22399. */
  22400. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22401. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22402. /**
  22403. * Instantiates a new FreeCameraInputsManager.
  22404. * @param camera Defines the camera the inputs belong to
  22405. */
  22406. function FreeCameraInputsManager(camera) {
  22407. return _super.call(this, camera) || this;
  22408. }
  22409. /**
  22410. * Add keyboard input support to the input manager.
  22411. * @returns the current input manager
  22412. */
  22413. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22414. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22415. return this;
  22416. };
  22417. /**
  22418. * Add mouse input support to the input manager.
  22419. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22420. * @returns the current input manager
  22421. */
  22422. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22423. if (touchEnabled === void 0) { touchEnabled = true; }
  22424. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22425. return this;
  22426. };
  22427. /**
  22428. * Add touch input support to the input manager.
  22429. * @returns the current input manager
  22430. */
  22431. FreeCameraInputsManager.prototype.addTouch = function () {
  22432. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22433. return this;
  22434. };
  22435. return FreeCameraInputsManager;
  22436. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22437. /***/ }),
  22438. /***/ "./Cameras/gamepadCamera.ts":
  22439. /*!**********************************!*\
  22440. !*** ./Cameras/gamepadCamera.ts ***!
  22441. \**********************************/
  22442. /*! exports provided: GamepadCamera */
  22443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22444. "use strict";
  22445. __webpack_require__.r(__webpack_exports__);
  22446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22448. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22449. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22450. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22451. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22452. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22453. });
  22454. /**
  22455. * This represents a FPS type of camera. This is only here for back compat purpose.
  22456. * Please use the UniversalCamera instead as both are identical.
  22457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22458. */
  22459. var GamepadCamera = /** @class */ (function (_super) {
  22460. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22461. /**
  22462. * Instantiates a new Gamepad Camera
  22463. * This represents a FPS type of camera. This is only here for back compat purpose.
  22464. * Please use the UniversalCamera instead as both are identical.
  22465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22466. * @param name Define the name of the camera in the scene
  22467. * @param position Define the start position of the camera in the scene
  22468. * @param scene Define the scene the camera belongs to
  22469. */
  22470. function GamepadCamera(name, position, scene) {
  22471. return _super.call(this, name, position, scene) || this;
  22472. }
  22473. /**
  22474. * Gets the current object class name.
  22475. * @return the class name
  22476. */
  22477. GamepadCamera.prototype.getClassName = function () {
  22478. return "GamepadCamera";
  22479. };
  22480. return GamepadCamera;
  22481. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22482. /***/ }),
  22483. /***/ "./Cameras/index.ts":
  22484. /*!**************************!*\
  22485. !*** ./Cameras/index.ts ***!
  22486. \**************************/
  22487. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22489. "use strict";
  22490. __webpack_require__.r(__webpack_exports__);
  22491. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22505. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22508. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22510. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22512. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22514. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22516. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22518. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22520. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22522. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22524. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22526. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22528. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22531. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22533. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22542. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22544. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22546. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22553. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22564. /***/ }),
  22565. /***/ "./Cameras/targetCamera.ts":
  22566. /*!*********************************!*\
  22567. !*** ./Cameras/targetCamera.ts ***!
  22568. \*********************************/
  22569. /*! exports provided: TargetCamera */
  22570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22571. "use strict";
  22572. __webpack_require__.r(__webpack_exports__);
  22573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22574. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22575. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22576. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22577. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22578. /**
  22579. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22580. * This is the base of the follow, arc rotate cameras and Free camera
  22581. * @see http://doc.babylonjs.com/features/cameras
  22582. */
  22583. var TargetCamera = /** @class */ (function (_super) {
  22584. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22585. /**
  22586. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22587. * This is the base of the follow, arc rotate cameras and Free camera
  22588. * @see http://doc.babylonjs.com/features/cameras
  22589. * @param name Defines the name of the camera in the scene
  22590. * @param position Defines the start position of the camera in the scene
  22591. * @param scene Defines the scene the camera belongs to
  22592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22593. */
  22594. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22595. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22596. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22597. /**
  22598. * Define the current direction the camera is moving to
  22599. */
  22600. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22601. /**
  22602. * Define the current rotation the camera is rotating to
  22603. */
  22604. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22605. /**
  22606. * When set, the up vector of the camera will be updated by the rotation of the camera
  22607. */
  22608. _this.updateUpVectorFromRotation = false;
  22609. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22610. /**
  22611. * Define the current rotation of the camera
  22612. */
  22613. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22614. /**
  22615. * Define the current speed of the camera
  22616. */
  22617. _this.speed = 2.0;
  22618. /**
  22619. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22620. * around all axis.
  22621. */
  22622. _this.noRotationConstraint = false;
  22623. /**
  22624. * Define the current target of the camera as an object or a position.
  22625. */
  22626. _this.lockedTarget = null;
  22627. /** @hidden */
  22628. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22629. /** @hidden */
  22630. _this._initialFocalDistance = 1;
  22631. /** @hidden */
  22632. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22633. /** @hidden */
  22634. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22635. /** @hidden */
  22636. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22637. /** @hidden */
  22638. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22639. /** @hidden */
  22640. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22641. /** @hidden */
  22642. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22643. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22644. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22645. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22646. _this._cachedRotationZ = 0;
  22647. _this._cachedQuaternionRotationZ = 0;
  22648. return _this;
  22649. }
  22650. /**
  22651. * Gets the position in front of the camera at a given distance.
  22652. * @param distance The distance from the camera we want the position to be
  22653. * @returns the position
  22654. */
  22655. TargetCamera.prototype.getFrontPosition = function (distance) {
  22656. this.getWorldMatrix();
  22657. var direction = this.getTarget().subtract(this.position);
  22658. direction.normalize();
  22659. direction.scaleInPlace(distance);
  22660. return this.globalPosition.add(direction);
  22661. };
  22662. /** @hidden */
  22663. TargetCamera.prototype._getLockedTargetPosition = function () {
  22664. if (!this.lockedTarget) {
  22665. return null;
  22666. }
  22667. if (this.lockedTarget.absolutePosition) {
  22668. this.lockedTarget.computeWorldMatrix();
  22669. }
  22670. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22671. };
  22672. /**
  22673. * Store current camera state of the camera (fov, position, rotation, etc..)
  22674. * @returns the camera
  22675. */
  22676. TargetCamera.prototype.storeState = function () {
  22677. this._storedPosition = this.position.clone();
  22678. this._storedRotation = this.rotation.clone();
  22679. if (this.rotationQuaternion) {
  22680. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22681. }
  22682. return _super.prototype.storeState.call(this);
  22683. };
  22684. /**
  22685. * Restored camera state. You must call storeState() first
  22686. * @returns whether it was successful or not
  22687. * @hidden
  22688. */
  22689. TargetCamera.prototype._restoreStateValues = function () {
  22690. if (!_super.prototype._restoreStateValues.call(this)) {
  22691. return false;
  22692. }
  22693. this.position = this._storedPosition.clone();
  22694. this.rotation = this._storedRotation.clone();
  22695. if (this.rotationQuaternion) {
  22696. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22697. }
  22698. this.cameraDirection.copyFromFloats(0, 0, 0);
  22699. this.cameraRotation.copyFromFloats(0, 0);
  22700. return true;
  22701. };
  22702. /** @hidden */
  22703. TargetCamera.prototype._initCache = function () {
  22704. _super.prototype._initCache.call(this);
  22705. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22706. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22707. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22708. };
  22709. /** @hidden */
  22710. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22711. if (!ignoreParentClass) {
  22712. _super.prototype._updateCache.call(this);
  22713. }
  22714. var lockedTargetPosition = this._getLockedTargetPosition();
  22715. if (!lockedTargetPosition) {
  22716. this._cache.lockedTarget = null;
  22717. }
  22718. else {
  22719. if (!this._cache.lockedTarget) {
  22720. this._cache.lockedTarget = lockedTargetPosition.clone();
  22721. }
  22722. else {
  22723. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22724. }
  22725. }
  22726. this._cache.rotation.copyFrom(this.rotation);
  22727. if (this.rotationQuaternion) {
  22728. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22729. }
  22730. };
  22731. // Synchronized
  22732. /** @hidden */
  22733. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22734. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22735. return false;
  22736. }
  22737. var lockedTargetPosition = this._getLockedTargetPosition();
  22738. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22739. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22740. };
  22741. // Methods
  22742. /** @hidden */
  22743. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22744. var engine = this.getEngine();
  22745. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22746. };
  22747. // Target
  22748. /** @hidden */
  22749. TargetCamera.prototype.setTarget = function (target) {
  22750. this.upVector.normalize();
  22751. this._initialFocalDistance = target.subtract(this.position).length();
  22752. if (this.position.z === target.z) {
  22753. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22754. }
  22755. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22756. this._camMatrix.invert();
  22757. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22758. var vDir = target.subtract(this.position);
  22759. if (vDir.x >= 0.0) {
  22760. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22761. }
  22762. else {
  22763. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22764. }
  22765. this.rotation.z = 0;
  22766. if (isNaN(this.rotation.x)) {
  22767. this.rotation.x = 0;
  22768. }
  22769. if (isNaN(this.rotation.y)) {
  22770. this.rotation.y = 0;
  22771. }
  22772. if (isNaN(this.rotation.z)) {
  22773. this.rotation.z = 0;
  22774. }
  22775. if (this.rotationQuaternion) {
  22776. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22777. }
  22778. };
  22779. /**
  22780. * Return the current target position of the camera. This value is expressed in local space.
  22781. * @returns the target position
  22782. */
  22783. TargetCamera.prototype.getTarget = function () {
  22784. return this._currentTarget;
  22785. };
  22786. /** @hidden */
  22787. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22788. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22789. };
  22790. /** @hidden */
  22791. TargetCamera.prototype._updatePosition = function () {
  22792. if (this.parent) {
  22793. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22794. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this.cameraDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22795. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22796. return;
  22797. }
  22798. this.position.addInPlace(this.cameraDirection);
  22799. };
  22800. /** @hidden */
  22801. TargetCamera.prototype._checkInputs = function () {
  22802. var needToMove = this._decideIfNeedsToMove();
  22803. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22804. // Move
  22805. if (needToMove) {
  22806. this._updatePosition();
  22807. }
  22808. // Rotate
  22809. if (needToRotate) {
  22810. this.rotation.x += this.cameraRotation.x;
  22811. this.rotation.y += this.cameraRotation.y;
  22812. //rotate, if quaternion is set and rotation was used
  22813. if (this.rotationQuaternion) {
  22814. var len = this.rotation.lengthSquared();
  22815. if (len) {
  22816. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22817. }
  22818. }
  22819. if (!this.noRotationConstraint) {
  22820. var limit = (Math.PI / 2) * 0.95;
  22821. if (this.rotation.x > limit) {
  22822. this.rotation.x = limit;
  22823. }
  22824. if (this.rotation.x < -limit) {
  22825. this.rotation.x = -limit;
  22826. }
  22827. }
  22828. }
  22829. // Inertia
  22830. if (needToMove) {
  22831. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22832. this.cameraDirection.x = 0;
  22833. }
  22834. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22835. this.cameraDirection.y = 0;
  22836. }
  22837. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22838. this.cameraDirection.z = 0;
  22839. }
  22840. this.cameraDirection.scaleInPlace(this.inertia);
  22841. }
  22842. if (needToRotate) {
  22843. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22844. this.cameraRotation.x = 0;
  22845. }
  22846. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22847. this.cameraRotation.y = 0;
  22848. }
  22849. this.cameraRotation.scaleInPlace(this.inertia);
  22850. }
  22851. _super.prototype._checkInputs.call(this);
  22852. };
  22853. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22854. if (this.rotationQuaternion) {
  22855. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22856. }
  22857. else {
  22858. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22859. }
  22860. };
  22861. /**
  22862. * 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)
  22863. * @returns the current camera
  22864. */
  22865. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22866. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22867. return this;
  22868. };
  22869. /** @hidden */
  22870. TargetCamera.prototype._getViewMatrix = function () {
  22871. if (this.lockedTarget) {
  22872. this.setTarget(this._getLockedTargetPosition());
  22873. }
  22874. // Compute
  22875. this._updateCameraRotationMatrix();
  22876. // Apply the changed rotation to the upVector
  22877. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22878. this._rotateUpVectorWithCameraRotationMatrix();
  22879. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22880. }
  22881. else if (this._cachedRotationZ != this.rotation.z) {
  22882. this._rotateUpVectorWithCameraRotationMatrix();
  22883. this._cachedRotationZ = this.rotation.z;
  22884. }
  22885. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22886. // Computing target and final matrix
  22887. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22888. if (this.updateUpVectorFromRotation) {
  22889. if (this.rotationQuaternion) {
  22890. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22891. }
  22892. else {
  22893. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22894. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22895. }
  22896. }
  22897. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22898. return this._viewMatrix;
  22899. };
  22900. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22901. if (this.parent) {
  22902. var parentWorldMatrix = this.parent.getWorldMatrix();
  22903. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22904. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22905. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22906. this._markSyncedWithParent();
  22907. }
  22908. else {
  22909. this._globalPosition.copyFrom(position);
  22910. this._globalCurrentTarget.copyFrom(target);
  22911. this._globalCurrentUpVector.copyFrom(up);
  22912. }
  22913. if (this.getScene().useRightHandedSystem) {
  22914. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22915. }
  22916. else {
  22917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22918. }
  22919. };
  22920. /**
  22921. * @hidden
  22922. */
  22923. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22924. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22925. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22926. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22927. if (!this.rotationQuaternion) {
  22928. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22929. }
  22930. rigCamera._cameraRigParams = {};
  22931. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22932. }
  22933. return rigCamera;
  22934. }
  22935. return null;
  22936. };
  22937. /**
  22938. * @hidden
  22939. */
  22940. TargetCamera.prototype._updateRigCameras = function () {
  22941. var camLeft = this._rigCameras[0];
  22942. var camRight = this._rigCameras[1];
  22943. this.computeWorldMatrix();
  22944. switch (this.cameraRigMode) {
  22945. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22946. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22947. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22948. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22949. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22950. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22951. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22952. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22953. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22954. break;
  22955. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22956. if (camLeft.rotationQuaternion) {
  22957. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22958. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22959. }
  22960. else {
  22961. camLeft.rotation.copyFrom(this.rotation);
  22962. camRight.rotation.copyFrom(this.rotation);
  22963. }
  22964. camLeft.position.copyFrom(this.position);
  22965. camRight.position.copyFrom(this.position);
  22966. break;
  22967. }
  22968. _super.prototype._updateRigCameras.call(this);
  22969. };
  22970. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22971. var target = this.getTarget();
  22972. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22973. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22974. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22975. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22976. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22977. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22978. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22979. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22980. rigCamera.setTarget(newFocalTarget);
  22981. };
  22982. /**
  22983. * Gets the current object class name.
  22984. * @return the class name
  22985. */
  22986. TargetCamera.prototype.getClassName = function () {
  22987. return "TargetCamera";
  22988. };
  22989. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22990. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22991. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  22992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22994. ], TargetCamera.prototype, "rotation", void 0);
  22995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22997. ], TargetCamera.prototype, "speed", void 0);
  22998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23000. ], TargetCamera.prototype, "lockedTarget", void 0);
  23001. return TargetCamera;
  23002. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23003. /***/ }),
  23004. /***/ "./Cameras/touchCamera.ts":
  23005. /*!********************************!*\
  23006. !*** ./Cameras/touchCamera.ts ***!
  23007. \********************************/
  23008. /*! exports provided: TouchCamera */
  23009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23010. "use strict";
  23011. __webpack_require__.r(__webpack_exports__);
  23012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23013. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23014. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23015. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23016. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23017. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23018. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23019. });
  23020. /**
  23021. * This represents a FPS type of camera controlled by touch.
  23022. * This is like a universal camera minus the Gamepad controls.
  23023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23024. */
  23025. var TouchCamera = /** @class */ (function (_super) {
  23026. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23027. /**
  23028. * Instantiates a new touch camera.
  23029. * This represents a FPS type of camera controlled by touch.
  23030. * This is like a universal camera minus the Gamepad controls.
  23031. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23032. * @param name Define the name of the camera in the scene
  23033. * @param position Define the start position of the camera in the scene
  23034. * @param scene Define the scene the camera belongs to
  23035. */
  23036. function TouchCamera(name, position, scene) {
  23037. var _this = _super.call(this, name, position, scene) || this;
  23038. _this.inputs.addTouch();
  23039. _this._setupInputs();
  23040. return _this;
  23041. }
  23042. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23043. /**
  23044. * Defines the touch sensibility for rotation.
  23045. * The higher the faster.
  23046. */
  23047. get: function () {
  23048. var touch = this.inputs.attached["touch"];
  23049. if (touch) {
  23050. return touch.touchAngularSensibility;
  23051. }
  23052. return 0;
  23053. },
  23054. set: function (value) {
  23055. var touch = this.inputs.attached["touch"];
  23056. if (touch) {
  23057. touch.touchAngularSensibility = value;
  23058. }
  23059. },
  23060. enumerable: true,
  23061. configurable: true
  23062. });
  23063. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23064. /**
  23065. * Defines the touch sensibility for move.
  23066. * The higher the faster.
  23067. */
  23068. get: function () {
  23069. var touch = this.inputs.attached["touch"];
  23070. if (touch) {
  23071. return touch.touchMoveSensibility;
  23072. }
  23073. return 0;
  23074. },
  23075. set: function (value) {
  23076. var touch = this.inputs.attached["touch"];
  23077. if (touch) {
  23078. touch.touchMoveSensibility = value;
  23079. }
  23080. },
  23081. enumerable: true,
  23082. configurable: true
  23083. });
  23084. /**
  23085. * Gets the current object class name.
  23086. * @return the class name
  23087. */
  23088. TouchCamera.prototype.getClassName = function () {
  23089. return "TouchCamera";
  23090. };
  23091. /** @hidden */
  23092. TouchCamera.prototype._setupInputs = function () {
  23093. var mouse = this.inputs.attached["mouse"];
  23094. if (mouse) {
  23095. mouse.touchEnabled = false;
  23096. }
  23097. };
  23098. return TouchCamera;
  23099. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23100. /***/ }),
  23101. /***/ "./Cameras/universalCamera.ts":
  23102. /*!************************************!*\
  23103. !*** ./Cameras/universalCamera.ts ***!
  23104. \************************************/
  23105. /*! exports provided: UniversalCamera */
  23106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23107. "use strict";
  23108. __webpack_require__.r(__webpack_exports__);
  23109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23111. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23112. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23113. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23114. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23115. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23116. // Forcing to use the Universal camera
  23117. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23118. });
  23119. /**
  23120. * 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,
  23121. * which still works and will still be found in many Playgrounds.
  23122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23123. */
  23124. var UniversalCamera = /** @class */ (function (_super) {
  23125. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23126. /**
  23127. * 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,
  23128. * which still works and will still be found in many Playgrounds.
  23129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23130. * @param name Define the name of the camera in the scene
  23131. * @param position Define the start position of the camera in the scene
  23132. * @param scene Define the scene the camera belongs to
  23133. */
  23134. function UniversalCamera(name, position, scene) {
  23135. var _this = _super.call(this, name, position, scene) || this;
  23136. _this.inputs.addGamepad();
  23137. return _this;
  23138. }
  23139. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23140. /**
  23141. * Defines the gamepad rotation sensiblity.
  23142. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23143. */
  23144. get: function () {
  23145. var gamepad = this.inputs.attached["gamepad"];
  23146. if (gamepad) {
  23147. return gamepad.gamepadAngularSensibility;
  23148. }
  23149. return 0;
  23150. },
  23151. set: function (value) {
  23152. var gamepad = this.inputs.attached["gamepad"];
  23153. if (gamepad) {
  23154. gamepad.gamepadAngularSensibility = value;
  23155. }
  23156. },
  23157. enumerable: true,
  23158. configurable: true
  23159. });
  23160. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23161. /**
  23162. * Defines the gamepad move sensiblity.
  23163. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23164. */
  23165. get: function () {
  23166. var gamepad = this.inputs.attached["gamepad"];
  23167. if (gamepad) {
  23168. return gamepad.gamepadMoveSensibility;
  23169. }
  23170. return 0;
  23171. },
  23172. set: function (value) {
  23173. var gamepad = this.inputs.attached["gamepad"];
  23174. if (gamepad) {
  23175. gamepad.gamepadMoveSensibility = value;
  23176. }
  23177. },
  23178. enumerable: true,
  23179. configurable: true
  23180. });
  23181. /**
  23182. * Gets the current object class name.
  23183. * @return the class name
  23184. */
  23185. UniversalCamera.prototype.getClassName = function () {
  23186. return "UniversalCamera";
  23187. };
  23188. return UniversalCamera;
  23189. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23190. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23191. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23192. };
  23193. /***/ }),
  23194. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23195. /*!*******************************************!*\
  23196. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23197. \*******************************************/
  23198. /*! exports provided: VirtualJoysticksCamera */
  23199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23200. "use strict";
  23201. __webpack_require__.r(__webpack_exports__);
  23202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23203. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23204. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23205. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23206. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23207. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23208. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23209. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23210. });
  23211. /**
  23212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23213. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23214. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23215. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23216. */
  23217. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23218. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23219. /**
  23220. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23221. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23222. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23223. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23224. * @param name Define the name of the camera in the scene
  23225. * @param position Define the start position of the camera in the scene
  23226. * @param scene Define the scene the camera belongs to
  23227. */
  23228. function VirtualJoysticksCamera(name, position, scene) {
  23229. var _this = _super.call(this, name, position, scene) || this;
  23230. _this.inputs.addVirtualJoystick();
  23231. return _this;
  23232. }
  23233. /**
  23234. * Gets the current object class name.
  23235. * @return the class name
  23236. */
  23237. VirtualJoysticksCamera.prototype.getClassName = function () {
  23238. return "VirtualJoysticksCamera";
  23239. };
  23240. return VirtualJoysticksCamera;
  23241. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23242. /***/ }),
  23243. /***/ "./Collisions/collider.ts":
  23244. /*!********************************!*\
  23245. !*** ./Collisions/collider.ts ***!
  23246. \********************************/
  23247. /*! exports provided: Collider */
  23248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23249. "use strict";
  23250. __webpack_require__.r(__webpack_exports__);
  23251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23253. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23254. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23255. return false;
  23256. }
  23257. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23258. return false;
  23259. }
  23260. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23261. return false;
  23262. }
  23263. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23264. return false;
  23265. }
  23266. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23267. return false;
  23268. }
  23269. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23270. return false;
  23271. }
  23272. return true;
  23273. };
  23274. var getLowestRoot = (function () {
  23275. var result = { root: 0, found: false };
  23276. return function (a, b, c, maxR) {
  23277. result.root = 0;
  23278. result.found = false;
  23279. var determinant = b * b - 4.0 * a * c;
  23280. if (determinant < 0) {
  23281. return result;
  23282. }
  23283. var sqrtD = Math.sqrt(determinant);
  23284. var r1 = (-b - sqrtD) / (2.0 * a);
  23285. var r2 = (-b + sqrtD) / (2.0 * a);
  23286. if (r1 > r2) {
  23287. var temp = r2;
  23288. r2 = r1;
  23289. r1 = temp;
  23290. }
  23291. if (r1 > 0 && r1 < maxR) {
  23292. result.root = r1;
  23293. result.found = true;
  23294. return result;
  23295. }
  23296. if (r2 > 0 && r2 < maxR) {
  23297. result.root = r2;
  23298. result.found = true;
  23299. return result;
  23300. }
  23301. return result;
  23302. };
  23303. })();
  23304. /** @hidden */
  23305. var Collider = /** @class */ (function () {
  23306. function Collider() {
  23307. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23308. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23309. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23310. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23311. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23312. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23313. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23314. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23315. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23316. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23317. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23318. /** @hidden */
  23319. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23320. /** @hidden */
  23321. this._retry = 0;
  23322. /** @hidden */
  23323. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23324. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23325. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23326. this._collisionMask = -1;
  23327. }
  23328. Object.defineProperty(Collider.prototype, "collisionMask", {
  23329. get: function () {
  23330. return this._collisionMask;
  23331. },
  23332. set: function (mask) {
  23333. this._collisionMask = !isNaN(mask) ? mask : -1;
  23334. },
  23335. enumerable: true,
  23336. configurable: true
  23337. });
  23338. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23339. /**
  23340. * Gets the plane normal used to compute the sliding response (in local space)
  23341. */
  23342. get: function () {
  23343. return this._slidePlaneNormal;
  23344. },
  23345. enumerable: true,
  23346. configurable: true
  23347. });
  23348. // Methods
  23349. /** @hidden */
  23350. Collider.prototype._initialize = function (source, dir, e) {
  23351. this._velocity = dir;
  23352. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23353. this._basePoint = source;
  23354. source.multiplyToRef(this._radius, this._basePointWorld);
  23355. dir.multiplyToRef(this._radius, this._velocityWorld);
  23356. this._velocityWorldLength = this._velocityWorld.length();
  23357. this._epsilon = e;
  23358. this.collisionFound = false;
  23359. };
  23360. /** @hidden */
  23361. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23362. pa.subtractToRef(point, this._tempVector);
  23363. pb.subtractToRef(point, this._tempVector2);
  23364. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23365. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23366. if (d < 0) {
  23367. return false;
  23368. }
  23369. pc.subtractToRef(point, this._tempVector3);
  23370. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23371. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23372. if (d < 0) {
  23373. return false;
  23374. }
  23375. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23376. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23377. return d >= 0;
  23378. };
  23379. /** @hidden */
  23380. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23381. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23382. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23383. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23384. return false;
  23385. }
  23386. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23387. return false;
  23388. }
  23389. return true;
  23390. };
  23391. /** @hidden */
  23392. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23393. var t0;
  23394. var embeddedInPlane = false;
  23395. //defensive programming, actually not needed.
  23396. if (!trianglePlaneArray) {
  23397. trianglePlaneArray = [];
  23398. }
  23399. if (!trianglePlaneArray[faceIndex]) {
  23400. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23401. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23402. }
  23403. var trianglePlane = trianglePlaneArray[faceIndex];
  23404. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23405. return;
  23406. }
  23407. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23408. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23409. if (normalDotVelocity == 0) {
  23410. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23411. return;
  23412. }
  23413. embeddedInPlane = true;
  23414. t0 = 0;
  23415. }
  23416. else {
  23417. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23418. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23419. if (t0 > t1) {
  23420. var temp = t1;
  23421. t1 = t0;
  23422. t0 = temp;
  23423. }
  23424. if (t0 > 1.0 || t1 < 0.0) {
  23425. return;
  23426. }
  23427. if (t0 < 0) {
  23428. t0 = 0;
  23429. }
  23430. if (t0 > 1.0) {
  23431. t0 = 1.0;
  23432. }
  23433. }
  23434. this._collisionPoint.copyFromFloats(0, 0, 0);
  23435. var found = false;
  23436. var t = 1.0;
  23437. if (!embeddedInPlane) {
  23438. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23439. this._velocity.scaleToRef(t0, this._tempVector);
  23440. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23441. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23442. found = true;
  23443. t = t0;
  23444. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23445. }
  23446. }
  23447. if (!found) {
  23448. var velocitySquaredLength = this._velocity.lengthSquared();
  23449. var a = velocitySquaredLength;
  23450. this._basePoint.subtractToRef(p1, this._tempVector);
  23451. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23452. var c = this._tempVector.lengthSquared() - 1.0;
  23453. var lowestRoot = getLowestRoot(a, b, c, t);
  23454. if (lowestRoot.found) {
  23455. t = lowestRoot.root;
  23456. found = true;
  23457. this._collisionPoint.copyFrom(p1);
  23458. }
  23459. this._basePoint.subtractToRef(p2, this._tempVector);
  23460. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23461. c = this._tempVector.lengthSquared() - 1.0;
  23462. lowestRoot = getLowestRoot(a, b, c, t);
  23463. if (lowestRoot.found) {
  23464. t = lowestRoot.root;
  23465. found = true;
  23466. this._collisionPoint.copyFrom(p2);
  23467. }
  23468. this._basePoint.subtractToRef(p3, this._tempVector);
  23469. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23470. c = this._tempVector.lengthSquared() - 1.0;
  23471. lowestRoot = getLowestRoot(a, b, c, t);
  23472. if (lowestRoot.found) {
  23473. t = lowestRoot.root;
  23474. found = true;
  23475. this._collisionPoint.copyFrom(p3);
  23476. }
  23477. p2.subtractToRef(p1, this._edge);
  23478. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23479. var edgeSquaredLength = this._edge.lengthSquared();
  23480. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23481. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23482. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23483. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23484. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23485. lowestRoot = getLowestRoot(a, b, c, t);
  23486. if (lowestRoot.found) {
  23487. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23488. if (f >= 0.0 && f <= 1.0) {
  23489. t = lowestRoot.root;
  23490. found = true;
  23491. this._edge.scaleInPlace(f);
  23492. p1.addToRef(this._edge, this._collisionPoint);
  23493. }
  23494. }
  23495. p3.subtractToRef(p2, this._edge);
  23496. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23497. edgeSquaredLength = this._edge.lengthSquared();
  23498. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23499. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23500. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23501. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23502. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23503. lowestRoot = getLowestRoot(a, b, c, t);
  23504. if (lowestRoot.found) {
  23505. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23506. if (f >= 0.0 && f <= 1.0) {
  23507. t = lowestRoot.root;
  23508. found = true;
  23509. this._edge.scaleInPlace(f);
  23510. p2.addToRef(this._edge, this._collisionPoint);
  23511. }
  23512. }
  23513. p1.subtractToRef(p3, this._edge);
  23514. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23515. edgeSquaredLength = this._edge.lengthSquared();
  23516. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23517. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23518. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23519. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23520. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23521. lowestRoot = getLowestRoot(a, b, c, t);
  23522. if (lowestRoot.found) {
  23523. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23524. if (f >= 0.0 && f <= 1.0) {
  23525. t = lowestRoot.root;
  23526. found = true;
  23527. this._edge.scaleInPlace(f);
  23528. p3.addToRef(this._edge, this._collisionPoint);
  23529. }
  23530. }
  23531. }
  23532. if (found) {
  23533. var distToCollision = t * this._velocity.length();
  23534. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23535. if (!this.intersectionPoint) {
  23536. this.intersectionPoint = this._collisionPoint.clone();
  23537. }
  23538. else {
  23539. this.intersectionPoint.copyFrom(this._collisionPoint);
  23540. }
  23541. this._nearestDistance = distToCollision;
  23542. this.collisionFound = true;
  23543. }
  23544. }
  23545. };
  23546. /** @hidden */
  23547. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23548. for (var i = indexStart; i < indexEnd; i += 3) {
  23549. var p1 = pts[indices[i] - decal];
  23550. var p2 = pts[indices[i + 1] - decal];
  23551. var p3 = pts[indices[i + 2] - decal];
  23552. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23553. }
  23554. };
  23555. /** @hidden */
  23556. Collider.prototype._getResponse = function (pos, vel) {
  23557. pos.addToRef(vel, this._destinationPoint);
  23558. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23559. this._basePoint.addToRef(vel, pos);
  23560. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23561. this._slidePlaneNormal.normalize();
  23562. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23563. pos.addInPlace(this._displacementVector);
  23564. this.intersectionPoint.addInPlace(this._displacementVector);
  23565. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23566. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23567. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23568. };
  23569. return Collider;
  23570. }());
  23571. /***/ }),
  23572. /***/ "./Collisions/collisionCoordinator.ts":
  23573. /*!********************************************!*\
  23574. !*** ./Collisions/collisionCoordinator.ts ***!
  23575. \********************************************/
  23576. /*! exports provided: DefaultCollisionCoordinator */
  23577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23578. "use strict";
  23579. __webpack_require__.r(__webpack_exports__);
  23580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23581. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23582. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23583. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23584. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23585. /** @hidden */
  23586. var DefaultCollisionCoordinator = /** @class */ (function () {
  23587. function DefaultCollisionCoordinator() {
  23588. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23589. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23590. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23591. }
  23592. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23593. position.divideToRef(collider._radius, this._scaledPosition);
  23594. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23595. collider.collidedMesh = null;
  23596. collider._retry = 0;
  23597. collider._initialVelocity = this._scaledVelocity;
  23598. collider._initialPosition = this._scaledPosition;
  23599. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23600. this._finalPosition.multiplyInPlace(collider._radius);
  23601. //run the callback
  23602. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23603. };
  23604. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23605. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23606. };
  23607. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23608. this._scene = scene;
  23609. };
  23610. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23611. if (excludedMesh === void 0) { excludedMesh = null; }
  23612. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23613. if (collider._retry >= maximumRetry) {
  23614. finalPosition.copyFrom(position);
  23615. return;
  23616. }
  23617. // Check if this is a mesh else camera or -1
  23618. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23619. collider._initialize(position, velocity, closeDistance);
  23620. // Check all meshes
  23621. for (var index = 0; index < this._scene.meshes.length; index++) {
  23622. var mesh = this._scene.meshes[index];
  23623. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23624. mesh._checkCollision(collider);
  23625. }
  23626. }
  23627. if (!collider.collisionFound) {
  23628. position.addToRef(velocity, finalPosition);
  23629. return;
  23630. }
  23631. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23632. collider._getResponse(position, velocity);
  23633. }
  23634. if (velocity.length() <= closeDistance) {
  23635. finalPosition.copyFrom(position);
  23636. return;
  23637. }
  23638. collider._retry++;
  23639. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23640. };
  23641. return DefaultCollisionCoordinator;
  23642. }());
  23643. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23644. return new DefaultCollisionCoordinator();
  23645. };
  23646. /***/ }),
  23647. /***/ "./Collisions/index.ts":
  23648. /*!*****************************!*\
  23649. !*** ./Collisions/index.ts ***!
  23650. \*****************************/
  23651. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23653. "use strict";
  23654. __webpack_require__.r(__webpack_exports__);
  23655. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23657. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23659. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23661. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23663. /***/ }),
  23664. /***/ "./Collisions/intersectionInfo.ts":
  23665. /*!****************************************!*\
  23666. !*** ./Collisions/intersectionInfo.ts ***!
  23667. \****************************************/
  23668. /*! exports provided: IntersectionInfo */
  23669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23670. "use strict";
  23671. __webpack_require__.r(__webpack_exports__);
  23672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23673. /**
  23674. * @hidden
  23675. */
  23676. var IntersectionInfo = /** @class */ (function () {
  23677. function IntersectionInfo(bu, bv, distance) {
  23678. this.bu = bu;
  23679. this.bv = bv;
  23680. this.distance = distance;
  23681. this.faceId = 0;
  23682. this.subMeshId = 0;
  23683. }
  23684. return IntersectionInfo;
  23685. }());
  23686. /***/ }),
  23687. /***/ "./Collisions/pickingInfo.ts":
  23688. /*!***********************************!*\
  23689. !*** ./Collisions/pickingInfo.ts ***!
  23690. \***********************************/
  23691. /*! exports provided: PickingInfo */
  23692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23693. "use strict";
  23694. __webpack_require__.r(__webpack_exports__);
  23695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23696. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23697. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23698. /**
  23699. * Information about the result of picking within a scene
  23700. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23701. */
  23702. var PickingInfo = /** @class */ (function () {
  23703. function PickingInfo() {
  23704. /** @hidden */
  23705. this._pickingUnavailable = false;
  23706. /**
  23707. * If the pick collided with an object
  23708. */
  23709. this.hit = false;
  23710. /**
  23711. * Distance away where the pick collided
  23712. */
  23713. this.distance = 0;
  23714. /**
  23715. * The location of pick collision
  23716. */
  23717. this.pickedPoint = null;
  23718. /**
  23719. * The mesh corresponding the the pick collision
  23720. */
  23721. this.pickedMesh = null;
  23722. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23723. this.bu = 0;
  23724. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23725. this.bv = 0;
  23726. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23727. this.faceId = -1;
  23728. /** Id of the the submesh that was picked */
  23729. this.subMeshId = 0;
  23730. /** If a sprite was picked, this will be the sprite the pick collided with */
  23731. this.pickedSprite = null;
  23732. /**
  23733. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23734. */
  23735. this.originMesh = null;
  23736. /**
  23737. * The ray that was used to perform the picking.
  23738. */
  23739. this.ray = null;
  23740. }
  23741. /**
  23742. * Gets the normal correspodning to the face the pick collided with
  23743. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23744. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23745. * @returns The normal correspodning to the face the pick collided with
  23746. */
  23747. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23748. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23749. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23750. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23751. return null;
  23752. }
  23753. var indices = this.pickedMesh.getIndices();
  23754. if (!indices) {
  23755. return null;
  23756. }
  23757. var result;
  23758. if (useVerticesNormals) {
  23759. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23760. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23761. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23762. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23763. normal0 = normal0.scale(this.bu);
  23764. normal1 = normal1.scale(this.bv);
  23765. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23766. result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
  23767. }
  23768. else {
  23769. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23770. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23771. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23772. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23773. var p1p2 = vertex1.subtract(vertex2);
  23774. var p3p2 = vertex3.subtract(vertex2);
  23775. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23776. }
  23777. if (useWorldCoordinates) {
  23778. var wm = this.pickedMesh.getWorldMatrix();
  23779. if (this.pickedMesh.nonUniformScaling) {
  23780. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23781. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23782. wm.setTranslationFromFloats(0, 0, 0);
  23783. wm.invert();
  23784. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23785. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23786. }
  23787. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23788. }
  23789. result.normalize();
  23790. return result;
  23791. };
  23792. /**
  23793. * Gets the texture coordinates of where the pick occured
  23794. * @returns the vector containing the coordnates of the texture
  23795. */
  23796. PickingInfo.prototype.getTextureCoordinates = function () {
  23797. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23798. return null;
  23799. }
  23800. var indices = this.pickedMesh.getIndices();
  23801. if (!indices) {
  23802. return null;
  23803. }
  23804. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23805. if (!uvs) {
  23806. return null;
  23807. }
  23808. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23809. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23810. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23811. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23812. uv1 = uv1.scale(this.bu);
  23813. uv2 = uv2.scale(this.bv);
  23814. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23815. };
  23816. return PickingInfo;
  23817. }());
  23818. /***/ }),
  23819. /***/ "./Culling/Octrees/index.ts":
  23820. /*!**********************************!*\
  23821. !*** ./Culling/Octrees/index.ts ***!
  23822. \**********************************/
  23823. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23825. "use strict";
  23826. __webpack_require__.r(__webpack_exports__);
  23827. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23829. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23831. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23833. /***/ }),
  23834. /***/ "./Culling/Octrees/octree.ts":
  23835. /*!***********************************!*\
  23836. !*** ./Culling/Octrees/octree.ts ***!
  23837. \***********************************/
  23838. /*! exports provided: Octree */
  23839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23840. "use strict";
  23841. __webpack_require__.r(__webpack_exports__);
  23842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23843. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23844. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23845. /**
  23846. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23847. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23848. */
  23849. var Octree = /** @class */ (function () {
  23850. /**
  23851. * Creates a octree
  23852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23853. * @param creationFunc function to be used to instatiate the octree
  23854. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23855. * @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.)
  23856. */
  23857. function Octree(creationFunc, maxBlockCapacity,
  23858. /** 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.) */
  23859. maxDepth) {
  23860. if (maxDepth === void 0) { maxDepth = 2; }
  23861. this.maxDepth = maxDepth;
  23862. /**
  23863. * Content stored in the octree
  23864. */
  23865. this.dynamicContent = new Array();
  23866. this._maxBlockCapacity = maxBlockCapacity || 64;
  23867. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23868. this._creationFunc = creationFunc;
  23869. }
  23870. // Methods
  23871. /**
  23872. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23873. * @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);
  23874. * @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);
  23875. * @param entries meshes to be added to the octree blocks
  23876. */
  23877. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23878. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23879. };
  23880. /**
  23881. * Adds a mesh to the octree
  23882. * @param entry Mesh to add to the octree
  23883. */
  23884. Octree.prototype.addMesh = function (entry) {
  23885. for (var index = 0; index < this.blocks.length; index++) {
  23886. var block = this.blocks[index];
  23887. block.addEntry(entry);
  23888. }
  23889. };
  23890. /**
  23891. * Remove an element from the octree
  23892. * @param entry defines the element to remove
  23893. */
  23894. Octree.prototype.removeMesh = function (entry) {
  23895. for (var index = 0; index < this.blocks.length; index++) {
  23896. var block = this.blocks[index];
  23897. block.removeEntry(entry);
  23898. }
  23899. };
  23900. /**
  23901. * Selects an array of meshes within the frustum
  23902. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23903. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23904. * @returns array of meshes within the frustum
  23905. */
  23906. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23907. this._selectionContent.reset();
  23908. for (var index = 0; index < this.blocks.length; index++) {
  23909. var block = this.blocks[index];
  23910. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23911. }
  23912. if (allowDuplicate) {
  23913. this._selectionContent.concat(this.dynamicContent);
  23914. }
  23915. else {
  23916. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23917. }
  23918. return this._selectionContent;
  23919. };
  23920. /**
  23921. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23922. * @param sphereCenter defines the bounding sphere center
  23923. * @param sphereRadius defines the bounding sphere radius
  23924. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23925. * @returns an array of objects that intersect the sphere
  23926. */
  23927. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23928. this._selectionContent.reset();
  23929. for (var index = 0; index < this.blocks.length; index++) {
  23930. var block = this.blocks[index];
  23931. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23932. }
  23933. if (allowDuplicate) {
  23934. this._selectionContent.concat(this.dynamicContent);
  23935. }
  23936. else {
  23937. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23938. }
  23939. return this._selectionContent;
  23940. };
  23941. /**
  23942. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23943. * @param ray defines the ray to test with
  23944. * @returns array of intersected objects
  23945. */
  23946. Octree.prototype.intersectsRay = function (ray) {
  23947. this._selectionContent.reset();
  23948. for (var index = 0; index < this.blocks.length; index++) {
  23949. var block = this.blocks[index];
  23950. block.intersectsRay(ray, this._selectionContent);
  23951. }
  23952. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23953. return this._selectionContent;
  23954. };
  23955. /**
  23956. * Adds a mesh into the octree block if it intersects the block
  23957. */
  23958. Octree.CreationFuncForMeshes = function (entry, block) {
  23959. var boundingInfo = entry.getBoundingInfo();
  23960. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23961. block.entries.push(entry);
  23962. }
  23963. };
  23964. /**
  23965. * Adds a submesh into the octree block if it intersects the block
  23966. */
  23967. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23968. var boundingInfo = entry.getBoundingInfo();
  23969. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23970. block.entries.push(entry);
  23971. }
  23972. };
  23973. return Octree;
  23974. }());
  23975. /***/ }),
  23976. /***/ "./Culling/Octrees/octreeBlock.ts":
  23977. /*!****************************************!*\
  23978. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23979. \****************************************/
  23980. /*! exports provided: OctreeBlock */
  23981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23982. "use strict";
  23983. __webpack_require__.r(__webpack_exports__);
  23984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23985. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23986. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23987. /**
  23988. * Class used to store a cell in an octree
  23989. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23990. */
  23991. var OctreeBlock = /** @class */ (function () {
  23992. /**
  23993. * Creates a new block
  23994. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  23995. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  23996. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23997. * @param depth defines the current depth of this block in the octree
  23998. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  23999. * @param creationFunc defines a callback to call when an element is added to the block
  24000. */
  24001. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24002. /**
  24003. * Gets the content of the current block
  24004. */
  24005. this.entries = new Array();
  24006. this._boundingVectors = new Array();
  24007. this._capacity = capacity;
  24008. this._depth = depth;
  24009. this._maxDepth = maxDepth;
  24010. this._creationFunc = creationFunc;
  24011. this._minPoint = minPoint;
  24012. this._maxPoint = maxPoint;
  24013. this._boundingVectors.push(minPoint.clone());
  24014. this._boundingVectors.push(maxPoint.clone());
  24015. this._boundingVectors.push(minPoint.clone());
  24016. this._boundingVectors[2].x = maxPoint.x;
  24017. this._boundingVectors.push(minPoint.clone());
  24018. this._boundingVectors[3].y = maxPoint.y;
  24019. this._boundingVectors.push(minPoint.clone());
  24020. this._boundingVectors[4].z = maxPoint.z;
  24021. this._boundingVectors.push(maxPoint.clone());
  24022. this._boundingVectors[5].z = minPoint.z;
  24023. this._boundingVectors.push(maxPoint.clone());
  24024. this._boundingVectors[6].x = minPoint.x;
  24025. this._boundingVectors.push(maxPoint.clone());
  24026. this._boundingVectors[7].y = minPoint.y;
  24027. }
  24028. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24029. // Property
  24030. /**
  24031. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24032. */
  24033. get: function () {
  24034. return this._capacity;
  24035. },
  24036. enumerable: true,
  24037. configurable: true
  24038. });
  24039. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24040. /**
  24041. * Gets the minimum vector (in world space) of the block's bounding box
  24042. */
  24043. get: function () {
  24044. return this._minPoint;
  24045. },
  24046. enumerable: true,
  24047. configurable: true
  24048. });
  24049. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24050. /**
  24051. * Gets the maximum vector (in world space) of the block's bounding box
  24052. */
  24053. get: function () {
  24054. return this._maxPoint;
  24055. },
  24056. enumerable: true,
  24057. configurable: true
  24058. });
  24059. // Methods
  24060. /**
  24061. * Add a new element to this block
  24062. * @param entry defines the element to add
  24063. */
  24064. OctreeBlock.prototype.addEntry = function (entry) {
  24065. if (this.blocks) {
  24066. for (var index = 0; index < this.blocks.length; index++) {
  24067. var block = this.blocks[index];
  24068. block.addEntry(entry);
  24069. }
  24070. return;
  24071. }
  24072. this._creationFunc(entry, this);
  24073. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24074. this.createInnerBlocks();
  24075. }
  24076. };
  24077. /**
  24078. * Remove an element from this block
  24079. * @param entry defines the element to remove
  24080. */
  24081. OctreeBlock.prototype.removeEntry = function (entry) {
  24082. if (this.blocks) {
  24083. for (var index = 0; index < this.blocks.length; index++) {
  24084. var block = this.blocks[index];
  24085. block.removeEntry(entry);
  24086. }
  24087. return;
  24088. }
  24089. var entryIndex = this.entries.indexOf(entry);
  24090. if (entryIndex > -1) {
  24091. this.entries.splice(entryIndex, 1);
  24092. }
  24093. };
  24094. /**
  24095. * Add an array of elements to this block
  24096. * @param entries defines the array of elements to add
  24097. */
  24098. OctreeBlock.prototype.addEntries = function (entries) {
  24099. for (var index = 0; index < entries.length; index++) {
  24100. var mesh = entries[index];
  24101. this.addEntry(mesh);
  24102. }
  24103. };
  24104. /**
  24105. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24106. * @param frustumPlanes defines the frustum planes to test
  24107. * @param selection defines the array to store current content if selection is positive
  24108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24109. */
  24110. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24111. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24112. if (this.blocks) {
  24113. for (var index = 0; index < this.blocks.length; index++) {
  24114. var block = this.blocks[index];
  24115. block.select(frustumPlanes, selection, allowDuplicate);
  24116. }
  24117. return;
  24118. }
  24119. if (allowDuplicate) {
  24120. selection.concat(this.entries);
  24121. }
  24122. else {
  24123. selection.concatWithNoDuplicate(this.entries);
  24124. }
  24125. }
  24126. };
  24127. /**
  24128. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24129. * @param sphereCenter defines the bounding sphere center
  24130. * @param sphereRadius defines the bounding sphere radius
  24131. * @param selection defines the array to store current content if selection is positive
  24132. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24133. */
  24134. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24135. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24136. if (this.blocks) {
  24137. for (var index = 0; index < this.blocks.length; index++) {
  24138. var block = this.blocks[index];
  24139. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24140. }
  24141. return;
  24142. }
  24143. if (allowDuplicate) {
  24144. selection.concat(this.entries);
  24145. }
  24146. else {
  24147. selection.concatWithNoDuplicate(this.entries);
  24148. }
  24149. }
  24150. };
  24151. /**
  24152. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24153. * @param ray defines the ray to test with
  24154. * @param selection defines the array to store current content if selection is positive
  24155. */
  24156. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24157. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24158. if (this.blocks) {
  24159. for (var index = 0; index < this.blocks.length; index++) {
  24160. var block = this.blocks[index];
  24161. block.intersectsRay(ray, selection);
  24162. }
  24163. return;
  24164. }
  24165. selection.concatWithNoDuplicate(this.entries);
  24166. }
  24167. };
  24168. /**
  24169. * Subdivide the content into child blocks (this block will then be empty)
  24170. */
  24171. OctreeBlock.prototype.createInnerBlocks = function () {
  24172. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24173. };
  24174. /**
  24175. * @hidden
  24176. */
  24177. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24178. target.blocks = new Array();
  24179. var blockSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  24180. // Segmenting space
  24181. for (var x = 0; x < 2; x++) {
  24182. for (var y = 0; y < 2; y++) {
  24183. for (var z = 0; z < 2; z++) {
  24184. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24185. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24186. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24187. block.addEntries(entries);
  24188. target.blocks.push(block);
  24189. }
  24190. }
  24191. }
  24192. };
  24193. return OctreeBlock;
  24194. }());
  24195. /***/ }),
  24196. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24197. /*!*************************************************!*\
  24198. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24199. \*************************************************/
  24200. /*! exports provided: OctreeSceneComponent */
  24201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24202. "use strict";
  24203. __webpack_require__.r(__webpack_exports__);
  24204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24205. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24206. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24207. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24208. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24209. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24210. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24211. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24212. if (maxCapacity === void 0) { maxCapacity = 64; }
  24213. if (maxDepth === void 0) { maxDepth = 2; }
  24214. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24215. if (!component) {
  24216. component = new OctreeSceneComponent(this);
  24217. this._addComponent(component);
  24218. }
  24219. if (!this._selectionOctree) {
  24220. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24221. }
  24222. var worldExtends = this.getWorldExtends();
  24223. // Update octree
  24224. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24225. return this._selectionOctree;
  24226. };
  24227. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24228. get: function () {
  24229. return this._selectionOctree;
  24230. },
  24231. enumerable: true,
  24232. configurable: true
  24233. });
  24234. /**
  24235. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24236. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24237. * @param maxCapacity defines the maximum size of each block (64 by default)
  24238. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24239. * @returns the new octree
  24240. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24242. */
  24243. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24244. if (maxCapacity === void 0) { maxCapacity = 64; }
  24245. if (maxDepth === void 0) { maxDepth = 2; }
  24246. var scene = this.getScene();
  24247. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24248. if (!component) {
  24249. component = new OctreeSceneComponent(scene);
  24250. scene._addComponent(component);
  24251. }
  24252. if (!this._submeshesOctree) {
  24253. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24254. }
  24255. this.computeWorldMatrix(true);
  24256. var boundingInfo = this.getBoundingInfo();
  24257. // Update octree
  24258. var bbox = boundingInfo.boundingBox;
  24259. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24260. return this._submeshesOctree;
  24261. };
  24262. /**
  24263. * Defines the octree scene component responsible to manage any octrees
  24264. * in a given scene.
  24265. */
  24266. var OctreeSceneComponent = /** @class */ (function () {
  24267. /**
  24268. * Creates a new instance of the component for the given scene
  24269. * @param scene Defines the scene to register the component in
  24270. */
  24271. function OctreeSceneComponent(scene) {
  24272. /**
  24273. * The component name helpfull to identify the component in the list of scene components.
  24274. */
  24275. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24276. /**
  24277. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24278. */
  24279. this.checksIsEnabled = true;
  24280. this._tempRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](1, 1, 1));
  24281. this.scene = scene;
  24282. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24283. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24284. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24285. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24286. }
  24287. /**
  24288. * Registers the component in a given scene
  24289. */
  24290. OctreeSceneComponent.prototype.register = function () {
  24291. var _this = this;
  24292. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24293. var sceneOctree = _this.scene.selectionOctree;
  24294. if (sceneOctree !== undefined && sceneOctree !== null) {
  24295. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24296. if (index !== -1) {
  24297. sceneOctree.dynamicContent.splice(index, 1);
  24298. }
  24299. }
  24300. });
  24301. this.scene.onMeshImportedObservable.add(function (mesh) {
  24302. var sceneOctree = _this.scene.selectionOctree;
  24303. if (sceneOctree !== undefined && sceneOctree !== null) {
  24304. sceneOctree.addMesh(mesh);
  24305. }
  24306. });
  24307. };
  24308. /**
  24309. * Return the list of active meshes
  24310. * @returns the list of active meshes
  24311. */
  24312. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24313. if (this.scene._selectionOctree) {
  24314. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24315. return selection;
  24316. }
  24317. return this.scene._getDefaultMeshCandidates();
  24318. };
  24319. /**
  24320. * Return the list of active sub meshes
  24321. * @param mesh The mesh to get the candidates sub meshes from
  24322. * @returns the list of active sub meshes
  24323. */
  24324. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24325. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24326. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24327. return intersections;
  24328. }
  24329. return this.scene._getDefaultSubMeshCandidates(mesh);
  24330. };
  24331. /**
  24332. * Return the list of sub meshes intersecting with a given local ray
  24333. * @param mesh defines the mesh to find the submesh for
  24334. * @param localRay defines the ray in local space
  24335. * @returns the list of intersecting sub meshes
  24336. */
  24337. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24338. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24339. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24340. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24341. return intersections;
  24342. }
  24343. return this.scene._getDefaultSubMeshCandidates(mesh);
  24344. };
  24345. /**
  24346. * Return the list of sub meshes colliding with a collider
  24347. * @param mesh defines the mesh to find the submesh for
  24348. * @param collider defines the collider to evaluate the collision against
  24349. * @returns the list of colliding sub meshes
  24350. */
  24351. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24352. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24353. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24354. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24355. return intersections;
  24356. }
  24357. return this.scene._getDefaultSubMeshCandidates(mesh);
  24358. };
  24359. /**
  24360. * Rebuilds the elements related to this component in case of
  24361. * context lost for instance.
  24362. */
  24363. OctreeSceneComponent.prototype.rebuild = function () {
  24364. // Nothing to do here.
  24365. };
  24366. /**
  24367. * Disposes the component and the associated ressources.
  24368. */
  24369. OctreeSceneComponent.prototype.dispose = function () {
  24370. // Nothing to do here.
  24371. };
  24372. return OctreeSceneComponent;
  24373. }());
  24374. /***/ }),
  24375. /***/ "./Culling/boundingBox.ts":
  24376. /*!********************************!*\
  24377. !*** ./Culling/boundingBox.ts ***!
  24378. \********************************/
  24379. /*! exports provided: BoundingBox */
  24380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24381. "use strict";
  24382. __webpack_require__.r(__webpack_exports__);
  24383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24384. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24385. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24386. /**
  24387. * Class used to store bounding box information
  24388. */
  24389. var BoundingBox = /** @class */ (function () {
  24390. /**
  24391. * Creates a new bounding box
  24392. * @param min defines the minimum vector (in local space)
  24393. * @param max defines the maximum vector (in local space)
  24394. * @param worldMatrix defines the new world matrix
  24395. */
  24396. function BoundingBox(min, max, worldMatrix) {
  24397. /**
  24398. * Gets the 8 vectors representing the bounding box in local space
  24399. */
  24400. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24401. /**
  24402. * Gets the center of the bounding box in local space
  24403. */
  24404. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24405. /**
  24406. * Gets the center of the bounding box in world space
  24407. */
  24408. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24409. /**
  24410. * Gets the extend size in local space
  24411. */
  24412. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24413. /**
  24414. * Gets the extend size in world space
  24415. */
  24416. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24417. /**
  24418. * Gets the OBB (object bounding box) directions
  24419. */
  24420. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24421. /**
  24422. * Gets the 8 vectors representing the bounding box in world space
  24423. */
  24424. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24425. /**
  24426. * Gets the minimum vector in world space
  24427. */
  24428. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24429. /**
  24430. * Gets the maximum vector in world space
  24431. */
  24432. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24433. /**
  24434. * Gets the minimum vector in local space
  24435. */
  24436. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24437. /**
  24438. * Gets the maximum vector in local space
  24439. */
  24440. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24441. this.reConstruct(min, max, worldMatrix);
  24442. }
  24443. // Methods
  24444. /**
  24445. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24446. * @param min defines the new minimum vector (in local space)
  24447. * @param max defines the new maximum vector (in local space)
  24448. * @param worldMatrix defines the new world matrix
  24449. */
  24450. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24451. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24452. var vectors = this.vectors;
  24453. this.minimum.copyFromFloats(minX, minY, minZ);
  24454. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24455. vectors[0].copyFromFloats(minX, minY, minZ);
  24456. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24457. vectors[2].copyFromFloats(maxX, minY, minZ);
  24458. vectors[3].copyFromFloats(minX, maxY, minZ);
  24459. vectors[4].copyFromFloats(minX, minY, maxZ);
  24460. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24461. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24462. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24463. // OBB
  24464. max.addToRef(min, this.center).scaleInPlace(0.5);
  24465. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24466. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24467. };
  24468. /**
  24469. * Scale the current bounding box by applying a scale factor
  24470. * @param factor defines the scale factor to apply
  24471. * @returns the current bounding box
  24472. */
  24473. BoundingBox.prototype.scale = function (factor) {
  24474. var tmpVectors = BoundingBox.TmpVector3;
  24475. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24476. var len = diff.length();
  24477. diff.normalizeFromLength(len);
  24478. var distance = len * factor;
  24479. var newRadius = diff.scaleInPlace(distance * 0.5);
  24480. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24481. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24482. this.reConstruct(min, max, this._worldMatrix);
  24483. return this;
  24484. };
  24485. /**
  24486. * Gets the world matrix of the bounding box
  24487. * @returns a matrix
  24488. */
  24489. BoundingBox.prototype.getWorldMatrix = function () {
  24490. return this._worldMatrix;
  24491. };
  24492. /** @hidden */
  24493. BoundingBox.prototype._update = function (world) {
  24494. var minWorld = this.minimumWorld;
  24495. var maxWorld = this.maximumWorld;
  24496. var directions = this.directions;
  24497. var vectorsWorld = this.vectorsWorld;
  24498. var vectors = this.vectors;
  24499. if (!world.isIdentity()) {
  24500. minWorld.setAll(Number.MAX_VALUE);
  24501. maxWorld.setAll(-Number.MAX_VALUE);
  24502. for (var index = 0; index < 8; ++index) {
  24503. var v = vectorsWorld[index];
  24504. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24505. minWorld.minimizeInPlace(v);
  24506. maxWorld.maximizeInPlace(v);
  24507. }
  24508. // Extend
  24509. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24510. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24511. }
  24512. else {
  24513. minWorld.copyFrom(this.minimum);
  24514. maxWorld.copyFrom(this.maximum);
  24515. for (var index = 0; index < 8; ++index) {
  24516. vectorsWorld[index].copyFrom(vectors[index]);
  24517. }
  24518. // Extend
  24519. this.extendSizeWorld.copyFrom(this.extendSize);
  24520. this.centerWorld.copyFrom(this.center);
  24521. }
  24522. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24523. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24524. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24525. this._worldMatrix = world;
  24526. };
  24527. /**
  24528. * Tests if the bounding box is intersecting the frustum planes
  24529. * @param frustumPlanes defines the frustum planes to test
  24530. * @returns true if there is an intersection
  24531. */
  24532. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24533. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24534. };
  24535. /**
  24536. * Tests if the bounding box is entirely inside the frustum planes
  24537. * @param frustumPlanes defines the frustum planes to test
  24538. * @returns true if there is an inclusion
  24539. */
  24540. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24541. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24542. };
  24543. /**
  24544. * Tests if a point is inside the bounding box
  24545. * @param point defines the point to test
  24546. * @returns true if the point is inside the bounding box
  24547. */
  24548. BoundingBox.prototype.intersectsPoint = function (point) {
  24549. var min = this.minimumWorld;
  24550. var max = this.maximumWorld;
  24551. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24552. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24553. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24554. if (maxX - pointX < delta || delta > pointX - minX) {
  24555. return false;
  24556. }
  24557. if (maxY - pointY < delta || delta > pointY - minY) {
  24558. return false;
  24559. }
  24560. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24561. return false;
  24562. }
  24563. return true;
  24564. };
  24565. /**
  24566. * Tests if the bounding box intersects with a bounding sphere
  24567. * @param sphere defines the sphere to test
  24568. * @returns true if there is an intersection
  24569. */
  24570. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24571. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24572. };
  24573. /**
  24574. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24575. * @param min defines the min vector to use
  24576. * @param max defines the max vector to use
  24577. * @returns true if there is an intersection
  24578. */
  24579. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24580. var myMin = this.minimumWorld;
  24581. var myMax = this.maximumWorld;
  24582. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24583. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24584. if (myMaxX < minX || myMinX > maxX) {
  24585. return false;
  24586. }
  24587. if (myMaxY < minY || myMinY > maxY) {
  24588. return false;
  24589. }
  24590. if (myMaxZ < minZ || myMinZ > maxZ) {
  24591. return false;
  24592. }
  24593. return true;
  24594. };
  24595. // Statics
  24596. /**
  24597. * Tests if two bounding boxes are intersections
  24598. * @param box0 defines the first box to test
  24599. * @param box1 defines the second box to test
  24600. * @returns true if there is an intersection
  24601. */
  24602. BoundingBox.Intersects = function (box0, box1) {
  24603. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24604. };
  24605. /**
  24606. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24607. * @param minPoint defines the minimum vector of the bounding box
  24608. * @param maxPoint defines the maximum vector of the bounding box
  24609. * @param sphereCenter defines the sphere center
  24610. * @param sphereRadius defines the sphere radius
  24611. * @returns true if there is an intersection
  24612. */
  24613. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24614. var vector = BoundingBox.TmpVector3[0];
  24615. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24616. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24617. return (num <= (sphereRadius * sphereRadius));
  24618. };
  24619. /**
  24620. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24621. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24622. * @param frustumPlanes defines the frustum planes to test
  24623. * @return true if there is an inclusion
  24624. */
  24625. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24626. for (var p = 0; p < 6; ++p) {
  24627. var frustumPlane = frustumPlanes[p];
  24628. for (var i = 0; i < 8; ++i) {
  24629. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24630. return false;
  24631. }
  24632. }
  24633. }
  24634. return true;
  24635. };
  24636. /**
  24637. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24638. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24639. * @param frustumPlanes defines the frustum planes to test
  24640. * @return true if there is an intersection
  24641. */
  24642. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24643. for (var p = 0; p < 6; ++p) {
  24644. var canReturnFalse = true;
  24645. var frustumPlane = frustumPlanes[p];
  24646. for (var i = 0; i < 8; ++i) {
  24647. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24648. canReturnFalse = false;
  24649. break;
  24650. }
  24651. }
  24652. if (canReturnFalse) {
  24653. return false;
  24654. }
  24655. }
  24656. return true;
  24657. };
  24658. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24659. return BoundingBox;
  24660. }());
  24661. /***/ }),
  24662. /***/ "./Culling/boundingInfo.ts":
  24663. /*!*********************************!*\
  24664. !*** ./Culling/boundingInfo.ts ***!
  24665. \*********************************/
  24666. /*! exports provided: BoundingInfo */
  24667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24668. "use strict";
  24669. __webpack_require__.r(__webpack_exports__);
  24670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24671. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24674. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24675. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24676. var _result0 = { min: 0, max: 0 };
  24677. var _result1 = { min: 0, max: 0 };
  24678. var computeBoxExtents = function (axis, box, result) {
  24679. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24680. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24681. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24682. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24683. var r = r0 + r1 + r2;
  24684. result.min = p - r;
  24685. result.max = p + r;
  24686. };
  24687. var axisOverlap = function (axis, box0, box1) {
  24688. computeBoxExtents(axis, box0, _result0);
  24689. computeBoxExtents(axis, box1, _result1);
  24690. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24691. };
  24692. /**
  24693. * Info for a bounding data of a mesh
  24694. */
  24695. var BoundingInfo = /** @class */ (function () {
  24696. /**
  24697. * Constructs bounding info
  24698. * @param minimum min vector of the bounding box/sphere
  24699. * @param maximum max vector of the bounding box/sphere
  24700. * @param worldMatrix defines the new world matrix
  24701. */
  24702. function BoundingInfo(minimum, maximum, worldMatrix) {
  24703. this._isLocked = false;
  24704. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24705. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24706. }
  24707. /**
  24708. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24709. * @param min defines the new minimum vector (in local space)
  24710. * @param max defines the new maximum vector (in local space)
  24711. * @param worldMatrix defines the new world matrix
  24712. */
  24713. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24714. this.boundingBox.reConstruct(min, max, worldMatrix);
  24715. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24716. };
  24717. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24718. /**
  24719. * min vector of the bounding box/sphere
  24720. */
  24721. get: function () {
  24722. return this.boundingBox.minimum;
  24723. },
  24724. enumerable: true,
  24725. configurable: true
  24726. });
  24727. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24728. /**
  24729. * max vector of the bounding box/sphere
  24730. */
  24731. get: function () {
  24732. return this.boundingBox.maximum;
  24733. },
  24734. enumerable: true,
  24735. configurable: true
  24736. });
  24737. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24738. /**
  24739. * If the info is locked and won't be updated to avoid perf overhead
  24740. */
  24741. get: function () {
  24742. return this._isLocked;
  24743. },
  24744. set: function (value) {
  24745. this._isLocked = value;
  24746. },
  24747. enumerable: true,
  24748. configurable: true
  24749. });
  24750. // Methods
  24751. /**
  24752. * Updates the bounding sphere and box
  24753. * @param world world matrix to be used to update
  24754. */
  24755. BoundingInfo.prototype.update = function (world) {
  24756. if (this._isLocked) {
  24757. return;
  24758. }
  24759. this.boundingBox._update(world);
  24760. this.boundingSphere._update(world);
  24761. };
  24762. /**
  24763. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24764. * @param center New center of the bounding info
  24765. * @param extend New extend of the bounding info
  24766. * @returns the current bounding info
  24767. */
  24768. BoundingInfo.prototype.centerOn = function (center, extend) {
  24769. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24770. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24771. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24772. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24773. return this;
  24774. };
  24775. /**
  24776. * Scale the current bounding info by applying a scale factor
  24777. * @param factor defines the scale factor to apply
  24778. * @returns the current bounding info
  24779. */
  24780. BoundingInfo.prototype.scale = function (factor) {
  24781. this.boundingBox.scale(factor);
  24782. this.boundingSphere.scale(factor);
  24783. return this;
  24784. };
  24785. /**
  24786. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24787. * @param frustumPlanes defines the frustum to test
  24788. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24789. * @returns true if the bounding info is in the frustum planes
  24790. */
  24791. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24792. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24793. 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);
  24794. if (inclusionTest) {
  24795. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24796. return true;
  24797. }
  24798. }
  24799. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24800. return false;
  24801. }
  24802. 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);
  24803. if (bSphereOnlyTest) {
  24804. return true;
  24805. }
  24806. return this.boundingBox.isInFrustum(frustumPlanes);
  24807. };
  24808. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24809. /**
  24810. * Gets the world distance between the min and max points of the bounding box
  24811. */
  24812. get: function () {
  24813. var boundingBox = this.boundingBox;
  24814. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24815. return diag.length();
  24816. },
  24817. enumerable: true,
  24818. configurable: true
  24819. });
  24820. /**
  24821. * Checks if a cullable object (mesh...) is in the camera frustum
  24822. * Unlike isInFrustum this cheks the full bounding box
  24823. * @param frustumPlanes Camera near/planes
  24824. * @returns true if the object is in frustum otherwise false
  24825. */
  24826. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24827. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24828. };
  24829. /** @hidden */
  24830. BoundingInfo.prototype._checkCollision = function (collider) {
  24831. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24832. };
  24833. /**
  24834. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24835. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24836. * @param point the point to check intersection with
  24837. * @returns if the point intersects
  24838. */
  24839. BoundingInfo.prototype.intersectsPoint = function (point) {
  24840. if (!this.boundingSphere.centerWorld) {
  24841. return false;
  24842. }
  24843. if (!this.boundingSphere.intersectsPoint(point)) {
  24844. return false;
  24845. }
  24846. if (!this.boundingBox.intersectsPoint(point)) {
  24847. return false;
  24848. }
  24849. return true;
  24850. };
  24851. /**
  24852. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24853. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24854. * @param boundingInfo the bounding info to check intersection with
  24855. * @param precise if the intersection should be done using OBB
  24856. * @returns if the bounding info intersects
  24857. */
  24858. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24859. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24860. return false;
  24861. }
  24862. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24863. return false;
  24864. }
  24865. if (!precise) {
  24866. return true;
  24867. }
  24868. var box0 = this.boundingBox;
  24869. var box1 = boundingInfo.boundingBox;
  24870. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24871. return false;
  24872. }
  24873. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24874. return false;
  24875. }
  24876. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24877. return false;
  24878. }
  24879. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24880. return false;
  24881. }
  24882. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24883. return false;
  24884. }
  24885. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24886. return false;
  24887. }
  24888. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24889. return false;
  24890. }
  24891. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24892. return false;
  24893. }
  24894. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24895. return false;
  24896. }
  24897. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24898. return false;
  24899. }
  24900. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24901. return false;
  24902. }
  24903. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24904. return false;
  24905. }
  24906. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24907. return false;
  24908. }
  24909. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24910. return false;
  24911. }
  24912. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24913. return false;
  24914. }
  24915. return true;
  24916. };
  24917. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24918. return BoundingInfo;
  24919. }());
  24920. /***/ }),
  24921. /***/ "./Culling/boundingSphere.ts":
  24922. /*!***********************************!*\
  24923. !*** ./Culling/boundingSphere.ts ***!
  24924. \***********************************/
  24925. /*! exports provided: BoundingSphere */
  24926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24927. "use strict";
  24928. __webpack_require__.r(__webpack_exports__);
  24929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24930. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24931. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24932. /**
  24933. * Class used to store bounding sphere information
  24934. */
  24935. var BoundingSphere = /** @class */ (function () {
  24936. /**
  24937. * Creates a new bounding sphere
  24938. * @param min defines the minimum vector (in local space)
  24939. * @param max defines the maximum vector (in local space)
  24940. * @param worldMatrix defines the new world matrix
  24941. */
  24942. function BoundingSphere(min, max, worldMatrix) {
  24943. /**
  24944. * Gets the center of the bounding sphere in local space
  24945. */
  24946. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24947. /**
  24948. * Gets the center of the bounding sphere in world space
  24949. */
  24950. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24951. /**
  24952. * Gets the minimum vector in local space
  24953. */
  24954. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24955. /**
  24956. * Gets the maximum vector in local space
  24957. */
  24958. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24959. this.reConstruct(min, max, worldMatrix);
  24960. }
  24961. /**
  24962. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24963. * @param min defines the new minimum vector (in local space)
  24964. * @param max defines the new maximum vector (in local space)
  24965. * @param worldMatrix defines the new world matrix
  24966. */
  24967. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24968. this.minimum.copyFrom(min);
  24969. this.maximum.copyFrom(max);
  24970. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24971. max.addToRef(min, this.center).scaleInPlace(0.5);
  24972. this.radius = distance * 0.5;
  24973. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24974. };
  24975. /**
  24976. * Scale the current bounding sphere by applying a scale factor
  24977. * @param factor defines the scale factor to apply
  24978. * @returns the current bounding box
  24979. */
  24980. BoundingSphere.prototype.scale = function (factor) {
  24981. var newRadius = this.radius * factor;
  24982. var tmpVectors = BoundingSphere.TmpVector3;
  24983. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24984. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24985. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24986. this.reConstruct(min, max, this._worldMatrix);
  24987. return this;
  24988. };
  24989. /**
  24990. * Gets the world matrix of the bounding box
  24991. * @returns a matrix
  24992. */
  24993. BoundingSphere.prototype.getWorldMatrix = function () {
  24994. return this._worldMatrix;
  24995. };
  24996. // Methods
  24997. /** @hidden */
  24998. BoundingSphere.prototype._update = function (worldMatrix) {
  24999. if (!worldMatrix.isIdentity()) {
  25000. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25001. var tempVector = BoundingSphere.TmpVector3[0];
  25002. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25003. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25004. }
  25005. else {
  25006. this.centerWorld.copyFrom(this.center);
  25007. this.radiusWorld = this.radius;
  25008. }
  25009. };
  25010. /**
  25011. * Tests if the bounding sphere is intersecting the frustum planes
  25012. * @param frustumPlanes defines the frustum planes to test
  25013. * @returns true if there is an intersection
  25014. */
  25015. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25016. var center = this.centerWorld;
  25017. var radius = this.radiusWorld;
  25018. for (var i = 0; i < 6; i++) {
  25019. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25020. return false;
  25021. }
  25022. }
  25023. return true;
  25024. };
  25025. /**
  25026. * Tests if the bounding sphere center is in between the frustum planes.
  25027. * Used for optimistic fast inclusion.
  25028. * @param frustumPlanes defines the frustum planes to test
  25029. * @returns true if the sphere center is in between the frustum planes
  25030. */
  25031. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25032. var center = this.centerWorld;
  25033. for (var i = 0; i < 6; i++) {
  25034. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25035. return false;
  25036. }
  25037. }
  25038. return true;
  25039. };
  25040. /**
  25041. * Tests if a point is inside the bounding sphere
  25042. * @param point defines the point to test
  25043. * @returns true if the point is inside the bounding sphere
  25044. */
  25045. BoundingSphere.prototype.intersectsPoint = function (point) {
  25046. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25047. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25048. return false;
  25049. }
  25050. return true;
  25051. };
  25052. // Statics
  25053. /**
  25054. * Checks if two sphere intersct
  25055. * @param sphere0 sphere 0
  25056. * @param sphere1 sphere 1
  25057. * @returns true if the speres intersect
  25058. */
  25059. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25060. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25061. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25062. if (radiusSum * radiusSum < squareDistance) {
  25063. return false;
  25064. }
  25065. return true;
  25066. };
  25067. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25068. return BoundingSphere;
  25069. }());
  25070. /***/ }),
  25071. /***/ "./Culling/index.ts":
  25072. /*!**************************!*\
  25073. !*** ./Culling/index.ts ***!
  25074. \**************************/
  25075. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25077. "use strict";
  25078. __webpack_require__.r(__webpack_exports__);
  25079. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25081. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25083. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25085. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25089. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25091. /***/ }),
  25092. /***/ "./Culling/ray.ts":
  25093. /*!************************!*\
  25094. !*** ./Culling/ray.ts ***!
  25095. \************************/
  25096. /*! exports provided: Ray */
  25097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25098. "use strict";
  25099. __webpack_require__.r(__webpack_exports__);
  25100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25101. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25102. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25103. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25104. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25105. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25106. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25107. /**
  25108. * Class representing a ray with position and direction
  25109. */
  25110. var Ray = /** @class */ (function () {
  25111. /**
  25112. * Creates a new ray
  25113. * @param origin origin point
  25114. * @param direction direction
  25115. * @param length length of the ray
  25116. */
  25117. function Ray(
  25118. /** origin point */
  25119. origin,
  25120. /** direction */
  25121. direction,
  25122. /** length of the ray */
  25123. length) {
  25124. if (length === void 0) { length = Number.MAX_VALUE; }
  25125. this.origin = origin;
  25126. this.direction = direction;
  25127. this.length = length;
  25128. }
  25129. // Methods
  25130. /**
  25131. * Checks if the ray intersects a box
  25132. * @param minimum bound of the box
  25133. * @param maximum bound of the box
  25134. * @param intersectionTreshold extra extend to be added to the box in all direction
  25135. * @returns if the box was hit
  25136. */
  25137. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25138. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25139. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25140. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25141. var d = 0.0;
  25142. var maxValue = Number.MAX_VALUE;
  25143. var inv;
  25144. var min;
  25145. var max;
  25146. var temp;
  25147. if (Math.abs(this.direction.x) < 0.0000001) {
  25148. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25149. return false;
  25150. }
  25151. }
  25152. else {
  25153. inv = 1.0 / this.direction.x;
  25154. min = (newMinimum.x - this.origin.x) * inv;
  25155. max = (newMaximum.x - this.origin.x) * inv;
  25156. if (max === -Infinity) {
  25157. max = Infinity;
  25158. }
  25159. if (min > max) {
  25160. temp = min;
  25161. min = max;
  25162. max = temp;
  25163. }
  25164. d = Math.max(min, d);
  25165. maxValue = Math.min(max, maxValue);
  25166. if (d > maxValue) {
  25167. return false;
  25168. }
  25169. }
  25170. if (Math.abs(this.direction.y) < 0.0000001) {
  25171. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25172. return false;
  25173. }
  25174. }
  25175. else {
  25176. inv = 1.0 / this.direction.y;
  25177. min = (newMinimum.y - this.origin.y) * inv;
  25178. max = (newMaximum.y - this.origin.y) * inv;
  25179. if (max === -Infinity) {
  25180. max = Infinity;
  25181. }
  25182. if (min > max) {
  25183. temp = min;
  25184. min = max;
  25185. max = temp;
  25186. }
  25187. d = Math.max(min, d);
  25188. maxValue = Math.min(max, maxValue);
  25189. if (d > maxValue) {
  25190. return false;
  25191. }
  25192. }
  25193. if (Math.abs(this.direction.z) < 0.0000001) {
  25194. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25195. return false;
  25196. }
  25197. }
  25198. else {
  25199. inv = 1.0 / this.direction.z;
  25200. min = (newMinimum.z - this.origin.z) * inv;
  25201. max = (newMaximum.z - this.origin.z) * inv;
  25202. if (max === -Infinity) {
  25203. max = Infinity;
  25204. }
  25205. if (min > max) {
  25206. temp = min;
  25207. min = max;
  25208. max = temp;
  25209. }
  25210. d = Math.max(min, d);
  25211. maxValue = Math.min(max, maxValue);
  25212. if (d > maxValue) {
  25213. return false;
  25214. }
  25215. }
  25216. return true;
  25217. };
  25218. /**
  25219. * Checks if the ray intersects a box
  25220. * @param box the bounding box to check
  25221. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25222. * @returns if the box was hit
  25223. */
  25224. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25225. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25226. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25227. };
  25228. /**
  25229. * If the ray hits a sphere
  25230. * @param sphere the bounding sphere to check
  25231. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25232. * @returns true if it hits the sphere
  25233. */
  25234. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25235. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25236. var x = sphere.center.x - this.origin.x;
  25237. var y = sphere.center.y - this.origin.y;
  25238. var z = sphere.center.z - this.origin.z;
  25239. var pyth = (x * x) + (y * y) + (z * z);
  25240. var radius = sphere.radius + intersectionTreshold;
  25241. var rr = radius * radius;
  25242. if (pyth <= rr) {
  25243. return true;
  25244. }
  25245. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25246. if (dot < 0.0) {
  25247. return false;
  25248. }
  25249. var temp = pyth - (dot * dot);
  25250. return temp <= rr;
  25251. };
  25252. /**
  25253. * If the ray hits a triange
  25254. * @param vertex0 triangle vertex
  25255. * @param vertex1 triangle vertex
  25256. * @param vertex2 triangle vertex
  25257. * @returns intersection information if hit
  25258. */
  25259. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25260. var edge1 = Ray.TmpVector3[0];
  25261. var edge2 = Ray.TmpVector3[1];
  25262. var pvec = Ray.TmpVector3[2];
  25263. var tvec = Ray.TmpVector3[3];
  25264. var qvec = Ray.TmpVector3[4];
  25265. vertex1.subtractToRef(vertex0, edge1);
  25266. vertex2.subtractToRef(vertex0, edge2);
  25267. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25268. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25269. if (det === 0) {
  25270. return null;
  25271. }
  25272. var invdet = 1 / det;
  25273. this.origin.subtractToRef(vertex0, tvec);
  25274. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25275. if (bu < 0 || bu > 1.0) {
  25276. return null;
  25277. }
  25278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25279. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25280. if (bv < 0 || bu + bv > 1.0) {
  25281. return null;
  25282. }
  25283. //check if the distance is longer than the predefined length.
  25284. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25285. if (distance > this.length) {
  25286. return null;
  25287. }
  25288. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25289. };
  25290. /**
  25291. * Checks if ray intersects a plane
  25292. * @param plane the plane to check
  25293. * @returns the distance away it was hit
  25294. */
  25295. Ray.prototype.intersectsPlane = function (plane) {
  25296. var distance;
  25297. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25298. if (Math.abs(result1) < 9.99999997475243E-07) {
  25299. return null;
  25300. }
  25301. else {
  25302. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25303. distance = (-plane.d - result2) / result1;
  25304. if (distance < 0.0) {
  25305. if (distance < -9.99999997475243E-07) {
  25306. return null;
  25307. }
  25308. else {
  25309. return 0;
  25310. }
  25311. }
  25312. return distance;
  25313. }
  25314. };
  25315. /**
  25316. * Checks if ray intersects a mesh
  25317. * @param mesh the mesh to check
  25318. * @param fastCheck if only the bounding box should checked
  25319. * @returns picking info of the intersecton
  25320. */
  25321. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25322. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25323. mesh.getWorldMatrix().invertToRef(tm);
  25324. if (this._tmpRay) {
  25325. Ray.TransformToRef(this, tm, this._tmpRay);
  25326. }
  25327. else {
  25328. this._tmpRay = Ray.Transform(this, tm);
  25329. }
  25330. return mesh.intersects(this._tmpRay, fastCheck);
  25331. };
  25332. /**
  25333. * Checks if ray intersects a mesh
  25334. * @param meshes the meshes to check
  25335. * @param fastCheck if only the bounding box should checked
  25336. * @param results array to store result in
  25337. * @returns Array of picking infos
  25338. */
  25339. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25340. if (results) {
  25341. results.length = 0;
  25342. }
  25343. else {
  25344. results = [];
  25345. }
  25346. for (var i = 0; i < meshes.length; i++) {
  25347. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25348. if (pickInfo.hit) {
  25349. results.push(pickInfo);
  25350. }
  25351. }
  25352. results.sort(this._comparePickingInfo);
  25353. return results;
  25354. };
  25355. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25356. if (pickingInfoA.distance < pickingInfoB.distance) {
  25357. return -1;
  25358. }
  25359. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25360. return 1;
  25361. }
  25362. else {
  25363. return 0;
  25364. }
  25365. };
  25366. /**
  25367. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25368. * @param sega the first point of the segment to test the intersection against
  25369. * @param segb the second point of the segment to test the intersection against
  25370. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25371. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25372. */
  25373. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25374. var o = this.origin;
  25375. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25376. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25377. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25378. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25379. segb.subtractToRef(sega, u);
  25380. this.direction.scaleToRef(Ray.rayl, v);
  25381. o.addToRef(v, rsegb);
  25382. sega.subtractToRef(o, w);
  25383. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25384. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25385. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25386. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25387. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25388. var D = a * c - b * b; // always >= 0
  25389. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25390. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25391. // compute the line parameters of the two closest points
  25392. if (D < Ray.smallnum) { // the lines are almost parallel
  25393. sN = 0.0; // force using point P0 on segment S1
  25394. sD = 1.0; // to prevent possible division by 0.0 later
  25395. tN = e;
  25396. tD = c;
  25397. }
  25398. else { // get the closest points on the infinite lines
  25399. sN = (b * e - c * d);
  25400. tN = (a * e - b * d);
  25401. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25402. sN = 0.0;
  25403. tN = e;
  25404. tD = c;
  25405. }
  25406. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25407. sN = sD;
  25408. tN = e + b;
  25409. tD = c;
  25410. }
  25411. }
  25412. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25413. tN = 0.0;
  25414. // recompute sc for this edge
  25415. if (-d < 0.0) {
  25416. sN = 0.0;
  25417. }
  25418. else if (-d > a) {
  25419. sN = sD;
  25420. }
  25421. else {
  25422. sN = -d;
  25423. sD = a;
  25424. }
  25425. }
  25426. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25427. tN = tD;
  25428. // recompute sc for this edge
  25429. if ((-d + b) < 0.0) {
  25430. sN = 0;
  25431. }
  25432. else if ((-d + b) > a) {
  25433. sN = sD;
  25434. }
  25435. else {
  25436. sN = (-d + b);
  25437. sD = a;
  25438. }
  25439. }
  25440. // finally do the division to get sc and tc
  25441. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25442. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25443. // get the difference of the two closest points
  25444. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25445. v.scaleToRef(tc, qtc);
  25446. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25447. u.scaleToRef(sc, qsc);
  25448. qsc.addInPlace(w);
  25449. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25450. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25451. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25452. if (isIntersected) {
  25453. return qsc.length();
  25454. }
  25455. return -1;
  25456. };
  25457. /**
  25458. * Update the ray from viewport position
  25459. * @param x position
  25460. * @param y y position
  25461. * @param viewportWidth viewport width
  25462. * @param viewportHeight viewport height
  25463. * @param world world matrix
  25464. * @param view view matrix
  25465. * @param projection projection matrix
  25466. * @returns this ray updated
  25467. */
  25468. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25469. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25470. return this;
  25471. };
  25472. // Statics
  25473. /**
  25474. * Creates a ray with origin and direction of 0,0,0
  25475. * @returns the new ray
  25476. */
  25477. Ray.Zero = function () {
  25478. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25479. };
  25480. /**
  25481. * Creates a new ray from screen space and viewport
  25482. * @param x position
  25483. * @param y y position
  25484. * @param viewportWidth viewport width
  25485. * @param viewportHeight viewport height
  25486. * @param world world matrix
  25487. * @param view view matrix
  25488. * @param projection projection matrix
  25489. * @returns new ray
  25490. */
  25491. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25492. var result = Ray.Zero();
  25493. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25494. };
  25495. /**
  25496. * 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
  25497. * transformed to the given world matrix.
  25498. * @param origin The origin point
  25499. * @param end The end point
  25500. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25501. * @returns the new ray
  25502. */
  25503. Ray.CreateNewFromTo = function (origin, end, world) {
  25504. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25505. var direction = end.subtract(origin);
  25506. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25507. direction.normalize();
  25508. return Ray.Transform(new Ray(origin, direction, length), world);
  25509. };
  25510. /**
  25511. * Transforms a ray by a matrix
  25512. * @param ray ray to transform
  25513. * @param matrix matrix to apply
  25514. * @returns the resulting new ray
  25515. */
  25516. Ray.Transform = function (ray, matrix) {
  25517. var result = new Ray(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0));
  25518. Ray.TransformToRef(ray, matrix, result);
  25519. return result;
  25520. };
  25521. /**
  25522. * Transforms a ray by a matrix
  25523. * @param ray ray to transform
  25524. * @param matrix matrix to apply
  25525. * @param result ray to store result in
  25526. */
  25527. Ray.TransformToRef = function (ray, matrix, result) {
  25528. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25529. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25530. result.length = ray.length;
  25531. var dir = result.direction;
  25532. var len = dir.length();
  25533. if (!(len === 0 || len === 1)) {
  25534. var num = 1.0 / len;
  25535. dir.x *= num;
  25536. dir.y *= num;
  25537. dir.z *= num;
  25538. result.length *= len;
  25539. }
  25540. };
  25541. /**
  25542. * Unproject a ray from screen space to object space
  25543. * @param sourceX defines the screen space x coordinate to use
  25544. * @param sourceY defines the screen space y coordinate to use
  25545. * @param viewportWidth defines the current width of the viewport
  25546. * @param viewportHeight defines the current height of the viewport
  25547. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25548. * @param view defines the view matrix to use
  25549. * @param projection defines the projection matrix to use
  25550. */
  25551. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25552. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25553. world.multiplyToRef(view, matrix);
  25554. matrix.multiplyToRef(projection, matrix);
  25555. matrix.invert();
  25556. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25557. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25558. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25559. nearScreenSource.z = -1.0;
  25560. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25561. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25562. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25563. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25564. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25565. this.origin.copyFrom(nearVec3);
  25566. farVec3.subtractToRef(nearVec3, this.direction);
  25567. this.direction.normalize();
  25568. };
  25569. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25570. Ray.smallnum = 0.00000001;
  25571. Ray.rayl = 10e8;
  25572. return Ray;
  25573. }());
  25574. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  25575. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25576. var result = Ray.Zero();
  25577. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  25578. return result;
  25579. };
  25580. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  25581. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25582. var engine = this.getEngine();
  25583. if (!camera) {
  25584. if (!this.activeCamera) {
  25585. throw new Error("Active camera not set");
  25586. }
  25587. camera = this.activeCamera;
  25588. }
  25589. var cameraViewport = camera.viewport;
  25590. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25591. // Moving coordinates to local viewport world
  25592. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25593. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25594. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  25595. return this;
  25596. };
  25597. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  25598. var result = Ray.Zero();
  25599. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  25600. return result;
  25601. };
  25602. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  25603. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25604. return this;
  25605. }
  25606. var engine = this.getEngine();
  25607. if (!camera) {
  25608. if (!this.activeCamera) {
  25609. throw new Error("Active camera not set");
  25610. }
  25611. camera = this.activeCamera;
  25612. }
  25613. var cameraViewport = camera.viewport;
  25614. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25615. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25616. // Moving coordinates to local viewport world
  25617. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25618. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25619. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  25620. return this;
  25621. };
  25622. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  25623. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25624. return null;
  25625. }
  25626. var pickingInfo = null;
  25627. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25628. var mesh = this.meshes[meshIndex];
  25629. if (predicate) {
  25630. if (!predicate(mesh)) {
  25631. continue;
  25632. }
  25633. }
  25634. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25635. continue;
  25636. }
  25637. var world = mesh.getWorldMatrix();
  25638. var ray = rayFunction(world);
  25639. var result = mesh.intersects(ray, fastCheck);
  25640. if (!result || !result.hit) {
  25641. continue;
  25642. }
  25643. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  25644. continue;
  25645. }
  25646. pickingInfo = result;
  25647. if (fastCheck) {
  25648. break;
  25649. }
  25650. }
  25651. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  25652. };
  25653. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate) {
  25654. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25655. return null;
  25656. }
  25657. var pickingInfos = new Array();
  25658. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25659. var mesh = this.meshes[meshIndex];
  25660. if (predicate) {
  25661. if (!predicate(mesh)) {
  25662. continue;
  25663. }
  25664. }
  25665. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25666. continue;
  25667. }
  25668. var world = mesh.getWorldMatrix();
  25669. var ray = rayFunction(world);
  25670. var result = mesh.intersects(ray, false);
  25671. if (!result || !result.hit) {
  25672. continue;
  25673. }
  25674. pickingInfos.push(result);
  25675. }
  25676. return pickingInfos;
  25677. };
  25678. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera) {
  25679. var _this = this;
  25680. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25681. return null;
  25682. }
  25683. var result = this._internalPick(function (world) {
  25684. if (!_this._tempPickingRay) {
  25685. _this._tempPickingRay = Ray.Zero();
  25686. }
  25687. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  25688. return _this._tempPickingRay;
  25689. }, predicate, fastCheck);
  25690. if (result) {
  25691. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  25692. }
  25693. return result;
  25694. };
  25695. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck) {
  25696. var _this = this;
  25697. var result = this._internalPick(function (world) {
  25698. if (!_this._pickWithRayInverseMatrix) {
  25699. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25700. }
  25701. world.invertToRef(_this._pickWithRayInverseMatrix);
  25702. if (!_this._cachedRayForTransform) {
  25703. _this._cachedRayForTransform = Ray.Zero();
  25704. }
  25705. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25706. return _this._cachedRayForTransform;
  25707. }, predicate, fastCheck);
  25708. if (result) {
  25709. result.ray = ray;
  25710. }
  25711. return result;
  25712. };
  25713. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera) {
  25714. var _this = this;
  25715. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  25716. };
  25717. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate) {
  25718. var _this = this;
  25719. return this._internalMultiPick(function (world) {
  25720. if (!_this._pickWithRayInverseMatrix) {
  25721. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25722. }
  25723. world.invertToRef(_this._pickWithRayInverseMatrix);
  25724. if (!_this._cachedRayForTransform) {
  25725. _this._cachedRayForTransform = Ray.Zero();
  25726. }
  25727. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25728. return _this._cachedRayForTransform;
  25729. }, predicate);
  25730. };
  25731. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  25732. if (length === void 0) { length = 100; }
  25733. if (!transform) {
  25734. transform = this.getWorldMatrix();
  25735. }
  25736. if (!origin) {
  25737. origin = this.position;
  25738. }
  25739. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  25740. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  25741. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  25742. return new Ray(origin, direction, length);
  25743. };
  25744. /***/ }),
  25745. /***/ "./Debug/axesViewer.ts":
  25746. /*!*****************************!*\
  25747. !*** ./Debug/axesViewer.ts ***!
  25748. \*****************************/
  25749. /*! exports provided: AxesViewer */
  25750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25751. "use strict";
  25752. __webpack_require__.r(__webpack_exports__);
  25753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25755. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25756. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25757. /**
  25758. * The Axes viewer will show 3 axes in a specific point in space
  25759. */
  25760. var AxesViewer = /** @class */ (function () {
  25761. /**
  25762. * Creates a new AxesViewer
  25763. * @param scene defines the hosting scene
  25764. * @param scaleLines defines a number used to scale line length (1 by default)
  25765. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25766. * @param xAxis defines the node hierarchy used to render the x-axis
  25767. * @param yAxis defines the node hierarchy used to render the y-axis
  25768. * @param zAxis defines the node hierarchy used to render the z-axis
  25769. */
  25770. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25771. if (scaleLines === void 0) { scaleLines = 1; }
  25772. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25773. this._scaleLinesFactor = 4;
  25774. this._instanced = false;
  25775. /**
  25776. * Gets or sets a number used to scale line length
  25777. */
  25778. this.scaleLines = 1;
  25779. this.scaleLines = scaleLines;
  25780. if (!xAxis) {
  25781. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25782. redColoredMaterial.disableLighting = true;
  25783. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25784. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25785. }
  25786. if (!yAxis) {
  25787. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25788. greenColoredMaterial.disableLighting = true;
  25789. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25790. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25791. }
  25792. if (!zAxis) {
  25793. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25794. blueColoredMaterial.disableLighting = true;
  25795. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25796. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25797. }
  25798. this._xAxis = xAxis;
  25799. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25800. this._yAxis = yAxis;
  25801. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25802. this._zAxis = zAxis;
  25803. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25804. if (renderingGroupId != null) {
  25805. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25806. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25807. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25808. }
  25809. this.scene = scene;
  25810. this.update(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward());
  25811. }
  25812. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25813. /** Gets the node hierarchy used to render x-axis */
  25814. get: function () {
  25815. return this._xAxis;
  25816. },
  25817. enumerable: true,
  25818. configurable: true
  25819. });
  25820. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25821. /** Gets the node hierarchy used to render y-axis */
  25822. get: function () {
  25823. return this._yAxis;
  25824. },
  25825. enumerable: true,
  25826. configurable: true
  25827. });
  25828. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25829. /** Gets the node hierarchy used to render z-axis */
  25830. get: function () {
  25831. return this._zAxis;
  25832. },
  25833. enumerable: true,
  25834. configurable: true
  25835. });
  25836. /**
  25837. * Force the viewer to update
  25838. * @param position defines the position of the viewer
  25839. * @param xaxis defines the x axis of the viewer
  25840. * @param yaxis defines the y axis of the viewer
  25841. * @param zaxis defines the z axis of the viewer
  25842. */
  25843. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25844. this._xAxis.position.copyFrom(position);
  25845. this._xAxis.setDirection(xaxis);
  25846. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25847. this._yAxis.position.copyFrom(position);
  25848. this._yAxis.setDirection(yaxis);
  25849. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25850. this._zAxis.position.copyFrom(position);
  25851. this._zAxis.setDirection(zaxis);
  25852. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25853. };
  25854. /**
  25855. * Creates an instance of this axes viewer.
  25856. * @returns a new axes viewer with instanced meshes
  25857. */
  25858. AxesViewer.prototype.createInstance = function () {
  25859. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25860. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25861. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25862. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25863. axesViewer._instanced = true;
  25864. return axesViewer;
  25865. };
  25866. /** Releases resources */
  25867. AxesViewer.prototype.dispose = function () {
  25868. if (this._xAxis) {
  25869. this._xAxis.dispose(false, !this._instanced);
  25870. delete this._xAxis;
  25871. }
  25872. if (this._yAxis) {
  25873. this._yAxis.dispose(false, !this._instanced);
  25874. delete this._yAxis;
  25875. }
  25876. if (this._zAxis) {
  25877. this._zAxis.dispose(false, !this._instanced);
  25878. delete this._zAxis;
  25879. }
  25880. delete this.scene;
  25881. };
  25882. AxesViewer._SetRenderingGroupId = function (node, id) {
  25883. node.getChildMeshes().forEach(function (mesh) {
  25884. mesh.renderingGroupId = id;
  25885. });
  25886. };
  25887. return AxesViewer;
  25888. }());
  25889. /***/ }),
  25890. /***/ "./Debug/boneAxesViewer.ts":
  25891. /*!*********************************!*\
  25892. !*** ./Debug/boneAxesViewer.ts ***!
  25893. \*********************************/
  25894. /*! exports provided: BoneAxesViewer */
  25895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25896. "use strict";
  25897. __webpack_require__.r(__webpack_exports__);
  25898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25900. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25902. /**
  25903. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25904. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25905. */
  25906. var BoneAxesViewer = /** @class */ (function (_super) {
  25907. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25908. /**
  25909. * Creates a new BoneAxesViewer
  25910. * @param scene defines the hosting scene
  25911. * @param bone defines the target bone
  25912. * @param mesh defines the target mesh
  25913. * @param scaleLines defines a scaling factor for line length (1 by default)
  25914. */
  25915. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25916. if (scaleLines === void 0) { scaleLines = 1; }
  25917. var _this = _super.call(this, scene, scaleLines) || this;
  25918. /** Gets current position */
  25919. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25920. /** Gets direction of X axis */
  25921. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25922. /** Gets direction of Y axis */
  25923. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25924. /** Gets direction of Z axis */
  25925. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25926. _this.mesh = mesh;
  25927. _this.bone = bone;
  25928. return _this;
  25929. }
  25930. /**
  25931. * Force the viewer to update
  25932. */
  25933. BoneAxesViewer.prototype.update = function () {
  25934. if (!this.mesh || !this.bone) {
  25935. return;
  25936. }
  25937. var bone = this.bone;
  25938. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25939. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25940. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25941. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25942. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25943. };
  25944. /** Releases resources */
  25945. BoneAxesViewer.prototype.dispose = function () {
  25946. if (this.mesh) {
  25947. this.mesh = null;
  25948. this.bone = null;
  25949. _super.prototype.dispose.call(this);
  25950. }
  25951. };
  25952. return BoneAxesViewer;
  25953. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25954. /***/ }),
  25955. /***/ "./Debug/debugLayer.ts":
  25956. /*!*****************************!*\
  25957. !*** ./Debug/debugLayer.ts ***!
  25958. \*****************************/
  25959. /*! exports provided: DebugLayer */
  25960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25961. "use strict";
  25962. __webpack_require__.r(__webpack_exports__);
  25963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25964. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25965. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25966. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25967. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25968. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25969. get: function () {
  25970. if (!this._debugLayer) {
  25971. this._debugLayer = new DebugLayer(this);
  25972. }
  25973. return this._debugLayer;
  25974. },
  25975. enumerable: true,
  25976. configurable: true
  25977. });
  25978. /**
  25979. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25980. * what is happening in your scene
  25981. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25982. */
  25983. var DebugLayer = /** @class */ (function () {
  25984. /**
  25985. * Instantiates a new debug layer.
  25986. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25987. * what is happening in your scene
  25988. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25989. * @param scene Defines the scene to inspect
  25990. */
  25991. function DebugLayer(scene) {
  25992. var _this = this;
  25993. this.BJSINSPECTOR = this._getGlobalInspector();
  25994. /**
  25995. * Observable triggered when a property is changed through the inspector.
  25996. */
  25997. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  25998. this._scene = scene;
  25999. this._scene.onDisposeObservable.add(function () {
  26000. // Debug layer
  26001. if (_this._scene._debugLayer) {
  26002. _this._scene._debugLayer.hide();
  26003. }
  26004. });
  26005. }
  26006. /** Creates the inspector window. */
  26007. DebugLayer.prototype._createInspector = function (config) {
  26008. if (this.isVisible()) {
  26009. return;
  26010. }
  26011. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26012. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26013. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26014. };
  26015. /** Get the inspector from bundle or global */
  26016. DebugLayer.prototype._getGlobalInspector = function () {
  26017. // UMD Global name detection from Webpack Bundle UMD Name.
  26018. if (typeof INSPECTOR !== 'undefined') {
  26019. return INSPECTOR;
  26020. }
  26021. // In case of module let s check the global emitted from the Inspector entry point.
  26022. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26023. return BABYLON;
  26024. }
  26025. return undefined;
  26026. };
  26027. /**
  26028. * Get if the inspector is visible or not.
  26029. * @returns true if visible otherwise, false
  26030. */
  26031. DebugLayer.prototype.isVisible = function () {
  26032. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26033. };
  26034. /**
  26035. * Hide the inspector and close its window.
  26036. */
  26037. DebugLayer.prototype.hide = function () {
  26038. if (this.BJSINSPECTOR) {
  26039. this.BJSINSPECTOR.Inspector.Hide();
  26040. }
  26041. };
  26042. /**
  26043. * Launch the debugLayer.
  26044. * @param config Define the configuration of the inspector
  26045. */
  26046. DebugLayer.prototype.show = function (config) {
  26047. if (typeof this.BJSINSPECTOR == 'undefined') {
  26048. // Load inspector and add it to the DOM
  26049. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  26050. }
  26051. else {
  26052. // Otherwise creates the inspector
  26053. this._createInspector(config);
  26054. }
  26055. };
  26056. /**
  26057. * Define the url to get the inspector script from.
  26058. * By default it uses the babylonjs CDN.
  26059. * @ignoreNaming
  26060. */
  26061. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  26062. return DebugLayer;
  26063. }());
  26064. /***/ }),
  26065. /***/ "./Debug/index.ts":
  26066. /*!************************!*\
  26067. !*** ./Debug/index.ts ***!
  26068. \************************/
  26069. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26071. "use strict";
  26072. __webpack_require__.r(__webpack_exports__);
  26073. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26075. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26077. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26079. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26081. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26083. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26085. /***/ }),
  26086. /***/ "./Debug/physicsViewer.ts":
  26087. /*!********************************!*\
  26088. !*** ./Debug/physicsViewer.ts ***!
  26089. \********************************/
  26090. /*! exports provided: PhysicsViewer */
  26091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26092. "use strict";
  26093. __webpack_require__.r(__webpack_exports__);
  26094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26095. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26096. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26097. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26098. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26099. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26100. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26101. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26102. /**
  26103. * Used to show the physics impostor around the specific mesh
  26104. */
  26105. var PhysicsViewer = /** @class */ (function () {
  26106. /**
  26107. * Creates a new PhysicsViewer
  26108. * @param scene defines the hosting scene
  26109. */
  26110. function PhysicsViewer(scene) {
  26111. /** @hidden */
  26112. this._impostors = [];
  26113. /** @hidden */
  26114. this._meshes = [];
  26115. /** @hidden */
  26116. this._numMeshes = 0;
  26117. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26118. var physicEngine = this._scene.getPhysicsEngine();
  26119. if (physicEngine) {
  26120. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26121. }
  26122. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26123. this._utilityLayer.pickUtilitySceneFirst = false;
  26124. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26125. }
  26126. /** @hidden */
  26127. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26128. var plugin = this._physicsEnginePlugin;
  26129. for (var i = 0; i < this._numMeshes; i++) {
  26130. var impostor = this._impostors[i];
  26131. if (!impostor) {
  26132. continue;
  26133. }
  26134. if (impostor.isDisposed) {
  26135. this.hideImpostor(this._impostors[i--]);
  26136. }
  26137. else {
  26138. var mesh = this._meshes[i];
  26139. if (mesh && plugin) {
  26140. plugin.syncMeshWithImpostor(mesh, impostor);
  26141. }
  26142. }
  26143. }
  26144. };
  26145. /**
  26146. * Renders a specified physic impostor
  26147. * @param impostor defines the impostor to render
  26148. * @returns the new debug mesh used to render the impostor
  26149. */
  26150. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26151. if (!this._scene) {
  26152. return null;
  26153. }
  26154. for (var i = 0; i < this._numMeshes; i++) {
  26155. if (this._impostors[i] == impostor) {
  26156. return null;
  26157. }
  26158. }
  26159. var debugMesh = this._getDebugMesh(impostor);
  26160. if (debugMesh) {
  26161. this._impostors[this._numMeshes] = impostor;
  26162. this._meshes[this._numMeshes] = debugMesh;
  26163. if (this._numMeshes === 0) {
  26164. this._renderFunction = this._updateDebugMeshes.bind(this);
  26165. this._scene.registerBeforeRender(this._renderFunction);
  26166. }
  26167. this._numMeshes++;
  26168. }
  26169. return debugMesh;
  26170. };
  26171. /**
  26172. * Hides a specified physic impostor
  26173. * @param impostor defines the impostor to hide
  26174. */
  26175. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26176. if (!impostor || !this._scene || !this._utilityLayer) {
  26177. return;
  26178. }
  26179. var removed = false;
  26180. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26181. for (var i = 0; i < this._numMeshes; i++) {
  26182. if (this._impostors[i] == impostor) {
  26183. var mesh = this._meshes[i];
  26184. if (!mesh) {
  26185. continue;
  26186. }
  26187. utilityLayerScene.removeMesh(mesh);
  26188. mesh.dispose();
  26189. this._numMeshes--;
  26190. if (this._numMeshes > 0) {
  26191. this._meshes[i] = this._meshes[this._numMeshes];
  26192. this._impostors[i] = this._impostors[this._numMeshes];
  26193. this._meshes[this._numMeshes] = null;
  26194. this._impostors[this._numMeshes] = null;
  26195. }
  26196. else {
  26197. this._meshes[0] = null;
  26198. this._impostors[0] = null;
  26199. }
  26200. removed = true;
  26201. break;
  26202. }
  26203. }
  26204. if (removed && this._numMeshes === 0) {
  26205. this._scene.unregisterBeforeRender(this._renderFunction);
  26206. }
  26207. };
  26208. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26209. if (!this._debugMaterial) {
  26210. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26211. this._debugMaterial.wireframe = true;
  26212. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26213. this._debugMaterial.disableLighting = true;
  26214. }
  26215. return this._debugMaterial;
  26216. };
  26217. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26218. if (!this._debugBoxMesh) {
  26219. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26220. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26221. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26222. }
  26223. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26224. };
  26225. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26226. if (!this._debugSphereMesh) {
  26227. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26228. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26229. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26230. }
  26231. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26232. };
  26233. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26234. if (!this._utilityLayer) {
  26235. return null;
  26236. }
  26237. var mesh = null;
  26238. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26239. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26240. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26241. impostor.getBoxSizeToRef(mesh.scaling);
  26242. }
  26243. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26244. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26245. var radius = impostor.getRadius();
  26246. mesh.scaling.x = radius * 2;
  26247. mesh.scaling.y = radius * 2;
  26248. mesh.scaling.z = radius * 2;
  26249. }
  26250. return mesh;
  26251. };
  26252. /** Releases all resources */
  26253. PhysicsViewer.prototype.dispose = function () {
  26254. for (var i = 0; i < this._numMeshes; i++) {
  26255. this.hideImpostor(this._impostors[i]);
  26256. }
  26257. if (this._debugBoxMesh) {
  26258. this._debugBoxMesh.dispose();
  26259. }
  26260. if (this._debugSphereMesh) {
  26261. this._debugSphereMesh.dispose();
  26262. }
  26263. if (this._debugMaterial) {
  26264. this._debugMaterial.dispose();
  26265. }
  26266. this._impostors.length = 0;
  26267. this._scene = null;
  26268. this._physicsEnginePlugin = null;
  26269. if (this._utilityLayer) {
  26270. this._utilityLayer.dispose();
  26271. this._utilityLayer = null;
  26272. }
  26273. };
  26274. return PhysicsViewer;
  26275. }());
  26276. /***/ }),
  26277. /***/ "./Debug/rayHelper.ts":
  26278. /*!****************************!*\
  26279. !*** ./Debug/rayHelper.ts ***!
  26280. \****************************/
  26281. /*! exports provided: RayHelper */
  26282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26283. "use strict";
  26284. __webpack_require__.r(__webpack_exports__);
  26285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26286. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26287. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26288. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26289. /**
  26290. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26291. * in order to better appreciate the issue one might have.
  26292. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26293. */
  26294. var RayHelper = /** @class */ (function () {
  26295. /**
  26296. * Instantiate a new ray helper.
  26297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26298. * in order to better appreciate the issue one might have.
  26299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26300. * @param ray Defines the ray we are currently tryin to visualize
  26301. */
  26302. function RayHelper(ray) {
  26303. this.ray = ray;
  26304. }
  26305. /**
  26306. * Helper function to create a colored helper in a scene in one line.
  26307. * @param ray Defines the ray we are currently tryin to visualize
  26308. * @param scene Defines the scene the ray is used in
  26309. * @param color Defines the color we want to see the ray in
  26310. * @returns The newly created ray helper.
  26311. */
  26312. RayHelper.CreateAndShow = function (ray, scene, color) {
  26313. var helper = new RayHelper(ray);
  26314. helper.show(scene, color);
  26315. return helper;
  26316. };
  26317. /**
  26318. * Shows the ray we are willing to debug.
  26319. * @param scene Defines the scene the ray needs to be rendered in
  26320. * @param color Defines the color the ray needs to be rendered in
  26321. */
  26322. RayHelper.prototype.show = function (scene, color) {
  26323. if (!this._renderFunction && this.ray) {
  26324. var ray = this.ray;
  26325. this._renderFunction = this._render.bind(this);
  26326. this._scene = scene;
  26327. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26328. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26329. if (this._renderFunction) {
  26330. this._scene.registerBeforeRender(this._renderFunction);
  26331. }
  26332. }
  26333. if (color && this._renderLine) {
  26334. this._renderLine.color.copyFrom(color);
  26335. }
  26336. };
  26337. /**
  26338. * Hides the ray we are debugging.
  26339. */
  26340. RayHelper.prototype.hide = function () {
  26341. if (this._renderFunction && this._scene) {
  26342. this._scene.unregisterBeforeRender(this._renderFunction);
  26343. this._scene = null;
  26344. this._renderFunction = null;
  26345. if (this._renderLine) {
  26346. this._renderLine.dispose();
  26347. this._renderLine = null;
  26348. }
  26349. this._renderPoints = [];
  26350. }
  26351. };
  26352. RayHelper.prototype._render = function () {
  26353. var ray = this.ray;
  26354. if (!ray) {
  26355. return;
  26356. }
  26357. var point = this._renderPoints[1];
  26358. var len = Math.min(ray.length, 1000000);
  26359. point.copyFrom(ray.direction);
  26360. point.scaleInPlace(len);
  26361. point.addInPlace(ray.origin);
  26362. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26363. };
  26364. /**
  26365. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26366. * @param mesh Defines the mesh we want the helper attached to
  26367. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26368. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26369. * @param length Defines the length of the ray
  26370. */
  26371. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26372. this._attachedToMesh = mesh;
  26373. var ray = this.ray;
  26374. if (!ray) {
  26375. return;
  26376. }
  26377. if (!ray.direction) {
  26378. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26379. }
  26380. if (!ray.origin) {
  26381. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26382. }
  26383. if (length) {
  26384. ray.length = length;
  26385. }
  26386. if (!meshSpaceOrigin) {
  26387. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26388. }
  26389. if (!meshSpaceDirection) {
  26390. // -1 so that this will work with Mesh.lookAt
  26391. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26392. }
  26393. if (!this._meshSpaceDirection) {
  26394. this._meshSpaceDirection = meshSpaceDirection.clone();
  26395. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26396. }
  26397. else {
  26398. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26399. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26400. }
  26401. if (!this._updateToMeshFunction) {
  26402. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26403. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26404. }
  26405. this._updateToMesh();
  26406. };
  26407. /**
  26408. * Detach the ray helper from the mesh it has previously been attached to.
  26409. */
  26410. RayHelper.prototype.detachFromMesh = function () {
  26411. if (this._attachedToMesh) {
  26412. if (this._updateToMeshFunction) {
  26413. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26414. }
  26415. this._attachedToMesh = null;
  26416. this._updateToMeshFunction = null;
  26417. }
  26418. };
  26419. RayHelper.prototype._updateToMesh = function () {
  26420. var ray = this.ray;
  26421. if (!this._attachedToMesh || !ray) {
  26422. return;
  26423. }
  26424. if (this._attachedToMesh._isDisposed) {
  26425. this.detachFromMesh();
  26426. return;
  26427. }
  26428. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26429. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26430. };
  26431. /**
  26432. * Dispose the helper and release its associated resources.
  26433. */
  26434. RayHelper.prototype.dispose = function () {
  26435. this.hide();
  26436. this.detachFromMesh();
  26437. this.ray = null;
  26438. };
  26439. return RayHelper;
  26440. }());
  26441. /***/ }),
  26442. /***/ "./Debug/skeletonViewer.ts":
  26443. /*!*********************************!*\
  26444. !*** ./Debug/skeletonViewer.ts ***!
  26445. \*********************************/
  26446. /*! exports provided: SkeletonViewer */
  26447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26448. "use strict";
  26449. __webpack_require__.r(__webpack_exports__);
  26450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26452. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26453. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26454. /**
  26455. * Class used to render a debug view of a given skeleton
  26456. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26457. */
  26458. var SkeletonViewer = /** @class */ (function () {
  26459. /**
  26460. * Creates a new SkeletonViewer
  26461. * @param skeleton defines the skeleton to render
  26462. * @param mesh defines the mesh attached to the skeleton
  26463. * @param scene defines the hosting scene
  26464. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26465. * @param renderingGroupId defines the rendering group id to use with the viewer
  26466. */
  26467. function SkeletonViewer(
  26468. /** defines the skeleton to render */
  26469. skeleton,
  26470. /** defines the mesh attached to the skeleton */
  26471. mesh, scene,
  26472. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26473. autoUpdateBonesMatrices,
  26474. /** defines the rendering group id to use with the viewer */
  26475. renderingGroupId) {
  26476. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26477. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26478. this.skeleton = skeleton;
  26479. this.mesh = mesh;
  26480. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26481. this.renderingGroupId = renderingGroupId;
  26482. /** Gets or sets the color used to render the skeleton */
  26483. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26484. this._debugLines = new Array();
  26485. this._isEnabled = false;
  26486. this._scene = scene;
  26487. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26488. this._utilityLayer.pickUtilitySceneFirst = false;
  26489. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26490. this.update();
  26491. this._renderFunction = this.update.bind(this);
  26492. }
  26493. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26494. /**
  26495. * Returns the mesh used to render the bones
  26496. */
  26497. get: function () {
  26498. return this._debugMesh;
  26499. },
  26500. enumerable: true,
  26501. configurable: true
  26502. });
  26503. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26504. get: function () {
  26505. return this._isEnabled;
  26506. },
  26507. /** Gets or sets a boolean indicating if the viewer is enabled */
  26508. set: function (value) {
  26509. if (this._isEnabled === value) {
  26510. return;
  26511. }
  26512. this._isEnabled = value;
  26513. if (value) {
  26514. this._scene.registerBeforeRender(this._renderFunction);
  26515. }
  26516. else {
  26517. this._scene.unregisterBeforeRender(this._renderFunction);
  26518. }
  26519. },
  26520. enumerable: true,
  26521. configurable: true
  26522. });
  26523. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26524. if (x === void 0) { x = 0; }
  26525. if (y === void 0) { y = 0; }
  26526. if (z === void 0) { z = 0; }
  26527. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26528. var parentBone = bone.getParent();
  26529. tmat.copyFrom(bone.getLocalMatrix());
  26530. if (x !== 0 || y !== 0 || z !== 0) {
  26531. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26532. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26533. tmat2.setTranslationFromFloats(x, y, z);
  26534. tmat2.multiplyToRef(tmat, tmat);
  26535. }
  26536. if (parentBone) {
  26537. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26538. }
  26539. tmat.multiplyToRef(meshMat, tmat);
  26540. position.x = tmat.m[12];
  26541. position.y = tmat.m[13];
  26542. position.z = tmat.m[14];
  26543. };
  26544. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26545. var len = bones.length;
  26546. var meshPos = this.mesh.position;
  26547. for (var i = 0; i < len; i++) {
  26548. var bone = bones[i];
  26549. var points = this._debugLines[i];
  26550. if (!points) {
  26551. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26552. this._debugLines[i] = points;
  26553. }
  26554. this._getBonePosition(points[0], bone, meshMat);
  26555. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26556. points[0].subtractInPlace(meshPos);
  26557. points[1].subtractInPlace(meshPos);
  26558. }
  26559. };
  26560. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26561. var len = bones.length;
  26562. var boneNum = 0;
  26563. var meshPos = this.mesh.position;
  26564. for (var i = len - 1; i >= 0; i--) {
  26565. var childBone = bones[i];
  26566. var parentBone = childBone.getParent();
  26567. if (!parentBone) {
  26568. continue;
  26569. }
  26570. var points = this._debugLines[boneNum];
  26571. if (!points) {
  26572. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26573. this._debugLines[boneNum] = points;
  26574. }
  26575. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26576. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26577. points[0].subtractInPlace(meshPos);
  26578. points[1].subtractInPlace(meshPos);
  26579. boneNum++;
  26580. }
  26581. };
  26582. /** Update the viewer to sync with current skeleton state */
  26583. SkeletonViewer.prototype.update = function () {
  26584. if (!this._utilityLayer) {
  26585. return;
  26586. }
  26587. if (this.autoUpdateBonesMatrices) {
  26588. this.skeleton.computeAbsoluteTransforms();
  26589. }
  26590. if (this.skeleton.bones[0].length === undefined) {
  26591. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26592. }
  26593. else {
  26594. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26595. }
  26596. var targetScene = this._utilityLayer.utilityLayerScene;
  26597. if (!this._debugMesh) {
  26598. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26599. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26600. }
  26601. else {
  26602. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26603. }
  26604. this._debugMesh.position.copyFrom(this.mesh.position);
  26605. this._debugMesh.color = this.color;
  26606. };
  26607. /** Release associated resources */
  26608. SkeletonViewer.prototype.dispose = function () {
  26609. this.isEnabled = false;
  26610. if (this._debugMesh) {
  26611. this.isEnabled = false;
  26612. this._debugMesh.dispose();
  26613. this._debugMesh = null;
  26614. }
  26615. if (this._utilityLayer) {
  26616. this._utilityLayer.dispose();
  26617. this._utilityLayer = null;
  26618. }
  26619. };
  26620. return SkeletonViewer;
  26621. }());
  26622. /***/ }),
  26623. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26624. /*!*****************************************************!*\
  26625. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26626. \*****************************************************/
  26627. /*! exports provided: _OcclusionDataStorage */
  26628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26629. "use strict";
  26630. __webpack_require__.r(__webpack_exports__);
  26631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26632. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26633. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26634. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26635. /** @hidden */
  26636. var _OcclusionDataStorage = /** @class */ (function () {
  26637. function _OcclusionDataStorage() {
  26638. /** @hidden */
  26639. this.occlusionInternalRetryCounter = 0;
  26640. /** @hidden */
  26641. this.isOcclusionQueryInProgress = false;
  26642. /** @hidden */
  26643. this.isOccluded = false;
  26644. /** @hidden */
  26645. this.occlusionRetryCount = -1;
  26646. /** @hidden */
  26647. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26648. /** @hidden */
  26649. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26650. }
  26651. return _OcclusionDataStorage;
  26652. }());
  26653. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26654. return this._gl.createQuery();
  26655. };
  26656. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26657. this._gl.deleteQuery(query);
  26658. return this;
  26659. };
  26660. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26661. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26662. };
  26663. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26664. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26665. };
  26666. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26667. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26668. this._gl.beginQuery(glAlgorithm, query);
  26669. return this;
  26670. };
  26671. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26672. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26673. this._gl.endQuery(glAlgorithm);
  26674. return this;
  26675. };
  26676. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26677. var timerQuery = this.getCaps().timerQuery;
  26678. if (timerQuery.createQueryEXT) {
  26679. return timerQuery.createQueryEXT();
  26680. }
  26681. return this.createQuery();
  26682. };
  26683. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26684. var timerQuery = this.getCaps().timerQuery;
  26685. if (timerQuery.deleteQueryEXT) {
  26686. timerQuery.deleteQueryEXT(query);
  26687. return;
  26688. }
  26689. this.deleteQuery(query);
  26690. };
  26691. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26692. var timerQuery = this.getCaps().timerQuery;
  26693. if (timerQuery.getQueryObjectEXT) {
  26694. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26695. }
  26696. return this.getQueryResult(query);
  26697. };
  26698. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26699. var timerQuery = this.getCaps().timerQuery;
  26700. if (timerQuery.getQueryObjectEXT) {
  26701. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26702. }
  26703. return this.isQueryResultAvailable(query);
  26704. };
  26705. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26706. var caps = this.getCaps();
  26707. var timerQuery = caps.timerQuery;
  26708. if (!timerQuery) {
  26709. return null;
  26710. }
  26711. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26712. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26713. if (caps.canUseTimestampForTimerQuery) {
  26714. token._startTimeQuery = this._createTimeQuery();
  26715. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26716. }
  26717. else {
  26718. if (this._currentNonTimestampToken) {
  26719. return this._currentNonTimestampToken;
  26720. }
  26721. token._timeElapsedQuery = this._createTimeQuery();
  26722. if (timerQuery.beginQueryEXT) {
  26723. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26724. }
  26725. else {
  26726. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26727. }
  26728. this._currentNonTimestampToken = token;
  26729. }
  26730. return token;
  26731. };
  26732. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26733. var caps = this.getCaps();
  26734. var timerQuery = caps.timerQuery;
  26735. if (!timerQuery || !token) {
  26736. return -1;
  26737. }
  26738. if (caps.canUseTimestampForTimerQuery) {
  26739. if (!token._startTimeQuery) {
  26740. return -1;
  26741. }
  26742. if (!token._endTimeQuery) {
  26743. token._endTimeQuery = this._createTimeQuery();
  26744. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26745. }
  26746. }
  26747. else if (!token._timeElapsedQueryEnded) {
  26748. if (!token._timeElapsedQuery) {
  26749. return -1;
  26750. }
  26751. if (timerQuery.endQueryEXT) {
  26752. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26753. }
  26754. else {
  26755. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26756. }
  26757. token._timeElapsedQueryEnded = true;
  26758. }
  26759. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26760. var available = false;
  26761. if (token._endTimeQuery) {
  26762. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26763. }
  26764. else if (token._timeElapsedQuery) {
  26765. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26766. }
  26767. if (available && !disjoint) {
  26768. var result = 0;
  26769. if (caps.canUseTimestampForTimerQuery) {
  26770. if (!token._startTimeQuery || !token._endTimeQuery) {
  26771. return -1;
  26772. }
  26773. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26774. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26775. result = timeEnd - timeStart;
  26776. this._deleteTimeQuery(token._startTimeQuery);
  26777. this._deleteTimeQuery(token._endTimeQuery);
  26778. token._startTimeQuery = null;
  26779. token._endTimeQuery = null;
  26780. }
  26781. else {
  26782. if (!token._timeElapsedQuery) {
  26783. return -1;
  26784. }
  26785. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26786. this._deleteTimeQuery(token._timeElapsedQuery);
  26787. token._timeElapsedQuery = null;
  26788. token._timeElapsedQueryEnded = false;
  26789. this._currentNonTimestampToken = null;
  26790. }
  26791. return result;
  26792. }
  26793. return -1;
  26794. };
  26795. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26796. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26797. };
  26798. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26799. get: function () {
  26800. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26801. },
  26802. enumerable: false,
  26803. configurable: true
  26804. });
  26805. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26806. get: function () {
  26807. if (!this.__occlusionDataStorage) {
  26808. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26809. }
  26810. return this.__occlusionDataStorage;
  26811. },
  26812. enumerable: false,
  26813. configurable: true
  26814. });
  26815. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26816. get: function () {
  26817. return this._occlusionDataStorage.isOccluded;
  26818. },
  26819. set: function (value) {
  26820. this._occlusionDataStorage.isOccluded = value;
  26821. },
  26822. enumerable: true,
  26823. configurable: true
  26824. });
  26825. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26826. get: function () {
  26827. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26828. },
  26829. set: function (value) {
  26830. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26831. },
  26832. enumerable: true,
  26833. configurable: true
  26834. });
  26835. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26836. get: function () {
  26837. return this._occlusionDataStorage.occlusionType;
  26838. },
  26839. set: function (value) {
  26840. this._occlusionDataStorage.occlusionType = value;
  26841. },
  26842. enumerable: true,
  26843. configurable: true
  26844. });
  26845. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26846. get: function () {
  26847. return this._occlusionDataStorage.occlusionRetryCount;
  26848. },
  26849. set: function (value) {
  26850. this._occlusionDataStorage.occlusionRetryCount = value;
  26851. },
  26852. enumerable: true,
  26853. configurable: true
  26854. });
  26855. // We also need to update AbstractMesh as there is a portion of the code there
  26856. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26857. var dataStorage = this._occlusionDataStorage;
  26858. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26859. dataStorage.isOccluded = false;
  26860. return false;
  26861. }
  26862. var engine = this.getEngine();
  26863. if (engine.webGLVersion < 2) {
  26864. dataStorage.isOccluded = false;
  26865. return false;
  26866. }
  26867. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26868. dataStorage.isOccluded = false;
  26869. return false;
  26870. }
  26871. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26872. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26873. if (isOcclusionQueryAvailable) {
  26874. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26875. dataStorage.isOcclusionQueryInProgress = false;
  26876. dataStorage.occlusionInternalRetryCounter = 0;
  26877. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26878. }
  26879. else {
  26880. dataStorage.occlusionInternalRetryCounter++;
  26881. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26882. dataStorage.isOcclusionQueryInProgress = false;
  26883. dataStorage.occlusionInternalRetryCounter = 0;
  26884. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26885. // if strict continue the last state of the object.
  26886. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26887. }
  26888. else {
  26889. return false;
  26890. }
  26891. }
  26892. }
  26893. var scene = this.getScene();
  26894. if (scene.getBoundingBoxRenderer) {
  26895. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26896. if (!this._occlusionQuery) {
  26897. this._occlusionQuery = engine.createQuery();
  26898. }
  26899. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26900. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26901. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26902. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26903. }
  26904. return dataStorage.isOccluded;
  26905. };
  26906. /***/ }),
  26907. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26908. /*!********************************************************!*\
  26909. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26910. \********************************************************/
  26911. /*! exports provided: _forceTransformFeedbackToBundle */
  26912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26913. "use strict";
  26914. __webpack_require__.r(__webpack_exports__);
  26915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26916. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26917. /** @hidden */
  26918. var _forceTransformFeedbackToBundle = true;
  26919. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26920. return this._gl.createTransformFeedback();
  26921. };
  26922. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26923. this._gl.deleteTransformFeedback(value);
  26924. };
  26925. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26926. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26927. };
  26928. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26929. if (usePoints === void 0) { usePoints = true; }
  26930. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26931. };
  26932. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26933. this._gl.endTransformFeedback();
  26934. };
  26935. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26936. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26937. };
  26938. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26939. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26940. };
  26941. /***/ }),
  26942. /***/ "./Engines/Extensions/index.ts":
  26943. /*!*************************************!*\
  26944. !*** ./Engines/Extensions/index.ts ***!
  26945. \*************************************/
  26946. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26948. "use strict";
  26949. __webpack_require__.r(__webpack_exports__);
  26950. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26952. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26954. /***/ }),
  26955. /***/ "./Engines/constants.ts":
  26956. /*!******************************!*\
  26957. !*** ./Engines/constants.ts ***!
  26958. \******************************/
  26959. /*! exports provided: Constants */
  26960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26961. "use strict";
  26962. __webpack_require__.r(__webpack_exports__);
  26963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26964. /** Defines the cross module used constants to avoid circular dependncies */
  26965. var Constants = /** @class */ (function () {
  26966. function Constants() {
  26967. }
  26968. /** Defines that alpha blending is disabled */
  26969. Constants.ALPHA_DISABLE = 0;
  26970. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26971. Constants.ALPHA_ADD = 1;
  26972. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26973. Constants.ALPHA_COMBINE = 2;
  26974. /** Defines that alpha blending to DEST - SRC * DEST */
  26975. Constants.ALPHA_SUBTRACT = 3;
  26976. /** Defines that alpha blending to SRC * DEST */
  26977. Constants.ALPHA_MULTIPLY = 4;
  26978. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26979. Constants.ALPHA_MAXIMIZED = 5;
  26980. /** Defines that alpha blending to SRC + DEST */
  26981. Constants.ALPHA_ONEONE = 6;
  26982. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26983. Constants.ALPHA_PREMULTIPLIED = 7;
  26984. /**
  26985. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26986. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26987. */
  26988. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  26989. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26990. Constants.ALPHA_INTERPOLATE = 9;
  26991. /**
  26992. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26993. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26994. */
  26995. Constants.ALPHA_SCREENMODE = 10;
  26996. /** Defines that the ressource is not delayed*/
  26997. Constants.DELAYLOADSTATE_NONE = 0;
  26998. /** Defines that the ressource was successfully delay loaded */
  26999. Constants.DELAYLOADSTATE_LOADED = 1;
  27000. /** Defines that the ressource is currently delay loading */
  27001. Constants.DELAYLOADSTATE_LOADING = 2;
  27002. /** Defines that the ressource is delayed and has not started loading */
  27003. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27004. // Depht or Stencil test Constants.
  27005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27006. Constants.NEVER = 0x0200;
  27007. /** 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 */
  27008. Constants.ALWAYS = 0x0207;
  27009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27010. Constants.LESS = 0x0201;
  27011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27012. Constants.EQUAL = 0x0202;
  27013. /** 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 */
  27014. Constants.LEQUAL = 0x0203;
  27015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27016. Constants.GREATER = 0x0204;
  27017. /** 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 */
  27018. Constants.GEQUAL = 0x0206;
  27019. /** 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 */
  27020. Constants.NOTEQUAL = 0x0205;
  27021. // Stencil Actions Constants.
  27022. /** Passed to stencilOperation to specify that stencil value must be kept */
  27023. Constants.KEEP = 0x1E00;
  27024. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27025. Constants.REPLACE = 0x1E01;
  27026. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27027. Constants.INCR = 0x1E02;
  27028. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27029. Constants.DECR = 0x1E03;
  27030. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27031. Constants.INVERT = 0x150A;
  27032. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27033. Constants.INCR_WRAP = 0x8507;
  27034. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27035. Constants.DECR_WRAP = 0x8508;
  27036. /** Texture is not repeating outside of 0..1 UVs */
  27037. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27038. /** Texture is repeating outside of 0..1 UVs */
  27039. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27040. /** Texture is repeating and mirrored */
  27041. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27042. /** ALPHA */
  27043. Constants.TEXTUREFORMAT_ALPHA = 0;
  27044. /** LUMINANCE */
  27045. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27046. /** LUMINANCE_ALPHA */
  27047. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27048. /** RGB */
  27049. Constants.TEXTUREFORMAT_RGB = 4;
  27050. /** RGBA */
  27051. Constants.TEXTUREFORMAT_RGBA = 5;
  27052. /** RED */
  27053. Constants.TEXTUREFORMAT_RED = 6;
  27054. /** RED (2nd reference) */
  27055. Constants.TEXTUREFORMAT_R = 6;
  27056. /** RG */
  27057. Constants.TEXTUREFORMAT_RG = 7;
  27058. /** RED_INTEGER */
  27059. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27060. /** RED_INTEGER (2nd reference) */
  27061. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27062. /** RG_INTEGER */
  27063. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27064. /** RGB_INTEGER */
  27065. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27066. /** RGBA_INTEGER */
  27067. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27068. /** UNSIGNED_BYTE */
  27069. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27070. /** UNSIGNED_BYTE (2nd reference) */
  27071. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27072. /** FLOAT */
  27073. Constants.TEXTURETYPE_FLOAT = 1;
  27074. /** HALF_FLOAT */
  27075. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27076. /** BYTE */
  27077. Constants.TEXTURETYPE_BYTE = 3;
  27078. /** SHORT */
  27079. Constants.TEXTURETYPE_SHORT = 4;
  27080. /** UNSIGNED_SHORT */
  27081. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27082. /** INT */
  27083. Constants.TEXTURETYPE_INT = 6;
  27084. /** UNSIGNED_INT */
  27085. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27086. /** UNSIGNED_SHORT_4_4_4_4 */
  27087. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27088. /** UNSIGNED_SHORT_5_5_5_1 */
  27089. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27090. /** UNSIGNED_SHORT_5_6_5 */
  27091. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27092. /** UNSIGNED_INT_2_10_10_10_REV */
  27093. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27094. /** UNSIGNED_INT_24_8 */
  27095. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27096. /** UNSIGNED_INT_10F_11F_11F_REV */
  27097. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27098. /** UNSIGNED_INT_5_9_9_9_REV */
  27099. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27100. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27101. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27102. /** nearest is mag = nearest and min = nearest and mip = linear */
  27103. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27104. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27105. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27106. /** Trilinear is mag = linear and min = linear and mip = linear */
  27107. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27108. /** nearest is mag = nearest and min = nearest and mip = linear */
  27109. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27110. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27111. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27112. /** Trilinear is mag = linear and min = linear and mip = linear */
  27113. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27114. /** mag = nearest and min = nearest and mip = nearest */
  27115. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27116. /** mag = nearest and min = linear and mip = nearest */
  27117. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27118. /** mag = nearest and min = linear and mip = linear */
  27119. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27120. /** mag = nearest and min = linear and mip = none */
  27121. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27122. /** mag = nearest and min = nearest and mip = none */
  27123. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27124. /** mag = linear and min = nearest and mip = nearest */
  27125. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27126. /** mag = linear and min = nearest and mip = linear */
  27127. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27128. /** mag = linear and min = linear and mip = none */
  27129. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27130. /** mag = linear and min = nearest and mip = none */
  27131. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27132. /** Explicit coordinates mode */
  27133. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27134. /** Spherical coordinates mode */
  27135. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27136. /** Planar coordinates mode */
  27137. Constants.TEXTURE_PLANAR_MODE = 2;
  27138. /** Cubic coordinates mode */
  27139. Constants.TEXTURE_CUBIC_MODE = 3;
  27140. /** Projection coordinates mode */
  27141. Constants.TEXTURE_PROJECTION_MODE = 4;
  27142. /** Skybox coordinates mode */
  27143. Constants.TEXTURE_SKYBOX_MODE = 5;
  27144. /** Inverse Cubic coordinates mode */
  27145. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27146. /** Equirectangular coordinates mode */
  27147. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27148. /** Equirectangular Fixed coordinates mode */
  27149. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27150. /** Equirectangular Fixed Mirrored coordinates mode */
  27151. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27152. // Texture rescaling mode
  27153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27154. Constants.SCALEMODE_FLOOR = 1;
  27155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27156. Constants.SCALEMODE_NEAREST = 2;
  27157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27158. Constants.SCALEMODE_CEILING = 3;
  27159. /**
  27160. * The dirty texture flag value
  27161. */
  27162. Constants.MATERIAL_TextureDirtyFlag = 1;
  27163. /**
  27164. * The dirty light flag value
  27165. */
  27166. Constants.MATERIAL_LightDirtyFlag = 2;
  27167. /**
  27168. * The dirty fresnel flag value
  27169. */
  27170. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27171. /**
  27172. * The dirty attribute flag value
  27173. */
  27174. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27175. /**
  27176. * The dirty misc flag value
  27177. */
  27178. Constants.MATERIAL_MiscDirtyFlag = 16;
  27179. /**
  27180. * The all dirty flag value
  27181. */
  27182. Constants.MATERIAL_AllDirtyFlag = 31;
  27183. /**
  27184. * Returns the triangle fill mode
  27185. */
  27186. Constants.MATERIAL_TriangleFillMode = 0;
  27187. /**
  27188. * Returns the wireframe mode
  27189. */
  27190. Constants.MATERIAL_WireFrameFillMode = 1;
  27191. /**
  27192. * Returns the point fill mode
  27193. */
  27194. Constants.MATERIAL_PointFillMode = 2;
  27195. /**
  27196. * Returns the point list draw mode
  27197. */
  27198. Constants.MATERIAL_PointListDrawMode = 3;
  27199. /**
  27200. * Returns the line list draw mode
  27201. */
  27202. Constants.MATERIAL_LineListDrawMode = 4;
  27203. /**
  27204. * Returns the line loop draw mode
  27205. */
  27206. Constants.MATERIAL_LineLoopDrawMode = 5;
  27207. /**
  27208. * Returns the line strip draw mode
  27209. */
  27210. Constants.MATERIAL_LineStripDrawMode = 6;
  27211. /**
  27212. * Returns the triangle strip draw mode
  27213. */
  27214. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27215. /**
  27216. * Returns the triangle fan draw mode
  27217. */
  27218. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27219. /**
  27220. * Stores the clock-wise side orientation
  27221. */
  27222. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27223. /**
  27224. * Stores the counter clock-wise side orientation
  27225. */
  27226. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27227. /**
  27228. * Nothing
  27229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27230. */
  27231. Constants.ACTION_NothingTrigger = 0;
  27232. /**
  27233. * On pick
  27234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27235. */
  27236. Constants.ACTION_OnPickTrigger = 1;
  27237. /**
  27238. * On left pick
  27239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27240. */
  27241. Constants.ACTION_OnLeftPickTrigger = 2;
  27242. /**
  27243. * On right pick
  27244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27245. */
  27246. Constants.ACTION_OnRightPickTrigger = 3;
  27247. /**
  27248. * On center pick
  27249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27250. */
  27251. Constants.ACTION_OnCenterPickTrigger = 4;
  27252. /**
  27253. * On pick down
  27254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27255. */
  27256. Constants.ACTION_OnPickDownTrigger = 5;
  27257. /**
  27258. * On double pick
  27259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27260. */
  27261. Constants.ACTION_OnDoublePickTrigger = 6;
  27262. /**
  27263. * On pick up
  27264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27265. */
  27266. Constants.ACTION_OnPickUpTrigger = 7;
  27267. /**
  27268. * On pick out.
  27269. * This trigger will only be raised if you also declared a OnPickDown
  27270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27271. */
  27272. Constants.ACTION_OnPickOutTrigger = 16;
  27273. /**
  27274. * On long press
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27276. */
  27277. Constants.ACTION_OnLongPressTrigger = 8;
  27278. /**
  27279. * On pointer over
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27281. */
  27282. Constants.ACTION_OnPointerOverTrigger = 9;
  27283. /**
  27284. * On pointer out
  27285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27286. */
  27287. Constants.ACTION_OnPointerOutTrigger = 10;
  27288. /**
  27289. * On every frame
  27290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27291. */
  27292. Constants.ACTION_OnEveryFrameTrigger = 11;
  27293. /**
  27294. * On intersection enter
  27295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27296. */
  27297. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27298. /**
  27299. * On intersection exit
  27300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27301. */
  27302. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27303. /**
  27304. * On key down
  27305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27306. */
  27307. Constants.ACTION_OnKeyDownTrigger = 14;
  27308. /**
  27309. * On key up
  27310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27311. */
  27312. Constants.ACTION_OnKeyUpTrigger = 15;
  27313. /**
  27314. * Billboard mode will only apply to Y axis
  27315. */
  27316. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27317. /**
  27318. * Billboard mode will apply to all axes
  27319. */
  27320. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27321. /**
  27322. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27323. */
  27324. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27325. /**
  27326. * Gets or sets base Assets URL
  27327. */
  27328. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27329. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27330. * Test order :
  27331. * Is the bounding sphere outside the frustum ?
  27332. * If not, are the bounding box vertices outside the frustum ?
  27333. * It not, then the cullable object is in the frustum.
  27334. */
  27335. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27336. /** Culling strategy : Bounding Sphere Only.
  27337. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27338. * It's also less accurate than the standard because some not visible objects can still be selected.
  27339. * Test : is the bounding sphere outside the frustum ?
  27340. * If not, then the cullable object is in the frustum.
  27341. */
  27342. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27343. /** Culling strategy : Optimistic Inclusion.
  27344. * This in an inclusion test first, then the standard exclusion test.
  27345. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27346. * 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.
  27347. * Anyway, it's as accurate as the standard strategy.
  27348. * Test :
  27349. * Is the cullable object bounding sphere center in the frustum ?
  27350. * If not, apply the default culling strategy.
  27351. */
  27352. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27353. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27354. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27355. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27356. * 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.
  27357. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27358. * Test :
  27359. * Is the cullable object bounding sphere center in the frustum ?
  27360. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27361. */
  27362. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27363. /**
  27364. * No logging while loading
  27365. */
  27366. Constants.SCENELOADER_NO_LOGGING = 0;
  27367. /**
  27368. * Minimal logging while loading
  27369. */
  27370. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27371. /**
  27372. * Summary logging while loading
  27373. */
  27374. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27375. /**
  27376. * Detailled logging while loading
  27377. */
  27378. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27379. return Constants;
  27380. }());
  27381. /***/ }),
  27382. /***/ "./Engines/engine.ts":
  27383. /*!***************************!*\
  27384. !*** ./Engines/engine.ts ***!
  27385. \***************************/
  27386. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27388. "use strict";
  27389. __webpack_require__.r(__webpack_exports__);
  27390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27395. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27396. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27397. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27398. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27399. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27400. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27401. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27402. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27403. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27404. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27405. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27406. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27407. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27408. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27409. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27410. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27411. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27412. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27413. /**
  27414. * Keeps track of all the buffer info used in engine.
  27415. */
  27416. var BufferPointer = /** @class */ (function () {
  27417. function BufferPointer() {
  27418. }
  27419. return BufferPointer;
  27420. }());
  27421. /**
  27422. * Interface for attribute information associated with buffer instanciation
  27423. */
  27424. var InstancingAttributeInfo = /** @class */ (function () {
  27425. function InstancingAttributeInfo() {
  27426. }
  27427. return InstancingAttributeInfo;
  27428. }());
  27429. /**
  27430. * Define options used to create a depth texture
  27431. */
  27432. var DepthTextureCreationOptions = /** @class */ (function () {
  27433. function DepthTextureCreationOptions() {
  27434. }
  27435. return DepthTextureCreationOptions;
  27436. }());
  27437. /**
  27438. * Class used to describe the capabilities of the engine relatively to the current browser
  27439. */
  27440. var EngineCapabilities = /** @class */ (function () {
  27441. function EngineCapabilities() {
  27442. }
  27443. return EngineCapabilities;
  27444. }());
  27445. /**
  27446. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27447. */
  27448. var Engine = /** @class */ (function () {
  27449. /**
  27450. * Creates a new engine
  27451. * @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
  27452. * @param antialias defines enable antialiasing (default: false)
  27453. * @param options defines further options to be sent to the getContext() function
  27454. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27455. */
  27456. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27457. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27458. var _this = this;
  27459. // Public members
  27460. /**
  27461. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27462. */
  27463. this.forcePOTTextures = false;
  27464. /**
  27465. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27466. */
  27467. this.isFullscreen = false;
  27468. /**
  27469. * Gets a boolean indicating if the pointer is currently locked
  27470. */
  27471. this.isPointerLock = false;
  27472. /**
  27473. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27474. */
  27475. this.cullBackFaces = true;
  27476. /**
  27477. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27478. */
  27479. this.renderEvenInBackground = true;
  27480. /**
  27481. * Gets or sets a boolean indicating that cache can be kept between frames
  27482. */
  27483. this.preventCacheWipeBetweenFrames = false;
  27484. /**
  27485. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27486. **/
  27487. this.enableOfflineSupport = false;
  27488. /**
  27489. * 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)
  27490. **/
  27491. this.disableManifestCheck = false;
  27492. /**
  27493. * Gets the list of created scenes
  27494. */
  27495. this.scenes = new Array();
  27496. /**
  27497. * Event raised when a new scene is created
  27498. */
  27499. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27500. /**
  27501. * Gets the list of created postprocesses
  27502. */
  27503. this.postProcesses = new Array();
  27504. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27505. this.validateShaderPrograms = false;
  27506. // Observables
  27507. /**
  27508. * Observable event triggered each time the rendering canvas is resized
  27509. */
  27510. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27511. /**
  27512. * Observable event triggered each time the canvas loses focus
  27513. */
  27514. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27515. /**
  27516. * Observable event triggered each time the canvas gains focus
  27517. */
  27518. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27519. /**
  27520. * Observable event triggered each time the canvas receives pointerout event
  27521. */
  27522. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27523. /**
  27524. * Observable event triggered before each texture is initialized
  27525. */
  27526. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27527. //WebVR
  27528. this._vrDisplay = undefined;
  27529. this._vrSupported = false;
  27530. this._vrExclusivePointerMode = false;
  27531. // Uniform buffers list
  27532. /**
  27533. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27534. */
  27535. this.disableUniformBuffers = false;
  27536. /** @hidden */
  27537. this._uniformBuffers = new Array();
  27538. // Observables
  27539. /**
  27540. * Observable raised when the engine begins a new frame
  27541. */
  27542. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27543. /**
  27544. * If set, will be used to request the next animation frame for the render loop
  27545. */
  27546. this.customAnimationFrameRequester = null;
  27547. /**
  27548. * Observable raised when the engine ends the current frame
  27549. */
  27550. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27551. /**
  27552. * Observable raised when the engine is about to compile a shader
  27553. */
  27554. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27555. /**
  27556. * Observable raised when the engine has jsut compiled a shader
  27557. */
  27558. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27559. this._windowIsBackground = false;
  27560. this._webGLVersion = 1.0;
  27561. /** @hidden */
  27562. this._badOS = false;
  27563. /** @hidden */
  27564. this._badDesktopOS = false;
  27565. /**
  27566. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27567. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27568. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27569. */
  27570. this.disableTextureBindingOptimization = false;
  27571. /**
  27572. * Observable signaled when VR display mode changes
  27573. */
  27574. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27575. /**
  27576. * Observable signaled when VR request present is complete
  27577. */
  27578. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27579. /**
  27580. * Observable signaled when VR request present starts
  27581. */
  27582. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27583. this._colorWrite = true;
  27584. /** @hidden */
  27585. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27586. /** @hidden */
  27587. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27588. this._renderingQueueLaunched = false;
  27589. this._activeRenderLoops = new Array();
  27590. // Deterministic lockstepMaxSteps
  27591. this._deterministicLockstep = false;
  27592. this._lockstepMaxSteps = 4;
  27593. // Lost context
  27594. /**
  27595. * Observable signaled when a context lost event is raised
  27596. */
  27597. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27598. /**
  27599. * Observable signaled when a context restored event is raised
  27600. */
  27601. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27602. this._contextWasLost = false;
  27603. this._doNotHandleContextLost = false;
  27604. // FPS
  27605. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27606. this._fps = 60;
  27607. this._deltaTime = 0;
  27608. /**
  27609. * Turn this value on if you want to pause FPS computation when in background
  27610. */
  27611. this.disablePerformanceMonitorInBackground = false;
  27612. // States
  27613. /** @hidden */
  27614. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27615. /** @hidden */
  27616. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27617. /** @hidden */
  27618. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27619. /** @hidden */
  27620. this._alphaMode = Engine.ALPHA_DISABLE;
  27621. // Cache
  27622. this._internalTexturesCache = new Array();
  27623. /** @hidden */
  27624. this._activeChannel = 0;
  27625. this._currentTextureChannel = -1;
  27626. /** @hidden */
  27627. this._boundTexturesCache = {};
  27628. this._compiledEffects = {};
  27629. this._vertexAttribArraysEnabled = [];
  27630. this._uintIndicesCurrentlySet = false;
  27631. this._currentBoundBuffer = new Array();
  27632. /** @hidden */
  27633. this._currentFramebuffer = null;
  27634. this._currentBufferPointers = new Array();
  27635. this._currentInstanceLocations = new Array();
  27636. this._currentInstanceBuffers = new Array();
  27637. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27638. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27639. this._vaoRecordInProgress = false;
  27640. this._mustWipeVertexAttributes = false;
  27641. this._nextFreeTextureSlots = new Array();
  27642. this._maxSimultaneousTextures = 0;
  27643. this._activeRequests = new Array();
  27644. // Hardware supported Compressed Textures
  27645. this._texturesSupported = new Array();
  27646. /**
  27647. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27648. */
  27649. this.premultipliedAlpha = true;
  27650. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27651. this._onVRFullScreenTriggered = function () {
  27652. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27653. //get the old size before we change
  27654. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27655. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27656. //get the width and height, change the render size
  27657. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27658. _this.setHardwareScalingLevel(1);
  27659. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27660. }
  27661. else {
  27662. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27663. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27664. }
  27665. };
  27666. this._unpackFlipYCached = null;
  27667. /**
  27668. * In case you are sharing the context with other applications, it might
  27669. * be interested to not cache the unpack flip y state to ensure a consistent
  27670. * value would be set.
  27671. */
  27672. this.enableUnpackFlipYCached = true;
  27673. this._boundUniforms = {};
  27674. // Register promises
  27675. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27676. var canvas = null;
  27677. Engine.Instances.push(this);
  27678. if (!canvasOrContext) {
  27679. return;
  27680. }
  27681. options = options || {};
  27682. if (canvasOrContext.getContext) {
  27683. canvas = canvasOrContext;
  27684. this._renderingCanvas = canvas;
  27685. if (antialias != null) {
  27686. options.antialias = antialias;
  27687. }
  27688. if (options.deterministicLockstep === undefined) {
  27689. options.deterministicLockstep = false;
  27690. }
  27691. if (options.lockstepMaxSteps === undefined) {
  27692. options.lockstepMaxSteps = 4;
  27693. }
  27694. if (options.preserveDrawingBuffer === undefined) {
  27695. options.preserveDrawingBuffer = false;
  27696. }
  27697. if (options.audioEngine === undefined) {
  27698. options.audioEngine = true;
  27699. }
  27700. if (options.stencil === undefined) {
  27701. options.stencil = true;
  27702. }
  27703. if (options.premultipliedAlpha === false) {
  27704. this.premultipliedAlpha = false;
  27705. }
  27706. this._deterministicLockstep = options.deterministicLockstep;
  27707. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27708. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27709. // Exceptions
  27710. if (navigator && navigator.userAgent) {
  27711. var ua = navigator.userAgent;
  27712. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27713. var exception = _a[_i];
  27714. var key = exception.key;
  27715. var targets = exception.targets;
  27716. if (ua.indexOf(key) > -1) {
  27717. if (exception.capture && exception.captureConstraint) {
  27718. var capture = exception.capture;
  27719. var constraint = exception.captureConstraint;
  27720. var regex = new RegExp(capture);
  27721. var matches = regex.exec(ua);
  27722. if (matches && matches.length > 0) {
  27723. var capturedValue = parseInt(matches[matches.length - 1]);
  27724. if (capturedValue >= constraint) {
  27725. continue;
  27726. }
  27727. }
  27728. }
  27729. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27730. var target = targets_1[_b];
  27731. switch (target) {
  27732. case "uniformBuffer":
  27733. this.disableUniformBuffers = true;
  27734. break;
  27735. case "textureBindingOptimization":
  27736. this.disableTextureBindingOptimization = true;
  27737. break;
  27738. }
  27739. }
  27740. }
  27741. }
  27742. }
  27743. // GL
  27744. if (!options.disableWebGL2Support) {
  27745. try {
  27746. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27747. if (this._gl) {
  27748. this._webGLVersion = 2.0;
  27749. // Prevent weird browsers to lie :-)
  27750. if (!this._gl.deleteQuery) {
  27751. this._webGLVersion = 1.0;
  27752. }
  27753. }
  27754. }
  27755. catch (e) {
  27756. // Do nothing
  27757. }
  27758. }
  27759. if (!this._gl) {
  27760. if (!canvas) {
  27761. throw new Error("The provided canvas is null or undefined.");
  27762. }
  27763. try {
  27764. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27765. }
  27766. catch (e) {
  27767. throw new Error("WebGL not supported");
  27768. }
  27769. }
  27770. if (!this._gl) {
  27771. throw new Error("WebGL not supported");
  27772. }
  27773. this._onCanvasFocus = function () {
  27774. _this.onCanvasFocusObservable.notifyObservers(_this);
  27775. };
  27776. this._onCanvasBlur = function () {
  27777. _this.onCanvasBlurObservable.notifyObservers(_this);
  27778. };
  27779. canvas.addEventListener("focus", this._onCanvasFocus);
  27780. canvas.addEventListener("blur", this._onCanvasBlur);
  27781. this._onBlur = function () {
  27782. if (_this.disablePerformanceMonitorInBackground) {
  27783. _this._performanceMonitor.disable();
  27784. }
  27785. _this._windowIsBackground = true;
  27786. };
  27787. this._onFocus = function () {
  27788. if (_this.disablePerformanceMonitorInBackground) {
  27789. _this._performanceMonitor.enable();
  27790. }
  27791. _this._windowIsBackground = false;
  27792. };
  27793. this._onCanvasPointerOut = function (ev) {
  27794. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27795. };
  27796. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27797. window.addEventListener("blur", this._onBlur);
  27798. window.addEventListener("focus", this._onFocus);
  27799. }
  27800. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27801. // Context lost
  27802. if (!this._doNotHandleContextLost) {
  27803. this._onContextLost = function (evt) {
  27804. evt.preventDefault();
  27805. _this._contextWasLost = true;
  27806. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27807. _this.onContextLostObservable.notifyObservers(_this);
  27808. };
  27809. this._onContextRestored = function () {
  27810. // Adding a timeout to avoid race condition at browser level
  27811. setTimeout(function () {
  27812. // Rebuild gl context
  27813. _this._initGLContext();
  27814. // Rebuild effects
  27815. _this._rebuildEffects();
  27816. // Rebuild textures
  27817. _this._rebuildInternalTextures();
  27818. // Rebuild buffers
  27819. _this._rebuildBuffers();
  27820. // Cache
  27821. _this.wipeCaches(true);
  27822. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27823. _this.onContextRestoredObservable.notifyObservers(_this);
  27824. _this._contextWasLost = false;
  27825. }, 0);
  27826. };
  27827. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27828. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27829. }
  27830. if (!options.doNotHandleTouchAction) {
  27831. this._disableTouchAction();
  27832. }
  27833. }
  27834. else {
  27835. this._gl = canvasOrContext;
  27836. this._renderingCanvas = this._gl.canvas;
  27837. if (this._gl.renderbufferStorageMultisample) {
  27838. this._webGLVersion = 2.0;
  27839. }
  27840. var attributes = this._gl.getContextAttributes();
  27841. if (attributes) {
  27842. options.stencil = attributes.stencil;
  27843. }
  27844. }
  27845. // Viewport
  27846. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27847. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27848. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27849. this.resize();
  27850. this._isStencilEnable = options.stencil ? true : false;
  27851. this._initGLContext();
  27852. if (canvas) {
  27853. // Fullscreen
  27854. this._onFullscreenChange = function () {
  27855. if (document.fullscreen !== undefined) {
  27856. _this.isFullscreen = document.fullscreen;
  27857. }
  27858. else if (document.mozFullScreen !== undefined) {
  27859. _this.isFullscreen = document.mozFullScreen;
  27860. }
  27861. else if (document.webkitIsFullScreen !== undefined) {
  27862. _this.isFullscreen = document.webkitIsFullScreen;
  27863. }
  27864. else if (document.msIsFullScreen !== undefined) {
  27865. _this.isFullscreen = document.msIsFullScreen;
  27866. }
  27867. // Pointer lock
  27868. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27869. canvas.requestPointerLock = canvas.requestPointerLock ||
  27870. canvas.msRequestPointerLock ||
  27871. canvas.mozRequestPointerLock ||
  27872. canvas.webkitRequestPointerLock;
  27873. if (canvas.requestPointerLock) {
  27874. canvas.requestPointerLock();
  27875. }
  27876. }
  27877. };
  27878. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27879. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27880. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27881. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27882. // Pointer lock
  27883. this._onPointerLockChange = function () {
  27884. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27885. document.webkitPointerLockElement === canvas ||
  27886. document.msPointerLockElement === canvas ||
  27887. document.pointerLockElement === canvas);
  27888. };
  27889. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27890. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27891. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27892. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27893. this._onVRDisplayPointerRestricted = function () {
  27894. if (canvas) {
  27895. canvas.requestPointerLock();
  27896. }
  27897. };
  27898. this._onVRDisplayPointerUnrestricted = function () {
  27899. document.exitPointerLock();
  27900. };
  27901. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27902. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27903. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27904. }
  27905. }
  27906. // Create Audio Engine if needed.
  27907. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27908. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27909. }
  27910. // Prepare buffer pointers
  27911. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27912. this._currentBufferPointers[i] = new BufferPointer();
  27913. }
  27914. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27915. // Load WebVR Devices
  27916. if (options.autoEnableWebVR) {
  27917. this.initWebVR();
  27918. }
  27919. // Detect if we are running on a faulty buggy OS.
  27920. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27921. // Detect if we are running on a faulty buggy desktop OS.
  27922. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27923. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27924. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27925. }
  27926. Object.defineProperty(Engine, "Instances", {
  27927. /** Gets the list of created engines */
  27928. get: function () {
  27929. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27930. },
  27931. enumerable: true,
  27932. configurable: true
  27933. });
  27934. Object.defineProperty(Engine, "LastCreatedEngine", {
  27935. /**
  27936. * Gets the latest created engine
  27937. */
  27938. get: function () {
  27939. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27940. },
  27941. enumerable: true,
  27942. configurable: true
  27943. });
  27944. Object.defineProperty(Engine, "LastCreatedScene", {
  27945. /**
  27946. * Gets the latest created scene
  27947. */
  27948. get: function () {
  27949. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27950. },
  27951. enumerable: true,
  27952. configurable: true
  27953. });
  27954. /**
  27955. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27956. * @param flag defines which part of the materials must be marked as dirty
  27957. * @param predicate defines a predicate used to filter which materials should be affected
  27958. */
  27959. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27960. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27961. var engine = Engine.Instances[engineIndex];
  27962. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27963. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27964. }
  27965. }
  27966. };
  27967. Object.defineProperty(Engine, "Version", {
  27968. /**
  27969. * Returns the current version of the framework
  27970. */
  27971. get: function () {
  27972. return "4.0.0-alpha.21";
  27973. },
  27974. enumerable: true,
  27975. configurable: true
  27976. });
  27977. Object.defineProperty(Engine.prototype, "description", {
  27978. /**
  27979. * Returns a string describing the current engine
  27980. */
  27981. get: function () {
  27982. var description = "WebGL" + this.webGLVersion;
  27983. if (this._caps.parallelShaderCompile) {
  27984. description += " - Parallel shader compilation";
  27985. }
  27986. return description;
  27987. },
  27988. enumerable: true,
  27989. configurable: true
  27990. });
  27991. Object.defineProperty(Engine, "ShadersRepository", {
  27992. /**
  27993. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27994. */
  27995. get: function () {
  27996. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  27997. },
  27998. set: function (value) {
  27999. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28000. },
  28001. enumerable: true,
  28002. configurable: true
  28003. });
  28004. /**
  28005. * Method called to create the default loading screen.
  28006. * This can be overriden in your own app.
  28007. * @param canvas The rendering canvas element
  28008. * @returns The loading screen
  28009. */
  28010. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28011. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28012. };
  28013. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28014. /**
  28015. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28016. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28017. */
  28018. get: function () {
  28019. return this._vrExclusivePointerMode;
  28020. },
  28021. enumerable: true,
  28022. configurable: true
  28023. });
  28024. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28025. /**
  28026. * Gets a boolean indicating that the engine supports uniform buffers
  28027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28028. */
  28029. get: function () {
  28030. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28031. },
  28032. enumerable: true,
  28033. configurable: true
  28034. });
  28035. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28036. /**
  28037. * Gets a boolean indicating that only power of 2 textures are supported
  28038. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28039. */
  28040. get: function () {
  28041. return this._webGLVersion < 2 || this.forcePOTTextures;
  28042. },
  28043. enumerable: true,
  28044. configurable: true
  28045. });
  28046. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28047. /**
  28048. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28050. */
  28051. get: function () {
  28052. return this._doNotHandleContextLost;
  28053. },
  28054. set: function (value) {
  28055. this._doNotHandleContextLost = value;
  28056. },
  28057. enumerable: true,
  28058. configurable: true
  28059. });
  28060. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28061. /**
  28062. * Gets the performance monitor attached to this engine
  28063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28064. */
  28065. get: function () {
  28066. return this._performanceMonitor;
  28067. },
  28068. enumerable: true,
  28069. configurable: true
  28070. });
  28071. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28072. /**
  28073. * Gets the list of texture formats supported
  28074. */
  28075. get: function () {
  28076. return this._texturesSupported;
  28077. },
  28078. enumerable: true,
  28079. configurable: true
  28080. });
  28081. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28082. /**
  28083. * Gets the list of texture formats in use
  28084. */
  28085. get: function () {
  28086. return this._textureFormatInUse;
  28087. },
  28088. enumerable: true,
  28089. configurable: true
  28090. });
  28091. Object.defineProperty(Engine.prototype, "currentViewport", {
  28092. /**
  28093. * Gets the current viewport
  28094. */
  28095. get: function () {
  28096. return this._cachedViewport;
  28097. },
  28098. enumerable: true,
  28099. configurable: true
  28100. });
  28101. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28102. /**
  28103. * Gets the default empty texture
  28104. */
  28105. get: function () {
  28106. if (!this._emptyTexture) {
  28107. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28108. }
  28109. return this._emptyTexture;
  28110. },
  28111. enumerable: true,
  28112. configurable: true
  28113. });
  28114. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28115. /**
  28116. * Gets the default empty 3D texture
  28117. */
  28118. get: function () {
  28119. if (!this._emptyTexture3D) {
  28120. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28121. }
  28122. return this._emptyTexture3D;
  28123. },
  28124. enumerable: true,
  28125. configurable: true
  28126. });
  28127. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28128. /**
  28129. * Gets the default empty cube texture
  28130. */
  28131. get: function () {
  28132. if (!this._emptyCubeTexture) {
  28133. var faceData = new Uint8Array(4);
  28134. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28135. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28136. }
  28137. return this._emptyCubeTexture;
  28138. },
  28139. enumerable: true,
  28140. configurable: true
  28141. });
  28142. Engine.prototype._disableTouchAction = function () {
  28143. if (!this._renderingCanvas) {
  28144. return;
  28145. }
  28146. this._renderingCanvas.setAttribute("touch-action", "none");
  28147. this._renderingCanvas.style.touchAction = "none";
  28148. this._renderingCanvas.style.msTouchAction = "none";
  28149. };
  28150. Engine.prototype._rebuildInternalTextures = function () {
  28151. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28152. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28153. var internalTexture = currentState_1[_i];
  28154. internalTexture._rebuild();
  28155. }
  28156. };
  28157. Engine.prototype._rebuildEffects = function () {
  28158. for (var key in this._compiledEffects) {
  28159. var effect = this._compiledEffects[key];
  28160. effect._prepareEffect();
  28161. }
  28162. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28163. };
  28164. /**
  28165. * Gets a boolean indicating if all created effects are ready
  28166. * @returns true if all effects are ready
  28167. */
  28168. Engine.prototype.areAllEffectsReady = function () {
  28169. for (var key in this._compiledEffects) {
  28170. var effect = this._compiledEffects[key];
  28171. if (!effect.isReady()) {
  28172. return false;
  28173. }
  28174. }
  28175. return true;
  28176. };
  28177. Engine.prototype._rebuildBuffers = function () {
  28178. // Index / Vertex
  28179. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28180. var scene = _a[_i];
  28181. scene.resetCachedMaterial();
  28182. scene._rebuildGeometries();
  28183. scene._rebuildTextures();
  28184. }
  28185. // Uniforms
  28186. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28187. var uniformBuffer = _c[_b];
  28188. uniformBuffer._rebuild();
  28189. }
  28190. };
  28191. Engine.prototype._initGLContext = function () {
  28192. // Caps
  28193. this._caps = new EngineCapabilities();
  28194. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28195. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28196. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28197. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28198. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28199. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28200. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28201. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28202. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28203. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28204. // Infos
  28205. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28206. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28207. if (rendererInfo != null) {
  28208. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28209. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28210. }
  28211. if (!this._glVendor) {
  28212. this._glVendor = "Unknown vendor";
  28213. }
  28214. if (!this._glRenderer) {
  28215. this._glRenderer = "Unknown renderer";
  28216. }
  28217. // Constants
  28218. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28219. if (this._gl.RGBA16F !== 0x881A) {
  28220. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28221. }
  28222. if (this._gl.RGBA32F !== 0x8814) {
  28223. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28224. }
  28225. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28226. this._gl.DEPTH24_STENCIL8 = 35056;
  28227. }
  28228. // Extensions
  28229. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28230. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28231. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28232. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28233. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28234. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28235. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28236. 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');
  28237. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28238. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28239. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28240. this._caps.highPrecisionShaderSupported = false;
  28241. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28242. if (this._caps.timerQuery) {
  28243. if (this._webGLVersion === 1) {
  28244. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28245. }
  28246. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28247. }
  28248. // Checks if some of the format renders first to allow the use of webgl inspector.
  28249. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28250. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28251. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28252. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28253. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28254. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28255. if (this._webGLVersion > 1) {
  28256. this._gl.HALF_FLOAT_OES = 0x140B;
  28257. }
  28258. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28259. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28260. // Draw buffers
  28261. if (this._webGLVersion > 1) {
  28262. this._caps.drawBuffersExtension = true;
  28263. }
  28264. else {
  28265. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28266. if (drawBuffersExtension !== null) {
  28267. this._caps.drawBuffersExtension = true;
  28268. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28269. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28270. for (var i = 0; i < 16; i++) {
  28271. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28272. }
  28273. }
  28274. else {
  28275. this._caps.drawBuffersExtension = false;
  28276. }
  28277. }
  28278. // Shader compiler threads
  28279. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28280. if (this._caps.parallelShaderCompile) {
  28281. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28282. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28283. }
  28284. // Depth Texture
  28285. if (this._webGLVersion > 1) {
  28286. this._caps.depthTextureExtension = true;
  28287. }
  28288. else {
  28289. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28290. if (depthTextureExtension != null) {
  28291. this._caps.depthTextureExtension = true;
  28292. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28293. }
  28294. }
  28295. // Vertex array object
  28296. if (this._webGLVersion > 1) {
  28297. this._caps.vertexArrayObject = true;
  28298. }
  28299. else {
  28300. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28301. if (vertexArrayObjectExtension != null) {
  28302. this._caps.vertexArrayObject = true;
  28303. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28304. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28305. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28306. }
  28307. else {
  28308. this._caps.vertexArrayObject = false;
  28309. }
  28310. }
  28311. // Instances count
  28312. if (this._webGLVersion > 1) {
  28313. this._caps.instancedArrays = true;
  28314. }
  28315. else {
  28316. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28317. if (instanceExtension != null) {
  28318. this._caps.instancedArrays = true;
  28319. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28320. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28321. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28322. }
  28323. else {
  28324. this._caps.instancedArrays = false;
  28325. }
  28326. }
  28327. // Intelligently add supported compressed formats in order to check for.
  28328. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28329. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28330. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28331. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28332. if (this._caps.astc) {
  28333. this.texturesSupported.push('-astc.ktx');
  28334. }
  28335. if (this._caps.s3tc) {
  28336. this.texturesSupported.push('-dxt.ktx');
  28337. }
  28338. if (this._caps.pvrtc) {
  28339. this.texturesSupported.push('-pvrtc.ktx');
  28340. }
  28341. if (this._caps.etc2) {
  28342. this.texturesSupported.push('-etc2.ktx');
  28343. }
  28344. if (this._caps.etc1) {
  28345. this.texturesSupported.push('-etc1.ktx');
  28346. }
  28347. if (this._gl.getShaderPrecisionFormat) {
  28348. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28349. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28350. if (vertex_highp && fragment_highp) {
  28351. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28352. }
  28353. }
  28354. // Depth buffer
  28355. this.setDepthBuffer(true);
  28356. this.setDepthFunctionToLessOrEqual();
  28357. this.setDepthWrite(true);
  28358. // Texture maps
  28359. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28360. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28361. this._nextFreeTextureSlots.push(slot);
  28362. }
  28363. };
  28364. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28365. /**
  28366. * Gets version of the current webGL context
  28367. */
  28368. get: function () {
  28369. return this._webGLVersion;
  28370. },
  28371. enumerable: true,
  28372. configurable: true
  28373. });
  28374. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28375. /**
  28376. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28377. */
  28378. get: function () {
  28379. return this._isStencilEnable;
  28380. },
  28381. enumerable: true,
  28382. configurable: true
  28383. });
  28384. Engine.prototype._prepareWorkingCanvas = function () {
  28385. if (this._workingCanvas) {
  28386. return;
  28387. }
  28388. this._workingCanvas = document.createElement("canvas");
  28389. var context = this._workingCanvas.getContext("2d");
  28390. if (context) {
  28391. this._workingContext = context;
  28392. }
  28393. };
  28394. /**
  28395. * Reset the texture cache to empty state
  28396. */
  28397. Engine.prototype.resetTextureCache = function () {
  28398. for (var key in this._boundTexturesCache) {
  28399. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28400. continue;
  28401. }
  28402. var boundTexture = this._boundTexturesCache[key];
  28403. if (boundTexture) {
  28404. this._removeDesignatedSlot(boundTexture);
  28405. }
  28406. this._boundTexturesCache[key] = null;
  28407. }
  28408. if (!this.disableTextureBindingOptimization) {
  28409. this._nextFreeTextureSlots = [];
  28410. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28411. this._nextFreeTextureSlots.push(slot);
  28412. }
  28413. }
  28414. this._currentTextureChannel = -1;
  28415. };
  28416. /**
  28417. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28419. * @returns true if engine is in deterministic lock step mode
  28420. */
  28421. Engine.prototype.isDeterministicLockStep = function () {
  28422. return this._deterministicLockstep;
  28423. };
  28424. /**
  28425. * Gets the max steps when engine is running in deterministic lock step
  28426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28427. * @returns the max steps
  28428. */
  28429. Engine.prototype.getLockstepMaxSteps = function () {
  28430. return this._lockstepMaxSteps;
  28431. };
  28432. /**
  28433. * Gets an object containing information about the current webGL context
  28434. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28435. */
  28436. Engine.prototype.getGlInfo = function () {
  28437. return {
  28438. vendor: this._glVendor,
  28439. renderer: this._glRenderer,
  28440. version: this._glVersion
  28441. };
  28442. };
  28443. /**
  28444. * Gets current aspect ratio
  28445. * @param camera defines the camera to use to get the aspect ratio
  28446. * @param useScreen defines if screen size must be used (or the current render target if any)
  28447. * @returns a number defining the aspect ratio
  28448. */
  28449. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28450. if (useScreen === void 0) { useScreen = false; }
  28451. var viewport = camera.viewport;
  28452. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28453. };
  28454. /**
  28455. * Gets current screen aspect ratio
  28456. * @returns a number defining the aspect ratio
  28457. */
  28458. Engine.prototype.getScreenAspectRatio = function () {
  28459. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28460. };
  28461. /**
  28462. * Gets the current render width
  28463. * @param useScreen defines if screen size must be used (or the current render target if any)
  28464. * @returns a number defining the current render width
  28465. */
  28466. Engine.prototype.getRenderWidth = function (useScreen) {
  28467. if (useScreen === void 0) { useScreen = false; }
  28468. if (!useScreen && this._currentRenderTarget) {
  28469. return this._currentRenderTarget.width;
  28470. }
  28471. return this._gl.drawingBufferWidth;
  28472. };
  28473. /**
  28474. * Gets the current render height
  28475. * @param useScreen defines if screen size must be used (or the current render target if any)
  28476. * @returns a number defining the current render height
  28477. */
  28478. Engine.prototype.getRenderHeight = function (useScreen) {
  28479. if (useScreen === void 0) { useScreen = false; }
  28480. if (!useScreen && this._currentRenderTarget) {
  28481. return this._currentRenderTarget.height;
  28482. }
  28483. return this._gl.drawingBufferHeight;
  28484. };
  28485. /**
  28486. * Gets the HTML canvas attached with the current webGL context
  28487. * @returns a HTML canvas
  28488. */
  28489. Engine.prototype.getRenderingCanvas = function () {
  28490. return this._renderingCanvas;
  28491. };
  28492. /**
  28493. * Gets the client rect of the HTML canvas attached with the current webGL context
  28494. * @returns a client rectanglee
  28495. */
  28496. Engine.prototype.getRenderingCanvasClientRect = function () {
  28497. if (!this._renderingCanvas) {
  28498. return null;
  28499. }
  28500. return this._renderingCanvas.getBoundingClientRect();
  28501. };
  28502. /**
  28503. * Defines the hardware scaling level.
  28504. * By default the hardware scaling level is computed from the window device ratio.
  28505. * 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.
  28506. * @param level defines the level to use
  28507. */
  28508. Engine.prototype.setHardwareScalingLevel = function (level) {
  28509. this._hardwareScalingLevel = level;
  28510. this.resize();
  28511. };
  28512. /**
  28513. * Gets the current hardware scaling level.
  28514. * By default the hardware scaling level is computed from the window device ratio.
  28515. * 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.
  28516. * @returns a number indicating the current hardware scaling level
  28517. */
  28518. Engine.prototype.getHardwareScalingLevel = function () {
  28519. return this._hardwareScalingLevel;
  28520. };
  28521. /**
  28522. * Gets the list of loaded textures
  28523. * @returns an array containing all loaded textures
  28524. */
  28525. Engine.prototype.getLoadedTexturesCache = function () {
  28526. return this._internalTexturesCache;
  28527. };
  28528. /**
  28529. * Gets the object containing all engine capabilities
  28530. * @returns the EngineCapabilities object
  28531. */
  28532. Engine.prototype.getCaps = function () {
  28533. return this._caps;
  28534. };
  28535. /**
  28536. * Gets the current depth function
  28537. * @returns a number defining the depth function
  28538. */
  28539. Engine.prototype.getDepthFunction = function () {
  28540. return this._depthCullingState.depthFunc;
  28541. };
  28542. /**
  28543. * Sets the current depth function
  28544. * @param depthFunc defines the function to use
  28545. */
  28546. Engine.prototype.setDepthFunction = function (depthFunc) {
  28547. this._depthCullingState.depthFunc = depthFunc;
  28548. };
  28549. /**
  28550. * Sets the current depth function to GREATER
  28551. */
  28552. Engine.prototype.setDepthFunctionToGreater = function () {
  28553. this._depthCullingState.depthFunc = this._gl.GREATER;
  28554. };
  28555. /**
  28556. * Sets the current depth function to GEQUAL
  28557. */
  28558. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28559. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28560. };
  28561. /**
  28562. * Sets the current depth function to LESS
  28563. */
  28564. Engine.prototype.setDepthFunctionToLess = function () {
  28565. this._depthCullingState.depthFunc = this._gl.LESS;
  28566. };
  28567. /**
  28568. * Sets the current depth function to LEQUAL
  28569. */
  28570. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28571. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28572. };
  28573. /**
  28574. * Gets a boolean indicating if stencil buffer is enabled
  28575. * @returns the current stencil buffer state
  28576. */
  28577. Engine.prototype.getStencilBuffer = function () {
  28578. return this._stencilState.stencilTest;
  28579. };
  28580. /**
  28581. * Enable or disable the stencil buffer
  28582. * @param enable defines if the stencil buffer must be enabled or disabled
  28583. */
  28584. Engine.prototype.setStencilBuffer = function (enable) {
  28585. this._stencilState.stencilTest = enable;
  28586. };
  28587. /**
  28588. * Gets the current stencil mask
  28589. * @returns a number defining the new stencil mask to use
  28590. */
  28591. Engine.prototype.getStencilMask = function () {
  28592. return this._stencilState.stencilMask;
  28593. };
  28594. /**
  28595. * Sets the current stencil mask
  28596. * @param mask defines the new stencil mask to use
  28597. */
  28598. Engine.prototype.setStencilMask = function (mask) {
  28599. this._stencilState.stencilMask = mask;
  28600. };
  28601. /**
  28602. * Gets the current stencil function
  28603. * @returns a number defining the stencil function to use
  28604. */
  28605. Engine.prototype.getStencilFunction = function () {
  28606. return this._stencilState.stencilFunc;
  28607. };
  28608. /**
  28609. * Gets the current stencil reference value
  28610. * @returns a number defining the stencil reference value to use
  28611. */
  28612. Engine.prototype.getStencilFunctionReference = function () {
  28613. return this._stencilState.stencilFuncRef;
  28614. };
  28615. /**
  28616. * Gets the current stencil mask
  28617. * @returns a number defining the stencil mask to use
  28618. */
  28619. Engine.prototype.getStencilFunctionMask = function () {
  28620. return this._stencilState.stencilFuncMask;
  28621. };
  28622. /**
  28623. * Sets the current stencil function
  28624. * @param stencilFunc defines the new stencil function to use
  28625. */
  28626. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28627. this._stencilState.stencilFunc = stencilFunc;
  28628. };
  28629. /**
  28630. * Sets the current stencil reference
  28631. * @param reference defines the new stencil reference to use
  28632. */
  28633. Engine.prototype.setStencilFunctionReference = function (reference) {
  28634. this._stencilState.stencilFuncRef = reference;
  28635. };
  28636. /**
  28637. * Sets the current stencil mask
  28638. * @param mask defines the new stencil mask to use
  28639. */
  28640. Engine.prototype.setStencilFunctionMask = function (mask) {
  28641. this._stencilState.stencilFuncMask = mask;
  28642. };
  28643. /**
  28644. * Gets the current stencil operation when stencil fails
  28645. * @returns a number defining stencil operation to use when stencil fails
  28646. */
  28647. Engine.prototype.getStencilOperationFail = function () {
  28648. return this._stencilState.stencilOpStencilFail;
  28649. };
  28650. /**
  28651. * Gets the current stencil operation when depth fails
  28652. * @returns a number defining stencil operation to use when depth fails
  28653. */
  28654. Engine.prototype.getStencilOperationDepthFail = function () {
  28655. return this._stencilState.stencilOpDepthFail;
  28656. };
  28657. /**
  28658. * Gets the current stencil operation when stencil passes
  28659. * @returns a number defining stencil operation to use when stencil passes
  28660. */
  28661. Engine.prototype.getStencilOperationPass = function () {
  28662. return this._stencilState.stencilOpStencilDepthPass;
  28663. };
  28664. /**
  28665. * Sets the stencil operation to use when stencil fails
  28666. * @param operation defines the stencil operation to use when stencil fails
  28667. */
  28668. Engine.prototype.setStencilOperationFail = function (operation) {
  28669. this._stencilState.stencilOpStencilFail = operation;
  28670. };
  28671. /**
  28672. * Sets the stencil operation to use when depth fails
  28673. * @param operation defines the stencil operation to use when depth fails
  28674. */
  28675. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28676. this._stencilState.stencilOpDepthFail = operation;
  28677. };
  28678. /**
  28679. * Sets the stencil operation to use when stencil passes
  28680. * @param operation defines the stencil operation to use when stencil passes
  28681. */
  28682. Engine.prototype.setStencilOperationPass = function (operation) {
  28683. this._stencilState.stencilOpStencilDepthPass = operation;
  28684. };
  28685. /**
  28686. * Sets a boolean indicating if the dithering state is enabled or disabled
  28687. * @param value defines the dithering state
  28688. */
  28689. Engine.prototype.setDitheringState = function (value) {
  28690. if (value) {
  28691. this._gl.enable(this._gl.DITHER);
  28692. }
  28693. else {
  28694. this._gl.disable(this._gl.DITHER);
  28695. }
  28696. };
  28697. /**
  28698. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28699. * @param value defines the rasterizer state
  28700. */
  28701. Engine.prototype.setRasterizerState = function (value) {
  28702. if (value) {
  28703. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28704. }
  28705. else {
  28706. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28707. }
  28708. };
  28709. /**
  28710. * stop executing a render loop function and remove it from the execution array
  28711. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28712. */
  28713. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28714. if (!renderFunction) {
  28715. this._activeRenderLoops = [];
  28716. return;
  28717. }
  28718. var index = this._activeRenderLoops.indexOf(renderFunction);
  28719. if (index >= 0) {
  28720. this._activeRenderLoops.splice(index, 1);
  28721. }
  28722. };
  28723. /** @hidden */
  28724. Engine.prototype._renderLoop = function () {
  28725. if (!this._contextWasLost) {
  28726. var shouldRender = true;
  28727. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28728. shouldRender = false;
  28729. }
  28730. if (shouldRender) {
  28731. // Start new frame
  28732. this.beginFrame();
  28733. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28734. var renderFunction = this._activeRenderLoops[index];
  28735. renderFunction();
  28736. }
  28737. // Present
  28738. this.endFrame();
  28739. }
  28740. }
  28741. if (this._activeRenderLoops.length > 0) {
  28742. // Register new frame
  28743. if (this.customAnimationFrameRequester) {
  28744. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28745. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28746. }
  28747. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28748. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28749. }
  28750. else {
  28751. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28752. }
  28753. }
  28754. else {
  28755. this._renderingQueueLaunched = false;
  28756. }
  28757. };
  28758. /**
  28759. * Register and execute a render loop. The engine can have more than one render function
  28760. * @param renderFunction defines the function to continuously execute
  28761. */
  28762. Engine.prototype.runRenderLoop = function (renderFunction) {
  28763. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28764. return;
  28765. }
  28766. this._activeRenderLoops.push(renderFunction);
  28767. if (!this._renderingQueueLaunched) {
  28768. this._renderingQueueLaunched = true;
  28769. this._bindedRenderFunction = this._renderLoop.bind(this);
  28770. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28771. }
  28772. };
  28773. /**
  28774. * Toggle full screen mode
  28775. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28776. */
  28777. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28778. if (this.isFullscreen) {
  28779. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28780. }
  28781. else {
  28782. this._pointerLockRequested = requestPointerLock;
  28783. if (this._renderingCanvas) {
  28784. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28785. }
  28786. }
  28787. };
  28788. /**
  28789. * Clear the current render buffer or the current render target (if any is set up)
  28790. * @param color defines the color to use
  28791. * @param backBuffer defines if the back buffer must be cleared
  28792. * @param depth defines if the depth buffer must be cleared
  28793. * @param stencil defines if the stencil buffer must be cleared
  28794. */
  28795. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28796. if (stencil === void 0) { stencil = false; }
  28797. this.applyStates();
  28798. var mode = 0;
  28799. if (backBuffer && color) {
  28800. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28801. mode |= this._gl.COLOR_BUFFER_BIT;
  28802. }
  28803. if (depth) {
  28804. this._gl.clearDepth(1.0);
  28805. mode |= this._gl.DEPTH_BUFFER_BIT;
  28806. }
  28807. if (stencil) {
  28808. this._gl.clearStencil(0);
  28809. mode |= this._gl.STENCIL_BUFFER_BIT;
  28810. }
  28811. this._gl.clear(mode);
  28812. };
  28813. /**
  28814. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28815. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28816. * @param y defines the y-coordinate of the corner of the clear rectangle
  28817. * @param width defines the width of the clear rectangle
  28818. * @param height defines the height of the clear rectangle
  28819. * @param clearColor defines the clear color
  28820. */
  28821. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28822. this.enableScissor(x, y, width, height);
  28823. this.clear(clearColor, true, true, true);
  28824. this.disableScissor();
  28825. };
  28826. /**
  28827. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28828. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28829. * @param y defines the y-coordinate of the corner of the clear rectangle
  28830. * @param width defines the width of the clear rectangle
  28831. * @param height defines the height of the clear rectangle
  28832. */
  28833. Engine.prototype.enableScissor = function (x, y, width, height) {
  28834. var gl = this._gl;
  28835. // Change state
  28836. gl.enable(gl.SCISSOR_TEST);
  28837. gl.scissor(x, y, width, height);
  28838. };
  28839. /**
  28840. * Disable previously set scissor test rectangle
  28841. */
  28842. Engine.prototype.disableScissor = function () {
  28843. var gl = this._gl;
  28844. gl.disable(gl.SCISSOR_TEST);
  28845. };
  28846. /** @hidden */
  28847. Engine.prototype._viewport = function (x, y, width, height) {
  28848. if (x !== this._viewportCached.x ||
  28849. y !== this._viewportCached.y ||
  28850. width !== this._viewportCached.z ||
  28851. height !== this._viewportCached.w) {
  28852. this._viewportCached.x = x;
  28853. this._viewportCached.y = y;
  28854. this._viewportCached.z = width;
  28855. this._viewportCached.w = height;
  28856. this._gl.viewport(x, y, width, height);
  28857. }
  28858. };
  28859. /**
  28860. * Set the WebGL's viewport
  28861. * @param viewport defines the viewport element to be used
  28862. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28863. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28864. */
  28865. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28866. var width = requiredWidth || this.getRenderWidth();
  28867. var height = requiredHeight || this.getRenderHeight();
  28868. var x = viewport.x || 0;
  28869. var y = viewport.y || 0;
  28870. this._cachedViewport = viewport;
  28871. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28872. };
  28873. /**
  28874. * Directly set the WebGL Viewport
  28875. * @param x defines the x coordinate of the viewport (in screen space)
  28876. * @param y defines the y coordinate of the viewport (in screen space)
  28877. * @param width defines the width of the viewport (in screen space)
  28878. * @param height defines the height of the viewport (in screen space)
  28879. * @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
  28880. */
  28881. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28882. var currentViewport = this._cachedViewport;
  28883. this._cachedViewport = null;
  28884. this._viewport(x, y, width, height);
  28885. return currentViewport;
  28886. };
  28887. /**
  28888. * Begin a new frame
  28889. */
  28890. Engine.prototype.beginFrame = function () {
  28891. this.onBeginFrameObservable.notifyObservers(this);
  28892. this._measureFps();
  28893. };
  28894. /**
  28895. * Enf the current frame
  28896. */
  28897. Engine.prototype.endFrame = function () {
  28898. // Force a flush in case we are using a bad OS.
  28899. if (this._badOS) {
  28900. this.flushFramebuffer();
  28901. }
  28902. // Submit frame to the vr device, if enabled
  28903. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28904. // TODO: We should only submit the frame if we read frameData successfully.
  28905. this._vrDisplay.submitFrame();
  28906. }
  28907. this.onEndFrameObservable.notifyObservers(this);
  28908. };
  28909. /**
  28910. * Resize the view according to the canvas' size
  28911. */
  28912. Engine.prototype.resize = function () {
  28913. // We're not resizing the size of the canvas while in VR mode & presenting
  28914. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28915. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28916. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28917. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28918. }
  28919. };
  28920. /**
  28921. * Force a specific size of the canvas
  28922. * @param width defines the new canvas' width
  28923. * @param height defines the new canvas' height
  28924. */
  28925. Engine.prototype.setSize = function (width, height) {
  28926. if (!this._renderingCanvas) {
  28927. return;
  28928. }
  28929. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28930. return;
  28931. }
  28932. this._renderingCanvas.width = width;
  28933. this._renderingCanvas.height = height;
  28934. for (var index = 0; index < this.scenes.length; index++) {
  28935. var scene = this.scenes[index];
  28936. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28937. var cam = scene.cameras[camIndex];
  28938. cam._currentRenderId = 0;
  28939. }
  28940. }
  28941. if (this.onResizeObservable.hasObservers) {
  28942. this.onResizeObservable.notifyObservers(this);
  28943. }
  28944. };
  28945. // WebVR functions
  28946. /**
  28947. * Gets a boolean indicating if a webVR device was detected
  28948. * @returns true if a webVR device was detected
  28949. */
  28950. Engine.prototype.isVRDevicePresent = function () {
  28951. return !!this._vrDisplay;
  28952. };
  28953. /**
  28954. * Gets the current webVR device
  28955. * @returns the current webVR device (or null)
  28956. */
  28957. Engine.prototype.getVRDevice = function () {
  28958. return this._vrDisplay;
  28959. };
  28960. /**
  28961. * Initializes a webVR display and starts listening to display change events
  28962. * The onVRDisplayChangedObservable will be notified upon these changes
  28963. * @returns The onVRDisplayChangedObservable
  28964. */
  28965. Engine.prototype.initWebVR = function () {
  28966. this.initWebVRAsync();
  28967. return this.onVRDisplayChangedObservable;
  28968. };
  28969. /**
  28970. * Initializes a webVR display and starts listening to display change events
  28971. * The onVRDisplayChangedObservable will be notified upon these changes
  28972. * @returns A promise containing a VRDisplay and if vr is supported
  28973. */
  28974. Engine.prototype.initWebVRAsync = function () {
  28975. var _this = this;
  28976. var notifyObservers = function () {
  28977. var eventArgs = {
  28978. vrDisplay: _this._vrDisplay,
  28979. vrSupported: _this._vrSupported
  28980. };
  28981. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28982. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28983. };
  28984. if (!this._onVrDisplayConnect) {
  28985. this._onVrDisplayConnect = function (event) {
  28986. _this._vrDisplay = event.display;
  28987. notifyObservers();
  28988. };
  28989. this._onVrDisplayDisconnect = function () {
  28990. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28991. _this._vrDisplay = undefined;
  28992. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28993. notifyObservers();
  28994. };
  28995. this._onVrDisplayPresentChange = function () {
  28996. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28997. };
  28998. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28999. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29000. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29001. }
  29002. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29003. this._webVRInitPromise.then(notifyObservers);
  29004. return this._webVRInitPromise;
  29005. };
  29006. /**
  29007. * Call this function to switch to webVR mode
  29008. * Will do nothing if webVR is not supported or if there is no webVR device
  29009. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29010. */
  29011. Engine.prototype.enableVR = function () {
  29012. var _this = this;
  29013. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29014. var onResolved = function () {
  29015. _this.onVRRequestPresentComplete.notifyObservers(true);
  29016. _this._onVRFullScreenTriggered();
  29017. };
  29018. var onRejected = function () {
  29019. _this.onVRRequestPresentComplete.notifyObservers(false);
  29020. };
  29021. this.onVRRequestPresentStart.notifyObservers(this);
  29022. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29023. }
  29024. };
  29025. /**
  29026. * Call this function to leave webVR mode
  29027. * Will do nothing if webVR is not supported or if there is no webVR device
  29028. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29029. */
  29030. Engine.prototype.disableVR = function () {
  29031. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29032. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29033. }
  29034. };
  29035. Engine.prototype._getVRDisplaysAsync = function () {
  29036. var _this = this;
  29037. return new Promise(function (res) {
  29038. if (navigator.getVRDisplays) {
  29039. navigator.getVRDisplays().then(function (devices) {
  29040. _this._vrSupported = true;
  29041. // note that devices may actually be an empty array. This is fine;
  29042. // we expect this._vrDisplay to be undefined in this case.
  29043. _this._vrDisplay = devices[0];
  29044. res({
  29045. vrDisplay: _this._vrDisplay,
  29046. vrSupported: _this._vrSupported
  29047. });
  29048. });
  29049. }
  29050. else {
  29051. _this._vrDisplay = undefined;
  29052. _this._vrSupported = false;
  29053. res({
  29054. vrDisplay: _this._vrDisplay,
  29055. vrSupported: _this._vrSupported
  29056. });
  29057. }
  29058. });
  29059. };
  29060. /**
  29061. * Binds the frame buffer to the specified texture.
  29062. * @param texture The texture to render to or null for the default canvas
  29063. * @param faceIndex The face of the texture to render to in case of cube texture
  29064. * @param requiredWidth The width of the target to render to
  29065. * @param requiredHeight The height of the target to render to
  29066. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29067. * @param depthStencilTexture The depth stencil texture to use to render
  29068. * @param lodLevel defines le lod level to bind to the frame buffer
  29069. */
  29070. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29071. if (lodLevel === void 0) { lodLevel = 0; }
  29072. if (this._currentRenderTarget) {
  29073. this.unBindFramebuffer(this._currentRenderTarget);
  29074. }
  29075. this._currentRenderTarget = texture;
  29076. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29077. var gl = this._gl;
  29078. if (texture.isCube) {
  29079. if (faceIndex === undefined) {
  29080. faceIndex = 0;
  29081. }
  29082. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29083. if (depthStencilTexture) {
  29084. if (depthStencilTexture._generateStencilBuffer) {
  29085. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29086. }
  29087. else {
  29088. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29089. }
  29090. }
  29091. }
  29092. if (this._cachedViewport && !forceFullscreenViewport) {
  29093. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29094. }
  29095. else {
  29096. if (!requiredWidth) {
  29097. requiredWidth = texture.width;
  29098. if (lodLevel) {
  29099. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29100. }
  29101. }
  29102. if (!requiredHeight) {
  29103. requiredHeight = texture.height;
  29104. if (lodLevel) {
  29105. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29106. }
  29107. }
  29108. this._viewport(0, 0, requiredWidth, requiredHeight);
  29109. }
  29110. this.wipeCaches();
  29111. };
  29112. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29113. if (this._currentFramebuffer !== framebuffer) {
  29114. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29115. this._currentFramebuffer = framebuffer;
  29116. }
  29117. };
  29118. /**
  29119. * Unbind the current render target texture from the webGL context
  29120. * @param texture defines the render target texture to unbind
  29121. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29122. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29123. */
  29124. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29125. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29126. this._currentRenderTarget = null;
  29127. // If MSAA, we need to bitblt back to main texture
  29128. var gl = this._gl;
  29129. if (texture._MSAAFramebuffer) {
  29130. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29131. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29132. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29133. }
  29134. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29135. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29136. gl.generateMipmap(gl.TEXTURE_2D);
  29137. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29138. }
  29139. if (onBeforeUnbind) {
  29140. if (texture._MSAAFramebuffer) {
  29141. // Bind the correct framebuffer
  29142. this.bindUnboundFramebuffer(texture._framebuffer);
  29143. }
  29144. onBeforeUnbind();
  29145. }
  29146. this.bindUnboundFramebuffer(null);
  29147. };
  29148. /**
  29149. * Unbind a list of render target textures from the webGL context
  29150. * This is used only when drawBuffer extension or webGL2 are active
  29151. * @param textures defines the render target textures to unbind
  29152. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29153. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29154. */
  29155. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29156. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29157. this._currentRenderTarget = null;
  29158. // If MSAA, we need to bitblt back to main texture
  29159. var gl = this._gl;
  29160. if (textures[0]._MSAAFramebuffer) {
  29161. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29162. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29163. var attachments = textures[0]._attachments;
  29164. if (!attachments) {
  29165. attachments = new Array(textures.length);
  29166. textures[0]._attachments = attachments;
  29167. }
  29168. for (var i = 0; i < textures.length; i++) {
  29169. var texture = textures[i];
  29170. for (var j = 0; j < attachments.length; j++) {
  29171. attachments[j] = gl.NONE;
  29172. }
  29173. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29174. gl.readBuffer(attachments[i]);
  29175. gl.drawBuffers(attachments);
  29176. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29177. }
  29178. for (var i = 0; i < attachments.length; i++) {
  29179. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29180. }
  29181. gl.drawBuffers(attachments);
  29182. }
  29183. for (var i = 0; i < textures.length; i++) {
  29184. var texture = textures[i];
  29185. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29186. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29187. gl.generateMipmap(gl.TEXTURE_2D);
  29188. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29189. }
  29190. }
  29191. if (onBeforeUnbind) {
  29192. if (textures[0]._MSAAFramebuffer) {
  29193. // Bind the correct framebuffer
  29194. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29195. }
  29196. onBeforeUnbind();
  29197. }
  29198. this.bindUnboundFramebuffer(null);
  29199. };
  29200. /**
  29201. * Force the mipmap generation for the given render target texture
  29202. * @param texture defines the render target texture to use
  29203. */
  29204. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29205. if (texture.generateMipMaps) {
  29206. var gl = this._gl;
  29207. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29208. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29209. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29210. }
  29211. };
  29212. /**
  29213. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29214. */
  29215. Engine.prototype.flushFramebuffer = function () {
  29216. this._gl.flush();
  29217. };
  29218. /**
  29219. * Unbind the current render target and bind the default framebuffer
  29220. */
  29221. Engine.prototype.restoreDefaultFramebuffer = function () {
  29222. if (this._currentRenderTarget) {
  29223. this.unBindFramebuffer(this._currentRenderTarget);
  29224. }
  29225. else {
  29226. this.bindUnboundFramebuffer(null);
  29227. }
  29228. if (this._cachedViewport) {
  29229. this.setViewport(this._cachedViewport);
  29230. }
  29231. this.wipeCaches();
  29232. };
  29233. // UBOs
  29234. /**
  29235. * Create an uniform buffer
  29236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29237. * @param elements defines the content of the uniform buffer
  29238. * @returns the webGL uniform buffer
  29239. */
  29240. Engine.prototype.createUniformBuffer = function (elements) {
  29241. var ubo = this._gl.createBuffer();
  29242. if (!ubo) {
  29243. throw new Error("Unable to create uniform buffer");
  29244. }
  29245. this.bindUniformBuffer(ubo);
  29246. if (elements instanceof Float32Array) {
  29247. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29248. }
  29249. else {
  29250. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29251. }
  29252. this.bindUniformBuffer(null);
  29253. ubo.references = 1;
  29254. return ubo;
  29255. };
  29256. /**
  29257. * Create a dynamic uniform buffer
  29258. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29259. * @param elements defines the content of the uniform buffer
  29260. * @returns the webGL uniform buffer
  29261. */
  29262. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29263. var ubo = this._gl.createBuffer();
  29264. if (!ubo) {
  29265. throw new Error("Unable to create dynamic uniform buffer");
  29266. }
  29267. this.bindUniformBuffer(ubo);
  29268. if (elements instanceof Float32Array) {
  29269. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29270. }
  29271. else {
  29272. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29273. }
  29274. this.bindUniformBuffer(null);
  29275. ubo.references = 1;
  29276. return ubo;
  29277. };
  29278. /**
  29279. * Update an existing uniform buffer
  29280. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29281. * @param uniformBuffer defines the target uniform buffer
  29282. * @param elements defines the content to update
  29283. * @param offset defines the offset in the uniform buffer where update should start
  29284. * @param count defines the size of the data to update
  29285. */
  29286. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29287. this.bindUniformBuffer(uniformBuffer);
  29288. if (offset === undefined) {
  29289. offset = 0;
  29290. }
  29291. if (count === undefined) {
  29292. if (elements instanceof Float32Array) {
  29293. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29294. }
  29295. else {
  29296. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29297. }
  29298. }
  29299. else {
  29300. if (elements instanceof Float32Array) {
  29301. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29302. }
  29303. else {
  29304. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29305. }
  29306. }
  29307. this.bindUniformBuffer(null);
  29308. };
  29309. // VBOs
  29310. Engine.prototype._resetVertexBufferBinding = function () {
  29311. this.bindArrayBuffer(null);
  29312. this._cachedVertexBuffers = null;
  29313. };
  29314. /**
  29315. * Creates a vertex buffer
  29316. * @param data the data for the vertex buffer
  29317. * @returns the new WebGL static buffer
  29318. */
  29319. Engine.prototype.createVertexBuffer = function (data) {
  29320. var vbo = this._gl.createBuffer();
  29321. if (!vbo) {
  29322. throw new Error("Unable to create vertex buffer");
  29323. }
  29324. this.bindArrayBuffer(vbo);
  29325. if (data instanceof Array) {
  29326. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29327. }
  29328. else {
  29329. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29330. }
  29331. this._resetVertexBufferBinding();
  29332. vbo.references = 1;
  29333. return vbo;
  29334. };
  29335. /**
  29336. * Creates a dynamic vertex buffer
  29337. * @param data the data for the dynamic vertex buffer
  29338. * @returns the new WebGL dynamic buffer
  29339. */
  29340. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29341. var vbo = this._gl.createBuffer();
  29342. if (!vbo) {
  29343. throw new Error("Unable to create dynamic vertex buffer");
  29344. }
  29345. this.bindArrayBuffer(vbo);
  29346. if (data instanceof Array) {
  29347. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29348. }
  29349. else {
  29350. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29351. }
  29352. this._resetVertexBufferBinding();
  29353. vbo.references = 1;
  29354. return vbo;
  29355. };
  29356. /**
  29357. * Update a dynamic index buffer
  29358. * @param indexBuffer defines the target index buffer
  29359. * @param indices defines the data to update
  29360. * @param offset defines the offset in the target index buffer where update should start
  29361. */
  29362. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29363. if (offset === void 0) { offset = 0; }
  29364. // Force cache update
  29365. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29366. this.bindIndexBuffer(indexBuffer);
  29367. var arrayBuffer;
  29368. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29369. arrayBuffer = indices;
  29370. }
  29371. else {
  29372. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29373. }
  29374. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29375. this._resetIndexBufferBinding();
  29376. };
  29377. /**
  29378. * Updates a dynamic vertex buffer.
  29379. * @param vertexBuffer the vertex buffer to update
  29380. * @param data the data used to update the vertex buffer
  29381. * @param byteOffset the byte offset of the data
  29382. * @param byteLength the byte length of the data
  29383. */
  29384. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29385. this.bindArrayBuffer(vertexBuffer);
  29386. if (byteOffset === undefined) {
  29387. byteOffset = 0;
  29388. }
  29389. if (byteLength === undefined) {
  29390. if (data instanceof Array) {
  29391. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29392. }
  29393. else {
  29394. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29395. }
  29396. }
  29397. else {
  29398. if (data instanceof Array) {
  29399. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29400. }
  29401. else {
  29402. if (data instanceof ArrayBuffer) {
  29403. data = new Uint8Array(data, byteOffset, byteLength);
  29404. }
  29405. else {
  29406. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29407. }
  29408. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29409. }
  29410. }
  29411. this._resetVertexBufferBinding();
  29412. };
  29413. Engine.prototype._resetIndexBufferBinding = function () {
  29414. this.bindIndexBuffer(null);
  29415. this._cachedIndexBuffer = null;
  29416. };
  29417. /**
  29418. * Creates a new index buffer
  29419. * @param indices defines the content of the index buffer
  29420. * @param updatable defines if the index buffer must be updatable
  29421. * @returns a new webGL buffer
  29422. */
  29423. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29424. var vbo = this._gl.createBuffer();
  29425. if (!vbo) {
  29426. throw new Error("Unable to create index buffer");
  29427. }
  29428. this.bindIndexBuffer(vbo);
  29429. // Check for 32 bits indices
  29430. var arrayBuffer;
  29431. var need32Bits = false;
  29432. if (indices instanceof Uint16Array) {
  29433. arrayBuffer = indices;
  29434. }
  29435. else {
  29436. //check 32 bit support
  29437. if (this._caps.uintIndices) {
  29438. if (indices instanceof Uint32Array) {
  29439. arrayBuffer = indices;
  29440. need32Bits = true;
  29441. }
  29442. else {
  29443. //number[] or Int32Array, check if 32 bit is necessary
  29444. for (var index = 0; index < indices.length; index++) {
  29445. if (indices[index] > 65535) {
  29446. need32Bits = true;
  29447. break;
  29448. }
  29449. }
  29450. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29451. }
  29452. }
  29453. else {
  29454. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29455. arrayBuffer = new Uint16Array(indices);
  29456. }
  29457. }
  29458. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29459. this._resetIndexBufferBinding();
  29460. vbo.references = 1;
  29461. vbo.is32Bits = need32Bits;
  29462. return vbo;
  29463. };
  29464. /**
  29465. * Bind a webGL buffer to the webGL context
  29466. * @param buffer defines the buffer to bind
  29467. */
  29468. Engine.prototype.bindArrayBuffer = function (buffer) {
  29469. if (!this._vaoRecordInProgress) {
  29470. this._unbindVertexArrayObject();
  29471. }
  29472. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29473. };
  29474. /**
  29475. * Bind an uniform buffer to the current webGL context
  29476. * @param buffer defines the buffer to bind
  29477. */
  29478. Engine.prototype.bindUniformBuffer = function (buffer) {
  29479. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29480. };
  29481. /**
  29482. * Bind a buffer to the current webGL context at a given location
  29483. * @param buffer defines the buffer to bind
  29484. * @param location defines the index where to bind the buffer
  29485. */
  29486. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29487. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29488. };
  29489. /**
  29490. * Bind a specific block at a given index in a specific shader program
  29491. * @param shaderProgram defines the shader program
  29492. * @param blockName defines the block name
  29493. * @param index defines the index where to bind the block
  29494. */
  29495. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29496. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29497. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29498. };
  29499. Engine.prototype.bindIndexBuffer = function (buffer) {
  29500. if (!this._vaoRecordInProgress) {
  29501. this._unbindVertexArrayObject();
  29502. }
  29503. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29504. };
  29505. Engine.prototype.bindBuffer = function (buffer, target) {
  29506. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29507. this._gl.bindBuffer(target, buffer);
  29508. this._currentBoundBuffer[target] = buffer;
  29509. }
  29510. };
  29511. /**
  29512. * update the bound buffer with the given data
  29513. * @param data defines the data to update
  29514. */
  29515. Engine.prototype.updateArrayBuffer = function (data) {
  29516. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29517. };
  29518. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29519. var pointer = this._currentBufferPointers[indx];
  29520. var changed = false;
  29521. if (!pointer.active) {
  29522. changed = true;
  29523. pointer.active = true;
  29524. pointer.index = indx;
  29525. pointer.size = size;
  29526. pointer.type = type;
  29527. pointer.normalized = normalized;
  29528. pointer.stride = stride;
  29529. pointer.offset = offset;
  29530. pointer.buffer = buffer;
  29531. }
  29532. else {
  29533. if (pointer.buffer !== buffer) {
  29534. pointer.buffer = buffer;
  29535. changed = true;
  29536. }
  29537. if (pointer.size !== size) {
  29538. pointer.size = size;
  29539. changed = true;
  29540. }
  29541. if (pointer.type !== type) {
  29542. pointer.type = type;
  29543. changed = true;
  29544. }
  29545. if (pointer.normalized !== normalized) {
  29546. pointer.normalized = normalized;
  29547. changed = true;
  29548. }
  29549. if (pointer.stride !== stride) {
  29550. pointer.stride = stride;
  29551. changed = true;
  29552. }
  29553. if (pointer.offset !== offset) {
  29554. pointer.offset = offset;
  29555. changed = true;
  29556. }
  29557. }
  29558. if (changed || this._vaoRecordInProgress) {
  29559. this.bindArrayBuffer(buffer);
  29560. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29561. }
  29562. };
  29563. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29564. if (indexBuffer == null) {
  29565. return;
  29566. }
  29567. if (this._cachedIndexBuffer !== indexBuffer) {
  29568. this._cachedIndexBuffer = indexBuffer;
  29569. this.bindIndexBuffer(indexBuffer);
  29570. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29571. }
  29572. };
  29573. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29574. var attributes = effect.getAttributesNames();
  29575. if (!this._vaoRecordInProgress) {
  29576. this._unbindVertexArrayObject();
  29577. }
  29578. this.unbindAllAttributes();
  29579. for (var index = 0; index < attributes.length; index++) {
  29580. var order = effect.getAttributeLocation(index);
  29581. if (order >= 0) {
  29582. var vertexBuffer = vertexBuffers[attributes[index]];
  29583. if (!vertexBuffer) {
  29584. continue;
  29585. }
  29586. this._gl.enableVertexAttribArray(order);
  29587. if (!this._vaoRecordInProgress) {
  29588. this._vertexAttribArraysEnabled[order] = true;
  29589. }
  29590. var buffer = vertexBuffer.getBuffer();
  29591. if (buffer) {
  29592. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29593. if (vertexBuffer.getIsInstanced()) {
  29594. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29595. if (!this._vaoRecordInProgress) {
  29596. this._currentInstanceLocations.push(order);
  29597. this._currentInstanceBuffers.push(buffer);
  29598. }
  29599. }
  29600. }
  29601. }
  29602. }
  29603. };
  29604. /**
  29605. * Records a vertex array object
  29606. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29607. * @param vertexBuffers defines the list of vertex buffers to store
  29608. * @param indexBuffer defines the index buffer to store
  29609. * @param effect defines the effect to store
  29610. * @returns the new vertex array object
  29611. */
  29612. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29613. var vao = this._gl.createVertexArray();
  29614. this._vaoRecordInProgress = true;
  29615. this._gl.bindVertexArray(vao);
  29616. this._mustWipeVertexAttributes = true;
  29617. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29618. this.bindIndexBuffer(indexBuffer);
  29619. this._vaoRecordInProgress = false;
  29620. this._gl.bindVertexArray(null);
  29621. return vao;
  29622. };
  29623. /**
  29624. * Bind a specific vertex array object
  29625. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29626. * @param vertexArrayObject defines the vertex array object to bind
  29627. * @param indexBuffer defines the index buffer to bind
  29628. */
  29629. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29630. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29631. this._cachedVertexArrayObject = vertexArrayObject;
  29632. this._gl.bindVertexArray(vertexArrayObject);
  29633. this._cachedVertexBuffers = null;
  29634. this._cachedIndexBuffer = null;
  29635. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29636. this._mustWipeVertexAttributes = true;
  29637. }
  29638. };
  29639. /**
  29640. * Bind webGl buffers directly to the webGL context
  29641. * @param vertexBuffer defines the vertex buffer to bind
  29642. * @param indexBuffer defines the index buffer to bind
  29643. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29644. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29645. * @param effect defines the effect associated with the vertex buffer
  29646. */
  29647. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29648. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29649. this._cachedVertexBuffers = vertexBuffer;
  29650. this._cachedEffectForVertexBuffers = effect;
  29651. var attributesCount = effect.getAttributesCount();
  29652. this._unbindVertexArrayObject();
  29653. this.unbindAllAttributes();
  29654. var offset = 0;
  29655. for (var index = 0; index < attributesCount; index++) {
  29656. if (index < vertexDeclaration.length) {
  29657. var order = effect.getAttributeLocation(index);
  29658. if (order >= 0) {
  29659. this._gl.enableVertexAttribArray(order);
  29660. this._vertexAttribArraysEnabled[order] = true;
  29661. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29662. }
  29663. offset += vertexDeclaration[index] * 4;
  29664. }
  29665. }
  29666. }
  29667. this._bindIndexBufferWithCache(indexBuffer);
  29668. };
  29669. Engine.prototype._unbindVertexArrayObject = function () {
  29670. if (!this._cachedVertexArrayObject) {
  29671. return;
  29672. }
  29673. this._cachedVertexArrayObject = null;
  29674. this._gl.bindVertexArray(null);
  29675. };
  29676. /**
  29677. * Bind a list of vertex buffers to the webGL context
  29678. * @param vertexBuffers defines the list of vertex buffers to bind
  29679. * @param indexBuffer defines the index buffer to bind
  29680. * @param effect defines the effect associated with the vertex buffers
  29681. */
  29682. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29683. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29684. this._cachedVertexBuffers = vertexBuffers;
  29685. this._cachedEffectForVertexBuffers = effect;
  29686. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29687. }
  29688. this._bindIndexBufferWithCache(indexBuffer);
  29689. };
  29690. /**
  29691. * Unbind all instance attributes
  29692. */
  29693. Engine.prototype.unbindInstanceAttributes = function () {
  29694. var boundBuffer;
  29695. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29696. var instancesBuffer = this._currentInstanceBuffers[i];
  29697. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29698. boundBuffer = instancesBuffer;
  29699. this.bindArrayBuffer(instancesBuffer);
  29700. }
  29701. var offsetLocation = this._currentInstanceLocations[i];
  29702. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29703. }
  29704. this._currentInstanceBuffers.length = 0;
  29705. this._currentInstanceLocations.length = 0;
  29706. };
  29707. /**
  29708. * Release and free the memory of a vertex array object
  29709. * @param vao defines the vertex array object to delete
  29710. */
  29711. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29712. this._gl.deleteVertexArray(vao);
  29713. };
  29714. /** @hidden */
  29715. Engine.prototype._releaseBuffer = function (buffer) {
  29716. buffer.references--;
  29717. if (buffer.references === 0) {
  29718. this._gl.deleteBuffer(buffer);
  29719. return true;
  29720. }
  29721. return false;
  29722. };
  29723. /**
  29724. * Creates a webGL buffer to use with instanciation
  29725. * @param capacity defines the size of the buffer
  29726. * @returns the webGL buffer
  29727. */
  29728. Engine.prototype.createInstancesBuffer = function (capacity) {
  29729. var buffer = this._gl.createBuffer();
  29730. if (!buffer) {
  29731. throw new Error("Unable to create instance buffer");
  29732. }
  29733. buffer.capacity = capacity;
  29734. this.bindArrayBuffer(buffer);
  29735. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29736. return buffer;
  29737. };
  29738. /**
  29739. * Delete a webGL buffer used with instanciation
  29740. * @param buffer defines the webGL buffer to delete
  29741. */
  29742. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29743. this._gl.deleteBuffer(buffer);
  29744. };
  29745. /**
  29746. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29747. * @param instancesBuffer defines the webGL buffer to update and bind
  29748. * @param data defines the data to store in the buffer
  29749. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29750. */
  29751. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29752. this.bindArrayBuffer(instancesBuffer);
  29753. if (data) {
  29754. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29755. }
  29756. if (offsetLocations[0].index !== undefined) {
  29757. var stride = 0;
  29758. for (var i = 0; i < offsetLocations.length; i++) {
  29759. var ai = offsetLocations[i];
  29760. stride += ai.attributeSize * 4;
  29761. }
  29762. for (var i = 0; i < offsetLocations.length; i++) {
  29763. var ai = offsetLocations[i];
  29764. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29765. this._gl.enableVertexAttribArray(ai.index);
  29766. this._vertexAttribArraysEnabled[ai.index] = true;
  29767. }
  29768. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29769. this._gl.vertexAttribDivisor(ai.index, 1);
  29770. this._currentInstanceLocations.push(ai.index);
  29771. this._currentInstanceBuffers.push(instancesBuffer);
  29772. }
  29773. }
  29774. else {
  29775. for (var index = 0; index < 4; index++) {
  29776. var offsetLocation = offsetLocations[index];
  29777. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29778. this._gl.enableVertexAttribArray(offsetLocation);
  29779. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29780. }
  29781. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29782. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29783. this._currentInstanceLocations.push(offsetLocation);
  29784. this._currentInstanceBuffers.push(instancesBuffer);
  29785. }
  29786. }
  29787. };
  29788. /**
  29789. * Apply all cached states (depth, culling, stencil and alpha)
  29790. */
  29791. Engine.prototype.applyStates = function () {
  29792. this._depthCullingState.apply(this._gl);
  29793. this._stencilState.apply(this._gl);
  29794. this._alphaState.apply(this._gl);
  29795. };
  29796. /**
  29797. * Send a draw order
  29798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29799. * @param indexStart defines the starting index
  29800. * @param indexCount defines the number of index to draw
  29801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29802. */
  29803. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29804. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29805. };
  29806. /**
  29807. * Draw a list of points
  29808. * @param verticesStart defines the index of first vertex to draw
  29809. * @param verticesCount defines the count of vertices to draw
  29810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29811. */
  29812. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29813. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29814. };
  29815. /**
  29816. * Draw a list of unindexed primitives
  29817. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29818. * @param verticesStart defines the index of first vertex to draw
  29819. * @param verticesCount defines the count of vertices to draw
  29820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29821. */
  29822. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29823. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29824. };
  29825. /**
  29826. * Draw a list of indexed primitives
  29827. * @param fillMode defines the primitive to use
  29828. * @param indexStart defines the starting index
  29829. * @param indexCount defines the number of index to draw
  29830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29831. */
  29832. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29833. // Apply states
  29834. this.applyStates();
  29835. this._drawCalls.addCount(1, false);
  29836. // Render
  29837. var drawMode = this._drawMode(fillMode);
  29838. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29839. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29840. if (instancesCount) {
  29841. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29842. }
  29843. else {
  29844. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29845. }
  29846. };
  29847. /**
  29848. * Draw a list of unindexed primitives
  29849. * @param fillMode defines the primitive to use
  29850. * @param verticesStart defines the index of first vertex to draw
  29851. * @param verticesCount defines the count of vertices to draw
  29852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29853. */
  29854. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29855. // Apply states
  29856. this.applyStates();
  29857. this._drawCalls.addCount(1, false);
  29858. var drawMode = this._drawMode(fillMode);
  29859. if (instancesCount) {
  29860. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29861. }
  29862. else {
  29863. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29864. }
  29865. };
  29866. Engine.prototype._drawMode = function (fillMode) {
  29867. switch (fillMode) {
  29868. // Triangle views
  29869. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29870. return this._gl.TRIANGLES;
  29871. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29872. return this._gl.POINTS;
  29873. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29874. return this._gl.LINES;
  29875. // Draw modes
  29876. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29877. return this._gl.POINTS;
  29878. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29879. return this._gl.LINES;
  29880. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29881. return this._gl.LINE_LOOP;
  29882. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29883. return this._gl.LINE_STRIP;
  29884. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29885. return this._gl.TRIANGLE_STRIP;
  29886. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29887. return this._gl.TRIANGLE_FAN;
  29888. default:
  29889. return this._gl.TRIANGLES;
  29890. }
  29891. };
  29892. // Shaders
  29893. /** @hidden */
  29894. Engine.prototype._releaseEffect = function (effect) {
  29895. if (this._compiledEffects[effect._key]) {
  29896. delete this._compiledEffects[effect._key];
  29897. this._deleteProgram(effect.getProgram());
  29898. }
  29899. };
  29900. /** @hidden */
  29901. Engine.prototype._deleteProgram = function (program) {
  29902. if (program) {
  29903. program.__SPECTOR_rebuildProgram = null;
  29904. if (program.transformFeedback) {
  29905. this.deleteTransformFeedback(program.transformFeedback);
  29906. program.transformFeedback = null;
  29907. }
  29908. this._gl.deleteProgram(program);
  29909. }
  29910. };
  29911. /**
  29912. * Create a new effect (used to store vertex/fragment shaders)
  29913. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29914. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29915. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29916. * @param samplers defines an array of string used to represent textures
  29917. * @param defines defines the string containing the defines to use to compile the shaders
  29918. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29919. * @param onCompiled defines a function to call when the effect creation is successful
  29920. * @param onError defines a function to call when the effect creation has failed
  29921. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29922. * @returns the new Effect
  29923. */
  29924. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29925. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29926. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29927. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29928. if (this._compiledEffects[name]) {
  29929. var compiledEffect = this._compiledEffects[name];
  29930. if (onCompiled && compiledEffect.isReady()) {
  29931. onCompiled(compiledEffect);
  29932. }
  29933. return compiledEffect;
  29934. }
  29935. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29936. effect._key = name;
  29937. this._compiledEffects[name] = effect;
  29938. return effect;
  29939. };
  29940. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29941. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29942. };
  29943. Engine.prototype._compileRawShader = function (source, type) {
  29944. var gl = this._gl;
  29945. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29946. if (!shader) {
  29947. throw new Error("Something went wrong while compile the shader.");
  29948. }
  29949. gl.shaderSource(shader, source);
  29950. gl.compileShader(shader);
  29951. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29952. var log = gl.getShaderInfoLog(shader);
  29953. if (log) {
  29954. throw new Error(log);
  29955. }
  29956. }
  29957. return shader;
  29958. };
  29959. /**
  29960. * Directly creates a webGL program
  29961. * @param vertexCode defines the vertex shader code to use
  29962. * @param fragmentCode defines the fragment shader code to use
  29963. * @param context defines the webGL context to use (if not set, the current one will be used)
  29964. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29965. * @returns the new webGL program
  29966. */
  29967. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  29968. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29969. context = context || this._gl;
  29970. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  29971. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  29972. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29973. };
  29974. /**
  29975. * Creates a webGL program
  29976. * @param vertexCode defines the vertex shader code to use
  29977. * @param fragmentCode defines the fragment shader code to use
  29978. * @param defines defines the string containing the defines to use to compile the shaders
  29979. * @param context defines the webGL context to use (if not set, the current one will be used)
  29980. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29981. * @returns the new webGL program
  29982. */
  29983. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  29984. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29985. context = context || this._gl;
  29986. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29987. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  29988. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  29989. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  29990. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29991. this.onAfterShaderCompilationObservable.notifyObservers(this);
  29992. return program;
  29993. };
  29994. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  29995. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29996. var shaderProgram = context.createProgram();
  29997. if (!shaderProgram) {
  29998. throw new Error("Unable to create program");
  29999. }
  30000. context.attachShader(shaderProgram, vertexShader);
  30001. context.attachShader(shaderProgram, fragmentShader);
  30002. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30003. var transformFeedback = this.createTransformFeedback();
  30004. this.bindTransformFeedback(transformFeedback);
  30005. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30006. shaderProgram.transformFeedback = transformFeedback;
  30007. }
  30008. context.linkProgram(shaderProgram);
  30009. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30010. this.bindTransformFeedback(null);
  30011. }
  30012. shaderProgram.context = context;
  30013. shaderProgram.vertexShader = vertexShader;
  30014. shaderProgram.fragmentShader = fragmentShader;
  30015. if (!this._caps.parallelShaderCompile) {
  30016. this._finalizeProgram(shaderProgram);
  30017. }
  30018. else {
  30019. shaderProgram.isParallelCompiled = true;
  30020. }
  30021. return shaderProgram;
  30022. };
  30023. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30024. var context = shaderProgram.context;
  30025. var vertexShader = shaderProgram.vertexShader;
  30026. var fragmentShader = shaderProgram.fragmentShader;
  30027. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30028. if (!linked) {
  30029. var error = context.getProgramInfoLog(shaderProgram);
  30030. if (error) {
  30031. throw new Error(error);
  30032. }
  30033. }
  30034. if (this.validateShaderPrograms) {
  30035. context.validateProgram(shaderProgram);
  30036. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30037. if (!validated) {
  30038. var error = context.getProgramInfoLog(shaderProgram);
  30039. if (error) {
  30040. throw new Error(error);
  30041. }
  30042. }
  30043. }
  30044. context.deleteShader(vertexShader);
  30045. context.deleteShader(fragmentShader);
  30046. shaderProgram.context = undefined;
  30047. shaderProgram.vertexShader = undefined;
  30048. shaderProgram.fragmentShader = undefined;
  30049. if (shaderProgram.onCompiled) {
  30050. shaderProgram.onCompiled();
  30051. shaderProgram.onCompiled = undefined;
  30052. }
  30053. };
  30054. /** @hidden */
  30055. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30056. if (!shaderProgram.isParallelCompiled) {
  30057. return true;
  30058. }
  30059. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30060. this._finalizeProgram(shaderProgram);
  30061. return true;
  30062. }
  30063. return false;
  30064. };
  30065. /** @hidden */
  30066. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30067. if (!shaderProgram.isParallelCompiled) {
  30068. action();
  30069. return;
  30070. }
  30071. shaderProgram.onCompiled = action;
  30072. };
  30073. /**
  30074. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30075. * @param shaderProgram defines the webGL program to use
  30076. * @param uniformsNames defines the list of uniform names
  30077. * @returns an array of webGL uniform locations
  30078. */
  30079. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30080. var results = new Array();
  30081. for (var index = 0; index < uniformsNames.length; index++) {
  30082. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30083. }
  30084. return results;
  30085. };
  30086. /**
  30087. * Gets the lsit of active attributes for a given webGL program
  30088. * @param shaderProgram defines the webGL program to use
  30089. * @param attributesNames defines the list of attribute names to get
  30090. * @returns an array of indices indicating the offset of each attribute
  30091. */
  30092. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30093. var results = [];
  30094. for (var index = 0; index < attributesNames.length; index++) {
  30095. try {
  30096. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30097. }
  30098. catch (e) {
  30099. results.push(-1);
  30100. }
  30101. }
  30102. return results;
  30103. };
  30104. /**
  30105. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30106. * @param effect defines the effect to activate
  30107. */
  30108. Engine.prototype.enableEffect = function (effect) {
  30109. if (!effect || effect === this._currentEffect) {
  30110. return;
  30111. }
  30112. // Use program
  30113. this.bindSamplers(effect);
  30114. this._currentEffect = effect;
  30115. if (effect.onBind) {
  30116. effect.onBind(effect);
  30117. }
  30118. if (effect._onBindObservable) {
  30119. effect._onBindObservable.notifyObservers(effect);
  30120. }
  30121. };
  30122. /**
  30123. * Set the value of an uniform to an array of int32
  30124. * @param uniform defines the webGL uniform location where to store the value
  30125. * @param array defines the array of int32 to store
  30126. */
  30127. Engine.prototype.setIntArray = function (uniform, array) {
  30128. if (!uniform) {
  30129. return;
  30130. }
  30131. this._gl.uniform1iv(uniform, array);
  30132. };
  30133. /**
  30134. * Set the value of an uniform to an array of int32 (stored as vec2)
  30135. * @param uniform defines the webGL uniform location where to store the value
  30136. * @param array defines the array of int32 to store
  30137. */
  30138. Engine.prototype.setIntArray2 = function (uniform, array) {
  30139. if (!uniform || array.length % 2 !== 0) {
  30140. return;
  30141. }
  30142. this._gl.uniform2iv(uniform, array);
  30143. };
  30144. /**
  30145. * Set the value of an uniform to an array of int32 (stored as vec3)
  30146. * @param uniform defines the webGL uniform location where to store the value
  30147. * @param array defines the array of int32 to store
  30148. */
  30149. Engine.prototype.setIntArray3 = function (uniform, array) {
  30150. if (!uniform || array.length % 3 !== 0) {
  30151. return;
  30152. }
  30153. this._gl.uniform3iv(uniform, array);
  30154. };
  30155. /**
  30156. * Set the value of an uniform to an array of int32 (stored as vec4)
  30157. * @param uniform defines the webGL uniform location where to store the value
  30158. * @param array defines the array of int32 to store
  30159. */
  30160. Engine.prototype.setIntArray4 = function (uniform, array) {
  30161. if (!uniform || array.length % 4 !== 0) {
  30162. return;
  30163. }
  30164. this._gl.uniform4iv(uniform, array);
  30165. };
  30166. /**
  30167. * Set the value of an uniform to an array of float32
  30168. * @param uniform defines the webGL uniform location where to store the value
  30169. * @param array defines the array of float32 to store
  30170. */
  30171. Engine.prototype.setFloatArray = function (uniform, array) {
  30172. if (!uniform) {
  30173. return;
  30174. }
  30175. this._gl.uniform1fv(uniform, array);
  30176. };
  30177. /**
  30178. * Set the value of an uniform to an array of float32 (stored as vec2)
  30179. * @param uniform defines the webGL uniform location where to store the value
  30180. * @param array defines the array of float32 to store
  30181. */
  30182. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30183. if (!uniform || array.length % 2 !== 0) {
  30184. return;
  30185. }
  30186. this._gl.uniform2fv(uniform, array);
  30187. };
  30188. /**
  30189. * Set the value of an uniform to an array of float32 (stored as vec3)
  30190. * @param uniform defines the webGL uniform location where to store the value
  30191. * @param array defines the array of float32 to store
  30192. */
  30193. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30194. if (!uniform || array.length % 3 !== 0) {
  30195. return;
  30196. }
  30197. this._gl.uniform3fv(uniform, array);
  30198. };
  30199. /**
  30200. * Set the value of an uniform to an array of float32 (stored as vec4)
  30201. * @param uniform defines the webGL uniform location where to store the value
  30202. * @param array defines the array of float32 to store
  30203. */
  30204. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30205. if (!uniform || array.length % 4 !== 0) {
  30206. return;
  30207. }
  30208. this._gl.uniform4fv(uniform, array);
  30209. };
  30210. /**
  30211. * Set the value of an uniform to an array of number
  30212. * @param uniform defines the webGL uniform location where to store the value
  30213. * @param array defines the array of number to store
  30214. */
  30215. Engine.prototype.setArray = function (uniform, array) {
  30216. if (!uniform) {
  30217. return;
  30218. }
  30219. this._gl.uniform1fv(uniform, array);
  30220. };
  30221. /**
  30222. * Set the value of an uniform to an array of number (stored as vec2)
  30223. * @param uniform defines the webGL uniform location where to store the value
  30224. * @param array defines the array of number to store
  30225. */
  30226. Engine.prototype.setArray2 = function (uniform, array) {
  30227. if (!uniform || array.length % 2 !== 0) {
  30228. return;
  30229. }
  30230. this._gl.uniform2fv(uniform, array);
  30231. };
  30232. /**
  30233. * Set the value of an uniform to an array of number (stored as vec3)
  30234. * @param uniform defines the webGL uniform location where to store the value
  30235. * @param array defines the array of number to store
  30236. */
  30237. Engine.prototype.setArray3 = function (uniform, array) {
  30238. if (!uniform || array.length % 3 !== 0) {
  30239. return;
  30240. }
  30241. this._gl.uniform3fv(uniform, array);
  30242. };
  30243. /**
  30244. * Set the value of an uniform to an array of number (stored as vec4)
  30245. * @param uniform defines the webGL uniform location where to store the value
  30246. * @param array defines the array of number to store
  30247. */
  30248. Engine.prototype.setArray4 = function (uniform, array) {
  30249. if (!uniform || array.length % 4 !== 0) {
  30250. return;
  30251. }
  30252. this._gl.uniform4fv(uniform, array);
  30253. };
  30254. /**
  30255. * Set the value of an uniform to an array of float32 (stored as matrices)
  30256. * @param uniform defines the webGL uniform location where to store the value
  30257. * @param matrices defines the array of float32 to store
  30258. */
  30259. Engine.prototype.setMatrices = function (uniform, matrices) {
  30260. if (!uniform) {
  30261. return;
  30262. }
  30263. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30264. };
  30265. /**
  30266. * Set the value of an uniform to a matrix
  30267. * @param uniform defines the webGL uniform location where to store the value
  30268. * @param matrix defines the matrix to store
  30269. */
  30270. Engine.prototype.setMatrix = function (uniform, matrix) {
  30271. if (!uniform) {
  30272. return;
  30273. }
  30274. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30275. };
  30276. /**
  30277. * Set the value of an uniform to a matrix (3x3)
  30278. * @param uniform defines the webGL uniform location where to store the value
  30279. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30280. */
  30281. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30282. if (!uniform) {
  30283. return;
  30284. }
  30285. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30286. };
  30287. /**
  30288. * Set the value of an uniform to a matrix (2x2)
  30289. * @param uniform defines the webGL uniform location where to store the value
  30290. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30291. */
  30292. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30293. if (!uniform) {
  30294. return;
  30295. }
  30296. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30297. };
  30298. /**
  30299. * Set the value of an uniform to a number (int)
  30300. * @param uniform defines the webGL uniform location where to store the value
  30301. * @param value defines the int number to store
  30302. */
  30303. Engine.prototype.setInt = function (uniform, value) {
  30304. if (!uniform) {
  30305. return;
  30306. }
  30307. this._gl.uniform1i(uniform, value);
  30308. };
  30309. /**
  30310. * Set the value of an uniform to a number (float)
  30311. * @param uniform defines the webGL uniform location where to store the value
  30312. * @param value defines the float number to store
  30313. */
  30314. Engine.prototype.setFloat = function (uniform, value) {
  30315. if (!uniform) {
  30316. return;
  30317. }
  30318. this._gl.uniform1f(uniform, value);
  30319. };
  30320. /**
  30321. * Set the value of an uniform to a vec2
  30322. * @param uniform defines the webGL uniform location where to store the value
  30323. * @param x defines the 1st component of the value
  30324. * @param y defines the 2nd component of the value
  30325. */
  30326. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30327. if (!uniform) {
  30328. return;
  30329. }
  30330. this._gl.uniform2f(uniform, x, y);
  30331. };
  30332. /**
  30333. * Set the value of an uniform to a vec3
  30334. * @param uniform defines the webGL uniform location where to store the value
  30335. * @param x defines the 1st component of the value
  30336. * @param y defines the 2nd component of the value
  30337. * @param z defines the 3rd component of the value
  30338. */
  30339. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30340. if (!uniform) {
  30341. return;
  30342. }
  30343. this._gl.uniform3f(uniform, x, y, z);
  30344. };
  30345. /**
  30346. * Set the value of an uniform to a boolean
  30347. * @param uniform defines the webGL uniform location where to store the value
  30348. * @param bool defines the boolean to store
  30349. */
  30350. Engine.prototype.setBool = function (uniform, bool) {
  30351. if (!uniform) {
  30352. return;
  30353. }
  30354. this._gl.uniform1i(uniform, bool);
  30355. };
  30356. /**
  30357. * Set the value of an uniform to a vec4
  30358. * @param uniform defines the webGL uniform location where to store the value
  30359. * @param x defines the 1st component of the value
  30360. * @param y defines the 2nd component of the value
  30361. * @param z defines the 3rd component of the value
  30362. * @param w defines the 4th component of the value
  30363. */
  30364. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30365. if (!uniform) {
  30366. return;
  30367. }
  30368. this._gl.uniform4f(uniform, x, y, z, w);
  30369. };
  30370. /**
  30371. * Set the value of an uniform to a Color3
  30372. * @param uniform defines the webGL uniform location where to store the value
  30373. * @param color3 defines the color to store
  30374. */
  30375. Engine.prototype.setColor3 = function (uniform, color3) {
  30376. if (!uniform) {
  30377. return;
  30378. }
  30379. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30380. };
  30381. /**
  30382. * Set the value of an uniform to a Color3 and an alpha value
  30383. * @param uniform defines the webGL uniform location where to store the value
  30384. * @param color3 defines the color to store
  30385. * @param alpha defines the alpha component to store
  30386. */
  30387. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30388. if (!uniform) {
  30389. return;
  30390. }
  30391. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30392. };
  30393. /**
  30394. * Sets a Color4 on a uniform variable
  30395. * @param uniform defines the uniform location
  30396. * @param color4 defines the value to be set
  30397. */
  30398. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30399. if (!uniform) {
  30400. return;
  30401. }
  30402. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30403. };
  30404. // States
  30405. /**
  30406. * Set various states to the webGL context
  30407. * @param culling defines backface culling state
  30408. * @param zOffset defines the value to apply to zOffset (0 by default)
  30409. * @param force defines if states must be applied even if cache is up to date
  30410. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30411. */
  30412. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30413. if (zOffset === void 0) { zOffset = 0; }
  30414. if (reverseSide === void 0) { reverseSide = false; }
  30415. // Culling
  30416. if (this._depthCullingState.cull !== culling || force) {
  30417. this._depthCullingState.cull = culling;
  30418. }
  30419. // Cull face
  30420. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30421. if (this._depthCullingState.cullFace !== cullFace || force) {
  30422. this._depthCullingState.cullFace = cullFace;
  30423. }
  30424. // Z offset
  30425. this.setZOffset(zOffset);
  30426. // Front face
  30427. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30428. if (this._depthCullingState.frontFace !== frontFace || force) {
  30429. this._depthCullingState.frontFace = frontFace;
  30430. }
  30431. };
  30432. /**
  30433. * Set the z offset to apply to current rendering
  30434. * @param value defines the offset to apply
  30435. */
  30436. Engine.prototype.setZOffset = function (value) {
  30437. this._depthCullingState.zOffset = value;
  30438. };
  30439. /**
  30440. * Gets the current value of the zOffset
  30441. * @returns the current zOffset state
  30442. */
  30443. Engine.prototype.getZOffset = function () {
  30444. return this._depthCullingState.zOffset;
  30445. };
  30446. /**
  30447. * Enable or disable depth buffering
  30448. * @param enable defines the state to set
  30449. */
  30450. Engine.prototype.setDepthBuffer = function (enable) {
  30451. this._depthCullingState.depthTest = enable;
  30452. };
  30453. /**
  30454. * Gets a boolean indicating if depth writing is enabled
  30455. * @returns the current depth writing state
  30456. */
  30457. Engine.prototype.getDepthWrite = function () {
  30458. return this._depthCullingState.depthMask;
  30459. };
  30460. /**
  30461. * Enable or disable depth writing
  30462. * @param enable defines the state to set
  30463. */
  30464. Engine.prototype.setDepthWrite = function (enable) {
  30465. this._depthCullingState.depthMask = enable;
  30466. };
  30467. /**
  30468. * Enable or disable color writing
  30469. * @param enable defines the state to set
  30470. */
  30471. Engine.prototype.setColorWrite = function (enable) {
  30472. this._gl.colorMask(enable, enable, enable, enable);
  30473. this._colorWrite = enable;
  30474. };
  30475. /**
  30476. * Gets a boolean indicating if color writing is enabled
  30477. * @returns the current color writing state
  30478. */
  30479. Engine.prototype.getColorWrite = function () {
  30480. return this._colorWrite;
  30481. };
  30482. /**
  30483. * Sets alpha constants used by some alpha blending modes
  30484. * @param r defines the red component
  30485. * @param g defines the green component
  30486. * @param b defines the blue component
  30487. * @param a defines the alpha component
  30488. */
  30489. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30490. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30491. };
  30492. /**
  30493. * Sets the current alpha mode
  30494. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30495. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30497. */
  30498. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30499. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30500. if (this._alphaMode === mode) {
  30501. return;
  30502. }
  30503. switch (mode) {
  30504. case Engine.ALPHA_DISABLE:
  30505. this._alphaState.alphaBlend = false;
  30506. break;
  30507. case Engine.ALPHA_PREMULTIPLIED:
  30508. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30509. this._alphaState.alphaBlend = true;
  30510. break;
  30511. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30512. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30513. this._alphaState.alphaBlend = true;
  30514. break;
  30515. case Engine.ALPHA_COMBINE:
  30516. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30517. this._alphaState.alphaBlend = true;
  30518. break;
  30519. case Engine.ALPHA_ONEONE:
  30520. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30521. this._alphaState.alphaBlend = true;
  30522. break;
  30523. case Engine.ALPHA_ADD:
  30524. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30525. this._alphaState.alphaBlend = true;
  30526. break;
  30527. case Engine.ALPHA_SUBTRACT:
  30528. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30529. this._alphaState.alphaBlend = true;
  30530. break;
  30531. case Engine.ALPHA_MULTIPLY:
  30532. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30533. this._alphaState.alphaBlend = true;
  30534. break;
  30535. case Engine.ALPHA_MAXIMIZED:
  30536. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30537. this._alphaState.alphaBlend = true;
  30538. break;
  30539. case Engine.ALPHA_INTERPOLATE:
  30540. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30541. this._alphaState.alphaBlend = true;
  30542. break;
  30543. case Engine.ALPHA_SCREENMODE:
  30544. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30545. this._alphaState.alphaBlend = true;
  30546. break;
  30547. }
  30548. if (!noDepthWriteChange) {
  30549. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30550. }
  30551. this._alphaMode = mode;
  30552. };
  30553. /**
  30554. * Gets the current alpha mode
  30555. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30556. * @returns the current alpha mode
  30557. */
  30558. Engine.prototype.getAlphaMode = function () {
  30559. return this._alphaMode;
  30560. };
  30561. // Textures
  30562. /**
  30563. * Clears the list of texture accessible through engine.
  30564. * This can help preventing texture load conflict due to name collision.
  30565. */
  30566. Engine.prototype.clearInternalTexturesCache = function () {
  30567. this._internalTexturesCache = [];
  30568. };
  30569. /**
  30570. * Force the entire cache to be cleared
  30571. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30572. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30573. */
  30574. Engine.prototype.wipeCaches = function (bruteForce) {
  30575. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30576. return;
  30577. }
  30578. this._currentEffect = null;
  30579. this._viewportCached.x = 0;
  30580. this._viewportCached.y = 0;
  30581. this._viewportCached.z = 0;
  30582. this._viewportCached.w = 0;
  30583. if (bruteForce) {
  30584. this.resetTextureCache();
  30585. this._currentProgram = null;
  30586. this._stencilState.reset();
  30587. this._depthCullingState.reset();
  30588. this.setDepthFunctionToLessOrEqual();
  30589. this._alphaState.reset();
  30590. this._unpackFlipYCached = null;
  30591. }
  30592. this._resetVertexBufferBinding();
  30593. this._cachedIndexBuffer = null;
  30594. this._cachedEffectForVertexBuffers = null;
  30595. this._unbindVertexArrayObject();
  30596. this.bindIndexBuffer(null);
  30597. };
  30598. /**
  30599. * Set the compressed texture format to use, based on the formats you have, and the formats
  30600. * supported by the hardware / browser.
  30601. *
  30602. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30603. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30604. * to API arguments needed to compressed textures. This puts the burden on the container
  30605. * generator to house the arcane code for determining these for current & future formats.
  30606. *
  30607. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30608. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30609. *
  30610. * Note: The result of this call is not taken into account when a texture is base64.
  30611. *
  30612. * @param formatsAvailable defines the list of those format families you have created
  30613. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30614. *
  30615. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30616. * @returns The extension selected.
  30617. */
  30618. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30619. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30620. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30621. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30622. return this._textureFormatInUse = this._texturesSupported[i];
  30623. }
  30624. }
  30625. }
  30626. // actively set format to nothing, to allow this to be called more than once
  30627. // and possibly fail the 2nd time
  30628. this._textureFormatInUse = null;
  30629. return null;
  30630. };
  30631. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30632. var gl = this._gl;
  30633. var magFilter = gl.NEAREST;
  30634. var minFilter = gl.NEAREST;
  30635. switch (samplingMode) {
  30636. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30637. magFilter = gl.LINEAR;
  30638. if (generateMipMaps) {
  30639. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30640. }
  30641. else {
  30642. minFilter = gl.LINEAR;
  30643. }
  30644. break;
  30645. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30646. magFilter = gl.LINEAR;
  30647. if (generateMipMaps) {
  30648. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30649. }
  30650. else {
  30651. minFilter = gl.LINEAR;
  30652. }
  30653. break;
  30654. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30655. magFilter = gl.NEAREST;
  30656. if (generateMipMaps) {
  30657. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30658. }
  30659. else {
  30660. minFilter = gl.NEAREST;
  30661. }
  30662. break;
  30663. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30664. magFilter = gl.NEAREST;
  30665. if (generateMipMaps) {
  30666. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30667. }
  30668. else {
  30669. minFilter = gl.NEAREST;
  30670. }
  30671. break;
  30672. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30673. magFilter = gl.NEAREST;
  30674. if (generateMipMaps) {
  30675. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30676. }
  30677. else {
  30678. minFilter = gl.LINEAR;
  30679. }
  30680. break;
  30681. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30682. magFilter = gl.NEAREST;
  30683. if (generateMipMaps) {
  30684. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30685. }
  30686. else {
  30687. minFilter = gl.LINEAR;
  30688. }
  30689. break;
  30690. case Engine.TEXTURE_NEAREST_LINEAR:
  30691. magFilter = gl.NEAREST;
  30692. minFilter = gl.LINEAR;
  30693. break;
  30694. case Engine.TEXTURE_NEAREST_NEAREST:
  30695. magFilter = gl.NEAREST;
  30696. minFilter = gl.NEAREST;
  30697. break;
  30698. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30699. magFilter = gl.LINEAR;
  30700. if (generateMipMaps) {
  30701. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30702. }
  30703. else {
  30704. minFilter = gl.NEAREST;
  30705. }
  30706. break;
  30707. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30708. magFilter = gl.LINEAR;
  30709. if (generateMipMaps) {
  30710. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30711. }
  30712. else {
  30713. minFilter = gl.NEAREST;
  30714. }
  30715. break;
  30716. case Engine.TEXTURE_LINEAR_LINEAR:
  30717. magFilter = gl.LINEAR;
  30718. minFilter = gl.LINEAR;
  30719. break;
  30720. case Engine.TEXTURE_LINEAR_NEAREST:
  30721. magFilter = gl.LINEAR;
  30722. minFilter = gl.NEAREST;
  30723. break;
  30724. }
  30725. return {
  30726. min: minFilter,
  30727. mag: magFilter
  30728. };
  30729. };
  30730. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30731. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30732. var img;
  30733. var onload = function () {
  30734. loadedImages[index] = img;
  30735. loadedImages._internalCount++;
  30736. if (scene) {
  30737. scene._removePendingData(img);
  30738. }
  30739. if (loadedImages._internalCount === 6) {
  30740. onfinish(loadedImages);
  30741. }
  30742. };
  30743. var onerror = function (message, exception) {
  30744. if (scene) {
  30745. scene._removePendingData(img);
  30746. }
  30747. if (onErrorCallBack) {
  30748. onErrorCallBack(message, exception);
  30749. }
  30750. };
  30751. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30752. if (scene) {
  30753. scene._addPendingData(img);
  30754. }
  30755. };
  30756. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30757. if (onError === void 0) { onError = null; }
  30758. var loadedImages = [];
  30759. loadedImages._internalCount = 0;
  30760. for (var index = 0; index < 6; index++) {
  30761. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30762. }
  30763. };
  30764. /** @hidden */
  30765. Engine.prototype._createTexture = function () {
  30766. var texture = this._gl.createTexture();
  30767. if (!texture) {
  30768. throw new Error("Unable to create texture");
  30769. }
  30770. return texture;
  30771. };
  30772. /**
  30773. * Usually called from Texture.ts.
  30774. * Passed information to create a WebGLTexture
  30775. * @param urlArg defines a value which contains one of the following:
  30776. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30777. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30778. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30779. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30780. * @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)
  30781. * @param scene needed for loading to the correct scene
  30782. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30783. * @param onLoad optional callback to be called upon successful completion
  30784. * @param onError optional callback to be called upon failure
  30785. * @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
  30786. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30787. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30788. * @param forcedExtension defines the extension to use to pick the right loader
  30789. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30790. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30791. */
  30792. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30793. var _this = this;
  30794. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30795. if (onLoad === void 0) { onLoad = null; }
  30796. if (onError === void 0) { onError = null; }
  30797. if (buffer === void 0) { buffer = null; }
  30798. if (fallback === void 0) { fallback = null; }
  30799. if (format === void 0) { format = null; }
  30800. if (forcedExtension === void 0) { forcedExtension = null; }
  30801. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30802. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30803. var fromData = url.substr(0, 5) === "data:";
  30804. var fromBlob = url.substr(0, 5) === "blob:";
  30805. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30806. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30807. // establish the file extension, if possible
  30808. var lastDot = url.lastIndexOf('.');
  30809. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30810. var loader = null;
  30811. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30812. var availableLoader = _a[_i];
  30813. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30814. loader = availableLoader;
  30815. break;
  30816. }
  30817. }
  30818. if (loader) {
  30819. url = loader.transformUrl(url, this._textureFormatInUse);
  30820. }
  30821. if (scene) {
  30822. scene._addPendingData(texture);
  30823. }
  30824. texture.url = url;
  30825. texture.generateMipMaps = !noMipmap;
  30826. texture.samplingMode = samplingMode;
  30827. texture.invertY = invertY;
  30828. if (!this._doNotHandleContextLost) {
  30829. // Keep a link to the buffer only if we plan to handle context lost
  30830. texture._buffer = buffer;
  30831. }
  30832. var onLoadObserver = null;
  30833. if (onLoad && !fallback) {
  30834. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30835. }
  30836. if (!fallback) {
  30837. this._internalTexturesCache.push(texture);
  30838. }
  30839. var onInternalError = function (message, exception) {
  30840. if (scene) {
  30841. scene._removePendingData(texture);
  30842. }
  30843. var customFallback = false;
  30844. if (loader) {
  30845. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30846. if (fallbackUrl) {
  30847. // Add Back
  30848. customFallback = true;
  30849. excludeLoaders.push(loader);
  30850. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  30851. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30852. }
  30853. }
  30854. if (!customFallback) {
  30855. if (onLoadObserver) {
  30856. texture.onLoadedObservable.remove(onLoadObserver);
  30857. }
  30858. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30859. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30860. }
  30861. }
  30862. if (onError) {
  30863. onError(message || "Unknown error", exception);
  30864. }
  30865. };
  30866. // processing for non-image formats
  30867. if (loader) {
  30868. var callback = function (data) {
  30869. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30870. if (loadFailed) {
  30871. onInternalError("TextureLoader failed to load data");
  30872. }
  30873. else {
  30874. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30875. done();
  30876. return false;
  30877. }, samplingMode);
  30878. }
  30879. });
  30880. };
  30881. if (!buffer) {
  30882. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30883. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30884. });
  30885. }
  30886. else {
  30887. callback(buffer);
  30888. }
  30889. }
  30890. else {
  30891. var onload = function (img) {
  30892. if (fromBlob && !_this._doNotHandleContextLost) {
  30893. // We need to store the image if we need to rebuild the texture
  30894. // in case of a webgl context lost
  30895. texture._buffer = img;
  30896. }
  30897. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30898. var gl = _this._gl;
  30899. var isPot = (img.width === potWidth && img.height === potHeight);
  30900. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30901. if (isPot) {
  30902. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30903. return false;
  30904. }
  30905. var maxTextureSize = _this._caps.maxTextureSize;
  30906. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30907. _this._prepareWorkingCanvas();
  30908. if (!_this._workingCanvas || !_this._workingContext) {
  30909. return false;
  30910. }
  30911. _this._workingCanvas.width = potWidth;
  30912. _this._workingCanvas.height = potHeight;
  30913. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30914. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30915. texture.width = potWidth;
  30916. texture.height = potHeight;
  30917. return false;
  30918. }
  30919. else {
  30920. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30921. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30922. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30923. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30924. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30925. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30926. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30927. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30928. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30929. _this._releaseTexture(source_1);
  30930. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30931. continuationCallback();
  30932. });
  30933. }
  30934. return true;
  30935. }, samplingMode);
  30936. };
  30937. if (!fromData || isBase64) {
  30938. if (buffer instanceof HTMLImageElement) {
  30939. onload(buffer);
  30940. }
  30941. else {
  30942. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30943. }
  30944. }
  30945. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30946. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30947. }
  30948. else {
  30949. onload(buffer);
  30950. }
  30951. }
  30952. return texture;
  30953. };
  30954. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30955. var _this = this;
  30956. var rtt = this.createRenderTargetTexture({
  30957. width: destination.width,
  30958. height: destination.height,
  30959. }, {
  30960. generateMipMaps: false,
  30961. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30962. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30963. generateDepthBuffer: false,
  30964. generateStencilBuffer: false
  30965. });
  30966. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  30967. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  30968. }
  30969. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  30970. _this._rescalePostProcess.onApply = function (effect) {
  30971. effect._bindTexture("textureSampler", source);
  30972. };
  30973. var hostingScene = scene;
  30974. if (!hostingScene) {
  30975. hostingScene = _this.scenes[_this.scenes.length - 1];
  30976. }
  30977. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  30978. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  30979. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  30980. _this.unBindFramebuffer(rtt);
  30981. _this._releaseTexture(rtt);
  30982. if (onComplete) {
  30983. onComplete();
  30984. }
  30985. });
  30986. };
  30987. /**
  30988. * Update a raw texture
  30989. * @param texture defines the texture to update
  30990. * @param data defines the data to store in the texture
  30991. * @param format defines the format of the data
  30992. * @param invertY defines if data must be stored with Y axis inverted
  30993. * @param compression defines the compression used (null by default)
  30994. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30995. */
  30996. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  30997. if (compression === void 0) { compression = null; }
  30998. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30999. if (!texture) {
  31000. return;
  31001. }
  31002. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31003. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31004. // babylon's internalFormat but gl's texImage2D format
  31005. var internalFormat = this._getInternalFormat(format);
  31006. var textureType = this._getWebGLTextureType(type);
  31007. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31008. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31009. if (!this._doNotHandleContextLost) {
  31010. texture._bufferView = data;
  31011. texture.format = format;
  31012. texture.type = type;
  31013. texture.invertY = invertY;
  31014. texture._compression = compression;
  31015. }
  31016. if (texture.width % 4 !== 0) {
  31017. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31018. }
  31019. if (compression && data) {
  31020. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31021. }
  31022. else {
  31023. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31024. }
  31025. if (texture.generateMipMaps) {
  31026. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31027. }
  31028. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31029. // this.resetTextureCache();
  31030. texture.isReady = true;
  31031. };
  31032. /**
  31033. * Creates a raw texture
  31034. * @param data defines the data to store in the texture
  31035. * @param width defines the width of the texture
  31036. * @param height defines the height of the texture
  31037. * @param format defines the format of the data
  31038. * @param generateMipMaps defines if the engine should generate the mip levels
  31039. * @param invertY defines if data must be stored with Y axis inverted
  31040. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31041. * @param compression defines the compression used (null by default)
  31042. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31043. * @returns the raw texture inside an InternalTexture
  31044. */
  31045. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31046. if (compression === void 0) { compression = null; }
  31047. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31048. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31049. texture.baseWidth = width;
  31050. texture.baseHeight = height;
  31051. texture.width = width;
  31052. texture.height = height;
  31053. texture.format = format;
  31054. texture.generateMipMaps = generateMipMaps;
  31055. texture.samplingMode = samplingMode;
  31056. texture.invertY = invertY;
  31057. texture._compression = compression;
  31058. texture.type = type;
  31059. if (!this._doNotHandleContextLost) {
  31060. texture._bufferView = data;
  31061. }
  31062. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31063. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31064. // Filters
  31065. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31066. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31067. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31068. if (generateMipMaps) {
  31069. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31070. }
  31071. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31072. this._internalTexturesCache.push(texture);
  31073. return texture;
  31074. };
  31075. /** @hidden */
  31076. Engine.prototype._unpackFlipY = function (value) {
  31077. if (this._unpackFlipYCached !== value) {
  31078. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31079. if (this.enableUnpackFlipYCached) {
  31080. this._unpackFlipYCached = value;
  31081. }
  31082. }
  31083. };
  31084. /** @hidden */
  31085. Engine.prototype._getUnpackAlignement = function () {
  31086. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31087. };
  31088. /**
  31089. * Creates a dynamic texture
  31090. * @param width defines the width of the texture
  31091. * @param height defines the height of the texture
  31092. * @param generateMipMaps defines if the engine should generate the mip levels
  31093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31094. * @returns the dynamic texture inside an InternalTexture
  31095. */
  31096. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31097. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31098. texture.baseWidth = width;
  31099. texture.baseHeight = height;
  31100. if (generateMipMaps) {
  31101. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31102. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31103. }
  31104. // this.resetTextureCache();
  31105. texture.width = width;
  31106. texture.height = height;
  31107. texture.isReady = false;
  31108. texture.generateMipMaps = generateMipMaps;
  31109. texture.samplingMode = samplingMode;
  31110. this.updateTextureSamplingMode(samplingMode, texture);
  31111. this._internalTexturesCache.push(texture);
  31112. return texture;
  31113. };
  31114. /**
  31115. * Update the sampling mode of a given texture
  31116. * @param samplingMode defines the required sampling mode
  31117. * @param texture defines the texture to update
  31118. */
  31119. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31120. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31121. if (texture.isCube) {
  31122. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31123. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31124. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31125. }
  31126. else if (texture.is3D) {
  31127. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31128. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31129. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31130. }
  31131. else {
  31132. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31133. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31134. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31135. }
  31136. texture.samplingMode = samplingMode;
  31137. };
  31138. /**
  31139. * Update the content of a dynamic texture
  31140. * @param texture defines the texture to update
  31141. * @param canvas defines the canvas containing the source
  31142. * @param invertY defines if data must be stored with Y axis inverted
  31143. * @param premulAlpha defines if alpha is stored as premultiplied
  31144. * @param format defines the format of the data
  31145. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31146. */
  31147. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31148. if (premulAlpha === void 0) { premulAlpha = false; }
  31149. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31150. if (!texture) {
  31151. return;
  31152. }
  31153. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31154. this._unpackFlipY(invertY);
  31155. if (premulAlpha) {
  31156. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31157. }
  31158. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31159. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31160. if (texture.generateMipMaps) {
  31161. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31162. }
  31163. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31164. if (premulAlpha) {
  31165. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31166. }
  31167. texture.isReady = true;
  31168. };
  31169. /**
  31170. * Update a video texture
  31171. * @param texture defines the texture to update
  31172. * @param video defines the video element to use
  31173. * @param invertY defines if data must be stored with Y axis inverted
  31174. */
  31175. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31176. if (!texture || texture._isDisabled) {
  31177. return;
  31178. }
  31179. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31180. this._unpackFlipY(!invertY); // Video are upside down by default
  31181. try {
  31182. // Testing video texture support
  31183. if (this._videoTextureSupported === undefined) {
  31184. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31185. if (this._gl.getError() !== 0) {
  31186. this._videoTextureSupported = false;
  31187. }
  31188. else {
  31189. this._videoTextureSupported = true;
  31190. }
  31191. }
  31192. // Copy video through the current working canvas if video texture is not supported
  31193. if (!this._videoTextureSupported) {
  31194. if (!texture._workingCanvas) {
  31195. texture._workingCanvas = document.createElement("canvas");
  31196. var context = texture._workingCanvas.getContext("2d");
  31197. if (!context) {
  31198. throw new Error("Unable to get 2d context");
  31199. }
  31200. texture._workingContext = context;
  31201. texture._workingCanvas.width = texture.width;
  31202. texture._workingCanvas.height = texture.height;
  31203. }
  31204. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31205. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31206. }
  31207. else {
  31208. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31209. }
  31210. if (texture.generateMipMaps) {
  31211. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31212. }
  31213. if (!wasPreviouslyBound) {
  31214. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31215. }
  31216. // this.resetTextureCache();
  31217. texture.isReady = true;
  31218. }
  31219. catch (ex) {
  31220. // Something unexpected
  31221. // Let's disable the texture
  31222. texture._isDisabled = true;
  31223. }
  31224. };
  31225. /**
  31226. * Updates a depth texture Comparison Mode and Function.
  31227. * If the comparison Function is equal to 0, the mode will be set to none.
  31228. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31229. * @param texture The texture to set the comparison function for
  31230. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31231. */
  31232. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31233. if (this.webGLVersion === 1) {
  31234. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31235. return;
  31236. }
  31237. var gl = this._gl;
  31238. if (texture.isCube) {
  31239. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31240. if (comparisonFunction === 0) {
  31241. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31242. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31243. }
  31244. else {
  31245. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31246. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31247. }
  31248. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31249. }
  31250. else {
  31251. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31252. if (comparisonFunction === 0) {
  31253. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31254. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31255. }
  31256. else {
  31257. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31258. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31259. }
  31260. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31261. }
  31262. texture._comparisonFunction = comparisonFunction;
  31263. };
  31264. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31265. var width = size.width || size;
  31266. var height = size.height || size;
  31267. internalTexture.baseWidth = width;
  31268. internalTexture.baseHeight = height;
  31269. internalTexture.width = width;
  31270. internalTexture.height = height;
  31271. internalTexture.isReady = true;
  31272. internalTexture.samples = 1;
  31273. internalTexture.generateMipMaps = false;
  31274. internalTexture._generateDepthBuffer = true;
  31275. internalTexture._generateStencilBuffer = generateStencil;
  31276. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31277. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31278. internalTexture._comparisonFunction = comparisonFunction;
  31279. var gl = this._gl;
  31280. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31281. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31282. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31283. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31284. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31285. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31286. if (comparisonFunction === 0) {
  31287. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31288. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31289. }
  31290. else {
  31291. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31292. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31293. }
  31294. };
  31295. /**
  31296. * Creates a depth stencil texture.
  31297. * This is only available in WebGL 2 or with the depth texture extension available.
  31298. * @param size The size of face edge in the texture.
  31299. * @param options The options defining the texture.
  31300. * @returns The texture
  31301. */
  31302. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31303. if (options.isCube) {
  31304. var width = size.width || size;
  31305. return this._createDepthStencilCubeTexture(width, options);
  31306. }
  31307. else {
  31308. return this._createDepthStencilTexture(size, options);
  31309. }
  31310. };
  31311. /**
  31312. * Creates a depth stencil texture.
  31313. * This is only available in WebGL 2 or with the depth texture extension available.
  31314. * @param size The size of face edge in the texture.
  31315. * @param options The options defining the texture.
  31316. * @returns The texture
  31317. */
  31318. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31319. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31320. if (!this._caps.depthTextureExtension) {
  31321. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31322. return internalTexture;
  31323. }
  31324. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31325. var gl = this._gl;
  31326. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31327. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31328. if (this.webGLVersion > 1) {
  31329. if (internalOptions.generateStencil) {
  31330. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31331. }
  31332. else {
  31333. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31334. }
  31335. }
  31336. else {
  31337. if (internalOptions.generateStencil) {
  31338. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31339. }
  31340. else {
  31341. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31342. }
  31343. }
  31344. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31345. return internalTexture;
  31346. };
  31347. /**
  31348. * Creates a depth stencil cube texture.
  31349. * This is only available in WebGL 2.
  31350. * @param size The size of face edge in the cube texture.
  31351. * @param options The options defining the cube texture.
  31352. * @returns The cube texture
  31353. */
  31354. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31355. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31356. internalTexture.isCube = true;
  31357. if (this.webGLVersion === 1) {
  31358. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31359. return internalTexture;
  31360. }
  31361. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31362. var gl = this._gl;
  31363. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31364. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31365. // Create the depth/stencil buffer
  31366. for (var face = 0; face < 6; face++) {
  31367. if (internalOptions.generateStencil) {
  31368. 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);
  31369. }
  31370. else {
  31371. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31372. }
  31373. }
  31374. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31375. return internalTexture;
  31376. };
  31377. /**
  31378. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31379. * @param renderTarget The render target to set the frame buffer for
  31380. */
  31381. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31382. // Create the framebuffer
  31383. var internalTexture = renderTarget.getInternalTexture();
  31384. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31385. return;
  31386. }
  31387. var gl = this._gl;
  31388. var depthStencilTexture = renderTarget.depthStencilTexture;
  31389. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31390. if (depthStencilTexture.isCube) {
  31391. if (depthStencilTexture._generateStencilBuffer) {
  31392. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31393. }
  31394. else {
  31395. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31396. }
  31397. }
  31398. else {
  31399. if (depthStencilTexture._generateStencilBuffer) {
  31400. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31401. }
  31402. else {
  31403. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31404. }
  31405. }
  31406. this.bindUnboundFramebuffer(null);
  31407. };
  31408. /**
  31409. * Creates a new render target texture
  31410. * @param size defines the size of the texture
  31411. * @param options defines the options used to create the texture
  31412. * @returns a new render target texture stored in an InternalTexture
  31413. */
  31414. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31415. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31416. if (options !== undefined && typeof options === "object") {
  31417. fullOptions.generateMipMaps = options.generateMipMaps;
  31418. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31419. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31420. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31421. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31422. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31423. }
  31424. else {
  31425. fullOptions.generateMipMaps = options;
  31426. fullOptions.generateDepthBuffer = true;
  31427. fullOptions.generateStencilBuffer = false;
  31428. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31429. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31430. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31431. }
  31432. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31433. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31434. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31435. }
  31436. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31437. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31438. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31439. }
  31440. var gl = this._gl;
  31441. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31442. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31443. var width = size.width || size;
  31444. var height = size.height || size;
  31445. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31446. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31447. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31448. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31449. }
  31450. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31451. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31452. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31453. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31454. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31455. // Create the framebuffer
  31456. var currentFrameBuffer = this._currentFramebuffer;
  31457. var framebuffer = gl.createFramebuffer();
  31458. this.bindUnboundFramebuffer(framebuffer);
  31459. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31460. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31461. if (fullOptions.generateMipMaps) {
  31462. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31463. }
  31464. // Unbind
  31465. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31466. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31467. this.bindUnboundFramebuffer(currentFrameBuffer);
  31468. texture._framebuffer = framebuffer;
  31469. texture.baseWidth = width;
  31470. texture.baseHeight = height;
  31471. texture.width = width;
  31472. texture.height = height;
  31473. texture.isReady = true;
  31474. texture.samples = 1;
  31475. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31476. texture.samplingMode = fullOptions.samplingMode;
  31477. texture.type = fullOptions.type;
  31478. texture.format = fullOptions.format;
  31479. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31480. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31481. // this.resetTextureCache();
  31482. this._internalTexturesCache.push(texture);
  31483. return texture;
  31484. };
  31485. /**
  31486. * Create a multi render target texture
  31487. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31488. * @param size defines the size of the texture
  31489. * @param options defines the creation options
  31490. * @returns the cube texture as an InternalTexture
  31491. */
  31492. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31493. var generateMipMaps = false;
  31494. var generateDepthBuffer = true;
  31495. var generateStencilBuffer = false;
  31496. var generateDepthTexture = false;
  31497. var textureCount = 1;
  31498. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31499. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31500. var types = new Array();
  31501. var samplingModes = new Array();
  31502. if (options !== undefined) {
  31503. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31504. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31505. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31506. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31507. textureCount = options.textureCount || 1;
  31508. if (options.types) {
  31509. types = options.types;
  31510. }
  31511. if (options.samplingModes) {
  31512. samplingModes = options.samplingModes;
  31513. }
  31514. }
  31515. var gl = this._gl;
  31516. // Create the framebuffer
  31517. var framebuffer = gl.createFramebuffer();
  31518. this.bindUnboundFramebuffer(framebuffer);
  31519. var width = size.width || size;
  31520. var height = size.height || size;
  31521. var textures = [];
  31522. var attachments = [];
  31523. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31524. for (var i = 0; i < textureCount; i++) {
  31525. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31526. var type = types[i] || defaultType;
  31527. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31528. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31529. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31530. }
  31531. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31532. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31533. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31534. }
  31535. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31536. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31537. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31538. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31539. }
  31540. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31541. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31542. textures.push(texture);
  31543. attachments.push(attachment);
  31544. gl.activeTexture(gl["TEXTURE" + i]);
  31545. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31546. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31547. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31548. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31549. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31550. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31551. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31552. if (generateMipMaps) {
  31553. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31554. }
  31555. // Unbind
  31556. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31557. texture._framebuffer = framebuffer;
  31558. texture._depthStencilBuffer = depthStencilBuffer;
  31559. texture.baseWidth = width;
  31560. texture.baseHeight = height;
  31561. texture.width = width;
  31562. texture.height = height;
  31563. texture.isReady = true;
  31564. texture.samples = 1;
  31565. texture.generateMipMaps = generateMipMaps;
  31566. texture.samplingMode = samplingMode;
  31567. texture.type = type;
  31568. texture._generateDepthBuffer = generateDepthBuffer;
  31569. texture._generateStencilBuffer = generateStencilBuffer;
  31570. texture._attachments = attachments;
  31571. this._internalTexturesCache.push(texture);
  31572. }
  31573. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31574. // Depth texture
  31575. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31576. gl.activeTexture(gl.TEXTURE0);
  31577. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31578. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31579. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31580. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31581. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31582. 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);
  31583. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31584. depthTexture._framebuffer = framebuffer;
  31585. depthTexture.baseWidth = width;
  31586. depthTexture.baseHeight = height;
  31587. depthTexture.width = width;
  31588. depthTexture.height = height;
  31589. depthTexture.isReady = true;
  31590. depthTexture.samples = 1;
  31591. depthTexture.generateMipMaps = generateMipMaps;
  31592. depthTexture.samplingMode = gl.NEAREST;
  31593. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31594. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31595. textures.push(depthTexture);
  31596. this._internalTexturesCache.push(depthTexture);
  31597. }
  31598. gl.drawBuffers(attachments);
  31599. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31600. this.bindUnboundFramebuffer(null);
  31601. this.resetTextureCache();
  31602. return textures;
  31603. };
  31604. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31605. if (samples === void 0) { samples = 1; }
  31606. var depthStencilBuffer = null;
  31607. var gl = this._gl;
  31608. // Create the depth/stencil buffer
  31609. if (generateStencilBuffer) {
  31610. depthStencilBuffer = gl.createRenderbuffer();
  31611. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31612. if (samples > 1) {
  31613. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31614. }
  31615. else {
  31616. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31617. }
  31618. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31619. }
  31620. else if (generateDepthBuffer) {
  31621. depthStencilBuffer = gl.createRenderbuffer();
  31622. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31623. if (samples > 1) {
  31624. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31625. }
  31626. else {
  31627. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31628. }
  31629. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31630. }
  31631. return depthStencilBuffer;
  31632. };
  31633. /**
  31634. * Updates the sample count of a render target texture
  31635. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31636. * @param texture defines the texture to update
  31637. * @param samples defines the sample count to set
  31638. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31639. */
  31640. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31641. if (this.webGLVersion < 2 || !texture) {
  31642. return 1;
  31643. }
  31644. if (texture.samples === samples) {
  31645. return samples;
  31646. }
  31647. var gl = this._gl;
  31648. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31649. // Dispose previous render buffers
  31650. if (texture._depthStencilBuffer) {
  31651. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31652. texture._depthStencilBuffer = null;
  31653. }
  31654. if (texture._MSAAFramebuffer) {
  31655. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31656. texture._MSAAFramebuffer = null;
  31657. }
  31658. if (texture._MSAARenderBuffer) {
  31659. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31660. texture._MSAARenderBuffer = null;
  31661. }
  31662. if (samples > 1) {
  31663. var framebuffer = gl.createFramebuffer();
  31664. if (!framebuffer) {
  31665. throw new Error("Unable to create multi sampled framebuffer");
  31666. }
  31667. texture._MSAAFramebuffer = framebuffer;
  31668. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31669. var colorRenderbuffer = gl.createRenderbuffer();
  31670. if (!colorRenderbuffer) {
  31671. throw new Error("Unable to create multi sampled framebuffer");
  31672. }
  31673. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31674. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31675. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31676. texture._MSAARenderBuffer = colorRenderbuffer;
  31677. }
  31678. else {
  31679. this.bindUnboundFramebuffer(texture._framebuffer);
  31680. }
  31681. texture.samples = samples;
  31682. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31683. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31684. this.bindUnboundFramebuffer(null);
  31685. return samples;
  31686. };
  31687. /**
  31688. * Update the sample count for a given multiple render target texture
  31689. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31690. * @param textures defines the textures to update
  31691. * @param samples defines the sample count to set
  31692. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31693. */
  31694. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31695. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31696. return 1;
  31697. }
  31698. if (textures[0].samples === samples) {
  31699. return samples;
  31700. }
  31701. var gl = this._gl;
  31702. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31703. // Dispose previous render buffers
  31704. if (textures[0]._depthStencilBuffer) {
  31705. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31706. textures[0]._depthStencilBuffer = null;
  31707. }
  31708. if (textures[0]._MSAAFramebuffer) {
  31709. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31710. textures[0]._MSAAFramebuffer = null;
  31711. }
  31712. for (var i = 0; i < textures.length; i++) {
  31713. if (textures[i]._MSAARenderBuffer) {
  31714. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31715. textures[i]._MSAARenderBuffer = null;
  31716. }
  31717. }
  31718. if (samples > 1) {
  31719. var framebuffer = gl.createFramebuffer();
  31720. if (!framebuffer) {
  31721. throw new Error("Unable to create multi sampled framebuffer");
  31722. }
  31723. this.bindUnboundFramebuffer(framebuffer);
  31724. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31725. var attachments = [];
  31726. for (var i = 0; i < textures.length; i++) {
  31727. var texture = textures[i];
  31728. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31729. var colorRenderbuffer = gl.createRenderbuffer();
  31730. if (!colorRenderbuffer) {
  31731. throw new Error("Unable to create multi sampled framebuffer");
  31732. }
  31733. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31734. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31735. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31736. texture._MSAAFramebuffer = framebuffer;
  31737. texture._MSAARenderBuffer = colorRenderbuffer;
  31738. texture.samples = samples;
  31739. texture._depthStencilBuffer = depthStencilBuffer;
  31740. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31741. attachments.push(attachment);
  31742. }
  31743. gl.drawBuffers(attachments);
  31744. }
  31745. else {
  31746. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31747. }
  31748. this.bindUnboundFramebuffer(null);
  31749. return samples;
  31750. };
  31751. /** @hidden */
  31752. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31753. if (faceIndex === void 0) { faceIndex = 0; }
  31754. if (lod === void 0) { lod = 0; }
  31755. var gl = this._gl;
  31756. var target = gl.TEXTURE_2D;
  31757. if (texture.isCube) {
  31758. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31759. }
  31760. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31761. };
  31762. /** @hidden */
  31763. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31764. if (faceIndex === void 0) { faceIndex = 0; }
  31765. if (lod === void 0) { lod = 0; }
  31766. var gl = this._gl;
  31767. var textureType = this._getWebGLTextureType(texture.type);
  31768. var format = this._getInternalFormat(texture.format);
  31769. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31770. this._unpackFlipY(texture.invertY);
  31771. var target = gl.TEXTURE_2D;
  31772. if (texture.isCube) {
  31773. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31774. }
  31775. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31776. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31777. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31778. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31779. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31780. };
  31781. /** @hidden */
  31782. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31783. if (faceIndex === void 0) { faceIndex = 0; }
  31784. if (lod === void 0) { lod = 0; }
  31785. var gl = this._gl;
  31786. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31787. this._bindTextureDirectly(bindTarget, texture, true);
  31788. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31789. this._bindTextureDirectly(bindTarget, null, true);
  31790. };
  31791. /** @hidden */
  31792. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31793. if (faceIndex === void 0) { faceIndex = 0; }
  31794. if (lod === void 0) { lod = 0; }
  31795. var gl = this._gl;
  31796. var textureType = this._getWebGLTextureType(texture.type);
  31797. var format = this._getInternalFormat(texture.format);
  31798. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31799. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31800. this._bindTextureDirectly(bindTarget, texture, true);
  31801. this._unpackFlipY(texture.invertY);
  31802. var target = gl.TEXTURE_2D;
  31803. if (texture.isCube) {
  31804. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31805. }
  31806. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31807. this._bindTextureDirectly(bindTarget, null, true);
  31808. };
  31809. /**
  31810. * Creates a new render target cube texture
  31811. * @param size defines the size of the texture
  31812. * @param options defines the options used to create the texture
  31813. * @returns a new render target cube texture stored in an InternalTexture
  31814. */
  31815. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31816. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ generateMipMaps: true, generateDepthBuffer: true, generateStencilBuffer: false, type: Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode: Engine.TEXTURE_TRILINEAR_SAMPLINGMODE, format: Engine.TEXTUREFORMAT_RGBA }, options);
  31817. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31818. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31819. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31820. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31821. }
  31822. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31823. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31824. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31825. }
  31826. var gl = this._gl;
  31827. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31828. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31829. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31830. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31831. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31832. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31833. }
  31834. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31835. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31836. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31837. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31838. for (var face = 0; face < 6; face++) {
  31839. 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);
  31840. }
  31841. // Create the framebuffer
  31842. var framebuffer = gl.createFramebuffer();
  31843. this.bindUnboundFramebuffer(framebuffer);
  31844. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31845. // MipMaps
  31846. if (fullOptions.generateMipMaps) {
  31847. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31848. }
  31849. // Unbind
  31850. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31851. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31852. this.bindUnboundFramebuffer(null);
  31853. texture._framebuffer = framebuffer;
  31854. texture.width = size;
  31855. texture.height = size;
  31856. texture.isReady = true;
  31857. texture.isCube = true;
  31858. texture.samples = 1;
  31859. texture.generateMipMaps = fullOptions.generateMipMaps;
  31860. texture.samplingMode = fullOptions.samplingMode;
  31861. texture.type = fullOptions.type;
  31862. texture.format = fullOptions.format;
  31863. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31864. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31865. this._internalTexturesCache.push(texture);
  31866. return texture;
  31867. };
  31868. /**
  31869. * Creates a cube texture
  31870. * @param rootUrl defines the url where the files to load is located
  31871. * @param scene defines the current scene
  31872. * @param files defines the list of files to load (1 per face)
  31873. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31874. * @param onLoad defines an optional callback raised when the texture is loaded
  31875. * @param onError defines an optional callback raised if there is an issue to load the texture
  31876. * @param format defines the format of the data
  31877. * @param forcedExtension defines the extension to use to pick the right loader
  31878. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31879. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31880. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31881. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31882. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31883. * @returns the cube texture as an InternalTexture
  31884. */
  31885. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31886. var _this = this;
  31887. if (onLoad === void 0) { onLoad = null; }
  31888. if (onError === void 0) { onError = null; }
  31889. if (forcedExtension === void 0) { forcedExtension = null; }
  31890. if (createPolynomials === void 0) { createPolynomials = false; }
  31891. if (lodScale === void 0) { lodScale = 0; }
  31892. if (lodOffset === void 0) { lodOffset = 0; }
  31893. if (fallback === void 0) { fallback = null; }
  31894. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31895. var gl = this._gl;
  31896. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31897. texture.isCube = true;
  31898. texture.url = rootUrl;
  31899. texture.generateMipMaps = !noMipmap;
  31900. texture._lodGenerationScale = lodScale;
  31901. texture._lodGenerationOffset = lodOffset;
  31902. if (!this._doNotHandleContextLost) {
  31903. texture._extension = forcedExtension;
  31904. texture._files = files;
  31905. }
  31906. var lastDot = rootUrl.lastIndexOf('.');
  31907. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31908. var loader = null;
  31909. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31910. var availableLoader = _a[_i];
  31911. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31912. loader = availableLoader;
  31913. break;
  31914. }
  31915. }
  31916. var onInternalError = function (request, exception) {
  31917. if (loader) {
  31918. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31919. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  31920. if (fallbackUrl) {
  31921. excludeLoaders.push(loader);
  31922. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31923. return;
  31924. }
  31925. }
  31926. if (onError && request) {
  31927. onError(request.status + " " + request.statusText, exception);
  31928. }
  31929. };
  31930. if (loader) {
  31931. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31932. var onloaddata = function (data) {
  31933. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31934. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31935. };
  31936. if (files && files.length === 6) {
  31937. if (loader.supportCascades) {
  31938. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31939. }
  31940. else if (onError) {
  31941. onError("Textures type does not support cascades.");
  31942. }
  31943. }
  31944. else {
  31945. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31946. }
  31947. }
  31948. else {
  31949. if (!files) {
  31950. throw new Error("Cannot load cubemap because files were not defined");
  31951. }
  31952. this._cascadeLoadImgs(scene, function (imgs) {
  31953. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31954. var height = width;
  31955. _this._prepareWorkingCanvas();
  31956. if (!_this._workingCanvas || !_this._workingContext) {
  31957. return;
  31958. }
  31959. _this._workingCanvas.width = width;
  31960. _this._workingCanvas.height = height;
  31961. var faces = [
  31962. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31963. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31964. ];
  31965. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31966. _this._unpackFlipY(false);
  31967. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  31968. for (var index = 0; index < faces.length; index++) {
  31969. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  31970. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31971. }
  31972. if (!noMipmap) {
  31973. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31974. }
  31975. _this._setCubeMapTextureParams(!noMipmap);
  31976. texture.width = width;
  31977. texture.height = height;
  31978. texture.isReady = true;
  31979. if (format) {
  31980. texture.format = format;
  31981. }
  31982. texture.onLoadedObservable.notifyObservers(texture);
  31983. texture.onLoadedObservable.clear();
  31984. if (onLoad) {
  31985. onLoad();
  31986. }
  31987. }, files, onError);
  31988. }
  31989. this._internalTexturesCache.push(texture);
  31990. return texture;
  31991. };
  31992. /**
  31993. * @hidden
  31994. */
  31995. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  31996. var gl = this._gl;
  31997. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31998. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  31999. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32000. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32001. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32002. // this.resetTextureCache();
  32003. };
  32004. /**
  32005. * Update a raw cube texture
  32006. * @param texture defines the texture to udpdate
  32007. * @param data defines the data to store
  32008. * @param format defines the data format
  32009. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32010. * @param invertY defines if data must be stored with Y axis inverted
  32011. * @param compression defines the compression used (null by default)
  32012. * @param level defines which level of the texture to update
  32013. */
  32014. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32015. if (compression === void 0) { compression = null; }
  32016. if (level === void 0) { level = 0; }
  32017. texture._bufferViewArray = data;
  32018. texture.format = format;
  32019. texture.type = type;
  32020. texture.invertY = invertY;
  32021. texture._compression = compression;
  32022. var gl = this._gl;
  32023. var textureType = this._getWebGLTextureType(type);
  32024. var internalFormat = this._getInternalFormat(format);
  32025. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32026. var needConversion = false;
  32027. if (internalFormat === gl.RGB) {
  32028. internalFormat = gl.RGBA;
  32029. needConversion = true;
  32030. }
  32031. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32032. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32033. if (texture.width % 4 !== 0) {
  32034. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32035. }
  32036. // Data are known to be in +X +Y +Z -X -Y -Z
  32037. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32038. var faceData = data[faceIndex];
  32039. if (compression) {
  32040. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32041. }
  32042. else {
  32043. if (needConversion) {
  32044. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32045. }
  32046. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32047. }
  32048. }
  32049. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32050. if (isPot && texture.generateMipMaps && level === 0) {
  32051. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32052. }
  32053. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32054. // this.resetTextureCache();
  32055. texture.isReady = true;
  32056. };
  32057. /**
  32058. * Creates a new raw cube texture
  32059. * @param data defines the array of data to use to create each face
  32060. * @param size defines the size of the textures
  32061. * @param format defines the format of the data
  32062. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32063. * @param generateMipMaps defines if the engine should generate the mip levels
  32064. * @param invertY defines if data must be stored with Y axis inverted
  32065. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32066. * @param compression defines the compression used (null by default)
  32067. * @returns the cube texture as an InternalTexture
  32068. */
  32069. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32070. if (compression === void 0) { compression = null; }
  32071. var gl = this._gl;
  32072. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32073. texture.isCube = true;
  32074. texture.format = format;
  32075. texture.type = type;
  32076. if (!this._doNotHandleContextLost) {
  32077. texture._bufferViewArray = data;
  32078. }
  32079. var textureType = this._getWebGLTextureType(type);
  32080. var internalFormat = this._getInternalFormat(format);
  32081. if (internalFormat === gl.RGB) {
  32082. internalFormat = gl.RGBA;
  32083. }
  32084. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32085. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32086. generateMipMaps = false;
  32087. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32088. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  32089. }
  32090. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32091. generateMipMaps = false;
  32092. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32093. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  32094. }
  32095. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32096. generateMipMaps = false;
  32097. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32098. }
  32099. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32100. generateMipMaps = false;
  32101. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32102. }
  32103. var width = size;
  32104. var height = width;
  32105. texture.width = width;
  32106. texture.height = height;
  32107. // Double check on POT to generate Mips.
  32108. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32109. if (!isPot) {
  32110. generateMipMaps = false;
  32111. }
  32112. // Upload data if needed. The texture won't be ready until then.
  32113. if (data) {
  32114. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32115. }
  32116. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32117. // Filters
  32118. if (data && generateMipMaps) {
  32119. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32120. }
  32121. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32122. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32123. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32124. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32125. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32126. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32127. texture.generateMipMaps = generateMipMaps;
  32128. return texture;
  32129. };
  32130. /**
  32131. * Creates a new raw cube texture from a specified url
  32132. * @param url defines the url where the data is located
  32133. * @param scene defines the current scene
  32134. * @param size defines the size of the textures
  32135. * @param format defines the format of the data
  32136. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32137. * @param noMipmap defines if the engine should avoid generating the mip levels
  32138. * @param callback defines a callback used to extract texture data from loaded data
  32139. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32140. * @param onLoad defines a callback called when texture is loaded
  32141. * @param onError defines a callback called if there is an error
  32142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @returns the cube texture as an InternalTexture
  32145. */
  32146. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32147. var _this = this;
  32148. if (onLoad === void 0) { onLoad = null; }
  32149. if (onError === void 0) { onError = null; }
  32150. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32151. if (invertY === void 0) { invertY = false; }
  32152. var gl = this._gl;
  32153. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32154. scene._addPendingData(texture);
  32155. texture.url = url;
  32156. this._internalTexturesCache.push(texture);
  32157. var onerror = function (request, exception) {
  32158. scene._removePendingData(texture);
  32159. if (onError && request) {
  32160. onError(request.status + " " + request.statusText, exception);
  32161. }
  32162. };
  32163. var internalCallback = function (data) {
  32164. var width = texture.width;
  32165. var faceDataArrays = callback(data);
  32166. if (!faceDataArrays) {
  32167. return;
  32168. }
  32169. if (mipmapGenerator) {
  32170. var textureType = _this._getWebGLTextureType(type);
  32171. var internalFormat = _this._getInternalFormat(format);
  32172. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32173. var needConversion = false;
  32174. if (internalFormat === gl.RGB) {
  32175. internalFormat = gl.RGBA;
  32176. needConversion = true;
  32177. }
  32178. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32179. _this._unpackFlipY(false);
  32180. var mipData = mipmapGenerator(faceDataArrays);
  32181. for (var level = 0; level < mipData.length; level++) {
  32182. var mipSize = width >> level;
  32183. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32184. var mipFaceData = mipData[level][faceIndex];
  32185. if (needConversion) {
  32186. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32187. }
  32188. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32189. }
  32190. }
  32191. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32192. }
  32193. else {
  32194. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32195. }
  32196. texture.isReady = true;
  32197. // this.resetTextureCache();
  32198. scene._removePendingData(texture);
  32199. if (onLoad) {
  32200. onLoad();
  32201. }
  32202. };
  32203. this._loadFile(url, function (data) {
  32204. internalCallback(data);
  32205. }, undefined, scene.offlineProvider, true, onerror);
  32206. return texture;
  32207. };
  32208. /**
  32209. * Update a raw 3D texture
  32210. * @param texture defines the texture to update
  32211. * @param data defines the data to store
  32212. * @param format defines the data format
  32213. * @param invertY defines if data must be stored with Y axis inverted
  32214. * @param compression defines the used compression (can be null)
  32215. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32216. */
  32217. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32218. if (compression === void 0) { compression = null; }
  32219. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32220. var internalType = this._getWebGLTextureType(textureType);
  32221. var internalFormat = this._getInternalFormat(format);
  32222. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32223. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32224. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32225. if (!this._doNotHandleContextLost) {
  32226. texture._bufferView = data;
  32227. texture.format = format;
  32228. texture.invertY = invertY;
  32229. texture._compression = compression;
  32230. }
  32231. if (texture.width % 4 !== 0) {
  32232. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32233. }
  32234. if (compression && data) {
  32235. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32236. }
  32237. else {
  32238. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32239. }
  32240. if (texture.generateMipMaps) {
  32241. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32242. }
  32243. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32244. // this.resetTextureCache();
  32245. texture.isReady = true;
  32246. };
  32247. /**
  32248. * Creates a new raw 3D texture
  32249. * @param data defines the data used to create the texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param depth defines the depth of the texture
  32253. * @param format defines the format of the texture
  32254. * @param generateMipMaps defines if the engine must generate mip levels
  32255. * @param invertY defines if data must be stored with Y axis inverted
  32256. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32257. * @param compression defines the compressed used (can be null)
  32258. * @param textureType defines the compressed used (can be null)
  32259. * @returns a new raw 3D texture (stored in an InternalTexture)
  32260. */
  32261. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32262. if (compression === void 0) { compression = null; }
  32263. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32264. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32265. texture.baseWidth = width;
  32266. texture.baseHeight = height;
  32267. texture.baseDepth = depth;
  32268. texture.width = width;
  32269. texture.height = height;
  32270. texture.depth = depth;
  32271. texture.format = format;
  32272. texture.type = textureType;
  32273. texture.generateMipMaps = generateMipMaps;
  32274. texture.samplingMode = samplingMode;
  32275. texture.is3D = true;
  32276. if (!this._doNotHandleContextLost) {
  32277. texture._bufferView = data;
  32278. }
  32279. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32280. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32281. // Filters
  32282. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32283. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32284. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32285. if (generateMipMaps) {
  32286. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32287. }
  32288. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32289. this._internalTexturesCache.push(texture);
  32290. return texture;
  32291. };
  32292. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32293. var gl = this._gl;
  32294. if (!gl) {
  32295. return;
  32296. }
  32297. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32298. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32299. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32300. if (!noMipmap && !isCompressed) {
  32301. gl.generateMipmap(gl.TEXTURE_2D);
  32302. }
  32303. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32304. // this.resetTextureCache();
  32305. if (scene) {
  32306. scene._removePendingData(texture);
  32307. }
  32308. texture.onLoadedObservable.notifyObservers(texture);
  32309. texture.onLoadedObservable.clear();
  32310. };
  32311. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32312. var _this = this;
  32313. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32314. var maxTextureSize = this.getCaps().maxTextureSize;
  32315. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32316. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32317. var gl = this._gl;
  32318. if (!gl) {
  32319. return;
  32320. }
  32321. if (!texture._webGLTexture) {
  32322. // this.resetTextureCache();
  32323. if (scene) {
  32324. scene._removePendingData(texture);
  32325. }
  32326. return;
  32327. }
  32328. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32329. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32330. texture.baseWidth = width;
  32331. texture.baseHeight = height;
  32332. texture.width = potWidth;
  32333. texture.height = potHeight;
  32334. texture.isReady = true;
  32335. if (processFunction(potWidth, potHeight, function () {
  32336. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32337. })) {
  32338. // Returning as texture needs extra async steps
  32339. return;
  32340. }
  32341. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32342. };
  32343. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32344. // Create new RGBA data container.
  32345. var rgbaData;
  32346. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32347. rgbaData = new Float32Array(width * height * 4);
  32348. }
  32349. else {
  32350. rgbaData = new Uint32Array(width * height * 4);
  32351. }
  32352. // Convert each pixel.
  32353. for (var x = 0; x < width; x++) {
  32354. for (var y = 0; y < height; y++) {
  32355. var index = (y * width + x) * 3;
  32356. var newIndex = (y * width + x) * 4;
  32357. // Map Old Value to new value.
  32358. rgbaData[newIndex + 0] = rgbData[index + 0];
  32359. rgbaData[newIndex + 1] = rgbData[index + 1];
  32360. rgbaData[newIndex + 2] = rgbData[index + 2];
  32361. // Add fully opaque alpha channel.
  32362. rgbaData[newIndex + 3] = 1;
  32363. }
  32364. }
  32365. return rgbaData;
  32366. };
  32367. /** @hidden */
  32368. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32369. var gl = this._gl;
  32370. if (texture._framebuffer) {
  32371. gl.deleteFramebuffer(texture._framebuffer);
  32372. texture._framebuffer = null;
  32373. }
  32374. if (texture._depthStencilBuffer) {
  32375. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32376. texture._depthStencilBuffer = null;
  32377. }
  32378. if (texture._MSAAFramebuffer) {
  32379. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32380. texture._MSAAFramebuffer = null;
  32381. }
  32382. if (texture._MSAARenderBuffer) {
  32383. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32384. texture._MSAARenderBuffer = null;
  32385. }
  32386. };
  32387. /** @hidden */
  32388. Engine.prototype._releaseTexture = function (texture) {
  32389. var gl = this._gl;
  32390. this._releaseFramebufferObjects(texture);
  32391. gl.deleteTexture(texture._webGLTexture);
  32392. // Unbind channels
  32393. this.unbindAllTextures();
  32394. var index = this._internalTexturesCache.indexOf(texture);
  32395. if (index !== -1) {
  32396. this._internalTexturesCache.splice(index, 1);
  32397. }
  32398. // Integrated fixed lod samplers.
  32399. if (texture._lodTextureHigh) {
  32400. texture._lodTextureHigh.dispose();
  32401. }
  32402. if (texture._lodTextureMid) {
  32403. texture._lodTextureMid.dispose();
  32404. }
  32405. if (texture._lodTextureLow) {
  32406. texture._lodTextureLow.dispose();
  32407. }
  32408. // Set output texture of post process to null if the texture has been released/disposed
  32409. this.scenes.forEach(function (scene) {
  32410. scene.postProcesses.forEach(function (postProcess) {
  32411. if (postProcess._outputTexture == texture) {
  32412. postProcess._outputTexture = null;
  32413. }
  32414. });
  32415. scene.cameras.forEach(function (camera) {
  32416. camera._postProcesses.forEach(function (postProcess) {
  32417. if (postProcess) {
  32418. if (postProcess._outputTexture == texture) {
  32419. postProcess._outputTexture = null;
  32420. }
  32421. }
  32422. });
  32423. });
  32424. });
  32425. };
  32426. Engine.prototype.setProgram = function (program) {
  32427. if (this._currentProgram !== program) {
  32428. this._gl.useProgram(program);
  32429. this._currentProgram = program;
  32430. }
  32431. };
  32432. /**
  32433. * Binds an effect to the webGL context
  32434. * @param effect defines the effect to bind
  32435. */
  32436. Engine.prototype.bindSamplers = function (effect) {
  32437. this.setProgram(effect.getProgram());
  32438. var samplers = effect.getSamplers();
  32439. for (var index = 0; index < samplers.length; index++) {
  32440. var uniform = effect.getUniform(samplers[index]);
  32441. if (uniform) {
  32442. this._boundUniforms[index] = uniform;
  32443. }
  32444. }
  32445. this._currentEffect = null;
  32446. };
  32447. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32448. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32449. return;
  32450. }
  32451. // Remove
  32452. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32453. // Bind last to it
  32454. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32455. // Bind to dummy
  32456. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32457. };
  32458. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32459. if (!internalTexture) {
  32460. return -1;
  32461. }
  32462. internalTexture._initialSlot = channel;
  32463. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32464. if (channel !== internalTexture._designatedSlot) {
  32465. this._textureCollisions.addCount(1, false);
  32466. }
  32467. }
  32468. else {
  32469. if (channel !== internalTexture._designatedSlot) {
  32470. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32471. return internalTexture._designatedSlot;
  32472. }
  32473. else {
  32474. // No slot for this texture, let's pick a new one (if we find a free slot)
  32475. if (this._nextFreeTextureSlots.length) {
  32476. return this._nextFreeTextureSlots[0];
  32477. }
  32478. // We need to recycle the oldest bound texture, sorry.
  32479. this._textureCollisions.addCount(1, false);
  32480. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32481. }
  32482. }
  32483. }
  32484. return channel;
  32485. };
  32486. Engine.prototype._linkTrackers = function (previous, next) {
  32487. previous.next = next;
  32488. next.previous = previous;
  32489. };
  32490. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32491. var currentSlot = internalTexture._designatedSlot;
  32492. if (currentSlot === -1) {
  32493. return -1;
  32494. }
  32495. internalTexture._designatedSlot = -1;
  32496. if (this.disableTextureBindingOptimization) {
  32497. return -1;
  32498. }
  32499. // Remove from bound list
  32500. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32501. // Free the slot
  32502. this._boundTexturesCache[currentSlot] = null;
  32503. this._nextFreeTextureSlots.push(currentSlot);
  32504. return currentSlot;
  32505. };
  32506. Engine.prototype._activateCurrentTexture = function () {
  32507. if (this._currentTextureChannel !== this._activeChannel) {
  32508. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32509. this._currentTextureChannel = this._activeChannel;
  32510. }
  32511. };
  32512. /** @hidden */
  32513. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32514. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32515. if (force === void 0) { force = false; }
  32516. var wasPreviouslyBound = false;
  32517. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32518. this._activeChannel = texture._designatedSlot;
  32519. }
  32520. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32521. var isTextureForRendering = texture && texture._initialSlot > -1;
  32522. if (currentTextureBound !== texture || force) {
  32523. if (currentTextureBound) {
  32524. this._removeDesignatedSlot(currentTextureBound);
  32525. }
  32526. this._activateCurrentTexture();
  32527. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32528. this._boundTexturesCache[this._activeChannel] = texture;
  32529. if (texture) {
  32530. if (!this.disableTextureBindingOptimization) {
  32531. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32532. if (slotIndex > -1) {
  32533. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32534. }
  32535. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32536. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32537. }
  32538. texture._designatedSlot = this._activeChannel;
  32539. }
  32540. }
  32541. else if (forTextureDataUpdate) {
  32542. wasPreviouslyBound = true;
  32543. this._activateCurrentTexture();
  32544. }
  32545. if (isTextureForRendering && !forTextureDataUpdate) {
  32546. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32547. }
  32548. return wasPreviouslyBound;
  32549. };
  32550. /** @hidden */
  32551. Engine.prototype._bindTexture = function (channel, texture) {
  32552. if (channel < 0) {
  32553. return;
  32554. }
  32555. if (texture) {
  32556. channel = this._getCorrectTextureChannel(channel, texture);
  32557. }
  32558. this._activeChannel = channel;
  32559. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32560. };
  32561. /**
  32562. * Sets a texture to the webGL context from a postprocess
  32563. * @param channel defines the channel to use
  32564. * @param postProcess defines the source postprocess
  32565. */
  32566. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32567. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32568. };
  32569. /**
  32570. * Binds the output of the passed in post process to the texture channel specified
  32571. * @param channel The channel the texture should be bound to
  32572. * @param postProcess The post process which's output should be bound
  32573. */
  32574. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32575. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32576. };
  32577. /**
  32578. * Unbind all textures from the webGL context
  32579. */
  32580. Engine.prototype.unbindAllTextures = function () {
  32581. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32582. this._activeChannel = channel;
  32583. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32584. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32585. if (this.webGLVersion > 1) {
  32586. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32587. }
  32588. }
  32589. };
  32590. /**
  32591. * Sets a texture to the according uniform.
  32592. * @param channel The texture channel
  32593. * @param uniform The uniform to set
  32594. * @param texture The texture to apply
  32595. */
  32596. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32597. if (channel < 0) {
  32598. return;
  32599. }
  32600. if (uniform) {
  32601. this._boundUniforms[channel] = uniform;
  32602. }
  32603. this._setTexture(channel, texture);
  32604. };
  32605. /**
  32606. * Sets a depth stencil texture from a render target to the according uniform.
  32607. * @param channel The texture channel
  32608. * @param uniform The uniform to set
  32609. * @param texture The render target texture containing the depth stencil texture to apply
  32610. */
  32611. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32612. if (channel < 0) {
  32613. return;
  32614. }
  32615. if (uniform) {
  32616. this._boundUniforms[channel] = uniform;
  32617. }
  32618. if (!texture || !texture.depthStencilTexture) {
  32619. this._setTexture(channel, null);
  32620. }
  32621. else {
  32622. this._setTexture(channel, texture, false, true);
  32623. }
  32624. };
  32625. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32626. var uniform = this._boundUniforms[sourceSlot];
  32627. if (uniform._currentState === destination) {
  32628. return;
  32629. }
  32630. this._gl.uniform1i(uniform, destination);
  32631. uniform._currentState = destination;
  32632. };
  32633. Engine.prototype._getTextureWrapMode = function (mode) {
  32634. switch (mode) {
  32635. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32636. return this._gl.REPEAT;
  32637. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32638. return this._gl.CLAMP_TO_EDGE;
  32639. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32640. return this._gl.MIRRORED_REPEAT;
  32641. }
  32642. return this._gl.REPEAT;
  32643. };
  32644. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32645. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32646. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32647. // Not ready?
  32648. if (!texture) {
  32649. if (this._boundTexturesCache[channel] != null) {
  32650. this._activeChannel = channel;
  32651. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32652. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32653. if (this.webGLVersion > 1) {
  32654. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32655. }
  32656. }
  32657. return false;
  32658. }
  32659. // Video
  32660. if (texture.video) {
  32661. this._activeChannel = channel;
  32662. texture.update();
  32663. }
  32664. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32665. texture.delayLoad();
  32666. return false;
  32667. }
  32668. var internalTexture;
  32669. if (depthStencilTexture) {
  32670. internalTexture = texture.depthStencilTexture;
  32671. }
  32672. else if (texture.isReady()) {
  32673. internalTexture = texture.getInternalTexture();
  32674. }
  32675. else if (texture.isCube) {
  32676. internalTexture = this.emptyCubeTexture;
  32677. }
  32678. else if (texture.is3D) {
  32679. internalTexture = this.emptyTexture3D;
  32680. }
  32681. else {
  32682. internalTexture = this.emptyTexture;
  32683. }
  32684. if (!isPartOfTextureArray) {
  32685. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32686. }
  32687. var needToBind = true;
  32688. if (this._boundTexturesCache[channel] === internalTexture) {
  32689. this._moveBoundTextureOnTop(internalTexture);
  32690. if (!isPartOfTextureArray) {
  32691. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32692. }
  32693. needToBind = false;
  32694. }
  32695. this._activeChannel = channel;
  32696. if (internalTexture && internalTexture.is3D) {
  32697. if (needToBind) {
  32698. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32699. }
  32700. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32701. internalTexture._cachedWrapU = texture.wrapU;
  32702. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32703. }
  32704. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32705. internalTexture._cachedWrapV = texture.wrapV;
  32706. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32707. }
  32708. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32709. internalTexture._cachedWrapR = texture.wrapR;
  32710. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32711. }
  32712. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32713. }
  32714. else if (internalTexture && internalTexture.isCube) {
  32715. if (needToBind) {
  32716. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32717. }
  32718. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32719. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32720. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32721. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32722. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32723. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32724. }
  32725. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32726. }
  32727. else {
  32728. if (needToBind) {
  32729. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32730. }
  32731. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32732. internalTexture._cachedWrapU = texture.wrapU;
  32733. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32734. }
  32735. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32736. internalTexture._cachedWrapV = texture.wrapV;
  32737. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32738. }
  32739. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32740. }
  32741. return true;
  32742. };
  32743. /**
  32744. * Sets an array of texture to the webGL context
  32745. * @param channel defines the channel where the texture array must be set
  32746. * @param uniform defines the associated uniform location
  32747. * @param textures defines the array of textures to bind
  32748. */
  32749. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32750. if (channel < 0 || !uniform) {
  32751. return;
  32752. }
  32753. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32754. this._textureUnits = new Int32Array(textures.length);
  32755. }
  32756. for (var i = 0; i < textures.length; i++) {
  32757. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32758. }
  32759. this._gl.uniform1iv(uniform, this._textureUnits);
  32760. for (var index = 0; index < textures.length; index++) {
  32761. this._setTexture(this._textureUnits[index], textures[index], true);
  32762. }
  32763. };
  32764. /** @hidden */
  32765. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32766. var internalTexture = texture.getInternalTexture();
  32767. if (!internalTexture) {
  32768. return;
  32769. }
  32770. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32771. var value = texture.anisotropicFilteringLevel;
  32772. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32773. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32774. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32775. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32776. }
  32777. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32778. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32779. internalTexture._cachedAnisotropicFilteringLevel = value;
  32780. }
  32781. };
  32782. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32783. this._bindTextureDirectly(target, texture, true, true);
  32784. this._gl.texParameterf(target, parameter, value);
  32785. };
  32786. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32787. if (texture) {
  32788. this._bindTextureDirectly(target, texture, true, true);
  32789. }
  32790. this._gl.texParameteri(target, parameter, value);
  32791. };
  32792. /**
  32793. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32794. * @param x defines the x coordinate of the rectangle where pixels must be read
  32795. * @param y defines the y coordinate of the rectangle where pixels must be read
  32796. * @param width defines the width of the rectangle where pixels must be read
  32797. * @param height defines the height of the rectangle where pixels must be read
  32798. * @returns a Uint8Array containing RGBA colors
  32799. */
  32800. Engine.prototype.readPixels = function (x, y, width, height) {
  32801. var data = new Uint8Array(height * width * 4);
  32802. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32803. return data;
  32804. };
  32805. /**
  32806. * Add an externaly attached data from its key.
  32807. * This method call will fail and return false, if such key already exists.
  32808. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32809. * @param key the unique key that identifies the data
  32810. * @param data the data object to associate to the key for this Engine instance
  32811. * @return true if no such key were already present and the data was added successfully, false otherwise
  32812. */
  32813. Engine.prototype.addExternalData = function (key, data) {
  32814. if (!this._externalData) {
  32815. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32816. }
  32817. return this._externalData.add(key, data);
  32818. };
  32819. /**
  32820. * Get an externaly attached data from its key
  32821. * @param key the unique key that identifies the data
  32822. * @return the associated data, if present (can be null), or undefined if not present
  32823. */
  32824. Engine.prototype.getExternalData = function (key) {
  32825. if (!this._externalData) {
  32826. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32827. }
  32828. return this._externalData.get(key);
  32829. };
  32830. /**
  32831. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32832. * @param key the unique key that identifies the data
  32833. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32834. * @return the associated data, can be null if the factory returned null.
  32835. */
  32836. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32837. if (!this._externalData) {
  32838. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32839. }
  32840. return this._externalData.getOrAddWithFactory(key, factory);
  32841. };
  32842. /**
  32843. * Remove an externaly attached data from the Engine instance
  32844. * @param key the unique key that identifies the data
  32845. * @return true if the data was successfully removed, false if it doesn't exist
  32846. */
  32847. Engine.prototype.removeExternalData = function (key) {
  32848. if (!this._externalData) {
  32849. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32850. }
  32851. return this._externalData.remove(key);
  32852. };
  32853. /**
  32854. * Unbind all vertex attributes from the webGL context
  32855. */
  32856. Engine.prototype.unbindAllAttributes = function () {
  32857. if (this._mustWipeVertexAttributes) {
  32858. this._mustWipeVertexAttributes = false;
  32859. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32860. this._gl.disableVertexAttribArray(i);
  32861. this._vertexAttribArraysEnabled[i] = false;
  32862. this._currentBufferPointers[i].active = false;
  32863. }
  32864. return;
  32865. }
  32866. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32867. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32868. continue;
  32869. }
  32870. this._gl.disableVertexAttribArray(i);
  32871. this._vertexAttribArraysEnabled[i] = false;
  32872. this._currentBufferPointers[i].active = false;
  32873. }
  32874. };
  32875. /**
  32876. * 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
  32877. */
  32878. Engine.prototype.releaseEffects = function () {
  32879. for (var name in this._compiledEffects) {
  32880. this._deleteProgram(this._compiledEffects[name]._program);
  32881. }
  32882. this._compiledEffects = {};
  32883. };
  32884. /**
  32885. * Dispose and release all associated resources
  32886. */
  32887. Engine.prototype.dispose = function () {
  32888. this.hideLoadingUI();
  32889. this.stopRenderLoop();
  32890. this.onNewSceneAddedObservable.clear();
  32891. // Release postProcesses
  32892. while (this.postProcesses.length) {
  32893. this.postProcesses[0].dispose();
  32894. }
  32895. // Empty texture
  32896. if (this._emptyTexture) {
  32897. this._releaseTexture(this._emptyTexture);
  32898. this._emptyTexture = null;
  32899. }
  32900. if (this._emptyCubeTexture) {
  32901. this._releaseTexture(this._emptyCubeTexture);
  32902. this._emptyCubeTexture = null;
  32903. }
  32904. // Rescale PP
  32905. if (this._rescalePostProcess) {
  32906. this._rescalePostProcess.dispose();
  32907. }
  32908. // Release scenes
  32909. while (this.scenes.length) {
  32910. this.scenes[0].dispose();
  32911. }
  32912. // Release audio engine
  32913. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32914. Engine.audioEngine.dispose();
  32915. }
  32916. // Release effects
  32917. this.releaseEffects();
  32918. // Unbind
  32919. this.unbindAllAttributes();
  32920. this._boundUniforms = [];
  32921. if (this._dummyFramebuffer) {
  32922. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32923. }
  32924. //WebVR
  32925. this.disableVR();
  32926. // Events
  32927. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32928. window.removeEventListener("blur", this._onBlur);
  32929. window.removeEventListener("focus", this._onFocus);
  32930. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32931. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32932. if (this._renderingCanvas) {
  32933. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32934. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32935. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32936. if (!this._doNotHandleContextLost) {
  32937. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32938. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32939. }
  32940. }
  32941. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32942. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32943. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32944. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32945. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32946. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32947. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32948. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32949. if (this._onVrDisplayConnect) {
  32950. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32951. if (this._onVrDisplayDisconnect) {
  32952. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32953. }
  32954. if (this._onVrDisplayPresentChange) {
  32955. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32956. }
  32957. this._onVrDisplayConnect = null;
  32958. this._onVrDisplayDisconnect = null;
  32959. }
  32960. }
  32961. // Remove from Instances
  32962. var index = Engine.Instances.indexOf(this);
  32963. if (index >= 0) {
  32964. Engine.Instances.splice(index, 1);
  32965. }
  32966. this._workingCanvas = null;
  32967. this._workingContext = null;
  32968. this._currentBufferPointers = [];
  32969. this._renderingCanvas = null;
  32970. this._currentProgram = null;
  32971. this._bindedRenderFunction = null;
  32972. this.onResizeObservable.clear();
  32973. this.onCanvasBlurObservable.clear();
  32974. this.onCanvasFocusObservable.clear();
  32975. this.onCanvasPointerOutObservable.clear();
  32976. this.onBeginFrameObservable.clear();
  32977. this.onEndFrameObservable.clear();
  32978. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  32979. // Abort active requests
  32980. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  32981. var request = _a[_i];
  32982. request.abort();
  32983. }
  32984. };
  32985. // Loading screen
  32986. /**
  32987. * Display the loading screen
  32988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32989. */
  32990. Engine.prototype.displayLoadingUI = function () {
  32991. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32992. return;
  32993. }
  32994. var loadingScreen = this.loadingScreen;
  32995. if (loadingScreen) {
  32996. loadingScreen.displayLoadingUI();
  32997. }
  32998. };
  32999. /**
  33000. * Hide the loading screen
  33001. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33002. */
  33003. Engine.prototype.hideLoadingUI = function () {
  33004. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33005. return;
  33006. }
  33007. var loadingScreen = this.loadingScreen;
  33008. if (loadingScreen) {
  33009. loadingScreen.hideLoadingUI();
  33010. }
  33011. };
  33012. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33013. /**
  33014. * Gets the current loading screen object
  33015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33016. */
  33017. get: function () {
  33018. if (!this._loadingScreen && this._renderingCanvas) {
  33019. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33020. }
  33021. return this._loadingScreen;
  33022. },
  33023. /**
  33024. * Sets the current loading screen object
  33025. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33026. */
  33027. set: function (loadingScreen) {
  33028. this._loadingScreen = loadingScreen;
  33029. },
  33030. enumerable: true,
  33031. configurable: true
  33032. });
  33033. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33034. /**
  33035. * Sets the current loading screen text
  33036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33037. */
  33038. set: function (text) {
  33039. this.loadingScreen.loadingUIText = text;
  33040. },
  33041. enumerable: true,
  33042. configurable: true
  33043. });
  33044. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33045. /**
  33046. * Sets the current loading screen background color
  33047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33048. */
  33049. set: function (color) {
  33050. this.loadingScreen.loadingUIBackgroundColor = color;
  33051. },
  33052. enumerable: true,
  33053. configurable: true
  33054. });
  33055. /**
  33056. * Attach a new callback raised when context lost event is fired
  33057. * @param callback defines the callback to call
  33058. */
  33059. Engine.prototype.attachContextLostEvent = function (callback) {
  33060. if (this._renderingCanvas) {
  33061. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33062. }
  33063. };
  33064. /**
  33065. * Attach a new callback raised when context restored event is fired
  33066. * @param callback defines the callback to call
  33067. */
  33068. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33069. if (this._renderingCanvas) {
  33070. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33071. }
  33072. };
  33073. /**
  33074. * Gets the source code of the vertex shader associated with a specific webGL program
  33075. * @param program defines the program to use
  33076. * @returns a string containing the source code of the vertex shader associated with the program
  33077. */
  33078. Engine.prototype.getVertexShaderSource = function (program) {
  33079. var shaders = this._gl.getAttachedShaders(program);
  33080. if (!shaders) {
  33081. return null;
  33082. }
  33083. return this._gl.getShaderSource(shaders[0]);
  33084. };
  33085. /**
  33086. * Gets the source code of the fragment shader associated with a specific webGL program
  33087. * @param program defines the program to use
  33088. * @returns a string containing the source code of the fragment shader associated with the program
  33089. */
  33090. Engine.prototype.getFragmentShaderSource = function (program) {
  33091. var shaders = this._gl.getAttachedShaders(program);
  33092. if (!shaders) {
  33093. return null;
  33094. }
  33095. return this._gl.getShaderSource(shaders[1]);
  33096. };
  33097. /**
  33098. * Get the current error code of the webGL context
  33099. * @returns the error code
  33100. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33101. */
  33102. Engine.prototype.getError = function () {
  33103. return this._gl.getError();
  33104. };
  33105. // FPS
  33106. /**
  33107. * Gets the current framerate
  33108. * @returns a number representing the framerate
  33109. */
  33110. Engine.prototype.getFps = function () {
  33111. return this._fps;
  33112. };
  33113. /**
  33114. * Gets the time spent between current and previous frame
  33115. * @returns a number representing the delta time in ms
  33116. */
  33117. Engine.prototype.getDeltaTime = function () {
  33118. return this._deltaTime;
  33119. };
  33120. Engine.prototype._measureFps = function () {
  33121. this._performanceMonitor.sampleFrame();
  33122. this._fps = this._performanceMonitor.averageFPS;
  33123. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33124. };
  33125. /** @hidden */
  33126. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33127. if (faceIndex === void 0) { faceIndex = -1; }
  33128. if (level === void 0) { level = 0; }
  33129. if (buffer === void 0) { buffer = null; }
  33130. var gl = this._gl;
  33131. if (!this._dummyFramebuffer) {
  33132. var dummy = gl.createFramebuffer();
  33133. if (!dummy) {
  33134. throw new Error("Unable to create dummy framebuffer");
  33135. }
  33136. this._dummyFramebuffer = dummy;
  33137. }
  33138. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33139. if (faceIndex > -1) {
  33140. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33141. }
  33142. else {
  33143. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33144. }
  33145. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33146. switch (readType) {
  33147. case gl.UNSIGNED_BYTE:
  33148. if (!buffer) {
  33149. buffer = new Uint8Array(4 * width * height);
  33150. }
  33151. readType = gl.UNSIGNED_BYTE;
  33152. break;
  33153. default:
  33154. if (!buffer) {
  33155. buffer = new Float32Array(4 * width * height);
  33156. }
  33157. readType = gl.FLOAT;
  33158. break;
  33159. }
  33160. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33161. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33162. return buffer;
  33163. };
  33164. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33165. if (this._webGLVersion > 1) {
  33166. return this._caps.colorBufferFloat;
  33167. }
  33168. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33169. };
  33170. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33171. if (this._webGLVersion > 1) {
  33172. return this._caps.colorBufferFloat;
  33173. }
  33174. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33175. };
  33176. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33177. Engine.prototype._canRenderToFramebuffer = function (type) {
  33178. var gl = this._gl;
  33179. //clear existing errors
  33180. while (gl.getError() !== gl.NO_ERROR) { }
  33181. var successful = true;
  33182. var texture = gl.createTexture();
  33183. gl.bindTexture(gl.TEXTURE_2D, texture);
  33184. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33185. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33186. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33187. var fb = gl.createFramebuffer();
  33188. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33189. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33190. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33191. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33192. successful = successful && (gl.getError() === gl.NO_ERROR);
  33193. //try render by clearing frame buffer's color buffer
  33194. if (successful) {
  33195. gl.clear(gl.COLOR_BUFFER_BIT);
  33196. successful = successful && (gl.getError() === gl.NO_ERROR);
  33197. }
  33198. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33199. if (successful) {
  33200. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33201. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33202. var readFormat = gl.RGBA;
  33203. var readType = gl.UNSIGNED_BYTE;
  33204. var buffer = new Uint8Array(4);
  33205. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33206. successful = successful && (gl.getError() === gl.NO_ERROR);
  33207. }
  33208. //clean up
  33209. gl.deleteTexture(texture);
  33210. gl.deleteFramebuffer(fb);
  33211. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33212. //clear accumulated errors
  33213. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33214. return successful;
  33215. };
  33216. /** @hidden */
  33217. Engine.prototype._getWebGLTextureType = function (type) {
  33218. if (this._webGLVersion === 1) {
  33219. switch (type) {
  33220. case Engine.TEXTURETYPE_FLOAT:
  33221. return this._gl.FLOAT;
  33222. case Engine.TEXTURETYPE_HALF_FLOAT:
  33223. return this._gl.HALF_FLOAT_OES;
  33224. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33225. return this._gl.UNSIGNED_BYTE;
  33226. }
  33227. return this._gl.UNSIGNED_BYTE;
  33228. }
  33229. switch (type) {
  33230. case Engine.TEXTURETYPE_BYTE:
  33231. return this._gl.BYTE;
  33232. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33233. return this._gl.UNSIGNED_BYTE;
  33234. case Engine.TEXTURETYPE_SHORT:
  33235. return this._gl.SHORT;
  33236. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33237. return this._gl.UNSIGNED_SHORT;
  33238. case Engine.TEXTURETYPE_INT:
  33239. return this._gl.INT;
  33240. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33241. return this._gl.UNSIGNED_INT;
  33242. case Engine.TEXTURETYPE_FLOAT:
  33243. return this._gl.FLOAT;
  33244. case Engine.TEXTURETYPE_HALF_FLOAT:
  33245. return this._gl.HALF_FLOAT;
  33246. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33247. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33248. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33249. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33250. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33251. return this._gl.UNSIGNED_SHORT_5_6_5;
  33252. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33253. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33254. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33255. return this._gl.UNSIGNED_INT_24_8;
  33256. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33257. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33258. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33259. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33260. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33261. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33262. }
  33263. return this._gl.UNSIGNED_BYTE;
  33264. };
  33265. Engine.prototype._getInternalFormat = function (format) {
  33266. var internalFormat = this._gl.RGBA;
  33267. switch (format) {
  33268. case Engine.TEXTUREFORMAT_ALPHA:
  33269. internalFormat = this._gl.ALPHA;
  33270. break;
  33271. case Engine.TEXTUREFORMAT_LUMINANCE:
  33272. internalFormat = this._gl.LUMINANCE;
  33273. break;
  33274. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33275. internalFormat = this._gl.LUMINANCE_ALPHA;
  33276. break;
  33277. case Engine.TEXTUREFORMAT_RED:
  33278. internalFormat = this._gl.RED;
  33279. break;
  33280. case Engine.TEXTUREFORMAT_RG:
  33281. internalFormat = this._gl.RG;
  33282. break;
  33283. case Engine.TEXTUREFORMAT_RGB:
  33284. internalFormat = this._gl.RGB;
  33285. break;
  33286. case Engine.TEXTUREFORMAT_RGBA:
  33287. internalFormat = this._gl.RGBA;
  33288. break;
  33289. }
  33290. if (this._webGLVersion > 1) {
  33291. switch (format) {
  33292. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33293. internalFormat = this._gl.RED_INTEGER;
  33294. break;
  33295. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33296. internalFormat = this._gl.RG_INTEGER;
  33297. break;
  33298. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33299. internalFormat = this._gl.RGB_INTEGER;
  33300. break;
  33301. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33302. internalFormat = this._gl.RGBA_INTEGER;
  33303. break;
  33304. }
  33305. }
  33306. return internalFormat;
  33307. };
  33308. /** @hidden */
  33309. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33310. if (this._webGLVersion === 1) {
  33311. if (format !== undefined) {
  33312. switch (format) {
  33313. case Engine.TEXTUREFORMAT_ALPHA:
  33314. return this._gl.ALPHA;
  33315. case Engine.TEXTUREFORMAT_LUMINANCE:
  33316. return this._gl.LUMINANCE;
  33317. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33318. return this._gl.LUMINANCE_ALPHA;
  33319. }
  33320. }
  33321. return this._gl.RGBA;
  33322. }
  33323. switch (type) {
  33324. case Engine.TEXTURETYPE_BYTE:
  33325. switch (format) {
  33326. case Engine.TEXTUREFORMAT_RED:
  33327. return this._gl.R8_SNORM;
  33328. case Engine.TEXTUREFORMAT_RG:
  33329. return this._gl.RG8_SNORM;
  33330. case Engine.TEXTUREFORMAT_RGB:
  33331. return this._gl.RGB8_SNORM;
  33332. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33333. return this._gl.R8I;
  33334. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33335. return this._gl.RG8I;
  33336. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33337. return this._gl.RGB8I;
  33338. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33339. return this._gl.RGBA8I;
  33340. default:
  33341. return this._gl.RGBA8_SNORM;
  33342. }
  33343. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33344. switch (format) {
  33345. case Engine.TEXTUREFORMAT_RED:
  33346. return this._gl.R8;
  33347. case Engine.TEXTUREFORMAT_RG:
  33348. return this._gl.RG8;
  33349. case Engine.TEXTUREFORMAT_RGB:
  33350. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33351. case Engine.TEXTUREFORMAT_RGBA:
  33352. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33353. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33354. return this._gl.R8UI;
  33355. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33356. return this._gl.RG8UI;
  33357. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33358. return this._gl.RGB8UI;
  33359. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33360. return this._gl.RGBA8UI;
  33361. default:
  33362. return this._gl.RGBA8;
  33363. }
  33364. case Engine.TEXTURETYPE_SHORT:
  33365. switch (format) {
  33366. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33367. return this._gl.R16I;
  33368. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33369. return this._gl.RG16I;
  33370. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33371. return this._gl.RGB16I;
  33372. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33373. return this._gl.RGBA16I;
  33374. default:
  33375. return this._gl.RGBA16I;
  33376. }
  33377. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33378. switch (format) {
  33379. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33380. return this._gl.R16UI;
  33381. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33382. return this._gl.RG16UI;
  33383. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33384. return this._gl.RGB16UI;
  33385. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33386. return this._gl.RGBA16UI;
  33387. default:
  33388. return this._gl.RGBA16UI;
  33389. }
  33390. case Engine.TEXTURETYPE_INT:
  33391. switch (format) {
  33392. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33393. return this._gl.R32I;
  33394. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33395. return this._gl.RG32I;
  33396. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33397. return this._gl.RGB32I;
  33398. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33399. return this._gl.RGBA32I;
  33400. default:
  33401. return this._gl.RGBA32I;
  33402. }
  33403. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33404. switch (format) {
  33405. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33406. return this._gl.R32UI;
  33407. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33408. return this._gl.RG32UI;
  33409. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33410. return this._gl.RGB32UI;
  33411. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33412. return this._gl.RGBA32UI;
  33413. default:
  33414. return this._gl.RGBA32UI;
  33415. }
  33416. case Engine.TEXTURETYPE_FLOAT:
  33417. switch (format) {
  33418. case Engine.TEXTUREFORMAT_RED:
  33419. return this._gl.R32F; // By default. Other possibility is R16F.
  33420. case Engine.TEXTUREFORMAT_RG:
  33421. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33422. case Engine.TEXTUREFORMAT_RGB:
  33423. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33424. case Engine.TEXTUREFORMAT_RGBA:
  33425. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33426. default:
  33427. return this._gl.RGBA32F;
  33428. }
  33429. case Engine.TEXTURETYPE_HALF_FLOAT:
  33430. switch (format) {
  33431. case Engine.TEXTUREFORMAT_RED:
  33432. return this._gl.R16F;
  33433. case Engine.TEXTUREFORMAT_RG:
  33434. return this._gl.RG16F;
  33435. case Engine.TEXTUREFORMAT_RGB:
  33436. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33437. case Engine.TEXTUREFORMAT_RGBA:
  33438. return this._gl.RGBA16F;
  33439. default:
  33440. return this._gl.RGBA16F;
  33441. }
  33442. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33443. return this._gl.RGB565;
  33444. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33445. return this._gl.R11F_G11F_B10F;
  33446. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33447. return this._gl.RGB9_E5;
  33448. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33449. return this._gl.RGBA4;
  33450. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33451. return this._gl.RGB5_A1;
  33452. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33453. switch (format) {
  33454. case Engine.TEXTUREFORMAT_RGBA:
  33455. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33456. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33457. return this._gl.RGB10_A2UI;
  33458. default:
  33459. return this._gl.RGB10_A2;
  33460. }
  33461. }
  33462. return this._gl.RGBA8;
  33463. };
  33464. /** @hidden */
  33465. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33466. if (type === Engine.TEXTURETYPE_FLOAT) {
  33467. return this._gl.RGBA32F;
  33468. }
  33469. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33470. return this._gl.RGBA16F;
  33471. }
  33472. return this._gl.RGBA8;
  33473. };
  33474. /** @hidden */
  33475. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33476. var _this = this;
  33477. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33478. this._activeRequests.push(request);
  33479. request.onCompleteObservable.add(function (request) {
  33480. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33481. });
  33482. return request;
  33483. };
  33484. /** @hidden */
  33485. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33486. var _this = this;
  33487. return new Promise(function (resolve, reject) {
  33488. _this._loadFile(url, function (data) {
  33489. resolve(data);
  33490. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33491. reject(exception);
  33492. });
  33493. });
  33494. };
  33495. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33496. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33497. var onload = function (data) {
  33498. loadedFiles[index] = data;
  33499. loadedFiles._internalCount++;
  33500. if (loadedFiles._internalCount === 6) {
  33501. onfinish(loadedFiles);
  33502. }
  33503. };
  33504. var onerror = function (request, exception) {
  33505. if (onErrorCallBack && request) {
  33506. onErrorCallBack(request.status + " " + request.statusText, exception);
  33507. }
  33508. };
  33509. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33510. };
  33511. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33512. if (onError === void 0) { onError = null; }
  33513. var loadedFiles = [];
  33514. loadedFiles._internalCount = 0;
  33515. for (var index = 0; index < 6; index++) {
  33516. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33517. }
  33518. };
  33519. // Statics
  33520. /**
  33521. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33522. * @returns true if the engine can be created
  33523. * @ignorenaming
  33524. */
  33525. Engine.isSupported = function () {
  33526. try {
  33527. var tempcanvas = document.createElement("canvas");
  33528. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33529. return gl != null && !!window.WebGLRenderingContext;
  33530. }
  33531. catch (e) {
  33532. return false;
  33533. }
  33534. };
  33535. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33536. Engine.ExceptionList = [
  33537. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33538. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33539. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33540. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33541. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33542. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33543. ];
  33544. /**
  33545. * Hidden
  33546. */
  33547. Engine._TextureLoaders = [];
  33548. // Const statics
  33549. /** Defines that alpha blending is disabled */
  33550. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33551. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33552. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33554. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33555. /** Defines that alpha blending to DEST - SRC * DEST */
  33556. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33557. /** Defines that alpha blending to SRC * DEST */
  33558. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33559. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33560. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33561. /** Defines that alpha blending to SRC + DEST */
  33562. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33563. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33564. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33565. /**
  33566. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33567. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33568. */
  33569. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33570. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33571. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33572. /**
  33573. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33574. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33575. */
  33576. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33577. /** Defines that the ressource is not delayed*/
  33578. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33579. /** Defines that the ressource was successfully delay loaded */
  33580. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33581. /** Defines that the ressource is currently delay loading */
  33582. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33583. /** Defines that the ressource is delayed and has not started loading */
  33584. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33585. // Depht or Stencil test Constants.
  33586. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33587. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33588. /** 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 */
  33589. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33591. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33592. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33593. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33594. /** 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 */
  33595. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33596. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33597. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33598. /** 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 */
  33599. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33600. /** 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 */
  33601. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33602. // Stencil Actions Constants.
  33603. /** Passed to stencilOperation to specify that stencil value must be kept */
  33604. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33605. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33606. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33607. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33608. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33609. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33610. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33611. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33612. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33613. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33614. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33615. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33616. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33617. /** Texture is not repeating outside of 0..1 UVs */
  33618. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33619. /** Texture is repeating outside of 0..1 UVs */
  33620. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33621. /** Texture is repeating and mirrored */
  33622. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33623. /** ALPHA */
  33624. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33625. /** LUMINANCE */
  33626. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33627. /** LUMINANCE_ALPHA */
  33628. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33629. /** RGB */
  33630. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33631. /** RGBA */
  33632. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33633. /** RED */
  33634. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33635. /** RED (2nd reference) */
  33636. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33637. /** RG */
  33638. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33639. /** RED_INTEGER */
  33640. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33641. /** RED_INTEGER (2nd reference) */
  33642. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33643. /** RG_INTEGER */
  33644. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33645. /** RGB_INTEGER */
  33646. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33647. /** RGBA_INTEGER */
  33648. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33649. /** UNSIGNED_BYTE */
  33650. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33651. /** UNSIGNED_BYTE (2nd reference) */
  33652. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33653. /** FLOAT */
  33654. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33655. /** HALF_FLOAT */
  33656. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33657. /** BYTE */
  33658. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33659. /** SHORT */
  33660. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33661. /** UNSIGNED_SHORT */
  33662. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33663. /** INT */
  33664. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33665. /** UNSIGNED_INT */
  33666. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33667. /** UNSIGNED_SHORT_4_4_4_4 */
  33668. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33669. /** UNSIGNED_SHORT_5_5_5_1 */
  33670. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33671. /** UNSIGNED_SHORT_5_6_5 */
  33672. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33673. /** UNSIGNED_INT_2_10_10_10_REV */
  33674. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33675. /** UNSIGNED_INT_24_8 */
  33676. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33677. /** UNSIGNED_INT_10F_11F_11F_REV */
  33678. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33679. /** UNSIGNED_INT_5_9_9_9_REV */
  33680. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33681. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33682. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33683. /** nearest is mag = nearest and min = nearest and mip = linear */
  33684. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33685. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33686. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33687. /** Trilinear is mag = linear and min = linear and mip = linear */
  33688. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33689. /** nearest is mag = nearest and min = nearest and mip = linear */
  33690. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33691. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33692. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33693. /** Trilinear is mag = linear and min = linear and mip = linear */
  33694. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33695. /** mag = nearest and min = nearest and mip = nearest */
  33696. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33697. /** mag = nearest and min = linear and mip = nearest */
  33698. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33699. /** mag = nearest and min = linear and mip = linear */
  33700. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33701. /** mag = nearest and min = linear and mip = none */
  33702. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33703. /** mag = nearest and min = nearest and mip = none */
  33704. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33705. /** mag = linear and min = nearest and mip = nearest */
  33706. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33707. /** mag = linear and min = nearest and mip = linear */
  33708. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33709. /** mag = linear and min = linear and mip = none */
  33710. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33711. /** mag = linear and min = nearest and mip = none */
  33712. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33713. /** Explicit coordinates mode */
  33714. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33715. /** Spherical coordinates mode */
  33716. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33717. /** Planar coordinates mode */
  33718. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33719. /** Cubic coordinates mode */
  33720. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33721. /** Projection coordinates mode */
  33722. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33723. /** Skybox coordinates mode */
  33724. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33725. /** Inverse Cubic coordinates mode */
  33726. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33727. /** Equirectangular coordinates mode */
  33728. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33729. /** Equirectangular Fixed coordinates mode */
  33730. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33731. /** Equirectangular Fixed Mirrored coordinates mode */
  33732. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33733. // Texture rescaling mode
  33734. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33735. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33736. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33737. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33738. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33739. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33740. // Updatable statics so stick with vars here
  33741. /**
  33742. * Gets or sets the epsilon value used by collision engine
  33743. */
  33744. Engine.CollisionsEpsilon = 0.001;
  33745. /**
  33746. * Method called to create the default rescale post process on each engine.
  33747. */
  33748. Engine._RescalePostProcessFactory = null;
  33749. return Engine;
  33750. }());
  33751. /***/ }),
  33752. /***/ "./Engines/engineStore.ts":
  33753. /*!********************************!*\
  33754. !*** ./Engines/engineStore.ts ***!
  33755. \********************************/
  33756. /*! exports provided: EngineStore */
  33757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33758. "use strict";
  33759. __webpack_require__.r(__webpack_exports__);
  33760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33761. /**
  33762. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33763. * during the life time of the application.
  33764. */
  33765. var EngineStore = /** @class */ (function () {
  33766. function EngineStore() {
  33767. }
  33768. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33769. /**
  33770. * Gets the latest created engine
  33771. */
  33772. get: function () {
  33773. if (this.Instances.length === 0) {
  33774. return null;
  33775. }
  33776. return this.Instances[this.Instances.length - 1];
  33777. },
  33778. enumerable: true,
  33779. configurable: true
  33780. });
  33781. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33782. /**
  33783. * Gets the latest created scene
  33784. */
  33785. get: function () {
  33786. var lastCreatedEngine = this.LastCreatedEngine;
  33787. if (!lastCreatedEngine) {
  33788. return null;
  33789. }
  33790. if (lastCreatedEngine.scenes.length === 0) {
  33791. return null;
  33792. }
  33793. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33794. },
  33795. enumerable: true,
  33796. configurable: true
  33797. });
  33798. /** Gets the list of created engines */
  33799. EngineStore.Instances = new Array();
  33800. return EngineStore;
  33801. }());
  33802. /***/ }),
  33803. /***/ "./Engines/index.ts":
  33804. /*!**************************!*\
  33805. !*** ./Engines/index.ts ***!
  33806. \**************************/
  33807. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33809. "use strict";
  33810. __webpack_require__.r(__webpack_exports__);
  33811. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33813. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33818. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33820. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33823. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33826. /***/ }),
  33827. /***/ "./Engines/nullEngine.ts":
  33828. /*!*******************************!*\
  33829. !*** ./Engines/nullEngine.ts ***!
  33830. \*******************************/
  33831. /*! exports provided: NullEngineOptions, NullEngine */
  33832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33833. "use strict";
  33834. __webpack_require__.r(__webpack_exports__);
  33835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33838. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33839. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33840. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33841. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33842. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33843. /**
  33844. * Options to create the null engine
  33845. */
  33846. var NullEngineOptions = /** @class */ (function () {
  33847. function NullEngineOptions() {
  33848. /**
  33849. * Render width (Default: 512)
  33850. */
  33851. this.renderWidth = 512;
  33852. /**
  33853. * Render height (Default: 256)
  33854. */
  33855. this.renderHeight = 256;
  33856. /**
  33857. * Texture size (Default: 512)
  33858. */
  33859. this.textureSize = 512;
  33860. /**
  33861. * If delta time between frames should be constant
  33862. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33863. */
  33864. this.deterministicLockstep = false;
  33865. /**
  33866. * Maximum about of steps between frames (Default: 4)
  33867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33868. */
  33869. this.lockstepMaxSteps = 4;
  33870. }
  33871. return NullEngineOptions;
  33872. }());
  33873. /**
  33874. * The null engine class provides support for headless version of babylon.js.
  33875. * This can be used in server side scenario or for testing purposes
  33876. */
  33877. var NullEngine = /** @class */ (function (_super) {
  33878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33879. function NullEngine(options) {
  33880. if (options === void 0) { options = new NullEngineOptions(); }
  33881. var _this = _super.call(this, null) || this;
  33882. if (options.deterministicLockstep === undefined) {
  33883. options.deterministicLockstep = false;
  33884. }
  33885. if (options.lockstepMaxSteps === undefined) {
  33886. options.lockstepMaxSteps = 4;
  33887. }
  33888. _this._options = options;
  33889. // Init caps
  33890. // We consider we are on a webgl1 capable device
  33891. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33892. _this._caps.maxTexturesImageUnits = 16;
  33893. _this._caps.maxVertexTextureImageUnits = 16;
  33894. _this._caps.maxTextureSize = 512;
  33895. _this._caps.maxCubemapTextureSize = 512;
  33896. _this._caps.maxRenderTextureSize = 512;
  33897. _this._caps.maxVertexAttribs = 16;
  33898. _this._caps.maxVaryingVectors = 16;
  33899. _this._caps.maxFragmentUniformVectors = 16;
  33900. _this._caps.maxVertexUniformVectors = 16;
  33901. // Extensions
  33902. _this._caps.standardDerivatives = false;
  33903. _this._caps.astc = null;
  33904. _this._caps.s3tc = null;
  33905. _this._caps.pvrtc = null;
  33906. _this._caps.etc1 = null;
  33907. _this._caps.etc2 = null;
  33908. _this._caps.textureAnisotropicFilterExtension = null;
  33909. _this._caps.maxAnisotropy = 0;
  33910. _this._caps.uintIndices = false;
  33911. _this._caps.fragmentDepthSupported = false;
  33912. _this._caps.highPrecisionShaderSupported = true;
  33913. _this._caps.colorBufferFloat = false;
  33914. _this._caps.textureFloat = false;
  33915. _this._caps.textureFloatLinearFiltering = false;
  33916. _this._caps.textureFloatRender = false;
  33917. _this._caps.textureHalfFloat = false;
  33918. _this._caps.textureHalfFloatLinearFiltering = false;
  33919. _this._caps.textureHalfFloatRender = false;
  33920. _this._caps.textureLOD = false;
  33921. _this._caps.drawBuffersExtension = false;
  33922. _this._caps.depthTextureExtension = false;
  33923. _this._caps.vertexArrayObject = false;
  33924. _this._caps.instancedArrays = false;
  33925. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33926. // Wrappers
  33927. if (typeof URL === "undefined") {
  33928. URL = {
  33929. createObjectURL: function () { },
  33930. revokeObjectURL: function () { }
  33931. };
  33932. }
  33933. if (typeof Blob === "undefined") {
  33934. Blob = function () { };
  33935. }
  33936. return _this;
  33937. }
  33938. /**
  33939. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33940. */
  33941. NullEngine.prototype.isDeterministicLockStep = function () {
  33942. return this._options.deterministicLockstep;
  33943. };
  33944. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33945. NullEngine.prototype.getLockstepMaxSteps = function () {
  33946. return this._options.lockstepMaxSteps;
  33947. };
  33948. /**
  33949. * Sets hardware scaling, used to save performance if needed
  33950. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33951. */
  33952. NullEngine.prototype.getHardwareScalingLevel = function () {
  33953. return 1.0;
  33954. };
  33955. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33956. return {
  33957. capacity: 0,
  33958. references: 1,
  33959. is32Bits: false
  33960. };
  33961. };
  33962. NullEngine.prototype.createIndexBuffer = function (indices) {
  33963. return {
  33964. capacity: 0,
  33965. references: 1,
  33966. is32Bits: false
  33967. };
  33968. };
  33969. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  33970. if (stencil === void 0) { stencil = false; }
  33971. };
  33972. NullEngine.prototype.getRenderWidth = function (useScreen) {
  33973. if (useScreen === void 0) { useScreen = false; }
  33974. if (!useScreen && this._currentRenderTarget) {
  33975. return this._currentRenderTarget.width;
  33976. }
  33977. return this._options.renderWidth;
  33978. };
  33979. NullEngine.prototype.getRenderHeight = function (useScreen) {
  33980. if (useScreen === void 0) { useScreen = false; }
  33981. if (!useScreen && this._currentRenderTarget) {
  33982. return this._currentRenderTarget.height;
  33983. }
  33984. return this._options.renderHeight;
  33985. };
  33986. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  33987. this._cachedViewport = viewport;
  33988. };
  33989. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  33990. return {
  33991. transformFeedback: null,
  33992. __SPECTOR_rebuildProgram: null,
  33993. isParallelCompiled: false
  33994. };
  33995. };
  33996. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  33997. return [];
  33998. };
  33999. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34000. return [];
  34001. };
  34002. NullEngine.prototype.bindSamplers = function (effect) {
  34003. this._currentEffect = null;
  34004. };
  34005. NullEngine.prototype.enableEffect = function (effect) {
  34006. this._currentEffect = effect;
  34007. if (effect.onBind) {
  34008. effect.onBind(effect);
  34009. }
  34010. if (effect._onBindObservable) {
  34011. effect._onBindObservable.notifyObservers(effect);
  34012. }
  34013. };
  34014. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34015. if (zOffset === void 0) { zOffset = 0; }
  34016. if (reverseSide === void 0) { reverseSide = false; }
  34017. };
  34018. NullEngine.prototype.setIntArray = function (uniform, array) {
  34019. };
  34020. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34021. };
  34022. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34023. };
  34024. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34025. };
  34026. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34027. };
  34028. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34029. };
  34030. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34031. };
  34032. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34033. };
  34034. NullEngine.prototype.setArray = function (uniform, array) {
  34035. };
  34036. NullEngine.prototype.setArray2 = function (uniform, array) {
  34037. };
  34038. NullEngine.prototype.setArray3 = function (uniform, array) {
  34039. };
  34040. NullEngine.prototype.setArray4 = function (uniform, array) {
  34041. };
  34042. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34043. };
  34044. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34045. };
  34046. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34047. };
  34048. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34049. };
  34050. NullEngine.prototype.setFloat = function (uniform, value) {
  34051. };
  34052. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34053. };
  34054. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34055. };
  34056. NullEngine.prototype.setBool = function (uniform, bool) {
  34057. };
  34058. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34059. };
  34060. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34061. };
  34062. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34063. };
  34064. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34065. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34066. if (this._alphaMode === mode) {
  34067. return;
  34068. }
  34069. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34070. if (!noDepthWriteChange) {
  34071. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34072. }
  34073. this._alphaMode = mode;
  34074. };
  34075. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34076. };
  34077. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34078. if (this.preventCacheWipeBetweenFrames) {
  34079. return;
  34080. }
  34081. this.resetTextureCache();
  34082. this._currentEffect = null;
  34083. if (bruteForce) {
  34084. this._currentProgram = null;
  34085. this._stencilState.reset();
  34086. this._depthCullingState.reset();
  34087. this._alphaState.reset();
  34088. }
  34089. this._cachedVertexBuffers = null;
  34090. this._cachedIndexBuffer = null;
  34091. this._cachedEffectForVertexBuffers = null;
  34092. };
  34093. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34094. };
  34095. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34096. };
  34097. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34098. };
  34099. /** @hidden */
  34100. NullEngine.prototype._createTexture = function () {
  34101. return {};
  34102. };
  34103. /** @hidden */
  34104. NullEngine.prototype._releaseTexture = function (texture) {
  34105. };
  34106. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34107. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34108. if (onLoad === void 0) { onLoad = null; }
  34109. if (onError === void 0) { onError = null; }
  34110. if (buffer === void 0) { buffer = null; }
  34111. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34112. var url = String(urlArg);
  34113. texture.url = url;
  34114. texture.generateMipMaps = !noMipmap;
  34115. texture.samplingMode = samplingMode;
  34116. texture.invertY = invertY;
  34117. texture.baseWidth = this._options.textureSize;
  34118. texture.baseHeight = this._options.textureSize;
  34119. texture.width = this._options.textureSize;
  34120. texture.height = this._options.textureSize;
  34121. if (format) {
  34122. texture.format = format;
  34123. }
  34124. texture.isReady = true;
  34125. if (onLoad) {
  34126. onLoad();
  34127. }
  34128. this._internalTexturesCache.push(texture);
  34129. return texture;
  34130. };
  34131. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34132. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34133. if (options !== undefined && typeof options === "object") {
  34134. fullOptions.generateMipMaps = options.generateMipMaps;
  34135. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34136. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34137. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34138. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34139. }
  34140. else {
  34141. fullOptions.generateMipMaps = options;
  34142. fullOptions.generateDepthBuffer = true;
  34143. fullOptions.generateStencilBuffer = false;
  34144. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34145. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34146. }
  34147. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34148. var width = size.width || size;
  34149. var height = size.height || size;
  34150. texture._depthStencilBuffer = {};
  34151. texture._framebuffer = {};
  34152. texture.baseWidth = width;
  34153. texture.baseHeight = height;
  34154. texture.width = width;
  34155. texture.height = height;
  34156. texture.isReady = true;
  34157. texture.samples = 1;
  34158. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34159. texture.samplingMode = fullOptions.samplingMode;
  34160. texture.type = fullOptions.type;
  34161. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34162. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34163. this._internalTexturesCache.push(texture);
  34164. return texture;
  34165. };
  34166. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34167. texture.samplingMode = samplingMode;
  34168. };
  34169. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34170. if (this._currentRenderTarget) {
  34171. this.unBindFramebuffer(this._currentRenderTarget);
  34172. }
  34173. this._currentRenderTarget = texture;
  34174. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34175. if (this._cachedViewport && !forceFullscreenViewport) {
  34176. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34177. }
  34178. };
  34179. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34180. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34181. this._currentRenderTarget = null;
  34182. if (onBeforeUnbind) {
  34183. if (texture._MSAAFramebuffer) {
  34184. this._currentFramebuffer = texture._framebuffer;
  34185. }
  34186. onBeforeUnbind();
  34187. }
  34188. this._currentFramebuffer = null;
  34189. };
  34190. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34191. var vbo = {
  34192. capacity: 1,
  34193. references: 1,
  34194. is32Bits: false
  34195. };
  34196. return vbo;
  34197. };
  34198. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34199. if (premulAlpha === void 0) { premulAlpha = false; }
  34200. };
  34201. NullEngine.prototype.areAllEffectsReady = function () {
  34202. return true;
  34203. };
  34204. /**
  34205. * @hidden
  34206. * Get the current error code of the webGL context
  34207. * @returns the error code
  34208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34209. */
  34210. NullEngine.prototype.getError = function () {
  34211. return 0;
  34212. };
  34213. /** @hidden */
  34214. NullEngine.prototype._getUnpackAlignement = function () {
  34215. return 1;
  34216. };
  34217. /** @hidden */
  34218. NullEngine.prototype._unpackFlipY = function (value) {
  34219. };
  34220. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34221. if (offset === void 0) { offset = 0; }
  34222. };
  34223. /**
  34224. * Updates a dynamic vertex buffer.
  34225. * @param vertexBuffer the vertex buffer to update
  34226. * @param data the data used to update the vertex buffer
  34227. * @param byteOffset the byte offset of the data (optional)
  34228. * @param byteLength the byte length of the data (optional)
  34229. */
  34230. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34231. };
  34232. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34233. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34234. this._boundTexturesCache[this._activeChannel] = texture;
  34235. return true;
  34236. }
  34237. return false;
  34238. };
  34239. /** @hidden */
  34240. NullEngine.prototype._bindTexture = function (channel, texture) {
  34241. if (channel < 0) {
  34242. return;
  34243. }
  34244. this._bindTextureDirectly(0, texture);
  34245. };
  34246. /** @hidden */
  34247. NullEngine.prototype._releaseBuffer = function (buffer) {
  34248. buffer.references--;
  34249. if (buffer.references === 0) {
  34250. return true;
  34251. }
  34252. return false;
  34253. };
  34254. NullEngine.prototype.releaseEffects = function () {
  34255. };
  34256. NullEngine.prototype.displayLoadingUI = function () {
  34257. };
  34258. NullEngine.prototype.hideLoadingUI = function () {
  34259. };
  34260. /** @hidden */
  34261. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34262. if (faceIndex === void 0) { faceIndex = 0; }
  34263. if (lod === void 0) { lod = 0; }
  34264. };
  34265. /** @hidden */
  34266. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34267. if (faceIndex === void 0) { faceIndex = 0; }
  34268. if (lod === void 0) { lod = 0; }
  34269. };
  34270. /** @hidden */
  34271. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34272. if (faceIndex === void 0) { faceIndex = 0; }
  34273. if (lod === void 0) { lod = 0; }
  34274. };
  34275. /** @hidden */
  34276. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34277. if (faceIndex === void 0) { faceIndex = 0; }
  34278. if (lod === void 0) { lod = 0; }
  34279. };
  34280. return NullEngine;
  34281. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34282. /***/ }),
  34283. /***/ "./Events/clipboardEvents.ts":
  34284. /*!***********************************!*\
  34285. !*** ./Events/clipboardEvents.ts ***!
  34286. \***********************************/
  34287. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34289. "use strict";
  34290. __webpack_require__.r(__webpack_exports__);
  34291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34293. /**
  34294. * Gather the list of clipboard event types as constants.
  34295. */
  34296. var ClipboardEventTypes = /** @class */ (function () {
  34297. function ClipboardEventTypes() {
  34298. }
  34299. /**
  34300. * The clipboard event is fired when a copy command is active (pressed).
  34301. */
  34302. ClipboardEventTypes.COPY = 0x01; //
  34303. /**
  34304. * The clipboard event is fired when a cut command is active (pressed).
  34305. */
  34306. ClipboardEventTypes.CUT = 0x02;
  34307. /**
  34308. * The clipboard event is fired when a paste command is active (pressed).
  34309. */
  34310. ClipboardEventTypes.PASTE = 0x03;
  34311. return ClipboardEventTypes;
  34312. }());
  34313. /**
  34314. * This class is used to store clipboard related info for the onClipboardObservable event.
  34315. */
  34316. var ClipboardInfo = /** @class */ (function () {
  34317. /**
  34318. *Creates an instance of ClipboardInfo.
  34319. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34320. * @param event Defines the related dom event
  34321. */
  34322. function ClipboardInfo(
  34323. /**
  34324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34325. */
  34326. type,
  34327. /**
  34328. * Defines the related dom event
  34329. */
  34330. event) {
  34331. this.type = type;
  34332. this.event = event;
  34333. }
  34334. /**
  34335. * Get the clipboard event's type from the keycode.
  34336. * @param keyCode Defines the keyCode for the current keyboard event.
  34337. * @return {number}
  34338. */
  34339. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34340. var charCode = keyCode;
  34341. //TODO: add codes for extended ASCII
  34342. switch (charCode) {
  34343. case 67: return ClipboardEventTypes.COPY;
  34344. case 86: return ClipboardEventTypes.PASTE;
  34345. case 88: return ClipboardEventTypes.CUT;
  34346. default: return -1;
  34347. }
  34348. };
  34349. return ClipboardInfo;
  34350. }());
  34351. /***/ }),
  34352. /***/ "./Events/index.ts":
  34353. /*!*************************!*\
  34354. !*** ./Events/index.ts ***!
  34355. \*************************/
  34356. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34358. "use strict";
  34359. __webpack_require__.r(__webpack_exports__);
  34360. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34364. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34369. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34372. /***/ }),
  34373. /***/ "./Events/keyboardEvents.ts":
  34374. /*!**********************************!*\
  34375. !*** ./Events/keyboardEvents.ts ***!
  34376. \**********************************/
  34377. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34379. "use strict";
  34380. __webpack_require__.r(__webpack_exports__);
  34381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34384. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34385. /**
  34386. * Gather the list of keyboard event types as constants.
  34387. */
  34388. var KeyboardEventTypes = /** @class */ (function () {
  34389. function KeyboardEventTypes() {
  34390. }
  34391. /**
  34392. * The keydown event is fired when a key becomes active (pressed).
  34393. */
  34394. KeyboardEventTypes.KEYDOWN = 0x01;
  34395. /**
  34396. * The keyup event is fired when a key has been released.
  34397. */
  34398. KeyboardEventTypes.KEYUP = 0x02;
  34399. return KeyboardEventTypes;
  34400. }());
  34401. /**
  34402. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34403. */
  34404. var KeyboardInfo = /** @class */ (function () {
  34405. /**
  34406. * Instantiates a new keyboard info.
  34407. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34408. * @param type Defines the type of event (KeyboardEventTypes)
  34409. * @param event Defines the related dom event
  34410. */
  34411. function KeyboardInfo(
  34412. /**
  34413. * Defines the type of event (KeyboardEventTypes)
  34414. */
  34415. type,
  34416. /**
  34417. * Defines the related dom event
  34418. */
  34419. event) {
  34420. this.type = type;
  34421. this.event = event;
  34422. }
  34423. return KeyboardInfo;
  34424. }());
  34425. /**
  34426. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34427. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34428. */
  34429. var KeyboardInfoPre = /** @class */ (function (_super) {
  34430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34431. /**
  34432. * Instantiates a new keyboard pre info.
  34433. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34434. * @param type Defines the type of event (KeyboardEventTypes)
  34435. * @param event Defines the related dom event
  34436. */
  34437. function KeyboardInfoPre(
  34438. /**
  34439. * Defines the type of event (KeyboardEventTypes)
  34440. */
  34441. type,
  34442. /**
  34443. * Defines the related dom event
  34444. */
  34445. event) {
  34446. var _this = _super.call(this, type, event) || this;
  34447. _this.type = type;
  34448. _this.event = event;
  34449. _this.skipOnPointerObservable = false;
  34450. return _this;
  34451. }
  34452. return KeyboardInfoPre;
  34453. }(KeyboardInfo));
  34454. /***/ }),
  34455. /***/ "./Events/pointerEvents.ts":
  34456. /*!*********************************!*\
  34457. !*** ./Events/pointerEvents.ts ***!
  34458. \*********************************/
  34459. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34461. "use strict";
  34462. __webpack_require__.r(__webpack_exports__);
  34463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34468. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34469. /**
  34470. * Gather the list of pointer event types as constants.
  34471. */
  34472. var PointerEventTypes = /** @class */ (function () {
  34473. function PointerEventTypes() {
  34474. }
  34475. /**
  34476. * 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.
  34477. */
  34478. PointerEventTypes.POINTERDOWN = 0x01;
  34479. /**
  34480. * The pointerup event is fired when a pointer is no longer active.
  34481. */
  34482. PointerEventTypes.POINTERUP = 0x02;
  34483. /**
  34484. * The pointermove event is fired when a pointer changes coordinates.
  34485. */
  34486. PointerEventTypes.POINTERMOVE = 0x04;
  34487. /**
  34488. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34489. */
  34490. PointerEventTypes.POINTERWHEEL = 0x08;
  34491. /**
  34492. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34493. */
  34494. PointerEventTypes.POINTERPICK = 0x10;
  34495. /**
  34496. * The pointertap event is fired when a the object has been touched and released without drag.
  34497. */
  34498. PointerEventTypes.POINTERTAP = 0x20;
  34499. /**
  34500. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34501. */
  34502. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34503. return PointerEventTypes;
  34504. }());
  34505. /**
  34506. * Base class of pointer info types.
  34507. */
  34508. var PointerInfoBase = /** @class */ (function () {
  34509. /**
  34510. * Instantiates the base class of pointers info.
  34511. * @param type Defines the type of event (PointerEventTypes)
  34512. * @param event Defines the related dom event
  34513. */
  34514. function PointerInfoBase(
  34515. /**
  34516. * Defines the type of event (PointerEventTypes)
  34517. */
  34518. type,
  34519. /**
  34520. * Defines the related dom event
  34521. */
  34522. event) {
  34523. this.type = type;
  34524. this.event = event;
  34525. }
  34526. return PointerInfoBase;
  34527. }());
  34528. /**
  34529. * This class is used to store pointer related info for the onPrePointerObservable event.
  34530. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34531. */
  34532. var PointerInfoPre = /** @class */ (function (_super) {
  34533. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34534. /**
  34535. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34536. * @param type Defines the type of event (PointerEventTypes)
  34537. * @param event Defines the related dom event
  34538. * @param localX Defines the local x coordinates of the pointer when the event occured
  34539. * @param localY Defines the local y coordinates of the pointer when the event occured
  34540. */
  34541. function PointerInfoPre(type, event, localX, localY) {
  34542. var _this = _super.call(this, type, event) || this;
  34543. /**
  34544. * Ray from a pointer if availible (eg. 6dof controller)
  34545. */
  34546. _this.ray = null;
  34547. _this.skipOnPointerObservable = false;
  34548. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34549. return _this;
  34550. }
  34551. return PointerInfoPre;
  34552. }(PointerInfoBase));
  34553. /**
  34554. * This type contains all the data related to a pointer event in Babylon.js.
  34555. * 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.
  34556. */
  34557. var PointerInfo = /** @class */ (function (_super) {
  34558. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34559. /**
  34560. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34561. * @param type Defines the type of event (PointerEventTypes)
  34562. * @param event Defines the related dom event
  34563. * @param pickInfo Defines the picking info associated to the info (if any)\
  34564. */
  34565. function PointerInfo(type, event,
  34566. /**
  34567. * Defines the picking info associated to the info (if any)\
  34568. */
  34569. pickInfo) {
  34570. var _this = _super.call(this, type, event) || this;
  34571. _this.pickInfo = pickInfo;
  34572. return _this;
  34573. }
  34574. return PointerInfo;
  34575. }(PointerInfoBase));
  34576. /***/ }),
  34577. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34578. /*!****************************************************!*\
  34579. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34580. \****************************************************/
  34581. /*! exports provided: DaydreamController */
  34582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34583. "use strict";
  34584. __webpack_require__.r(__webpack_exports__);
  34585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34587. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34588. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34589. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34590. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34591. /**
  34592. * Google Daydream controller
  34593. */
  34594. var DaydreamController = /** @class */ (function (_super) {
  34595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34596. /**
  34597. * Creates a new DaydreamController from a gamepad
  34598. * @param vrGamepad the gamepad that the controller should be created from
  34599. */
  34600. function DaydreamController(vrGamepad) {
  34601. var _this = _super.call(this, vrGamepad) || this;
  34602. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34603. return _this;
  34604. }
  34605. /**
  34606. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34607. * @param scene scene in which to add meshes
  34608. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34609. */
  34610. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34611. var _this = this;
  34612. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34613. _this._defaultModel = newMeshes[1];
  34614. _this.attachToMesh(_this._defaultModel);
  34615. if (meshLoaded) {
  34616. meshLoaded(_this._defaultModel);
  34617. }
  34618. });
  34619. };
  34620. /**
  34621. * Called once for each button that changed state since the last frame
  34622. * @param buttonIdx Which button index changed
  34623. * @param state New state of the button
  34624. * @param changes Which properties on the state changed since last frame
  34625. */
  34626. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34627. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34628. if (buttonIdx === 0) {
  34629. var observable = this.onTriggerStateChangedObservable;
  34630. if (observable) {
  34631. observable.notifyObservers(state);
  34632. }
  34633. }
  34634. else {
  34635. // If the app or home buttons are ever made available
  34636. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34637. }
  34638. };
  34639. /**
  34640. * Base Url for the controller model.
  34641. */
  34642. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34643. /**
  34644. * File name for the controller model.
  34645. */
  34646. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34647. /**
  34648. * Gamepad Id prefix used to identify Daydream Controller.
  34649. */
  34650. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34651. return DaydreamController;
  34652. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34653. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34654. canCreate: function (gamepadInfo) {
  34655. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34656. },
  34657. create: function (gamepadInfo) {
  34658. return new DaydreamController(gamepadInfo);
  34659. }
  34660. });
  34661. /***/ }),
  34662. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34663. /*!**************************************************!*\
  34664. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34665. \**************************************************/
  34666. /*! exports provided: GearVRController */
  34667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34668. "use strict";
  34669. __webpack_require__.r(__webpack_exports__);
  34670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34673. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34674. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34675. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34676. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34677. /**
  34678. * Gear VR Controller
  34679. */
  34680. var GearVRController = /** @class */ (function (_super) {
  34681. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34682. /**
  34683. * Creates a new GearVRController from a gamepad
  34684. * @param vrGamepad the gamepad that the controller should be created from
  34685. */
  34686. function GearVRController(vrGamepad) {
  34687. var _this = _super.call(this, vrGamepad) || this;
  34688. _this._buttonIndexToObservableNameMap = [
  34689. 'onTrackpadChangedObservable',
  34690. 'onTriggerStateChangedObservable' // Trigger
  34691. ];
  34692. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34693. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34694. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34695. _this._disableTrackPosition(_this._calculatedPosition);
  34696. return _this;
  34697. }
  34698. /**
  34699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34700. * @param scene scene in which to add meshes
  34701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34702. */
  34703. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34704. var _this = this;
  34705. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34706. // Offset the controller so it will rotate around the users wrist
  34707. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34708. newMeshes[1].parent = mesh;
  34709. newMeshes[1].position.z = -0.15;
  34710. _this._defaultModel = mesh;
  34711. _this.attachToMesh(_this._defaultModel);
  34712. if (meshLoaded) {
  34713. meshLoaded(_this._defaultModel);
  34714. }
  34715. });
  34716. };
  34717. /**
  34718. * Called once for each button that changed state since the last frame
  34719. * @param buttonIdx Which button index changed
  34720. * @param state New state of the button
  34721. * @param changes Which properties on the state changed since last frame
  34722. */
  34723. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34724. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34725. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34726. // Only emit events for buttons that we know how to map from index to observable
  34727. var observable = this[observableName];
  34728. if (observable) {
  34729. observable.notifyObservers(state);
  34730. }
  34731. }
  34732. };
  34733. /**
  34734. * Base Url for the controller model.
  34735. */
  34736. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34737. /**
  34738. * File name for the controller model.
  34739. */
  34740. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34741. /**
  34742. * Gamepad Id prefix used to identify this controller.
  34743. */
  34744. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34745. return GearVRController;
  34746. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34747. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34748. canCreate: function (gamepadInfo) {
  34749. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34750. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34751. },
  34752. create: function (gamepadInfo) {
  34753. return new GearVRController(gamepadInfo);
  34754. }
  34755. });
  34756. /***/ }),
  34757. /***/ "./Gamepads/Controllers/genericController.ts":
  34758. /*!***************************************************!*\
  34759. !*** ./Gamepads/Controllers/genericController.ts ***!
  34760. \***************************************************/
  34761. /*! exports provided: GenericController */
  34762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34763. "use strict";
  34764. __webpack_require__.r(__webpack_exports__);
  34765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34766. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34767. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34768. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34769. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34770. /**
  34771. * Generic Controller
  34772. */
  34773. var GenericController = /** @class */ (function (_super) {
  34774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34775. /**
  34776. * Creates a new GenericController from a gamepad
  34777. * @param vrGamepad the gamepad that the controller should be created from
  34778. */
  34779. function GenericController(vrGamepad) {
  34780. return _super.call(this, vrGamepad) || this;
  34781. }
  34782. /**
  34783. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34784. * @param scene scene in which to add meshes
  34785. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34786. */
  34787. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34788. var _this = this;
  34789. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34790. _this._defaultModel = newMeshes[1];
  34791. _this.attachToMesh(_this._defaultModel);
  34792. if (meshLoaded) {
  34793. meshLoaded(_this._defaultModel);
  34794. }
  34795. });
  34796. };
  34797. /**
  34798. * Called once for each button that changed state since the last frame
  34799. * @param buttonIdx Which button index changed
  34800. * @param state New state of the button
  34801. * @param changes Which properties on the state changed since last frame
  34802. */
  34803. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34804. console.log("Button id: " + buttonIdx + "state: ");
  34805. console.dir(state);
  34806. };
  34807. /**
  34808. * Base Url for the controller model.
  34809. */
  34810. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34811. /**
  34812. * File name for the controller model.
  34813. */
  34814. GenericController.MODEL_FILENAME = 'generic.babylon';
  34815. return GenericController;
  34816. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34817. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34818. /***/ }),
  34819. /***/ "./Gamepads/Controllers/index.ts":
  34820. /*!***************************************!*\
  34821. !*** ./Gamepads/Controllers/index.ts ***!
  34822. \***************************************/
  34823. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34825. "use strict";
  34826. __webpack_require__.r(__webpack_exports__);
  34827. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34829. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34831. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34833. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34835. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34839. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34841. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34843. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34845. /***/ }),
  34846. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34847. /*!*******************************************************!*\
  34848. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34849. \*******************************************************/
  34850. /*! exports provided: OculusTouchController */
  34851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34852. "use strict";
  34853. __webpack_require__.r(__webpack_exports__);
  34854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34855. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34856. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34857. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34858. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34859. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34860. /**
  34861. * Oculus Touch Controller
  34862. */
  34863. var OculusTouchController = /** @class */ (function (_super) {
  34864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34865. /**
  34866. * Creates a new OculusTouchController from a gamepad
  34867. * @param vrGamepad the gamepad that the controller should be created from
  34868. */
  34869. function OculusTouchController(vrGamepad) {
  34870. var _this = _super.call(this, vrGamepad) || this;
  34871. /**
  34872. * Fired when the secondary trigger on this controller is modified
  34873. */
  34874. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34875. /**
  34876. * Fired when the thumb rest on this controller is modified
  34877. */
  34878. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34879. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34880. return _this;
  34881. }
  34882. /**
  34883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34884. * @param scene scene in which to add meshes
  34885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34886. */
  34887. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34888. var _this = this;
  34889. var meshName;
  34890. // Hand
  34891. if (this.hand === 'left') {
  34892. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34893. }
  34894. else { // Right is the default if no hand is specified
  34895. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34896. }
  34897. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34898. /*
  34899. Parent Mesh name: oculus_touch_left
  34900. - body
  34901. - trigger
  34902. - thumbstick
  34903. - grip
  34904. - button_y
  34905. - button_x
  34906. - button_enter
  34907. */
  34908. _this._defaultModel = newMeshes[1];
  34909. _this.attachToMesh(_this._defaultModel);
  34910. if (meshLoaded) {
  34911. meshLoaded(_this._defaultModel);
  34912. }
  34913. });
  34914. };
  34915. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34916. /**
  34917. * Fired when the A button on this controller is modified
  34918. */
  34919. get: function () {
  34920. if (this.hand === 'right') {
  34921. return this.onMainButtonStateChangedObservable;
  34922. }
  34923. else {
  34924. throw new Error('No A button on left hand');
  34925. }
  34926. },
  34927. enumerable: true,
  34928. configurable: true
  34929. });
  34930. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34931. /**
  34932. * Fired when the B button on this controller is modified
  34933. */
  34934. get: function () {
  34935. if (this.hand === 'right') {
  34936. return this.onSecondaryButtonStateChangedObservable;
  34937. }
  34938. else {
  34939. throw new Error('No B button on left hand');
  34940. }
  34941. },
  34942. enumerable: true,
  34943. configurable: true
  34944. });
  34945. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34946. /**
  34947. * Fired when the X button on this controller is modified
  34948. */
  34949. get: function () {
  34950. if (this.hand === 'left') {
  34951. return this.onMainButtonStateChangedObservable;
  34952. }
  34953. else {
  34954. throw new Error('No X button on right hand');
  34955. }
  34956. },
  34957. enumerable: true,
  34958. configurable: true
  34959. });
  34960. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34961. /**
  34962. * Fired when the Y button on this controller is modified
  34963. */
  34964. get: function () {
  34965. if (this.hand === 'left') {
  34966. return this.onSecondaryButtonStateChangedObservable;
  34967. }
  34968. else {
  34969. throw new Error('No Y button on right hand');
  34970. }
  34971. },
  34972. enumerable: true,
  34973. configurable: true
  34974. });
  34975. /**
  34976. * Called once for each button that changed state since the last frame
  34977. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34978. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34979. * 2) secondary trigger (same)
  34980. * 3) A (right) X (left), touch, pressed = value
  34981. * 4) B / Y
  34982. * 5) thumb rest
  34983. * @param buttonIdx Which button index changed
  34984. * @param state New state of the button
  34985. * @param changes Which properties on the state changed since last frame
  34986. */
  34987. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34988. var notifyObject = state; //{ state: state, changes: changes };
  34989. var triggerDirection = this.hand === 'right' ? -1 : 1;
  34990. switch (buttonIdx) {
  34991. case 0:
  34992. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34993. return;
  34994. case 1: // index trigger
  34995. if (this._defaultModel) {
  34996. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  34997. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  34998. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  34999. }
  35000. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35001. return;
  35002. case 2: // secondary trigger
  35003. if (this._defaultModel) {
  35004. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35005. }
  35006. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35007. return;
  35008. case 3:
  35009. if (this._defaultModel) {
  35010. if (notifyObject.pressed) {
  35011. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35012. }
  35013. else {
  35014. (this._defaultModel.getChildren()[1]).position.y = 0;
  35015. }
  35016. }
  35017. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35018. return;
  35019. case 4:
  35020. if (this._defaultModel) {
  35021. if (notifyObject.pressed) {
  35022. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35023. }
  35024. else {
  35025. (this._defaultModel.getChildren()[2]).position.y = 0;
  35026. }
  35027. }
  35028. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35029. return;
  35030. case 5:
  35031. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35032. return;
  35033. }
  35034. };
  35035. /**
  35036. * Base Url for the controller model.
  35037. */
  35038. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35039. /**
  35040. * File name for the left controller model.
  35041. */
  35042. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35043. /**
  35044. * File name for the right controller model.
  35045. */
  35046. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35047. return OculusTouchController;
  35048. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35049. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35050. canCreate: function (gamepadInfo) {
  35051. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35052. },
  35053. create: function (gamepadInfo) {
  35054. return new OculusTouchController(gamepadInfo);
  35055. }
  35056. });
  35057. /***/ }),
  35058. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35059. /*!*******************************************************!*\
  35060. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35061. \*******************************************************/
  35062. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35064. "use strict";
  35065. __webpack_require__.r(__webpack_exports__);
  35066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35070. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35071. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35072. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35073. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35074. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35075. /**
  35076. * Defines the types of pose enabled controllers that are supported
  35077. */
  35078. var PoseEnabledControllerType;
  35079. (function (PoseEnabledControllerType) {
  35080. /**
  35081. * HTC Vive
  35082. */
  35083. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35084. /**
  35085. * Oculus Rift
  35086. */
  35087. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35088. /**
  35089. * Windows mixed reality
  35090. */
  35091. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35092. /**
  35093. * Samsung gear VR
  35094. */
  35095. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35096. /**
  35097. * Google Daydream
  35098. */
  35099. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35100. /**
  35101. * Generic
  35102. */
  35103. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35104. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35105. /**
  35106. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35107. */
  35108. var PoseEnabledControllerHelper = /** @class */ (function () {
  35109. function PoseEnabledControllerHelper() {
  35110. }
  35111. /**
  35112. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35113. * @param vrGamepad the gamepad to initialized
  35114. * @returns a vr controller of the type the gamepad identified as
  35115. */
  35116. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35117. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35118. var factory = _a[_i];
  35119. if (factory.canCreate(vrGamepad)) {
  35120. return factory.create(vrGamepad);
  35121. }
  35122. }
  35123. if (this._DefaultControllerFactory) {
  35124. return this._DefaultControllerFactory(vrGamepad);
  35125. }
  35126. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35127. };
  35128. /** @hidden */
  35129. PoseEnabledControllerHelper._ControllerFactories = [];
  35130. /** @hidden */
  35131. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35132. return PoseEnabledControllerHelper;
  35133. }());
  35134. /**
  35135. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35136. */
  35137. var PoseEnabledController = /** @class */ (function (_super) {
  35138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35139. /**
  35140. * Creates a new PoseEnabledController from a gamepad
  35141. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35142. */
  35143. function PoseEnabledController(browserGamepad) {
  35144. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35145. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35146. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35147. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35148. /**
  35149. * The device position in babylon space
  35150. */
  35151. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35152. /**
  35153. * The device rotation in babylon space
  35154. */
  35155. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35156. /**
  35157. * The scale factor of the device in babylon space
  35158. */
  35159. _this.deviceScaleFactor = 1;
  35160. // Used to convert 6dof controllers to 3dof
  35161. _this._trackPosition = true;
  35162. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35163. _this._draggedRoomRotation = 0;
  35164. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35165. /**
  35166. * Internal, matrix used to convert room space to babylon space
  35167. * @hidden
  35168. */
  35169. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35170. /**
  35171. * Node to be used when casting a ray from the controller
  35172. * @hidden
  35173. */
  35174. _this._pointingPoseNode = null;
  35175. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35176. /**
  35177. * @hidden
  35178. */
  35179. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35180. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35181. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35182. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35183. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35184. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35185. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35186. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35187. return _this;
  35188. }
  35189. /**
  35190. * @hidden
  35191. */
  35192. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35193. if (this._trackPosition) {
  35194. this._calculatedPosition.copyFrom(fixedPosition);
  35195. this._trackPosition = false;
  35196. }
  35197. };
  35198. /**
  35199. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35200. */
  35201. PoseEnabledController.prototype.update = function () {
  35202. _super.prototype.update.call(this);
  35203. this._updatePoseAndMesh();
  35204. };
  35205. /**
  35206. * Updates only the pose device and mesh without doing any button event checking
  35207. */
  35208. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35209. var pose = this.browserGamepad.pose;
  35210. this.updateFromDevice(pose);
  35211. 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) {
  35212. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35213. camera._computeDevicePosition();
  35214. this._deviceToWorld.setTranslation(camera.devicePosition);
  35215. if (camera.deviceRotationQuaternion) {
  35216. var camera = camera;
  35217. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35218. // Find the radian distance away that the headset is from the controllers rotation
  35219. var distanceAway = Math.atan2(Math.sin(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].y - this._draggedRoomRotation), Math.cos(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].y - this._draggedRoomRotation));
  35220. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35221. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35222. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35223. this._draggedRoomRotation += rotationAmount;
  35224. // Rotate controller around headset
  35225. var sin = Math.sin(-rotationAmount);
  35226. var cos = Math.cos(-rotationAmount);
  35227. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35228. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35229. }
  35230. }
  35231. }
  35232. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35233. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35234. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35235. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35236. if (this._mesh) {
  35237. this._mesh.position.copyFrom(this.devicePosition);
  35238. if (this._mesh.rotationQuaternion) {
  35239. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35240. }
  35241. }
  35242. };
  35243. /**
  35244. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35245. * @param poseData raw pose fromthe device
  35246. */
  35247. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35248. if (poseData) {
  35249. this.rawPose = poseData;
  35250. if (poseData.position) {
  35251. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35252. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35253. this._deviceRoomPosition.z *= -1;
  35254. }
  35255. if (this._trackPosition) {
  35256. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35257. }
  35258. this._calculatedPosition.addInPlace(this.position);
  35259. }
  35260. var pose = this.rawPose;
  35261. if (poseData.orientation && pose.orientation) {
  35262. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35263. if (this._mesh) {
  35264. if (this._mesh.getScene().useRightHandedSystem) {
  35265. this._deviceRoomRotationQuaternion.z *= -1;
  35266. this._deviceRoomRotationQuaternion.w *= -1;
  35267. }
  35268. else {
  35269. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35270. }
  35271. }
  35272. // if the camera is set, rotate to the camera's rotation
  35273. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35274. }
  35275. }
  35276. };
  35277. /**
  35278. * Attaches a mesh to the controller
  35279. * @param mesh the mesh to be attached
  35280. */
  35281. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35282. if (this._mesh) {
  35283. this._mesh.parent = null;
  35284. }
  35285. this._mesh = mesh;
  35286. if (this._poseControlledCamera) {
  35287. this._mesh.parent = this._poseControlledCamera;
  35288. }
  35289. if (!this._mesh.rotationQuaternion) {
  35290. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35291. }
  35292. // 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
  35293. this._updatePoseAndMesh();
  35294. if (this._pointingPoseNode) {
  35295. var parents = [];
  35296. var obj = this._pointingPoseNode;
  35297. while (obj.parent) {
  35298. parents.push(obj.parent);
  35299. obj = obj.parent;
  35300. }
  35301. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35302. }
  35303. this._meshAttachedObservable.notifyObservers(mesh);
  35304. };
  35305. /**
  35306. * Attaches the controllers mesh to a camera
  35307. * @param camera the camera the mesh should be attached to
  35308. */
  35309. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35310. this._poseControlledCamera = camera;
  35311. if (this._mesh) {
  35312. this._mesh.parent = this._poseControlledCamera;
  35313. }
  35314. };
  35315. /**
  35316. * Disposes of the controller
  35317. */
  35318. PoseEnabledController.prototype.dispose = function () {
  35319. if (this._mesh) {
  35320. this._mesh.dispose();
  35321. }
  35322. this._mesh = null;
  35323. _super.prototype.dispose.call(this);
  35324. };
  35325. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35326. /**
  35327. * The mesh that is attached to the controller
  35328. */
  35329. get: function () {
  35330. return this._mesh;
  35331. },
  35332. enumerable: true,
  35333. configurable: true
  35334. });
  35335. /**
  35336. * Gets the ray of the controller in the direction the controller is pointing
  35337. * @param length the length the resulting ray should be
  35338. * @returns a ray in the direction the controller is pointing
  35339. */
  35340. PoseEnabledController.prototype.getForwardRay = function (length) {
  35341. if (length === void 0) { length = 100; }
  35342. if (!this.mesh) {
  35343. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1), length);
  35344. }
  35345. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35346. var origin = m.getTranslation();
  35347. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35348. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35349. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35350. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35351. };
  35352. /**
  35353. * Name of the child mesh that can be used to cast a ray from the controller
  35354. */
  35355. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35356. return PoseEnabledController;
  35357. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35358. /***/ }),
  35359. /***/ "./Gamepads/Controllers/viveController.ts":
  35360. /*!************************************************!*\
  35361. !*** ./Gamepads/Controllers/viveController.ts ***!
  35362. \************************************************/
  35363. /*! exports provided: ViveController */
  35364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35365. "use strict";
  35366. __webpack_require__.r(__webpack_exports__);
  35367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35368. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35369. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35370. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35371. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35372. /**
  35373. * Vive Controller
  35374. */
  35375. var ViveController = /** @class */ (function (_super) {
  35376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35377. /**
  35378. * Creates a new ViveController from a gamepad
  35379. * @param vrGamepad the gamepad that the controller should be created from
  35380. */
  35381. function ViveController(vrGamepad) {
  35382. var _this = _super.call(this, vrGamepad) || this;
  35383. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35384. _this._invertLeftStickY = true;
  35385. return _this;
  35386. }
  35387. /**
  35388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35389. * @param scene scene in which to add meshes
  35390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35391. */
  35392. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35393. var _this = this;
  35394. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35395. /*
  35396. Parent Mesh name: ViveWand
  35397. - body
  35398. - r_gripper
  35399. - l_gripper
  35400. - menu_button
  35401. - system_button
  35402. - trackpad
  35403. - trigger
  35404. - LED
  35405. */
  35406. _this._defaultModel = newMeshes[1];
  35407. _this.attachToMesh(_this._defaultModel);
  35408. if (meshLoaded) {
  35409. meshLoaded(_this._defaultModel);
  35410. }
  35411. });
  35412. };
  35413. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35414. /**
  35415. * Fired when the left button on this controller is modified
  35416. */
  35417. get: function () {
  35418. return this.onMainButtonStateChangedObservable;
  35419. },
  35420. enumerable: true,
  35421. configurable: true
  35422. });
  35423. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35424. /**
  35425. * Fired when the right button on this controller is modified
  35426. */
  35427. get: function () {
  35428. return this.onMainButtonStateChangedObservable;
  35429. },
  35430. enumerable: true,
  35431. configurable: true
  35432. });
  35433. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35434. /**
  35435. * Fired when the menu button on this controller is modified
  35436. */
  35437. get: function () {
  35438. return this.onSecondaryButtonStateChangedObservable;
  35439. },
  35440. enumerable: true,
  35441. configurable: true
  35442. });
  35443. /**
  35444. * Called once for each button that changed state since the last frame
  35445. * Vive mapping:
  35446. * 0: touchpad
  35447. * 1: trigger
  35448. * 2: left AND right buttons
  35449. * 3: menu button
  35450. * @param buttonIdx Which button index changed
  35451. * @param state New state of the button
  35452. * @param changes Which properties on the state changed since last frame
  35453. */
  35454. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35455. var notifyObject = state; //{ state: state, changes: changes };
  35456. switch (buttonIdx) {
  35457. case 0:
  35458. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35459. return;
  35460. case 1: // index trigger
  35461. if (this._defaultModel) {
  35462. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35463. }
  35464. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35465. return;
  35466. case 2: // left AND right button
  35467. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35468. return;
  35469. case 3:
  35470. if (this._defaultModel) {
  35471. if (notifyObject.pressed) {
  35472. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35473. }
  35474. else {
  35475. (this._defaultModel.getChildren()[2]).position.y = 0;
  35476. }
  35477. }
  35478. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35479. return;
  35480. }
  35481. };
  35482. /**
  35483. * Base Url for the controller model.
  35484. */
  35485. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35486. /**
  35487. * File name for the controller model.
  35488. */
  35489. ViveController.MODEL_FILENAME = 'wand.babylon';
  35490. return ViveController;
  35491. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35492. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35493. canCreate: function (gamepadInfo) {
  35494. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35495. },
  35496. create: function (gamepadInfo) {
  35497. return new ViveController(gamepadInfo);
  35498. }
  35499. });
  35500. /***/ }),
  35501. /***/ "./Gamepads/Controllers/webVRController.ts":
  35502. /*!*************************************************!*\
  35503. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35504. \*************************************************/
  35505. /*! exports provided: WebVRController */
  35506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35507. "use strict";
  35508. __webpack_require__.r(__webpack_exports__);
  35509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35511. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35512. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35513. /**
  35514. * Defines the WebVRController object that represents controllers tracked in 3D space
  35515. */
  35516. var WebVRController = /** @class */ (function (_super) {
  35517. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35518. /**
  35519. * Creates a new WebVRController from a gamepad
  35520. * @param vrGamepad the gamepad that the WebVRController should be created from
  35521. */
  35522. function WebVRController(vrGamepad) {
  35523. var _this = _super.call(this, vrGamepad) || this;
  35524. // Observables
  35525. /**
  35526. * Fired when the trigger state has changed
  35527. */
  35528. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35529. /**
  35530. * Fired when the main button state has changed
  35531. */
  35532. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35533. /**
  35534. * Fired when the secondary button state has changed
  35535. */
  35536. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35537. /**
  35538. * Fired when the pad state has changed
  35539. */
  35540. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35541. /**
  35542. * Fired when controllers stick values have changed
  35543. */
  35544. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35545. /**
  35546. * X and Y axis corrisponding to the controllers joystick
  35547. */
  35548. _this.pad = { x: 0, y: 0 };
  35549. // avoid GC, store state in a tmp object
  35550. _this._changes = {
  35551. pressChanged: false,
  35552. touchChanged: false,
  35553. valueChanged: false,
  35554. changed: false
  35555. };
  35556. _this._buttons = new Array(vrGamepad.buttons.length);
  35557. _this.hand = vrGamepad.hand;
  35558. return _this;
  35559. }
  35560. /**
  35561. * Fired when a controller button's state has changed
  35562. * @param callback the callback containing the button that was modified
  35563. */
  35564. WebVRController.prototype.onButtonStateChange = function (callback) {
  35565. this._onButtonStateChange = callback;
  35566. };
  35567. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35568. /**
  35569. * The default controller model for the controller
  35570. */
  35571. get: function () {
  35572. return this._defaultModel;
  35573. },
  35574. enumerable: true,
  35575. configurable: true
  35576. });
  35577. /**
  35578. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35579. */
  35580. WebVRController.prototype.update = function () {
  35581. _super.prototype.update.call(this);
  35582. for (var index = 0; index < this._buttons.length; index++) {
  35583. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35584. }
  35585. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35586. this.pad.x = this.leftStick.x;
  35587. this.pad.y = this.leftStick.y;
  35588. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35589. }
  35590. };
  35591. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35592. if (!newState) {
  35593. newState = {
  35594. pressed: false,
  35595. touched: false,
  35596. value: 0
  35597. };
  35598. }
  35599. if (!currentState) {
  35600. this._buttons[buttonIndex] = {
  35601. pressed: newState.pressed,
  35602. touched: newState.touched,
  35603. value: newState.value
  35604. };
  35605. return;
  35606. }
  35607. this._checkChanges(newState, currentState);
  35608. if (this._changes.changed) {
  35609. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35610. this._handleButtonChange(buttonIndex, newState, this._changes);
  35611. }
  35612. this._buttons[buttonIndex].pressed = newState.pressed;
  35613. this._buttons[buttonIndex].touched = newState.touched;
  35614. // oculus triggers are never 0, thou not touched.
  35615. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35616. };
  35617. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35618. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35619. this._changes.touchChanged = newState.touched !== currentState.touched;
  35620. this._changes.valueChanged = newState.value !== currentState.value;
  35621. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35622. return this._changes;
  35623. };
  35624. /**
  35625. * Disposes of th webVRCOntroller
  35626. */
  35627. WebVRController.prototype.dispose = function () {
  35628. _super.prototype.dispose.call(this);
  35629. this.onTriggerStateChangedObservable.clear();
  35630. this.onMainButtonStateChangedObservable.clear();
  35631. this.onSecondaryButtonStateChangedObservable.clear();
  35632. this.onPadStateChangedObservable.clear();
  35633. this.onPadValuesChangedObservable.clear();
  35634. };
  35635. return WebVRController;
  35636. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35637. /***/ }),
  35638. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35639. /*!*********************************************************!*\
  35640. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35641. \*********************************************************/
  35642. /*! exports provided: WindowsMotionController */
  35643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35644. "use strict";
  35645. __webpack_require__.r(__webpack_exports__);
  35646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35647. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35648. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35649. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35650. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35651. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35652. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35653. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35654. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35655. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35656. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35657. /**
  35658. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35659. */
  35660. var LoadedMeshInfo = /** @class */ (function () {
  35661. function LoadedMeshInfo() {
  35662. /**
  35663. * Map of the button meshes contained in the controller
  35664. */
  35665. this.buttonMeshes = {};
  35666. /**
  35667. * Map of the axis meshes contained in the controller
  35668. */
  35669. this.axisMeshes = {};
  35670. }
  35671. return LoadedMeshInfo;
  35672. }());
  35673. /**
  35674. * Defines the WindowsMotionController object that the state of the windows motion controller
  35675. */
  35676. var WindowsMotionController = /** @class */ (function (_super) {
  35677. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35678. /**
  35679. * Creates a new WindowsMotionController from a gamepad
  35680. * @param vrGamepad the gamepad that the controller should be created from
  35681. */
  35682. function WindowsMotionController(vrGamepad) {
  35683. var _this = _super.call(this, vrGamepad) || this;
  35684. _this._mapping = {
  35685. // Semantic button names
  35686. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35687. // A mapping of the button name to glTF model node name
  35688. // that should be transformed by button value.
  35689. buttonMeshNames: {
  35690. 'trigger': 'SELECT',
  35691. 'menu': 'MENU',
  35692. 'grip': 'GRASP',
  35693. 'thumbstick': 'THUMBSTICK_PRESS',
  35694. 'trackpad': 'TOUCHPAD_PRESS'
  35695. },
  35696. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35697. buttonObservableNames: {
  35698. 'trigger': 'onTriggerStateChangedObservable',
  35699. 'menu': 'onSecondaryButtonStateChangedObservable',
  35700. 'grip': 'onMainButtonStateChangedObservable',
  35701. 'thumbstick': 'onPadStateChangedObservable',
  35702. 'trackpad': 'onTrackpadChangedObservable'
  35703. },
  35704. // A mapping of the axis name to glTF model node name
  35705. // that should be transformed by axis value.
  35706. // This array mirrors the browserGamepad.axes array, such that
  35707. // the mesh corresponding to axis 0 is in this array index 0.
  35708. axisMeshNames: [
  35709. 'THUMBSTICK_X',
  35710. 'THUMBSTICK_Y',
  35711. 'TOUCHPAD_TOUCH_X',
  35712. 'TOUCHPAD_TOUCH_Y'
  35713. ],
  35714. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35715. };
  35716. /**
  35717. * Fired when the trackpad on this controller is clicked
  35718. */
  35719. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35720. /**
  35721. * Fired when the trackpad on this controller is modified
  35722. */
  35723. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35724. /**
  35725. * The current x and y values of this controller's trackpad
  35726. */
  35727. _this.trackpad = { x: 0, y: 0 };
  35728. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35729. _this._loadedMeshInfo = null;
  35730. return _this;
  35731. }
  35732. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35733. /**
  35734. * Fired when the trigger on this controller is modified
  35735. */
  35736. get: function () {
  35737. return this.onTriggerStateChangedObservable;
  35738. },
  35739. enumerable: true,
  35740. configurable: true
  35741. });
  35742. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35743. /**
  35744. * Fired when the menu button on this controller is modified
  35745. */
  35746. get: function () {
  35747. return this.onSecondaryButtonStateChangedObservable;
  35748. },
  35749. enumerable: true,
  35750. configurable: true
  35751. });
  35752. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35753. /**
  35754. * Fired when the grip button on this controller is modified
  35755. */
  35756. get: function () {
  35757. return this.onMainButtonStateChangedObservable;
  35758. },
  35759. enumerable: true,
  35760. configurable: true
  35761. });
  35762. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35763. /**
  35764. * Fired when the thumbstick button on this controller is modified
  35765. */
  35766. get: function () {
  35767. return this.onPadStateChangedObservable;
  35768. },
  35769. enumerable: true,
  35770. configurable: true
  35771. });
  35772. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35773. /**
  35774. * Fired when the touchpad button on this controller is modified
  35775. */
  35776. get: function () {
  35777. return this.onTrackpadChangedObservable;
  35778. },
  35779. enumerable: true,
  35780. configurable: true
  35781. });
  35782. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35783. /**
  35784. * Fired when the touchpad values on this controller are modified
  35785. */
  35786. get: function () {
  35787. return this.onTrackpadValuesChangedObservable;
  35788. },
  35789. enumerable: true,
  35790. configurable: true
  35791. });
  35792. WindowsMotionController.prototype._updateTrackpad = function () {
  35793. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35794. this.trackpad.x = this.browserGamepad["axes"][2];
  35795. this.trackpad.y = this.browserGamepad["axes"][3];
  35796. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35797. }
  35798. };
  35799. /**
  35800. * Called once per frame by the engine.
  35801. */
  35802. WindowsMotionController.prototype.update = function () {
  35803. _super.prototype.update.call(this);
  35804. if (this.browserGamepad.axes) {
  35805. this._updateTrackpad();
  35806. // Only need to animate axes if there is a loaded mesh
  35807. if (this._loadedMeshInfo) {
  35808. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35809. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35810. }
  35811. }
  35812. }
  35813. };
  35814. /**
  35815. * Called once for each button that changed state since the last frame
  35816. * @param buttonIdx Which button index changed
  35817. * @param state New state of the button
  35818. * @param changes Which properties on the state changed since last frame
  35819. */
  35820. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35821. var buttonName = this._mapping.buttons[buttonIdx];
  35822. if (!buttonName) {
  35823. return;
  35824. }
  35825. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35826. this._updateTrackpad();
  35827. // Only emit events for buttons that we know how to map from index to name
  35828. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35829. if (observable) {
  35830. observable.notifyObservers(state);
  35831. }
  35832. this._lerpButtonTransform(buttonName, state.value);
  35833. };
  35834. /**
  35835. * Moves the buttons on the controller mesh based on their current state
  35836. * @param buttonName the name of the button to move
  35837. * @param buttonValue the value of the button which determines the buttons new position
  35838. */
  35839. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35840. // If there is no loaded mesh, there is nothing to transform.
  35841. if (!this._loadedMeshInfo) {
  35842. return;
  35843. }
  35844. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35845. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35846. return;
  35847. }
  35848. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35849. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35850. };
  35851. /**
  35852. * Moves the axis on the controller mesh based on its current state
  35853. * @param axis the index of the axis
  35854. * @param axisValue the value of the axis which determines the meshes new position
  35855. * @hidden
  35856. */
  35857. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35858. if (!this._loadedMeshInfo) {
  35859. return;
  35860. }
  35861. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35862. if (!meshInfo) {
  35863. return;
  35864. }
  35865. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35866. return;
  35867. }
  35868. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35869. var lerpValue = axisValue * 0.5 + 0.5;
  35870. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35871. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35872. };
  35873. /**
  35874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35875. * @param scene scene in which to add meshes
  35876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35877. */
  35878. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35879. var _this = this;
  35880. if (forceDefault === void 0) { forceDefault = false; }
  35881. var path;
  35882. var filename;
  35883. // Checking if GLB loader is present
  35884. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35885. // Determine the device specific folder based on the ID suffix
  35886. var device = 'default';
  35887. if (this.id && !forceDefault) {
  35888. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35889. device = ((match && match[0]) || device);
  35890. }
  35891. // Hand
  35892. if (this.hand === 'left') {
  35893. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35894. }
  35895. else { // Right is the default if no hand is specified
  35896. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35897. }
  35898. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35899. }
  35900. else {
  35901. _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");
  35902. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35903. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35904. }
  35905. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35906. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35907. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35908. if (!_this._loadedMeshInfo) {
  35909. return;
  35910. }
  35911. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35912. _this.attachToMesh(_this._defaultModel);
  35913. if (meshLoaded) {
  35914. meshLoaded(_this._defaultModel);
  35915. }
  35916. }, null, function (scene, message) {
  35917. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35918. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35919. if (!forceDefault) {
  35920. _this.initControllerMesh(scene, meshLoaded, true);
  35921. }
  35922. });
  35923. };
  35924. /**
  35925. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35926. * can be transformed by button presses and axes values, based on this._mapping.
  35927. *
  35928. * @param scene scene in which the meshes exist
  35929. * @param meshes list of meshes that make up the controller model to process
  35930. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35931. */
  35932. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35933. var loadedMeshInfo = null;
  35934. // Create a new mesh to contain the glTF hierarchy
  35935. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35936. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35937. var childMesh = null;
  35938. for (var i = 0; i < meshes.length; i++) {
  35939. var mesh = meshes[i];
  35940. if (!mesh.parent) {
  35941. // Exclude controller meshes from picking results
  35942. mesh.isPickable = false;
  35943. // Handle root node, attach to the new parentMesh
  35944. childMesh = mesh;
  35945. break;
  35946. }
  35947. }
  35948. if (childMesh) {
  35949. childMesh.setParent(parentMesh);
  35950. // Create our mesh info. Note that this method will always return non-null.
  35951. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35952. }
  35953. else {
  35954. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35955. }
  35956. return loadedMeshInfo;
  35957. };
  35958. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35959. var loadedMeshInfo = new LoadedMeshInfo();
  35960. var i;
  35961. loadedMeshInfo.rootNode = rootNode;
  35962. // Reset the caches
  35963. loadedMeshInfo.buttonMeshes = {};
  35964. loadedMeshInfo.axisMeshes = {};
  35965. // Button Meshes
  35966. for (i = 0; i < this._mapping.buttons.length; i++) {
  35967. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  35968. if (!buttonMeshName) {
  35969. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  35970. continue;
  35971. }
  35972. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  35973. if (!buttonMesh) {
  35974. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  35975. continue;
  35976. }
  35977. var buttonMeshInfo = {
  35978. index: i,
  35979. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  35980. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  35981. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  35982. };
  35983. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  35984. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  35985. }
  35986. else {
  35987. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  35988. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  35989. '(VALUE: ' + !!buttonMeshInfo.value +
  35990. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  35991. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  35992. ')');
  35993. }
  35994. }
  35995. // Axis Meshes
  35996. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  35997. var axisMeshName = this._mapping.axisMeshNames[i];
  35998. if (!axisMeshName) {
  35999. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36000. continue;
  36001. }
  36002. var axisMesh = getChildByName(rootNode, axisMeshName);
  36003. if (!axisMesh) {
  36004. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36005. continue;
  36006. }
  36007. var axisMeshInfo = {
  36008. index: i,
  36009. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36010. min: getImmediateChildByName(axisMesh, 'MIN'),
  36011. max: getImmediateChildByName(axisMesh, 'MAX')
  36012. };
  36013. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36014. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36015. }
  36016. else {
  36017. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36018. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36019. '(VALUE: ' + !!axisMeshInfo.value +
  36020. ', MIN: ' + !!axisMeshInfo.min +
  36021. ', MAX:' + !!axisMeshInfo.max +
  36022. ')');
  36023. }
  36024. }
  36025. // Pointing Ray
  36026. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36027. if (!loadedMeshInfo.pointingPoseNode) {
  36028. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36029. }
  36030. else {
  36031. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36032. }
  36033. return loadedMeshInfo;
  36034. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36035. function getChildByName(node, name) {
  36036. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36037. }
  36038. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36039. function getImmediateChildByName(node, name) {
  36040. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36041. }
  36042. };
  36043. /**
  36044. * Gets the ray of the controller in the direction the controller is pointing
  36045. * @param length the length the resulting ray should be
  36046. * @returns a ray in the direction the controller is pointing
  36047. */
  36048. WindowsMotionController.prototype.getForwardRay = function (length) {
  36049. if (length === void 0) { length = 100; }
  36050. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36051. return _super.prototype.getForwardRay.call(this, length);
  36052. }
  36053. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36054. var origin = m.getTranslation();
  36055. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36056. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36057. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36058. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36059. };
  36060. /**
  36061. * Disposes of the controller
  36062. */
  36063. WindowsMotionController.prototype.dispose = function () {
  36064. _super.prototype.dispose.call(this);
  36065. this.onTrackpadChangedObservable.clear();
  36066. };
  36067. /**
  36068. * The base url used to load the left and right controller models
  36069. */
  36070. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36071. /**
  36072. * The name of the left controller model file
  36073. */
  36074. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36075. /**
  36076. * The name of the right controller model file
  36077. */
  36078. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36079. /**
  36080. * The controller name prefix for this controller type
  36081. */
  36082. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36083. /**
  36084. * The controller id pattern for this controller type
  36085. */
  36086. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36087. return WindowsMotionController;
  36088. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36089. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36090. canCreate: function (gamepadInfo) {
  36091. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36092. },
  36093. create: function (gamepadInfo) {
  36094. return new WindowsMotionController(gamepadInfo);
  36095. }
  36096. });
  36097. /***/ }),
  36098. /***/ "./Gamepads/gamepad.ts":
  36099. /*!*****************************!*\
  36100. !*** ./Gamepads/gamepad.ts ***!
  36101. \*****************************/
  36102. /*! exports provided: StickValues, Gamepad, GenericPad */
  36103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36104. "use strict";
  36105. __webpack_require__.r(__webpack_exports__);
  36106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36109. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36110. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36111. /**
  36112. * Represents a gamepad control stick position
  36113. */
  36114. var StickValues = /** @class */ (function () {
  36115. /**
  36116. * Initializes the gamepad x and y control stick values
  36117. * @param x The x component of the gamepad control stick value
  36118. * @param y The y component of the gamepad control stick value
  36119. */
  36120. function StickValues(
  36121. /**
  36122. * The x component of the control stick
  36123. */
  36124. x,
  36125. /**
  36126. * The y component of the control stick
  36127. */
  36128. y) {
  36129. this.x = x;
  36130. this.y = y;
  36131. }
  36132. return StickValues;
  36133. }());
  36134. /**
  36135. * Represents a gamepad
  36136. */
  36137. var Gamepad = /** @class */ (function () {
  36138. /**
  36139. * Initializes the gamepad
  36140. * @param id The id of the gamepad
  36141. * @param index The index of the gamepad
  36142. * @param browserGamepad The browser gamepad
  36143. * @param leftStickX The x component of the left joystick
  36144. * @param leftStickY The y component of the left joystick
  36145. * @param rightStickX The x component of the right joystick
  36146. * @param rightStickY The y component of the right joystick
  36147. */
  36148. function Gamepad(
  36149. /**
  36150. * The id of the gamepad
  36151. */
  36152. id,
  36153. /**
  36154. * The index of the gamepad
  36155. */
  36156. index,
  36157. /**
  36158. * The browser gamepad
  36159. */
  36160. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36161. if (leftStickX === void 0) { leftStickX = 0; }
  36162. if (leftStickY === void 0) { leftStickY = 1; }
  36163. if (rightStickX === void 0) { rightStickX = 2; }
  36164. if (rightStickY === void 0) { rightStickY = 3; }
  36165. this.id = id;
  36166. this.index = index;
  36167. this.browserGamepad = browserGamepad;
  36168. this._leftStick = { x: 0, y: 0 };
  36169. this._rightStick = { x: 0, y: 0 };
  36170. /** @hidden */
  36171. this._isConnected = true;
  36172. /**
  36173. * Specifies whether the left control stick should be Y-inverted
  36174. */
  36175. this._invertLeftStickY = false;
  36176. this.type = Gamepad.GAMEPAD;
  36177. this._leftStickAxisX = leftStickX;
  36178. this._leftStickAxisY = leftStickY;
  36179. this._rightStickAxisX = rightStickX;
  36180. this._rightStickAxisY = rightStickY;
  36181. if (this.browserGamepad.axes.length >= 2) {
  36182. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36183. }
  36184. if (this.browserGamepad.axes.length >= 4) {
  36185. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36186. }
  36187. }
  36188. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36189. /**
  36190. * Specifies if the gamepad has been connected
  36191. */
  36192. get: function () {
  36193. return this._isConnected;
  36194. },
  36195. enumerable: true,
  36196. configurable: true
  36197. });
  36198. /**
  36199. * Callback triggered when the left joystick has changed
  36200. * @param callback
  36201. */
  36202. Gamepad.prototype.onleftstickchanged = function (callback) {
  36203. this._onleftstickchanged = callback;
  36204. };
  36205. /**
  36206. * Callback triggered when the right joystick has changed
  36207. * @param callback
  36208. */
  36209. Gamepad.prototype.onrightstickchanged = function (callback) {
  36210. this._onrightstickchanged = callback;
  36211. };
  36212. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36213. /**
  36214. * Gets the left joystick
  36215. */
  36216. get: function () {
  36217. return this._leftStick;
  36218. },
  36219. /**
  36220. * Sets the left joystick values
  36221. */
  36222. set: function (newValues) {
  36223. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36224. this._onleftstickchanged(newValues);
  36225. }
  36226. this._leftStick = newValues;
  36227. },
  36228. enumerable: true,
  36229. configurable: true
  36230. });
  36231. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36232. /**
  36233. * Gets the right joystick
  36234. */
  36235. get: function () {
  36236. return this._rightStick;
  36237. },
  36238. /**
  36239. * Sets the right joystick value
  36240. */
  36241. set: function (newValues) {
  36242. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36243. this._onrightstickchanged(newValues);
  36244. }
  36245. this._rightStick = newValues;
  36246. },
  36247. enumerable: true,
  36248. configurable: true
  36249. });
  36250. /**
  36251. * Updates the gamepad joystick positions
  36252. */
  36253. Gamepad.prototype.update = function () {
  36254. if (this._leftStick) {
  36255. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36256. if (this._invertLeftStickY) {
  36257. this.leftStick.y *= -1;
  36258. }
  36259. }
  36260. if (this._rightStick) {
  36261. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36262. }
  36263. };
  36264. /**
  36265. * Disposes the gamepad
  36266. */
  36267. Gamepad.prototype.dispose = function () {
  36268. };
  36269. /**
  36270. * Represents a gamepad controller
  36271. */
  36272. Gamepad.GAMEPAD = 0;
  36273. /**
  36274. * Represents a generic controller
  36275. */
  36276. Gamepad.GENERIC = 1;
  36277. /**
  36278. * Represents an XBox controller
  36279. */
  36280. Gamepad.XBOX = 2;
  36281. /**
  36282. * Represents a pose-enabled controller
  36283. */
  36284. Gamepad.POSE_ENABLED = 3;
  36285. return Gamepad;
  36286. }());
  36287. /**
  36288. * Represents a generic gamepad
  36289. */
  36290. var GenericPad = /** @class */ (function (_super) {
  36291. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36292. /**
  36293. * Initializes the generic gamepad
  36294. * @param id The id of the generic gamepad
  36295. * @param index The index of the generic gamepad
  36296. * @param browserGamepad The browser gamepad
  36297. */
  36298. function GenericPad(id, index, browserGamepad) {
  36299. var _this = _super.call(this, id, index, browserGamepad) || this;
  36300. /**
  36301. * Observable triggered when a button has been pressed
  36302. */
  36303. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36304. /**
  36305. * Observable triggered when a button has been released
  36306. */
  36307. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36308. _this.type = Gamepad.GENERIC;
  36309. _this._buttons = new Array(browserGamepad.buttons.length);
  36310. return _this;
  36311. }
  36312. /**
  36313. * Callback triggered when a button has been pressed
  36314. * @param callback Called when a button has been pressed
  36315. */
  36316. GenericPad.prototype.onbuttondown = function (callback) {
  36317. this._onbuttondown = callback;
  36318. };
  36319. /**
  36320. * Callback triggered when a button has been released
  36321. * @param callback Called when a button has been released
  36322. */
  36323. GenericPad.prototype.onbuttonup = function (callback) {
  36324. this._onbuttonup = callback;
  36325. };
  36326. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36327. if (newValue !== currentValue) {
  36328. if (newValue === 1) {
  36329. if (this._onbuttondown) {
  36330. this._onbuttondown(buttonIndex);
  36331. }
  36332. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36333. }
  36334. if (newValue === 0) {
  36335. if (this._onbuttonup) {
  36336. this._onbuttonup(buttonIndex);
  36337. }
  36338. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36339. }
  36340. }
  36341. return newValue;
  36342. };
  36343. /**
  36344. * Updates the generic gamepad
  36345. */
  36346. GenericPad.prototype.update = function () {
  36347. _super.prototype.update.call(this);
  36348. for (var index = 0; index < this._buttons.length; index++) {
  36349. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36350. }
  36351. };
  36352. /**
  36353. * Disposes the generic gamepad
  36354. */
  36355. GenericPad.prototype.dispose = function () {
  36356. _super.prototype.dispose.call(this);
  36357. this.onButtonDownObservable.clear();
  36358. this.onButtonUpObservable.clear();
  36359. };
  36360. return GenericPad;
  36361. }(Gamepad));
  36362. /***/ }),
  36363. /***/ "./Gamepads/gamepadManager.ts":
  36364. /*!************************************!*\
  36365. !*** ./Gamepads/gamepadManager.ts ***!
  36366. \************************************/
  36367. /*! exports provided: GamepadManager */
  36368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36369. "use strict";
  36370. __webpack_require__.r(__webpack_exports__);
  36371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36372. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36373. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36374. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36375. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36376. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36377. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36378. /**
  36379. * Manager for handling gamepads
  36380. */
  36381. var GamepadManager = /** @class */ (function () {
  36382. /**
  36383. * Initializes the gamepad manager
  36384. * @param _scene BabylonJS scene
  36385. */
  36386. function GamepadManager(_scene) {
  36387. var _this = this;
  36388. this._scene = _scene;
  36389. this._babylonGamepads = [];
  36390. this._oneGamepadConnected = false;
  36391. /** @hidden */
  36392. this._isMonitoring = false;
  36393. /**
  36394. * observable to be triggered when the gamepad controller has been disconnected
  36395. */
  36396. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36397. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36398. this._gamepadEventSupported = false;
  36399. }
  36400. else {
  36401. this._gamepadEventSupported = 'GamepadEvent' in window;
  36402. this._gamepadSupport = (navigator.getGamepads ||
  36403. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36404. }
  36405. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36406. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36407. for (var i in _this._babylonGamepads) {
  36408. var gamepad = _this._babylonGamepads[i];
  36409. if (gamepad && gamepad._isConnected) {
  36410. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36411. }
  36412. }
  36413. });
  36414. this._onGamepadConnectedEvent = function (evt) {
  36415. var gamepad = evt.gamepad;
  36416. if (gamepad.index in _this._babylonGamepads) {
  36417. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36418. return;
  36419. }
  36420. }
  36421. var newGamepad;
  36422. if (_this._babylonGamepads[gamepad.index]) {
  36423. newGamepad = _this._babylonGamepads[gamepad.index];
  36424. newGamepad.browserGamepad = gamepad;
  36425. newGamepad._isConnected = true;
  36426. }
  36427. else {
  36428. newGamepad = _this._addNewGamepad(gamepad);
  36429. }
  36430. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36431. _this._startMonitoringGamepads();
  36432. };
  36433. this._onGamepadDisconnectedEvent = function (evt) {
  36434. var gamepad = evt.gamepad;
  36435. // Remove the gamepad from the list of gamepads to monitor.
  36436. for (var i in _this._babylonGamepads) {
  36437. if (_this._babylonGamepads[i].index === gamepad.index) {
  36438. var disconnectedGamepad = _this._babylonGamepads[i];
  36439. disconnectedGamepad._isConnected = false;
  36440. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36441. break;
  36442. }
  36443. }
  36444. };
  36445. if (this._gamepadSupport) {
  36446. //first add already-connected gamepads
  36447. this._updateGamepadObjects();
  36448. if (this._babylonGamepads.length) {
  36449. this._startMonitoringGamepads();
  36450. }
  36451. // Checking if the gamepad connected event is supported (like in Firefox)
  36452. if (this._gamepadEventSupported) {
  36453. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36454. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36455. }
  36456. else {
  36457. this._startMonitoringGamepads();
  36458. }
  36459. }
  36460. }
  36461. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36462. /**
  36463. * The gamepads in the game pad manager
  36464. */
  36465. get: function () {
  36466. return this._babylonGamepads;
  36467. },
  36468. enumerable: true,
  36469. configurable: true
  36470. });
  36471. /**
  36472. * Get the gamepad controllers based on type
  36473. * @param type The type of gamepad controller
  36474. * @returns Nullable gamepad
  36475. */
  36476. GamepadManager.prototype.getGamepadByType = function (type) {
  36477. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36478. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36479. var gamepad = _a[_i];
  36480. if (gamepad && gamepad.type === type) {
  36481. return gamepad;
  36482. }
  36483. }
  36484. return null;
  36485. };
  36486. /**
  36487. * Disposes the gamepad manager
  36488. */
  36489. GamepadManager.prototype.dispose = function () {
  36490. if (this._gamepadEventSupported) {
  36491. if (this._onGamepadConnectedEvent) {
  36492. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36493. }
  36494. if (this._onGamepadDisconnectedEvent) {
  36495. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36496. }
  36497. this._onGamepadConnectedEvent = null;
  36498. this._onGamepadDisconnectedEvent = null;
  36499. }
  36500. this._babylonGamepads.forEach(function (gamepad) {
  36501. gamepad.dispose();
  36502. });
  36503. this.onGamepadConnectedObservable.clear();
  36504. this.onGamepadDisconnectedObservable.clear();
  36505. this._oneGamepadConnected = false;
  36506. this._stopMonitoringGamepads();
  36507. this._babylonGamepads = [];
  36508. };
  36509. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36510. if (!this._oneGamepadConnected) {
  36511. this._oneGamepadConnected = true;
  36512. }
  36513. var newGamepad;
  36514. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36515. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36516. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36517. }
  36518. // if pose is supported, use the (WebVR) pose enabled controller
  36519. else if (gamepad.pose) {
  36520. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36521. }
  36522. else {
  36523. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36524. }
  36525. this._babylonGamepads[newGamepad.index] = newGamepad;
  36526. return newGamepad;
  36527. };
  36528. GamepadManager.prototype._startMonitoringGamepads = function () {
  36529. if (!this._isMonitoring) {
  36530. this._isMonitoring = true;
  36531. //back-comp
  36532. if (!this._scene) {
  36533. this._checkGamepadsStatus();
  36534. }
  36535. }
  36536. };
  36537. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36538. this._isMonitoring = false;
  36539. };
  36540. /** @hidden */
  36541. GamepadManager.prototype._checkGamepadsStatus = function () {
  36542. var _this = this;
  36543. // Hack to be compatible Chrome
  36544. this._updateGamepadObjects();
  36545. for (var i in this._babylonGamepads) {
  36546. var gamepad = this._babylonGamepads[i];
  36547. if (!gamepad || !gamepad.isConnected) {
  36548. continue;
  36549. }
  36550. gamepad.update();
  36551. }
  36552. if (this._isMonitoring && !this._scene) {
  36553. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36554. }
  36555. };
  36556. // This function is called only on Chrome, which does not properly support
  36557. // connection/disconnection events and forces you to recopy again the gamepad object
  36558. GamepadManager.prototype._updateGamepadObjects = function () {
  36559. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36560. for (var i = 0; i < gamepads.length; i++) {
  36561. var gamepad = gamepads[i];
  36562. if (gamepad) {
  36563. if (!this._babylonGamepads[gamepad.index]) {
  36564. var newGamepad = this._addNewGamepad(gamepad);
  36565. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36566. }
  36567. else {
  36568. // Forced to copy again this object for Chrome for unknown reason
  36569. this._babylonGamepads[i].browserGamepad = gamepad;
  36570. if (!this._babylonGamepads[i].isConnected) {
  36571. this._babylonGamepads[i]._isConnected = true;
  36572. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36573. }
  36574. }
  36575. }
  36576. }
  36577. };
  36578. return GamepadManager;
  36579. }());
  36580. /***/ }),
  36581. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36582. /*!*******************************************!*\
  36583. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36584. \*******************************************/
  36585. /*! exports provided: GamepadSystemSceneComponent */
  36586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36587. "use strict";
  36588. __webpack_require__.r(__webpack_exports__);
  36589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36590. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36591. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36592. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36593. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36594. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36595. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36596. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36597. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36598. get: function () {
  36599. if (!this._gamepadManager) {
  36600. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36601. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36602. if (!component) {
  36603. component = new GamepadSystemSceneComponent(this);
  36604. this._addComponent(component);
  36605. }
  36606. }
  36607. return this._gamepadManager;
  36608. },
  36609. enumerable: true,
  36610. configurable: true
  36611. });
  36612. /**
  36613. * Adds a gamepad to the free camera inputs manager
  36614. */
  36615. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36616. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36617. return this;
  36618. };
  36619. /**
  36620. * Adds a gamepad to the arc rotate camera inputs manager
  36621. */
  36622. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36623. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36624. return this;
  36625. };
  36626. /**
  36627. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36628. */
  36629. var GamepadSystemSceneComponent = /** @class */ (function () {
  36630. /**
  36631. * Creates a new instance of the component for the given scene
  36632. * @param scene Defines the scene to register the component in
  36633. */
  36634. function GamepadSystemSceneComponent(scene) {
  36635. /**
  36636. * The component name helpfull to identify the component in the list of scene components.
  36637. */
  36638. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36639. this.scene = scene;
  36640. }
  36641. /**
  36642. * Registers the component in a given scene
  36643. */
  36644. GamepadSystemSceneComponent.prototype.register = function () {
  36645. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36646. };
  36647. /**
  36648. * Rebuilds the elements related to this component in case of
  36649. * context lost for instance.
  36650. */
  36651. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36652. // Nothing to do for gamepads
  36653. };
  36654. /**
  36655. * Disposes the component and the associated ressources
  36656. */
  36657. GamepadSystemSceneComponent.prototype.dispose = function () {
  36658. var gamepadManager = this.scene._gamepadManager;
  36659. if (gamepadManager) {
  36660. gamepadManager.dispose();
  36661. this.scene._gamepadManager = null;
  36662. }
  36663. };
  36664. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36665. var gamepadManager = this.scene._gamepadManager;
  36666. if (gamepadManager && gamepadManager._isMonitoring) {
  36667. gamepadManager._checkGamepadsStatus();
  36668. }
  36669. };
  36670. return GamepadSystemSceneComponent;
  36671. }());
  36672. /***/ }),
  36673. /***/ "./Gamepads/index.ts":
  36674. /*!***************************!*\
  36675. !*** ./Gamepads/index.ts ***!
  36676. \***************************/
  36677. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36679. "use strict";
  36680. __webpack_require__.r(__webpack_exports__);
  36681. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36692. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36696. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36698. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36700. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36704. /***/ }),
  36705. /***/ "./Gamepads/xboxGamepad.ts":
  36706. /*!*********************************!*\
  36707. !*** ./Gamepads/xboxGamepad.ts ***!
  36708. \*********************************/
  36709. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36711. "use strict";
  36712. __webpack_require__.r(__webpack_exports__);
  36713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36717. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36718. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36719. /**
  36720. * Defines supported buttons for XBox360 compatible gamepads
  36721. */
  36722. var Xbox360Button;
  36723. (function (Xbox360Button) {
  36724. /** A */
  36725. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36726. /** B */
  36727. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36728. /** X */
  36729. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36730. /** Y */
  36731. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36732. /** Start */
  36733. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36734. /** Back */
  36735. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36736. /** Left button */
  36737. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36738. /** Right button */
  36739. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36740. /** Left stick */
  36741. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36742. /** Right stick */
  36743. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36744. })(Xbox360Button || (Xbox360Button = {}));
  36745. /** Defines values for XBox360 DPad */
  36746. var Xbox360Dpad;
  36747. (function (Xbox360Dpad) {
  36748. /** Up */
  36749. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36750. /** Down */
  36751. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36752. /** Left */
  36753. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36754. /** Right */
  36755. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36756. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36757. /**
  36758. * Defines a XBox360 gamepad
  36759. */
  36760. var Xbox360Pad = /** @class */ (function (_super) {
  36761. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36762. /**
  36763. * Creates a new XBox360 gamepad object
  36764. * @param id defines the id of this gamepad
  36765. * @param index defines its index
  36766. * @param gamepad defines the internal HTML gamepad object
  36767. * @param xboxOne defines if it is a XBox One gamepad
  36768. */
  36769. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36770. if (xboxOne === void 0) { xboxOne = false; }
  36771. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36772. _this._leftTrigger = 0;
  36773. _this._rightTrigger = 0;
  36774. /** Observable raised when a button is pressed */
  36775. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36776. /** Observable raised when a button is released */
  36777. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36778. /** Observable raised when a pad is pressed */
  36779. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36780. /** Observable raised when a pad is released */
  36781. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36782. _this._buttonA = 0;
  36783. _this._buttonB = 0;
  36784. _this._buttonX = 0;
  36785. _this._buttonY = 0;
  36786. _this._buttonBack = 0;
  36787. _this._buttonStart = 0;
  36788. _this._buttonLB = 0;
  36789. _this._buttonRB = 0;
  36790. _this._buttonLeftStick = 0;
  36791. _this._buttonRightStick = 0;
  36792. _this._dPadUp = 0;
  36793. _this._dPadDown = 0;
  36794. _this._dPadLeft = 0;
  36795. _this._dPadRight = 0;
  36796. _this._isXboxOnePad = false;
  36797. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36798. _this._isXboxOnePad = xboxOne;
  36799. return _this;
  36800. }
  36801. /**
  36802. * Defines the callback to call when left trigger is pressed
  36803. * @param callback defines the callback to use
  36804. */
  36805. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36806. this._onlefttriggerchanged = callback;
  36807. };
  36808. /**
  36809. * Defines the callback to call when right trigger is pressed
  36810. * @param callback defines the callback to use
  36811. */
  36812. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36813. this._onrighttriggerchanged = callback;
  36814. };
  36815. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36816. /**
  36817. * Gets the left trigger value
  36818. */
  36819. get: function () {
  36820. return this._leftTrigger;
  36821. },
  36822. /**
  36823. * Sets the left trigger value
  36824. */
  36825. set: function (newValue) {
  36826. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36827. this._onlefttriggerchanged(newValue);
  36828. }
  36829. this._leftTrigger = newValue;
  36830. },
  36831. enumerable: true,
  36832. configurable: true
  36833. });
  36834. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36835. /**
  36836. * Gets the right trigger value
  36837. */
  36838. get: function () {
  36839. return this._rightTrigger;
  36840. },
  36841. /**
  36842. * Sets the right trigger value
  36843. */
  36844. set: function (newValue) {
  36845. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36846. this._onrighttriggerchanged(newValue);
  36847. }
  36848. this._rightTrigger = newValue;
  36849. },
  36850. enumerable: true,
  36851. configurable: true
  36852. });
  36853. /**
  36854. * Defines the callback to call when a button is pressed
  36855. * @param callback defines the callback to use
  36856. */
  36857. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36858. this._onbuttondown = callback;
  36859. };
  36860. /**
  36861. * Defines the callback to call when a button is released
  36862. * @param callback defines the callback to use
  36863. */
  36864. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36865. this._onbuttonup = callback;
  36866. };
  36867. /**
  36868. * Defines the callback to call when a pad is pressed
  36869. * @param callback defines the callback to use
  36870. */
  36871. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36872. this._ondpaddown = callback;
  36873. };
  36874. /**
  36875. * Defines the callback to call when a pad is released
  36876. * @param callback defines the callback to use
  36877. */
  36878. Xbox360Pad.prototype.ondpadup = function (callback) {
  36879. this._ondpadup = callback;
  36880. };
  36881. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36882. if (newValue !== currentValue) {
  36883. if (newValue === 1) {
  36884. if (this._onbuttondown) {
  36885. this._onbuttondown(buttonType);
  36886. }
  36887. this.onButtonDownObservable.notifyObservers(buttonType);
  36888. }
  36889. if (newValue === 0) {
  36890. if (this._onbuttonup) {
  36891. this._onbuttonup(buttonType);
  36892. }
  36893. this.onButtonUpObservable.notifyObservers(buttonType);
  36894. }
  36895. }
  36896. return newValue;
  36897. };
  36898. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36899. if (newValue !== currentValue) {
  36900. if (newValue === 1) {
  36901. if (this._ondpaddown) {
  36902. this._ondpaddown(buttonType);
  36903. }
  36904. this.onPadDownObservable.notifyObservers(buttonType);
  36905. }
  36906. if (newValue === 0) {
  36907. if (this._ondpadup) {
  36908. this._ondpadup(buttonType);
  36909. }
  36910. this.onPadUpObservable.notifyObservers(buttonType);
  36911. }
  36912. }
  36913. return newValue;
  36914. };
  36915. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36916. /**
  36917. * Gets the value of the `A` button
  36918. */
  36919. get: function () {
  36920. return this._buttonA;
  36921. },
  36922. /**
  36923. * Sets the value of the `A` button
  36924. */
  36925. set: function (value) {
  36926. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36927. },
  36928. enumerable: true,
  36929. configurable: true
  36930. });
  36931. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36932. /**
  36933. * Gets the value of the `B` button
  36934. */
  36935. get: function () {
  36936. return this._buttonB;
  36937. },
  36938. /**
  36939. * Sets the value of the `B` button
  36940. */
  36941. set: function (value) {
  36942. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36943. },
  36944. enumerable: true,
  36945. configurable: true
  36946. });
  36947. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36948. /**
  36949. * Gets the value of the `X` button
  36950. */
  36951. get: function () {
  36952. return this._buttonX;
  36953. },
  36954. /**
  36955. * Sets the value of the `X` button
  36956. */
  36957. set: function (value) {
  36958. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36959. },
  36960. enumerable: true,
  36961. configurable: true
  36962. });
  36963. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36964. /**
  36965. * Gets the value of the `Y` button
  36966. */
  36967. get: function () {
  36968. return this._buttonY;
  36969. },
  36970. /**
  36971. * Sets the value of the `Y` button
  36972. */
  36973. set: function (value) {
  36974. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  36975. },
  36976. enumerable: true,
  36977. configurable: true
  36978. });
  36979. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  36980. /**
  36981. * Gets the value of the `Start` button
  36982. */
  36983. get: function () {
  36984. return this._buttonStart;
  36985. },
  36986. /**
  36987. * Sets the value of the `Start` button
  36988. */
  36989. set: function (value) {
  36990. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  36991. },
  36992. enumerable: true,
  36993. configurable: true
  36994. });
  36995. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  36996. /**
  36997. * Gets the value of the `Back` button
  36998. */
  36999. get: function () {
  37000. return this._buttonBack;
  37001. },
  37002. /**
  37003. * Sets the value of the `Back` button
  37004. */
  37005. set: function (value) {
  37006. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37007. },
  37008. enumerable: true,
  37009. configurable: true
  37010. });
  37011. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37012. /**
  37013. * Gets the value of the `Left` button
  37014. */
  37015. get: function () {
  37016. return this._buttonLB;
  37017. },
  37018. /**
  37019. * Sets the value of the `Left` button
  37020. */
  37021. set: function (value) {
  37022. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37023. },
  37024. enumerable: true,
  37025. configurable: true
  37026. });
  37027. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37028. /**
  37029. * Gets the value of the `Right` button
  37030. */
  37031. get: function () {
  37032. return this._buttonRB;
  37033. },
  37034. /**
  37035. * Sets the value of the `Right` button
  37036. */
  37037. set: function (value) {
  37038. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37039. },
  37040. enumerable: true,
  37041. configurable: true
  37042. });
  37043. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37044. /**
  37045. * Gets the value of the Left joystick
  37046. */
  37047. get: function () {
  37048. return this._buttonLeftStick;
  37049. },
  37050. /**
  37051. * Sets the value of the Left joystick
  37052. */
  37053. set: function (value) {
  37054. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37055. },
  37056. enumerable: true,
  37057. configurable: true
  37058. });
  37059. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37060. /**
  37061. * Gets the value of the Right joystick
  37062. */
  37063. get: function () {
  37064. return this._buttonRightStick;
  37065. },
  37066. /**
  37067. * Sets the value of the Right joystick
  37068. */
  37069. set: function (value) {
  37070. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37071. },
  37072. enumerable: true,
  37073. configurable: true
  37074. });
  37075. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37076. /**
  37077. * Gets the value of D-pad up
  37078. */
  37079. get: function () {
  37080. return this._dPadUp;
  37081. },
  37082. /**
  37083. * Sets the value of D-pad up
  37084. */
  37085. set: function (value) {
  37086. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37087. },
  37088. enumerable: true,
  37089. configurable: true
  37090. });
  37091. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37092. /**
  37093. * Gets the value of D-pad down
  37094. */
  37095. get: function () {
  37096. return this._dPadDown;
  37097. },
  37098. /**
  37099. * Sets the value of D-pad down
  37100. */
  37101. set: function (value) {
  37102. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37103. },
  37104. enumerable: true,
  37105. configurable: true
  37106. });
  37107. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37108. /**
  37109. * Gets the value of D-pad left
  37110. */
  37111. get: function () {
  37112. return this._dPadLeft;
  37113. },
  37114. /**
  37115. * Sets the value of D-pad left
  37116. */
  37117. set: function (value) {
  37118. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37119. },
  37120. enumerable: true,
  37121. configurable: true
  37122. });
  37123. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37124. /**
  37125. * Gets the value of D-pad right
  37126. */
  37127. get: function () {
  37128. return this._dPadRight;
  37129. },
  37130. /**
  37131. * Sets the value of D-pad right
  37132. */
  37133. set: function (value) {
  37134. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37135. },
  37136. enumerable: true,
  37137. configurable: true
  37138. });
  37139. /**
  37140. * Force the gamepad to synchronize with device values
  37141. */
  37142. Xbox360Pad.prototype.update = function () {
  37143. _super.prototype.update.call(this);
  37144. if (this._isXboxOnePad) {
  37145. this.buttonA = this.browserGamepad.buttons[0].value;
  37146. this.buttonB = this.browserGamepad.buttons[1].value;
  37147. this.buttonX = this.browserGamepad.buttons[2].value;
  37148. this.buttonY = this.browserGamepad.buttons[3].value;
  37149. this.buttonLB = this.browserGamepad.buttons[4].value;
  37150. this.buttonRB = this.browserGamepad.buttons[5].value;
  37151. this.leftTrigger = this.browserGamepad.axes[2];
  37152. this.rightTrigger = this.browserGamepad.axes[5];
  37153. this.buttonBack = this.browserGamepad.buttons[9].value;
  37154. this.buttonStart = this.browserGamepad.buttons[8].value;
  37155. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37156. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37157. this.dPadUp = this.browserGamepad.buttons[11].value;
  37158. this.dPadDown = this.browserGamepad.buttons[12].value;
  37159. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37160. this.dPadRight = this.browserGamepad.buttons[14].value;
  37161. }
  37162. else {
  37163. this.buttonA = this.browserGamepad.buttons[0].value;
  37164. this.buttonB = this.browserGamepad.buttons[1].value;
  37165. this.buttonX = this.browserGamepad.buttons[2].value;
  37166. this.buttonY = this.browserGamepad.buttons[3].value;
  37167. this.buttonLB = this.browserGamepad.buttons[4].value;
  37168. this.buttonRB = this.browserGamepad.buttons[5].value;
  37169. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37170. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37171. this.buttonBack = this.browserGamepad.buttons[8].value;
  37172. this.buttonStart = this.browserGamepad.buttons[9].value;
  37173. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37174. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37175. this.dPadUp = this.browserGamepad.buttons[12].value;
  37176. this.dPadDown = this.browserGamepad.buttons[13].value;
  37177. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37178. this.dPadRight = this.browserGamepad.buttons[15].value;
  37179. }
  37180. };
  37181. /**
  37182. * Disposes the gamepad
  37183. */
  37184. Xbox360Pad.prototype.dispose = function () {
  37185. _super.prototype.dispose.call(this);
  37186. this.onButtonDownObservable.clear();
  37187. this.onButtonUpObservable.clear();
  37188. this.onPadDownObservable.clear();
  37189. this.onPadUpObservable.clear();
  37190. };
  37191. return Xbox360Pad;
  37192. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37193. /***/ }),
  37194. /***/ "./Gizmos/axisDragGizmo.ts":
  37195. /*!*********************************!*\
  37196. !*** ./Gizmos/axisDragGizmo.ts ***!
  37197. \*********************************/
  37198. /*! exports provided: AxisDragGizmo */
  37199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37200. "use strict";
  37201. __webpack_require__.r(__webpack_exports__);
  37202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37203. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37204. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37205. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37206. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37207. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37208. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37209. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37210. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37211. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37212. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37213. /**
  37214. * Single axis drag gizmo
  37215. */
  37216. var AxisDragGizmo = /** @class */ (function (_super) {
  37217. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37218. /**
  37219. * Creates an AxisDragGizmo
  37220. * @param gizmoLayer The utility layer the gizmo will be added to
  37221. * @param dragAxis The axis which the gizmo will be able to drag on
  37222. * @param color The color of the gizmo
  37223. */
  37224. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37225. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37226. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37227. var _this = _super.call(this, gizmoLayer) || this;
  37228. _this._pointerObserver = null;
  37229. /**
  37230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37231. */
  37232. _this.snapDistance = 0;
  37233. /**
  37234. * Event that fires each time the gizmo snaps to a new location.
  37235. * * snapDistance is the the change in distance
  37236. */
  37237. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37238. // Create Material
  37239. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37240. coloredMaterial.disableLighting = true;
  37241. coloredMaterial.emissiveColor = color;
  37242. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37243. hoverMaterial.disableLighting = true;
  37244. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37245. // Build mesh on root node
  37246. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37247. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37248. arrow.scaling.scaleInPlace(1 / 3);
  37249. arrow.parent = _this._rootMesh;
  37250. var currentSnapDragDistance = 0;
  37251. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37252. var tmpSnapEvent = { snapDistance: 0 };
  37253. // Add drag behavior to handle events when the gizmo is dragged
  37254. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37255. _this.dragBehavior.moveAttached = false;
  37256. _this._rootMesh.addBehavior(_this.dragBehavior);
  37257. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37258. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37259. _this.dragBehavior.onDragObservable.add(function (event) {
  37260. if (_this.attachedMesh) {
  37261. // Convert delta to local translation if it has a parent
  37262. if (_this.attachedMesh.parent) {
  37263. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37264. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37265. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37266. }
  37267. else {
  37268. localDelta.copyFrom(event.delta);
  37269. }
  37270. // Snapping logic
  37271. if (_this.snapDistance == 0) {
  37272. _this.attachedMesh.position.addInPlace(localDelta);
  37273. }
  37274. else {
  37275. currentSnapDragDistance += event.dragDistance;
  37276. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37277. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37278. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37279. localDelta.normalizeToRef(tmpVector);
  37280. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37281. _this.attachedMesh.position.addInPlace(tmpVector);
  37282. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37283. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37284. }
  37285. }
  37286. }
  37287. });
  37288. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37289. if (_this._customMeshSet) {
  37290. return;
  37291. }
  37292. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37293. var material = isHovered ? hoverMaterial : coloredMaterial;
  37294. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37295. m.material = material;
  37296. if (m.color) {
  37297. m.color = material.emissiveColor;
  37298. }
  37299. });
  37300. });
  37301. return _this;
  37302. }
  37303. /** @hidden */
  37304. AxisDragGizmo._CreateArrow = function (scene, material) {
  37305. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37306. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37307. var line = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("line", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, scene);
  37308. line.color = material.emissiveColor;
  37309. cylinder.parent = arrow;
  37310. line.parent = arrow;
  37311. // Position arrow pointing in its drag axis
  37312. cylinder.scaling.scaleInPlace(0.05);
  37313. cylinder.material = material;
  37314. cylinder.rotation.x = Math.PI / 2;
  37315. cylinder.position.z += 0.3;
  37316. line.scaling.scaleInPlace(0.26);
  37317. line.rotation.x = Math.PI / 2;
  37318. line.material = material;
  37319. return arrow;
  37320. };
  37321. /** @hidden */
  37322. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37323. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37324. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37325. var mesh = _a[_i];
  37326. var childInstance = mesh.createInstance(mesh.name);
  37327. childInstance.parent = instance;
  37328. }
  37329. return instance;
  37330. };
  37331. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37332. if (this.dragBehavior) {
  37333. this.dragBehavior.enabled = value ? true : false;
  37334. }
  37335. };
  37336. /**
  37337. * Disposes of the gizmo
  37338. */
  37339. AxisDragGizmo.prototype.dispose = function () {
  37340. this.onSnapObservable.clear();
  37341. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37342. this.dragBehavior.detach();
  37343. _super.prototype.dispose.call(this);
  37344. };
  37345. return AxisDragGizmo;
  37346. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37347. /***/ }),
  37348. /***/ "./Gizmos/axisScaleGizmo.ts":
  37349. /*!**********************************!*\
  37350. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37351. \**********************************/
  37352. /*! exports provided: AxisScaleGizmo */
  37353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37354. "use strict";
  37355. __webpack_require__.r(__webpack_exports__);
  37356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37357. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37358. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37359. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37360. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37361. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37362. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37363. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37364. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37365. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37366. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37367. /**
  37368. * Single axis scale gizmo
  37369. */
  37370. var AxisScaleGizmo = /** @class */ (function (_super) {
  37371. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37372. /**
  37373. * Creates an AxisScaleGizmo
  37374. * @param gizmoLayer The utility layer the gizmo will be added to
  37375. * @param dragAxis The axis which the gizmo will be able to scale on
  37376. * @param color The color of the gizmo
  37377. */
  37378. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37379. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37380. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37381. var _this = _super.call(this, gizmoLayer) || this;
  37382. _this._pointerObserver = null;
  37383. /**
  37384. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37385. */
  37386. _this.snapDistance = 0;
  37387. /**
  37388. * Event that fires each time the gizmo snaps to a new location.
  37389. * * snapDistance is the the change in distance
  37390. */
  37391. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37392. /**
  37393. * If the scaling operation should be done on all axis (default: false)
  37394. */
  37395. _this.uniformScaling = false;
  37396. // Create Material
  37397. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37398. _this._coloredMaterial.disableLighting = true;
  37399. _this._coloredMaterial.emissiveColor = color;
  37400. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37401. hoverMaterial.disableLighting = true;
  37402. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37403. // Build mesh on root node
  37404. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37405. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37406. var arrowTail = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("yPosMesh", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, gizmoLayer.utilityLayerScene);
  37407. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37408. arrow.addChild(arrowMesh);
  37409. arrow.addChild(arrowTail);
  37410. // Position arrow pointing in its drag axis
  37411. arrowMesh.scaling.scaleInPlace(0.1);
  37412. arrowMesh.material = _this._coloredMaterial;
  37413. arrowMesh.rotation.x = Math.PI / 2;
  37414. arrowMesh.position.z += 0.3;
  37415. arrowTail.scaling.scaleInPlace(0.26);
  37416. arrowTail.rotation.x = Math.PI / 2;
  37417. arrowTail.material = _this._coloredMaterial;
  37418. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37419. _this._rootMesh.addChild(arrow);
  37420. arrow.scaling.scaleInPlace(1 / 3);
  37421. // Add drag behavior to handle events when the gizmo is dragged
  37422. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37423. _this.dragBehavior.moveAttached = false;
  37424. _this._rootMesh.addBehavior(_this.dragBehavior);
  37425. var currentSnapDragDistance = 0;
  37426. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37427. var tmpSnapEvent = { snapDistance: 0 };
  37428. _this.dragBehavior.onDragObservable.add(function (event) {
  37429. if (_this.attachedMesh) {
  37430. // Snapping logic
  37431. var snapped = false;
  37432. var dragSteps = 0;
  37433. if (_this.uniformScaling) {
  37434. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37435. if (tmpVector.y < 0) {
  37436. tmpVector.scaleInPlace(-1);
  37437. }
  37438. }
  37439. else {
  37440. tmpVector.copyFrom(dragAxis);
  37441. }
  37442. if (_this.snapDistance == 0) {
  37443. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37444. }
  37445. else {
  37446. currentSnapDragDistance += event.dragDistance;
  37447. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37448. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37449. if (currentSnapDragDistance < 0) {
  37450. dragSteps *= -1;
  37451. }
  37452. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37453. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37454. snapped = true;
  37455. }
  37456. else {
  37457. tmpVector.scaleInPlace(0);
  37458. }
  37459. }
  37460. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37461. if (snapped) {
  37462. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37463. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37464. }
  37465. }
  37466. });
  37467. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37468. if (_this._customMeshSet) {
  37469. return;
  37470. }
  37471. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37472. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37473. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37474. m.material = material;
  37475. if (m.color) {
  37476. m.color = material.emissiveColor;
  37477. }
  37478. });
  37479. });
  37480. return _this;
  37481. }
  37482. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37483. if (this.dragBehavior) {
  37484. this.dragBehavior.enabled = value ? true : false;
  37485. }
  37486. };
  37487. /**
  37488. * Disposes of the gizmo
  37489. */
  37490. AxisScaleGizmo.prototype.dispose = function () {
  37491. this.onSnapObservable.clear();
  37492. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37493. this.dragBehavior.detach();
  37494. _super.prototype.dispose.call(this);
  37495. };
  37496. /**
  37497. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37498. * @param mesh The mesh to replace the default mesh of the gizmo
  37499. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37500. */
  37501. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37502. var _this = this;
  37503. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37504. _super.prototype.setCustomMesh.call(this, mesh);
  37505. if (useGizmoMaterial) {
  37506. this._rootMesh.getChildMeshes().forEach(function (m) {
  37507. m.material = _this._coloredMaterial;
  37508. if (m.color) {
  37509. m.color = _this._coloredMaterial.emissiveColor;
  37510. }
  37511. });
  37512. this._customMeshSet = false;
  37513. }
  37514. };
  37515. return AxisScaleGizmo;
  37516. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37517. /***/ }),
  37518. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37519. /*!************************************!*\
  37520. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37521. \************************************/
  37522. /*! exports provided: BoundingBoxGizmo */
  37523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37524. "use strict";
  37525. __webpack_require__.r(__webpack_exports__);
  37526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37527. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37528. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37529. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37530. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37531. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37532. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37533. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37534. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37535. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37536. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37537. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37538. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37539. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37540. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37541. /**
  37542. * Bounding box gizmo
  37543. */
  37544. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37545. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37546. /**
  37547. * Creates an BoundingBoxGizmo
  37548. * @param gizmoLayer The utility layer the gizmo will be added to
  37549. * @param color The color of the gizmo
  37550. */
  37551. function BoundingBoxGizmo(color, gizmoLayer) {
  37552. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37553. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37554. var _this = _super.call(this, gizmoLayer) || this;
  37555. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37556. _this._renderObserver = null;
  37557. _this._pointerObserver = null;
  37558. _this._scaleDragSpeed = 0.2;
  37559. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37560. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37561. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37562. /**
  37563. * 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)
  37564. */
  37565. _this.ignoreChildren = false;
  37566. /**
  37567. * 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)
  37568. */
  37569. _this.includeChildPredicate = null;
  37570. /**
  37571. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37572. */
  37573. _this.rotationSphereSize = 0.1;
  37574. /**
  37575. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37576. */
  37577. _this.scaleBoxSize = 0.1;
  37578. /**
  37579. * 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)
  37580. */
  37581. _this.fixedDragMeshScreenSize = false;
  37582. /**
  37583. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37584. */
  37585. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37586. /**
  37587. * Fired when a rotation sphere or scale box is dragged
  37588. */
  37589. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37590. /**
  37591. * Fired when a scale box is dragged
  37592. */
  37593. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37594. /**
  37595. * Fired when a scale box drag is ended
  37596. */
  37597. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37598. /**
  37599. * Fired when a rotation sphere is dragged
  37600. */
  37601. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37602. /**
  37603. * Fired when a rotation sphere drag is ended
  37604. */
  37605. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37606. /**
  37607. * 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)
  37608. */
  37609. _this.scalePivot = null;
  37610. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37611. // Dragging
  37612. _this._dragMesh = null;
  37613. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37614. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37615. _this._updateScale = false;
  37616. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37617. // Create Materials
  37618. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37619. coloredMaterial.disableLighting = true;
  37620. coloredMaterial.emissiveColor = color;
  37621. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37622. hoverColoredMaterial.disableLighting = true;
  37623. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37624. // Build bounding box out of lines
  37625. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37626. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37627. var lines = [];
  37628. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));
  37629. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  37630. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37631. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  37632. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37633. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  37634. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37635. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37636. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37637. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37638. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  37639. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  37640. lines.forEach(function (l) {
  37641. l.color = color;
  37642. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37643. l.isPickable = false;
  37644. _this._lineBoundingBox.addChild(l);
  37645. });
  37646. _this._rootMesh.addChild(_this._lineBoundingBox);
  37647. // Create rotation spheres
  37648. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37649. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37650. var _loop_1 = function (i_1) {
  37651. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37652. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37653. sphere.material = coloredMaterial;
  37654. // Drag behavior
  37655. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37656. _dragBehavior.moveAttached = false;
  37657. _dragBehavior.updateDragPlane = false;
  37658. sphere.addBehavior(_dragBehavior);
  37659. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37660. var totalTurnAmountOfDrag = 0;
  37661. _dragBehavior.onDragStartObservable.add(function () {
  37662. startingTurnDirection.copyFrom(sphere.forward);
  37663. totalTurnAmountOfDrag = 0;
  37664. });
  37665. _dragBehavior.onDragObservable.add(function (event) {
  37666. _this.onRotationSphereDragObservable.notifyObservers({});
  37667. if (_this.attachedMesh) {
  37668. var originalParent = _this.attachedMesh.parent;
  37669. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37670. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37671. return;
  37672. }
  37673. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37674. var worldDragDirection = startingTurnDirection;
  37675. // Project the world right on to the drag plane
  37676. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37677. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37678. // project drag delta on to the resulting drag axis and rotate based on that
  37679. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37680. // Make rotation relative to size of mesh.
  37681. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37682. // Rotate based on axis
  37683. if (!_this.attachedMesh.rotationQuaternion) {
  37684. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37685. }
  37686. if (!_this._anchorMesh.rotationQuaternion) {
  37687. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37688. }
  37689. // Do not allow the object to turn more than a full circle
  37690. totalTurnAmountOfDrag += projectDist;
  37691. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37692. if (i_1 >= 8) {
  37693. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37694. }
  37695. else if (i_1 >= 4) {
  37696. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37697. }
  37698. else {
  37699. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37700. }
  37701. // Rotate around center of bounding box
  37702. _this._anchorMesh.addChild(_this.attachedMesh);
  37703. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37704. _this._anchorMesh.removeChild(_this.attachedMesh);
  37705. _this.attachedMesh.setParent(originalParent);
  37706. }
  37707. _this.updateBoundingBox();
  37708. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37709. }
  37710. _this._updateDummy();
  37711. });
  37712. // Selection/deselection
  37713. _dragBehavior.onDragStartObservable.add(function () {
  37714. _this.onDragStartObservable.notifyObservers({});
  37715. _this._selectNode(sphere);
  37716. });
  37717. _dragBehavior.onDragEndObservable.add(function () {
  37718. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37719. _this._selectNode(null);
  37720. _this._updateDummy();
  37721. });
  37722. this_1._rotateSpheresParent.addChild(sphere);
  37723. };
  37724. var this_1 = this, _dragBehavior;
  37725. for (var i_1 = 0; i_1 < 12; i_1++) {
  37726. _loop_1(i_1);
  37727. }
  37728. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37729. // Create scale cubes
  37730. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37731. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37732. for (var i = 0; i < 2; i++) {
  37733. for (var j = 0; j < 2; j++) {
  37734. var _loop_2 = function () {
  37735. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37736. box.material = coloredMaterial;
  37737. // Dragging logic
  37738. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37739. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37740. _dragBehavior.moveAttached = false;
  37741. box.addBehavior(_dragBehavior);
  37742. _dragBehavior.onDragObservable.add(function (event) {
  37743. _this.onScaleBoxDragObservable.notifyObservers({});
  37744. if (_this.attachedMesh) {
  37745. var originalParent = _this.attachedMesh.parent;
  37746. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37747. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37748. return;
  37749. }
  37750. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37751. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37752. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37753. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37754. _this.updateBoundingBox();
  37755. if (_this.scalePivot) {
  37756. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37757. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37758. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37759. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37760. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37761. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37762. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37763. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37764. }
  37765. else {
  37766. // Scale from the position of the opposite corner
  37767. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37768. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37769. }
  37770. _this._anchorMesh.addChild(_this.attachedMesh);
  37771. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37772. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37773. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37774. }
  37775. _this._anchorMesh.removeChild(_this.attachedMesh);
  37776. _this.attachedMesh.setParent(originalParent);
  37777. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37778. }
  37779. _this._updateDummy();
  37780. });
  37781. // Selection/deselection
  37782. _dragBehavior.onDragStartObservable.add(function () {
  37783. _this.onDragStartObservable.notifyObservers({});
  37784. _this._selectNode(box);
  37785. });
  37786. _dragBehavior.onDragEndObservable.add(function () {
  37787. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37788. _this._selectNode(null);
  37789. _this._updateDummy();
  37790. });
  37791. this_2._scaleBoxesParent.addChild(box);
  37792. };
  37793. var this_2 = this, _dragBehavior;
  37794. for (var k = 0; k < 2; k++) {
  37795. _loop_2();
  37796. }
  37797. }
  37798. }
  37799. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37800. // Hover color change
  37801. var pointerIds = new Array();
  37802. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37803. if (!pointerIds[pointerInfo.event.pointerId]) {
  37804. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37805. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37806. pointerIds[pointerInfo.event.pointerId] = mesh;
  37807. mesh.material = hoverColoredMaterial;
  37808. }
  37809. });
  37810. }
  37811. else {
  37812. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37813. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37814. delete pointerIds[pointerInfo.event.pointerId];
  37815. }
  37816. }
  37817. });
  37818. // Update bounding box positions
  37819. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37820. // Only update the bouding box if scaling has changed
  37821. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37822. _this.updateBoundingBox();
  37823. }
  37824. else if (_this.fixedDragMeshScreenSize) {
  37825. _this._updateRotationSpheres();
  37826. _this._updateScaleBoxes();
  37827. }
  37828. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37829. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37830. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37831. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37832. }
  37833. });
  37834. _this.updateBoundingBox();
  37835. return _this;
  37836. }
  37837. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37838. var _this = this;
  37839. if (value) {
  37840. // Reset anchor mesh to match attached mesh's scale
  37841. // This is needed to avoid invalid box/sphere position on first drag
  37842. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37843. var originalParent = value.parent;
  37844. this._anchorMesh.addChild(value);
  37845. this._anchorMesh.removeChild(value);
  37846. value.setParent(originalParent);
  37847. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37848. this.updateBoundingBox();
  37849. value.getChildMeshes(false).forEach(function (m) {
  37850. m.markAsDirty("scaling");
  37851. });
  37852. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37853. _this._updateDummy();
  37854. });
  37855. }
  37856. };
  37857. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37858. this._rotateSpheresParent.getChildMeshes()
  37859. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37860. m.isVisible = (!selectedMesh || m == selectedMesh);
  37861. });
  37862. };
  37863. /**
  37864. * Updates the bounding box information for the Gizmo
  37865. */
  37866. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37867. if (this.attachedMesh) {
  37868. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37869. var originalParent = this.attachedMesh.parent;
  37870. this.attachedMesh.setParent(null);
  37871. this._update();
  37872. // Rotate based on axis
  37873. if (!this.attachedMesh.rotationQuaternion) {
  37874. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37875. }
  37876. if (!this._anchorMesh.rotationQuaternion) {
  37877. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37878. }
  37879. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37880. // Store original position and reset mesh to origin before computing the bounding box
  37881. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37882. this._tmpVector.copyFrom(this.attachedMesh.position);
  37883. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37884. this.attachedMesh.position.set(0, 0, 0);
  37885. // Update bounding dimensions/positions
  37886. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37887. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37888. // Update gizmo to match bounding box scaling and rotation
  37889. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37890. 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);
  37891. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37892. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37893. this._lineBoundingBox.computeWorldMatrix();
  37894. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37895. // restore position/rotation values
  37896. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37897. this.attachedMesh.position.copyFrom(this._tmpVector);
  37898. this.attachedMesh.setParent(originalParent);
  37899. }
  37900. this._updateRotationSpheres();
  37901. this._updateScaleBoxes();
  37902. if (this.attachedMesh) {
  37903. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37904. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37905. }
  37906. };
  37907. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37908. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37909. for (var i = 0; i < 3; i++) {
  37910. for (var j = 0; j < 2; j++) {
  37911. for (var k = 0; k < 2; k++) {
  37912. var index = ((i * 4) + (j * 2)) + k;
  37913. if (i == 0) {
  37914. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37915. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37916. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Right()).normalizeToNew().add(rotateSpheres[index].position));
  37917. }
  37918. if (i == 1) {
  37919. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37920. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37921. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up()).normalizeToNew().add(rotateSpheres[index].position));
  37922. }
  37923. if (i == 2) {
  37924. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37925. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37926. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Forward()).normalizeToNew().add(rotateSpheres[index].position));
  37927. }
  37928. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37929. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37930. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37931. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37932. }
  37933. else {
  37934. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37935. }
  37936. }
  37937. }
  37938. }
  37939. };
  37940. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37941. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37942. for (var i = 0; i < 2; i++) {
  37943. for (var j = 0; j < 2; j++) {
  37944. for (var k = 0; k < 2; k++) {
  37945. var index = ((i * 4) + (j * 2)) + k;
  37946. if (scaleBoxes[index]) {
  37947. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37948. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37949. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37950. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37951. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37952. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37953. }
  37954. else {
  37955. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37956. }
  37957. }
  37958. }
  37959. }
  37960. }
  37961. };
  37962. /**
  37963. * Enables rotation on the specified axis and disables rotation on the others
  37964. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37965. */
  37966. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  37967. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  37968. if (i < 4) {
  37969. m.setEnabled(axis.indexOf("x") != -1);
  37970. }
  37971. else if (i < 8) {
  37972. m.setEnabled(axis.indexOf("y") != -1);
  37973. }
  37974. else {
  37975. m.setEnabled(axis.indexOf("z") != -1);
  37976. }
  37977. });
  37978. };
  37979. /**
  37980. * Enables/disables scaling
  37981. * @param enable if scaling should be enabled
  37982. */
  37983. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  37984. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  37985. m.setEnabled(enable);
  37986. });
  37987. };
  37988. BoundingBoxGizmo.prototype._updateDummy = function () {
  37989. if (this._dragMesh) {
  37990. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  37991. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  37992. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  37993. }
  37994. };
  37995. /**
  37996. * Enables a pointer drag behavior on the bounding box of the gizmo
  37997. */
  37998. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  37999. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38000. this._dragMesh.visibility = 0;
  38001. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38002. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38003. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38004. };
  38005. /**
  38006. * Disposes of the gizmo
  38007. */
  38008. BoundingBoxGizmo.prototype.dispose = function () {
  38009. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38010. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38011. this._lineBoundingBox.dispose();
  38012. this._rotateSpheresParent.dispose();
  38013. this._scaleBoxesParent.dispose();
  38014. if (this._dragMesh) {
  38015. this._dragMesh.dispose();
  38016. }
  38017. _super.prototype.dispose.call(this);
  38018. };
  38019. /**
  38020. * 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)
  38021. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38022. * @returns the bounding box mesh with the passed in mesh as a child
  38023. */
  38024. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38025. var makeNotPickable = function (root) {
  38026. root.isPickable = false;
  38027. root.getChildMeshes().forEach(function (c) {
  38028. makeNotPickable(c);
  38029. });
  38030. };
  38031. makeNotPickable(mesh);
  38032. // Reset position to get boudning box from origin with no rotation
  38033. if (!mesh.rotationQuaternion) {
  38034. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38035. }
  38036. var oldPos = mesh.position.clone();
  38037. var oldRot = mesh.rotationQuaternion.clone();
  38038. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38039. mesh.position.set(0, 0, 0);
  38040. // Update bounding dimensions/positions
  38041. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38042. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38043. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38044. // Adjust scale to avoid undefined behavior when adding child
  38045. if (box.scaling.y === 0) {
  38046. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38047. }
  38048. if (box.scaling.x === 0) {
  38049. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38050. }
  38051. if (box.scaling.z === 0) {
  38052. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38053. }
  38054. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38055. // Restore original positions
  38056. mesh.addChild(box);
  38057. mesh.rotationQuaternion.copyFrom(oldRot);
  38058. mesh.position.copyFrom(oldPos);
  38059. // Reverse parenting
  38060. mesh.removeChild(box);
  38061. box.addChild(mesh);
  38062. box.visibility = 0;
  38063. return box;
  38064. };
  38065. /**
  38066. * CustomMeshes are not supported by this gizmo
  38067. * @param mesh The mesh to replace the default mesh of the gizmo
  38068. */
  38069. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38070. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38071. };
  38072. return BoundingBoxGizmo;
  38073. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38074. /***/ }),
  38075. /***/ "./Gizmos/gizmo.ts":
  38076. /*!*************************!*\
  38077. !*** ./Gizmos/gizmo.ts ***!
  38078. \*************************/
  38079. /*! exports provided: Gizmo */
  38080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38081. "use strict";
  38082. __webpack_require__.r(__webpack_exports__);
  38083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38085. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38086. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38087. /**
  38088. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38089. */
  38090. var Gizmo = /** @class */ (function () {
  38091. /**
  38092. * Creates a gizmo
  38093. * @param gizmoLayer The utility layer the gizmo will be added to
  38094. */
  38095. function Gizmo(
  38096. /** The utility layer the gizmo will be added to */
  38097. gizmoLayer) {
  38098. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38099. var _this = this;
  38100. this.gizmoLayer = gizmoLayer;
  38101. /**
  38102. * Ratio for the scale of the gizmo (Default: 1)
  38103. */
  38104. this.scaleRatio = 1;
  38105. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38106. /**
  38107. * If a custom mesh has been set (Default: false)
  38108. */
  38109. this._customMeshSet = false;
  38110. /**
  38111. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38112. */
  38113. this.updateGizmoRotationToMatchAttachedMesh = true;
  38114. /**
  38115. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38116. */
  38117. this.updateGizmoPositionToMatchAttachedMesh = true;
  38118. /**
  38119. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38120. */
  38121. this._updateScale = true;
  38122. this._interactionsEnabled = true;
  38123. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38124. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38125. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38126. _this._update();
  38127. });
  38128. this.attachedMesh = null;
  38129. }
  38130. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38131. /**
  38132. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38133. * * When set, interactions will be enabled
  38134. */
  38135. get: function () {
  38136. return this._attachedMesh;
  38137. },
  38138. set: function (value) {
  38139. this._attachedMesh = value;
  38140. this._rootMesh.setEnabled(value ? true : false);
  38141. this._attachedMeshChanged(value);
  38142. },
  38143. enumerable: true,
  38144. configurable: true
  38145. });
  38146. /**
  38147. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38148. * @param mesh The mesh to replace the default mesh of the gizmo
  38149. */
  38150. Gizmo.prototype.setCustomMesh = function (mesh) {
  38151. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38152. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38153. }
  38154. this._rootMesh.getChildMeshes().forEach(function (c) {
  38155. c.dispose();
  38156. });
  38157. mesh.parent = this._rootMesh;
  38158. this._customMeshSet = true;
  38159. };
  38160. Gizmo.prototype._attachedMeshChanged = function (value) {
  38161. };
  38162. /**
  38163. * @hidden
  38164. * Updates the gizmo to match the attached mesh's position/rotation
  38165. */
  38166. Gizmo.prototype._update = function () {
  38167. if (this.attachedMesh) {
  38168. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38169. if (!this._rootMesh.rotationQuaternion) {
  38170. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38171. }
  38172. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38173. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38174. if (this.attachedMesh.scaling.x < 0) {
  38175. this.attachedMesh.scaling.x *= -1;
  38176. }
  38177. if (this.attachedMesh.scaling.y < 0) {
  38178. this.attachedMesh.scaling.y *= -1;
  38179. }
  38180. if (this.attachedMesh.scaling.z < 0) {
  38181. this.attachedMesh.scaling.z *= -1;
  38182. }
  38183. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38184. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38185. this.attachedMesh.computeWorldMatrix();
  38186. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38187. }
  38188. else if (this._rootMesh.rotationQuaternion) {
  38189. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38190. }
  38191. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38192. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38193. }
  38194. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38195. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38196. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38197. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38198. }
  38199. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38200. var dist = this._tempVector.length() * this.scaleRatio;
  38201. this._rootMesh.scaling.set(dist, dist, dist);
  38202. }
  38203. }
  38204. };
  38205. /**
  38206. * Disposes of the gizmo
  38207. */
  38208. Gizmo.prototype.dispose = function () {
  38209. this._rootMesh.dispose();
  38210. if (this._beforeRenderObserver) {
  38211. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38212. }
  38213. };
  38214. return Gizmo;
  38215. }());
  38216. /***/ }),
  38217. /***/ "./Gizmos/gizmoManager.ts":
  38218. /*!********************************!*\
  38219. !*** ./Gizmos/gizmoManager.ts ***!
  38220. \********************************/
  38221. /*! exports provided: GizmoManager */
  38222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38223. "use strict";
  38224. __webpack_require__.r(__webpack_exports__);
  38225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38226. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38227. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38228. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38229. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38231. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38232. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38233. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38234. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38235. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38236. /**
  38237. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38238. */
  38239. var GizmoManager = /** @class */ (function () {
  38240. /**
  38241. * Instatiates a gizmo manager
  38242. * @param scene the scene to overlay the gizmos on top of
  38243. */
  38244. function GizmoManager(scene) {
  38245. var _this = this;
  38246. this.scene = scene;
  38247. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38248. this.clearGizmoOnEmptyPointerEvent = false;
  38249. /** Fires an event when the manager is attached to a mesh */
  38250. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38251. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38252. this._pointerObserver = null;
  38253. this._attachedMesh = null;
  38254. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38255. /**
  38256. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38257. */
  38258. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38259. /**
  38260. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38261. */
  38262. this.attachableMeshes = null;
  38263. /**
  38264. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38265. */
  38266. this.usePointerToAttachGizmos = true;
  38267. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38268. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38269. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38270. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38271. // Instatiate/dispose gizmos based on pointer actions
  38272. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38273. if (!_this.usePointerToAttachGizmos) {
  38274. return;
  38275. }
  38276. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38277. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38278. var node = pointerInfo.pickInfo.pickedMesh;
  38279. if (_this.attachableMeshes == null) {
  38280. // Attach to the most parent node
  38281. while (node && node.parent != null) {
  38282. node = node.parent;
  38283. }
  38284. }
  38285. else {
  38286. // Attach to the parent node that is an attachableMesh
  38287. var found = false;
  38288. _this.attachableMeshes.forEach(function (mesh) {
  38289. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38290. node = mesh;
  38291. found = true;
  38292. }
  38293. });
  38294. if (!found) {
  38295. node = null;
  38296. }
  38297. }
  38298. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38299. if (_this._attachedMesh != node) {
  38300. _this.attachToMesh(node);
  38301. }
  38302. }
  38303. else {
  38304. if (_this.clearGizmoOnEmptyPointerEvent) {
  38305. _this.attachToMesh(null);
  38306. }
  38307. }
  38308. }
  38309. else {
  38310. if (_this.clearGizmoOnEmptyPointerEvent) {
  38311. _this.attachToMesh(null);
  38312. }
  38313. }
  38314. }
  38315. });
  38316. }
  38317. /**
  38318. * Attaches a set of gizmos to the specified mesh
  38319. * @param mesh The mesh the gizmo's should be attached to
  38320. */
  38321. GizmoManager.prototype.attachToMesh = function (mesh) {
  38322. if (this._attachedMesh) {
  38323. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38324. }
  38325. this._attachedMesh = mesh;
  38326. for (var key in this.gizmos) {
  38327. var gizmo = (this.gizmos[key]);
  38328. if (gizmo && this._gizmosEnabled[key]) {
  38329. gizmo.attachedMesh = mesh;
  38330. }
  38331. }
  38332. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38333. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38334. }
  38335. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38336. };
  38337. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38338. get: function () {
  38339. return this._gizmosEnabled.positionGizmo;
  38340. },
  38341. /**
  38342. * If the position gizmo is enabled
  38343. */
  38344. set: function (value) {
  38345. if (value) {
  38346. if (!this.gizmos.positionGizmo) {
  38347. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38348. }
  38349. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38350. }
  38351. else if (this.gizmos.positionGizmo) {
  38352. this.gizmos.positionGizmo.attachedMesh = null;
  38353. }
  38354. this._gizmosEnabled.positionGizmo = value;
  38355. },
  38356. enumerable: true,
  38357. configurable: true
  38358. });
  38359. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38360. get: function () {
  38361. return this._gizmosEnabled.rotationGizmo;
  38362. },
  38363. /**
  38364. * If the rotation gizmo is enabled
  38365. */
  38366. set: function (value) {
  38367. if (value) {
  38368. if (!this.gizmos.rotationGizmo) {
  38369. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38370. }
  38371. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38372. }
  38373. else if (this.gizmos.rotationGizmo) {
  38374. this.gizmos.rotationGizmo.attachedMesh = null;
  38375. }
  38376. this._gizmosEnabled.rotationGizmo = value;
  38377. },
  38378. enumerable: true,
  38379. configurable: true
  38380. });
  38381. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38382. get: function () {
  38383. return this._gizmosEnabled.scaleGizmo;
  38384. },
  38385. /**
  38386. * If the scale gizmo is enabled
  38387. */
  38388. set: function (value) {
  38389. if (value) {
  38390. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38391. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38392. }
  38393. else if (this.gizmos.scaleGizmo) {
  38394. this.gizmos.scaleGizmo.attachedMesh = null;
  38395. }
  38396. this._gizmosEnabled.scaleGizmo = value;
  38397. },
  38398. enumerable: true,
  38399. configurable: true
  38400. });
  38401. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38402. get: function () {
  38403. return this._gizmosEnabled.boundingBoxGizmo;
  38404. },
  38405. /**
  38406. * If the boundingBox gizmo is enabled
  38407. */
  38408. set: function (value) {
  38409. if (value) {
  38410. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38411. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38412. if (this._attachedMesh) {
  38413. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38414. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38415. }
  38416. }
  38417. else if (this.gizmos.boundingBoxGizmo) {
  38418. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38419. }
  38420. this._gizmosEnabled.boundingBoxGizmo = value;
  38421. },
  38422. enumerable: true,
  38423. configurable: true
  38424. });
  38425. /**
  38426. * Disposes of the gizmo manager
  38427. */
  38428. GizmoManager.prototype.dispose = function () {
  38429. this.scene.onPointerObservable.remove(this._pointerObserver);
  38430. for (var key in this.gizmos) {
  38431. var gizmo = (this.gizmos[key]);
  38432. if (gizmo) {
  38433. gizmo.dispose();
  38434. }
  38435. }
  38436. this._defaultKeepDepthUtilityLayer.dispose();
  38437. this._defaultUtilityLayer.dispose();
  38438. this.boundingBoxDragBehavior.detach();
  38439. this.onAttachedToMeshObservable.clear();
  38440. };
  38441. return GizmoManager;
  38442. }());
  38443. /***/ }),
  38444. /***/ "./Gizmos/index.ts":
  38445. /*!*************************!*\
  38446. !*** ./Gizmos/index.ts ***!
  38447. \*************************/
  38448. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo */
  38449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38450. "use strict";
  38451. __webpack_require__.r(__webpack_exports__);
  38452. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38454. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38456. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38458. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38460. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38462. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38464. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38466. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38468. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38470. /***/ }),
  38471. /***/ "./Gizmos/planeRotationGizmo.ts":
  38472. /*!**************************************!*\
  38473. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38474. \**************************************/
  38475. /*! exports provided: PlaneRotationGizmo */
  38476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38477. "use strict";
  38478. __webpack_require__.r(__webpack_exports__);
  38479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38480. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38481. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38483. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38484. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38485. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38486. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38487. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38488. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38489. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38490. /**
  38491. * Single plane rotation gizmo
  38492. */
  38493. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38495. /**
  38496. * Creates a PlaneRotationGizmo
  38497. * @param gizmoLayer The utility layer the gizmo will be added to
  38498. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38499. * @param color The color of the gizmo
  38500. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38501. */
  38502. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38503. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38504. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38505. if (tessellation === void 0) { tessellation = 32; }
  38506. var _this = _super.call(this, gizmoLayer) || this;
  38507. _this._pointerObserver = null;
  38508. /**
  38509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38510. */
  38511. _this.snapDistance = 0;
  38512. /**
  38513. * Event that fires each time the gizmo snaps to a new location.
  38514. * * snapDistance is the the change in distance
  38515. */
  38516. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38517. // Create Material
  38518. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38519. coloredMaterial.disableLighting = true;
  38520. coloredMaterial.emissiveColor = color;
  38521. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38522. hoverMaterial.disableLighting = true;
  38523. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38524. // Build mesh on root node
  38525. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38526. // Create circle out of lines
  38527. var radius = 0.8;
  38528. var points = new Array();
  38529. for (var i = 0; i < tessellation; i++) {
  38530. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38531. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38532. }
  38533. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38534. rotationMesh.color = coloredMaterial.emissiveColor;
  38535. // Position arrow pointing in its drag axis
  38536. rotationMesh.scaling.scaleInPlace(0.26);
  38537. rotationMesh.material = coloredMaterial;
  38538. rotationMesh.rotation.x = Math.PI / 2;
  38539. parentMesh.addChild(rotationMesh);
  38540. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38541. _this._rootMesh.addChild(parentMesh);
  38542. parentMesh.scaling.scaleInPlace(1 / 3);
  38543. // Add drag behavior to handle events when the gizmo is dragged
  38544. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38545. _this.dragBehavior.moveAttached = false;
  38546. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38547. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38548. _this._rootMesh.addBehavior(_this.dragBehavior);
  38549. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38550. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38551. if (_this.attachedMesh) {
  38552. lastDragPosition.copyFrom(e.dragPlanePoint);
  38553. }
  38554. });
  38555. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38556. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38557. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38558. var tmpSnapEvent = { snapDistance: 0 };
  38559. var currentSnapDragDistance = 0;
  38560. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38561. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38562. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38563. _this.dragBehavior.onDragObservable.add(function (event) {
  38564. if (_this.attachedMesh) {
  38565. if (!_this.attachedMesh.rotationQuaternion) {
  38566. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38567. }
  38568. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38569. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38570. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38571. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38572. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38573. var angle = Math.atan2(cross.length(), dot);
  38574. planeNormalTowardsCamera.copyFrom(planeNormal);
  38575. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38576. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38577. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38578. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38579. }
  38580. // Flip up vector depending on which side the camera is on
  38581. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38582. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38583. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38584. planeNormalTowardsCamera.scaleInPlace(-1);
  38585. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38586. }
  38587. }
  38588. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38589. if (halfCircleSide) {
  38590. angle = -angle;
  38591. }
  38592. // Snapping logic
  38593. var snapped = false;
  38594. if (_this.snapDistance != 0) {
  38595. currentSnapDragDistance += angle;
  38596. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38597. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38598. if (currentSnapDragDistance < 0) {
  38599. dragSteps *= -1;
  38600. }
  38601. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38602. angle = _this.snapDistance * dragSteps;
  38603. snapped = true;
  38604. }
  38605. else {
  38606. angle = 0;
  38607. }
  38608. }
  38609. // If the mesh has a parent, convert needed world rotation to local rotation
  38610. tmpMatrix.reset();
  38611. if (_this.attachedMesh.parent) {
  38612. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38613. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38614. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38615. }
  38616. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38617. var quaternionCoefficient = Math.sin(angle / 2);
  38618. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38619. // 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
  38620. if (tmpMatrix.determinant() > 0) {
  38621. amountToRotate.toEulerAnglesToRef(tmpVector);
  38622. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38623. }
  38624. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38625. // Rotate selected mesh quaternion over fixed axis
  38626. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38627. }
  38628. else {
  38629. // Rotate selected mesh quaternion over rotated axis
  38630. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38631. }
  38632. lastDragPosition.copyFrom(event.dragPlanePoint);
  38633. if (snapped) {
  38634. tmpSnapEvent.snapDistance = angle;
  38635. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38636. }
  38637. }
  38638. });
  38639. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38640. if (_this._customMeshSet) {
  38641. return;
  38642. }
  38643. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38644. var material = isHovered ? hoverMaterial : coloredMaterial;
  38645. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38646. m.material = material;
  38647. if (m.color) {
  38648. m.color = material.emissiveColor;
  38649. }
  38650. });
  38651. });
  38652. return _this;
  38653. }
  38654. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38655. if (this.dragBehavior) {
  38656. this.dragBehavior.enabled = value ? true : false;
  38657. }
  38658. };
  38659. /**
  38660. * Disposes of the gizmo
  38661. */
  38662. PlaneRotationGizmo.prototype.dispose = function () {
  38663. this.onSnapObservable.clear();
  38664. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38665. this.dragBehavior.detach();
  38666. _super.prototype.dispose.call(this);
  38667. };
  38668. return PlaneRotationGizmo;
  38669. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38670. /***/ }),
  38671. /***/ "./Gizmos/positionGizmo.ts":
  38672. /*!*********************************!*\
  38673. !*** ./Gizmos/positionGizmo.ts ***!
  38674. \*********************************/
  38675. /*! exports provided: PositionGizmo */
  38676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38677. "use strict";
  38678. __webpack_require__.r(__webpack_exports__);
  38679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38681. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38682. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38683. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38684. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38685. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38686. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38687. /**
  38688. * Gizmo that enables dragging a mesh along 3 axis
  38689. */
  38690. var PositionGizmo = /** @class */ (function (_super) {
  38691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38692. /**
  38693. * Creates a PositionGizmo
  38694. * @param gizmoLayer The utility layer the gizmo will be added to
  38695. */
  38696. function PositionGizmo(gizmoLayer) {
  38697. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38698. var _this = _super.call(this, gizmoLayer) || this;
  38699. /** Fires an event when any of it's sub gizmos are dragged */
  38700. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38701. /** Fires an event when any of it's sub gizmos are released from dragging */
  38702. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38703. _this.xGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer);
  38704. _this.yGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer);
  38705. _this.zGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer);
  38706. // Relay drag events
  38707. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38708. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38709. _this.onDragStartObservable.notifyObservers({});
  38710. });
  38711. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38712. _this.onDragEndObservable.notifyObservers({});
  38713. });
  38714. });
  38715. _this.attachedMesh = null;
  38716. return _this;
  38717. }
  38718. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38719. set: function (mesh) {
  38720. if (this.xGizmo) {
  38721. this.xGizmo.attachedMesh = mesh;
  38722. this.yGizmo.attachedMesh = mesh;
  38723. this.zGizmo.attachedMesh = mesh;
  38724. }
  38725. },
  38726. enumerable: true,
  38727. configurable: true
  38728. });
  38729. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38730. get: function () {
  38731. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38732. },
  38733. set: function (value) {
  38734. if (this.xGizmo) {
  38735. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38736. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38737. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38738. }
  38739. },
  38740. enumerable: true,
  38741. configurable: true
  38742. });
  38743. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38744. get: function () {
  38745. return this.xGizmo.snapDistance;
  38746. },
  38747. /**
  38748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38749. */
  38750. set: function (value) {
  38751. if (this.xGizmo) {
  38752. this.xGizmo.snapDistance = value;
  38753. this.yGizmo.snapDistance = value;
  38754. this.zGizmo.snapDistance = value;
  38755. }
  38756. },
  38757. enumerable: true,
  38758. configurable: true
  38759. });
  38760. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38761. get: function () {
  38762. return this.xGizmo.scaleRatio;
  38763. },
  38764. /**
  38765. * Ratio for the scale of the gizmo (Default: 1)
  38766. */
  38767. set: function (value) {
  38768. if (this.xGizmo) {
  38769. this.xGizmo.scaleRatio = value;
  38770. this.yGizmo.scaleRatio = value;
  38771. this.zGizmo.scaleRatio = value;
  38772. }
  38773. },
  38774. enumerable: true,
  38775. configurable: true
  38776. });
  38777. /**
  38778. * Disposes of the gizmo
  38779. */
  38780. PositionGizmo.prototype.dispose = function () {
  38781. this.xGizmo.dispose();
  38782. this.yGizmo.dispose();
  38783. this.zGizmo.dispose();
  38784. this.onDragStartObservable.clear();
  38785. this.onDragEndObservable.clear();
  38786. };
  38787. /**
  38788. * CustomMeshes are not supported by this gizmo
  38789. * @param mesh The mesh to replace the default mesh of the gizmo
  38790. */
  38791. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38792. _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)");
  38793. };
  38794. return PositionGizmo;
  38795. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38796. /***/ }),
  38797. /***/ "./Gizmos/rotationGizmo.ts":
  38798. /*!*********************************!*\
  38799. !*** ./Gizmos/rotationGizmo.ts ***!
  38800. \*********************************/
  38801. /*! exports provided: RotationGizmo */
  38802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38803. "use strict";
  38804. __webpack_require__.r(__webpack_exports__);
  38805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38806. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38807. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38808. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38809. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38810. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38811. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38812. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38813. /**
  38814. * Gizmo that enables rotating a mesh along 3 axis
  38815. */
  38816. var RotationGizmo = /** @class */ (function (_super) {
  38817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38818. /**
  38819. * Creates a RotationGizmo
  38820. * @param gizmoLayer The utility layer the gizmo will be added to
  38821. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38822. */
  38823. function RotationGizmo(gizmoLayer, tessellation) {
  38824. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38825. if (tessellation === void 0) { tessellation = 32; }
  38826. var _this = _super.call(this, gizmoLayer) || this;
  38827. /** Fires an event when any of it's sub gizmos are dragged */
  38828. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38829. /** Fires an event when any of it's sub gizmos are released from dragging */
  38830. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38831. _this.xGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer, tessellation);
  38832. _this.yGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer, tessellation);
  38833. _this.zGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer, tessellation);
  38834. // Relay drag events
  38835. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38836. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38837. _this.onDragStartObservable.notifyObservers({});
  38838. });
  38839. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38840. _this.onDragEndObservable.notifyObservers({});
  38841. });
  38842. });
  38843. _this.attachedMesh = null;
  38844. return _this;
  38845. }
  38846. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38847. set: function (mesh) {
  38848. if (this.xGizmo) {
  38849. this.xGizmo.attachedMesh = mesh;
  38850. this.yGizmo.attachedMesh = mesh;
  38851. this.zGizmo.attachedMesh = mesh;
  38852. }
  38853. },
  38854. enumerable: true,
  38855. configurable: true
  38856. });
  38857. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38858. get: function () {
  38859. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38860. },
  38861. set: function (value) {
  38862. if (this.xGizmo) {
  38863. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38864. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38865. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38866. }
  38867. },
  38868. enumerable: true,
  38869. configurable: true
  38870. });
  38871. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38872. get: function () {
  38873. return this.xGizmo.snapDistance;
  38874. },
  38875. /**
  38876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38877. */
  38878. set: function (value) {
  38879. if (this.xGizmo) {
  38880. this.xGizmo.snapDistance = value;
  38881. this.yGizmo.snapDistance = value;
  38882. this.zGizmo.snapDistance = value;
  38883. }
  38884. },
  38885. enumerable: true,
  38886. configurable: true
  38887. });
  38888. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  38889. get: function () {
  38890. return this.xGizmo.scaleRatio;
  38891. },
  38892. /**
  38893. * Ratio for the scale of the gizmo (Default: 1)
  38894. */
  38895. set: function (value) {
  38896. if (this.xGizmo) {
  38897. this.xGizmo.scaleRatio = value;
  38898. this.yGizmo.scaleRatio = value;
  38899. this.zGizmo.scaleRatio = value;
  38900. }
  38901. },
  38902. enumerable: true,
  38903. configurable: true
  38904. });
  38905. /**
  38906. * Disposes of the gizmo
  38907. */
  38908. RotationGizmo.prototype.dispose = function () {
  38909. this.xGizmo.dispose();
  38910. this.yGizmo.dispose();
  38911. this.zGizmo.dispose();
  38912. this.onDragStartObservable.clear();
  38913. this.onDragEndObservable.clear();
  38914. };
  38915. /**
  38916. * CustomMeshes are not supported by this gizmo
  38917. * @param mesh The mesh to replace the default mesh of the gizmo
  38918. */
  38919. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  38920. _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)");
  38921. };
  38922. return RotationGizmo;
  38923. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38924. /***/ }),
  38925. /***/ "./Gizmos/scaleGizmo.ts":
  38926. /*!******************************!*\
  38927. !*** ./Gizmos/scaleGizmo.ts ***!
  38928. \******************************/
  38929. /*! exports provided: ScaleGizmo */
  38930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38931. "use strict";
  38932. __webpack_require__.r(__webpack_exports__);
  38933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  38934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38935. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38936. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38937. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38938. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  38939. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38940. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38941. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38942. /**
  38943. * Gizmo that enables scaling a mesh along 3 axis
  38944. */
  38945. var ScaleGizmo = /** @class */ (function (_super) {
  38946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  38947. /**
  38948. * Creates a ScaleGizmo
  38949. * @param gizmoLayer The utility layer the gizmo will be added to
  38950. */
  38951. function ScaleGizmo(gizmoLayer) {
  38952. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38953. var _this = _super.call(this, gizmoLayer) || this;
  38954. /** Fires an event when any of it's sub gizmos are dragged */
  38955. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38956. /** Fires an event when any of it's sub gizmos are released from dragging */
  38957. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38958. _this.xGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer);
  38959. _this.yGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer);
  38960. _this.zGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer);
  38961. // Create uniform scale gizmo
  38962. _this.uniformScaleGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Yellow().scale(0.5), gizmoLayer);
  38963. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  38964. _this.uniformScaleGizmo.uniformScaling = true;
  38965. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38966. uniformScalingMesh.scaling.scaleInPlace(0.02);
  38967. uniformScalingMesh.visibility = 0;
  38968. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38969. octahedron.scaling.scaleInPlace(0.007);
  38970. uniformScalingMesh.addChild(octahedron);
  38971. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  38972. // Relay drag events
  38973. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  38974. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38975. _this.onDragStartObservable.notifyObservers({});
  38976. });
  38977. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38978. _this.onDragEndObservable.notifyObservers({});
  38979. });
  38980. });
  38981. _this.attachedMesh = null;
  38982. return _this;
  38983. }
  38984. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  38985. set: function (mesh) {
  38986. if (this.xGizmo) {
  38987. this.xGizmo.attachedMesh = mesh;
  38988. this.yGizmo.attachedMesh = mesh;
  38989. this.zGizmo.attachedMesh = mesh;
  38990. this.uniformScaleGizmo.attachedMesh = mesh;
  38991. }
  38992. },
  38993. enumerable: true,
  38994. configurable: true
  38995. });
  38996. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38997. get: function () {
  38998. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38999. },
  39000. set: function (value) {
  39001. if (!value) {
  39002. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39003. }
  39004. if (this.xGizmo) {
  39005. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39006. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39007. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39008. }
  39009. },
  39010. enumerable: true,
  39011. configurable: true
  39012. });
  39013. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39014. get: function () {
  39015. return this.xGizmo.snapDistance;
  39016. },
  39017. /**
  39018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39019. */
  39020. set: function (value) {
  39021. if (this.xGizmo) {
  39022. this.xGizmo.snapDistance = value;
  39023. this.yGizmo.snapDistance = value;
  39024. this.zGizmo.snapDistance = value;
  39025. this.uniformScaleGizmo.snapDistance = value;
  39026. }
  39027. },
  39028. enumerable: true,
  39029. configurable: true
  39030. });
  39031. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39032. get: function () {
  39033. return this.xGizmo.scaleRatio;
  39034. },
  39035. /**
  39036. * Ratio for the scale of the gizmo (Default: 1)
  39037. */
  39038. set: function (value) {
  39039. if (this.xGizmo) {
  39040. this.xGizmo.scaleRatio = value;
  39041. this.yGizmo.scaleRatio = value;
  39042. this.zGizmo.scaleRatio = value;
  39043. this.uniformScaleGizmo.scaleRatio = value;
  39044. }
  39045. },
  39046. enumerable: true,
  39047. configurable: true
  39048. });
  39049. /**
  39050. * Disposes of the gizmo
  39051. */
  39052. ScaleGizmo.prototype.dispose = function () {
  39053. this.xGizmo.dispose();
  39054. this.yGizmo.dispose();
  39055. this.zGizmo.dispose();
  39056. this.uniformScaleGizmo.dispose();
  39057. this.onDragStartObservable.clear();
  39058. this.onDragEndObservable.clear();
  39059. };
  39060. return ScaleGizmo;
  39061. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39062. /***/ }),
  39063. /***/ "./Helpers/environmentHelper.ts":
  39064. /*!**************************************!*\
  39065. !*** ./Helpers/environmentHelper.ts ***!
  39066. \**************************************/
  39067. /*! exports provided: EnvironmentHelper */
  39068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39069. "use strict";
  39070. __webpack_require__.r(__webpack_exports__);
  39071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39073. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39074. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39075. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39076. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39077. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39078. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39079. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39080. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39081. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39082. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39083. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39084. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39085. /**
  39086. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39087. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39088. * It also helps with the default setup of your imageProcessing configuration.
  39089. */
  39090. var EnvironmentHelper = /** @class */ (function () {
  39091. /**
  39092. * constructor
  39093. * @param options Defines the options we want to customize the helper
  39094. * @param scene The scene to add the material to
  39095. */
  39096. function EnvironmentHelper(options, scene) {
  39097. var _this = this;
  39098. this._errorHandler = function (message, exception) {
  39099. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39100. };
  39101. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39102. this._scene = scene;
  39103. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39104. this._setupBackground();
  39105. this._setupImageProcessing();
  39106. }
  39107. /**
  39108. * Creates the default options for the helper.
  39109. */
  39110. EnvironmentHelper._getDefaultOptions = function () {
  39111. return {
  39112. createGround: true,
  39113. groundSize: 15,
  39114. groundTexture: this._groundTextureCDNUrl,
  39115. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39116. groundOpacity: 0.9,
  39117. enableGroundShadow: true,
  39118. groundShadowLevel: 0.5,
  39119. enableGroundMirror: false,
  39120. groundMirrorSizeRatio: 0.3,
  39121. groundMirrorBlurKernel: 64,
  39122. groundMirrorAmount: 1,
  39123. groundMirrorFresnelWeight: 1,
  39124. groundMirrorFallOffDistance: 0,
  39125. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39126. groundYBias: 0.00001,
  39127. createSkybox: true,
  39128. skyboxSize: 20,
  39129. skyboxTexture: this._skyboxTextureCDNUrl,
  39130. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39131. backgroundYRotation: 0,
  39132. sizeAuto: true,
  39133. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39134. setupImageProcessing: true,
  39135. environmentTexture: this._environmentTextureCDNUrl,
  39136. cameraExposure: 0.8,
  39137. cameraContrast: 1.2,
  39138. toneMappingEnabled: true,
  39139. };
  39140. };
  39141. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39142. /**
  39143. * Gets the root mesh created by the helper.
  39144. */
  39145. get: function () {
  39146. return this._rootMesh;
  39147. },
  39148. enumerable: true,
  39149. configurable: true
  39150. });
  39151. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39152. /**
  39153. * Gets the skybox created by the helper.
  39154. */
  39155. get: function () {
  39156. return this._skybox;
  39157. },
  39158. enumerable: true,
  39159. configurable: true
  39160. });
  39161. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39162. /**
  39163. * Gets the skybox texture created by the helper.
  39164. */
  39165. get: function () {
  39166. return this._skyboxTexture;
  39167. },
  39168. enumerable: true,
  39169. configurable: true
  39170. });
  39171. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39172. /**
  39173. * Gets the skybox material created by the helper.
  39174. */
  39175. get: function () {
  39176. return this._skyboxMaterial;
  39177. },
  39178. enumerable: true,
  39179. configurable: true
  39180. });
  39181. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39182. /**
  39183. * Gets the ground mesh created by the helper.
  39184. */
  39185. get: function () {
  39186. return this._ground;
  39187. },
  39188. enumerable: true,
  39189. configurable: true
  39190. });
  39191. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39192. /**
  39193. * Gets the ground texture created by the helper.
  39194. */
  39195. get: function () {
  39196. return this._groundTexture;
  39197. },
  39198. enumerable: true,
  39199. configurable: true
  39200. });
  39201. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39202. /**
  39203. * Gets the ground mirror created by the helper.
  39204. */
  39205. get: function () {
  39206. return this._groundMirror;
  39207. },
  39208. enumerable: true,
  39209. configurable: true
  39210. });
  39211. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39212. /**
  39213. * Gets the ground mirror render list to helps pushing the meshes
  39214. * you wish in the ground reflection.
  39215. */
  39216. get: function () {
  39217. if (this._groundMirror) {
  39218. return this._groundMirror.renderList;
  39219. }
  39220. return null;
  39221. },
  39222. enumerable: true,
  39223. configurable: true
  39224. });
  39225. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39226. /**
  39227. * Gets the ground material created by the helper.
  39228. */
  39229. get: function () {
  39230. return this._groundMaterial;
  39231. },
  39232. enumerable: true,
  39233. configurable: true
  39234. });
  39235. /**
  39236. * Updates the background according to the new options
  39237. * @param options
  39238. */
  39239. EnvironmentHelper.prototype.updateOptions = function (options) {
  39240. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39241. if (this._ground && !newOptions.createGround) {
  39242. this._ground.dispose();
  39243. this._ground = null;
  39244. }
  39245. if (this._groundMaterial && !newOptions.createGround) {
  39246. this._groundMaterial.dispose();
  39247. this._groundMaterial = null;
  39248. }
  39249. if (this._groundTexture) {
  39250. if (this._options.groundTexture != newOptions.groundTexture) {
  39251. this._groundTexture.dispose();
  39252. this._groundTexture = null;
  39253. }
  39254. }
  39255. if (this._skybox && !newOptions.createSkybox) {
  39256. this._skybox.dispose();
  39257. this._skybox = null;
  39258. }
  39259. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39260. this._skyboxMaterial.dispose();
  39261. this._skyboxMaterial = null;
  39262. }
  39263. if (this._skyboxTexture) {
  39264. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39265. this._skyboxTexture.dispose();
  39266. this._skyboxTexture = null;
  39267. }
  39268. }
  39269. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39270. this._groundMirror.dispose();
  39271. this._groundMirror = null;
  39272. }
  39273. if (this._scene.environmentTexture) {
  39274. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39275. this._scene.environmentTexture.dispose();
  39276. }
  39277. }
  39278. this._options = newOptions;
  39279. this._setupBackground();
  39280. this._setupImageProcessing();
  39281. };
  39282. /**
  39283. * Sets the primary color of all the available elements.
  39284. * @param color the main color to affect to the ground and the background
  39285. */
  39286. EnvironmentHelper.prototype.setMainColor = function (color) {
  39287. if (this.groundMaterial) {
  39288. this.groundMaterial.primaryColor = color;
  39289. }
  39290. if (this.skyboxMaterial) {
  39291. this.skyboxMaterial.primaryColor = color;
  39292. }
  39293. if (this.groundMirror) {
  39294. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39295. }
  39296. };
  39297. /**
  39298. * Setup the image processing according to the specified options.
  39299. */
  39300. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39301. if (this._options.setupImageProcessing) {
  39302. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39303. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39304. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39305. this._setupEnvironmentTexture();
  39306. }
  39307. };
  39308. /**
  39309. * Setup the environment texture according to the specified options.
  39310. */
  39311. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39312. if (this._scene.environmentTexture) {
  39313. return;
  39314. }
  39315. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39316. this._scene.environmentTexture = this._options.environmentTexture;
  39317. return;
  39318. }
  39319. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39320. this._scene.environmentTexture = environmentTexture;
  39321. };
  39322. /**
  39323. * Setup the background according to the specified options.
  39324. */
  39325. EnvironmentHelper.prototype._setupBackground = function () {
  39326. if (!this._rootMesh) {
  39327. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39328. }
  39329. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39330. var sceneSize = this._getSceneSize();
  39331. if (this._options.createGround) {
  39332. this._setupGround(sceneSize);
  39333. this._setupGroundMaterial();
  39334. this._setupGroundDiffuseTexture();
  39335. if (this._options.enableGroundMirror) {
  39336. this._setupGroundMirrorTexture(sceneSize);
  39337. }
  39338. this._setupMirrorInGroundMaterial();
  39339. }
  39340. if (this._options.createSkybox) {
  39341. this._setupSkybox(sceneSize);
  39342. this._setupSkyboxMaterial();
  39343. this._setupSkyboxReflectionTexture();
  39344. }
  39345. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39346. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39347. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39348. };
  39349. /**
  39350. * Get the scene sizes according to the setup.
  39351. */
  39352. EnvironmentHelper.prototype._getSceneSize = function () {
  39353. var _this = this;
  39354. var groundSize = this._options.groundSize;
  39355. var skyboxSize = this._options.skyboxSize;
  39356. var rootPosition = this._options.rootPosition;
  39357. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39358. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39359. }
  39360. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39361. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39362. });
  39363. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39364. if (this._options.sizeAuto) {
  39365. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39366. this._scene.activeCamera.upperRadiusLimit) {
  39367. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39368. skyboxSize = groundSize;
  39369. }
  39370. var sceneDiagonalLenght = sceneDiagonal.length();
  39371. if (sceneDiagonalLenght > groundSize) {
  39372. groundSize = sceneDiagonalLenght * 2;
  39373. skyboxSize = groundSize;
  39374. }
  39375. // 10 % bigger.
  39376. groundSize *= 1.1;
  39377. skyboxSize *= 1.5;
  39378. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39379. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39380. }
  39381. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39382. };
  39383. /**
  39384. * Setup the ground according to the specified options.
  39385. */
  39386. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39387. var _this = this;
  39388. if (!this._ground || this._ground.isDisposed()) {
  39389. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39390. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39391. this._ground.parent = this._rootMesh;
  39392. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39393. }
  39394. this._ground.receiveShadows = this._options.enableGroundShadow;
  39395. };
  39396. /**
  39397. * Setup the ground material according to the specified options.
  39398. */
  39399. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39400. if (!this._groundMaterial) {
  39401. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39402. }
  39403. this._groundMaterial.alpha = this._options.groundOpacity;
  39404. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39405. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39406. this._groundMaterial.primaryColor = this._options.groundColor;
  39407. this._groundMaterial.useRGBColor = false;
  39408. this._groundMaterial.enableNoise = true;
  39409. if (this._ground) {
  39410. this._ground.material = this._groundMaterial;
  39411. }
  39412. };
  39413. /**
  39414. * Setup the ground diffuse texture according to the specified options.
  39415. */
  39416. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39417. if (!this._groundMaterial) {
  39418. return;
  39419. }
  39420. if (this._groundTexture) {
  39421. return;
  39422. }
  39423. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39424. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39425. return;
  39426. }
  39427. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39428. diffuseTexture.gammaSpace = false;
  39429. diffuseTexture.hasAlpha = true;
  39430. this._groundMaterial.diffuseTexture = diffuseTexture;
  39431. };
  39432. /**
  39433. * Setup the ground mirror texture according to the specified options.
  39434. */
  39435. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39436. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39437. if (!this._groundMirror) {
  39438. this._groundMirror = new _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__["MirrorTexture"]("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, false, this._options.groundMirrorTextureType, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, true);
  39439. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39440. this._groundMirror.anisotropicFilteringLevel = 1;
  39441. this._groundMirror.wrapU = wrapping;
  39442. this._groundMirror.wrapV = wrapping;
  39443. this._groundMirror.gammaSpace = false;
  39444. if (this._groundMirror.renderList) {
  39445. for (var i = 0; i < this._scene.meshes.length; i++) {
  39446. var mesh = this._scene.meshes[i];
  39447. if (mesh !== this._ground &&
  39448. mesh !== this._skybox &&
  39449. mesh !== this._rootMesh) {
  39450. this._groundMirror.renderList.push(mesh);
  39451. }
  39452. }
  39453. }
  39454. }
  39455. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39456. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39457. };
  39458. /**
  39459. * Setup the ground to receive the mirror texture.
  39460. */
  39461. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39462. if (this._groundMaterial) {
  39463. this._groundMaterial.reflectionTexture = this._groundMirror;
  39464. this._groundMaterial.reflectionFresnel = true;
  39465. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39466. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39467. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39468. }
  39469. };
  39470. /**
  39471. * Setup the skybox according to the specified options.
  39472. */
  39473. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39474. var _this = this;
  39475. if (!this._skybox || this._skybox.isDisposed()) {
  39476. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39477. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39478. }
  39479. this._skybox.parent = this._rootMesh;
  39480. };
  39481. /**
  39482. * Setup the skybox material according to the specified options.
  39483. */
  39484. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39485. if (!this._skybox) {
  39486. return;
  39487. }
  39488. if (!this._skyboxMaterial) {
  39489. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39490. }
  39491. this._skyboxMaterial.useRGBColor = false;
  39492. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39493. this._skyboxMaterial.enableNoise = true;
  39494. this._skybox.material = this._skyboxMaterial;
  39495. };
  39496. /**
  39497. * Setup the skybox reflection texture according to the specified options.
  39498. */
  39499. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39500. if (!this._skyboxMaterial) {
  39501. return;
  39502. }
  39503. if (this._skyboxTexture) {
  39504. return;
  39505. }
  39506. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39507. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39508. return;
  39509. }
  39510. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39511. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39512. this._skyboxTexture.gammaSpace = false;
  39513. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39514. };
  39515. /**
  39516. * Dispose all the elements created by the Helper.
  39517. */
  39518. EnvironmentHelper.prototype.dispose = function () {
  39519. if (this._groundMaterial) {
  39520. this._groundMaterial.dispose(true, true);
  39521. }
  39522. if (this._skyboxMaterial) {
  39523. this._skyboxMaterial.dispose(true, true);
  39524. }
  39525. this._rootMesh.dispose(false);
  39526. };
  39527. /**
  39528. * Default ground texture URL.
  39529. */
  39530. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39531. /**
  39532. * Default skybox texture URL.
  39533. */
  39534. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39535. /**
  39536. * Default environment texture URL.
  39537. */
  39538. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39539. return EnvironmentHelper;
  39540. }());
  39541. /***/ }),
  39542. /***/ "./Helpers/index.ts":
  39543. /*!**************************!*\
  39544. !*** ./Helpers/index.ts ***!
  39545. \**************************/
  39546. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39548. "use strict";
  39549. __webpack_require__.r(__webpack_exports__);
  39550. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39552. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39554. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39556. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39558. /***/ }),
  39559. /***/ "./Helpers/photoDome.ts":
  39560. /*!******************************!*\
  39561. !*** ./Helpers/photoDome.ts ***!
  39562. \******************************/
  39563. /*! exports provided: PhotoDome */
  39564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39565. "use strict";
  39566. __webpack_require__.r(__webpack_exports__);
  39567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39569. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39570. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39571. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39572. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39573. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39574. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39575. /**
  39576. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39577. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39578. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39579. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39580. */
  39581. var PhotoDome = /** @class */ (function (_super) {
  39582. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39583. /**
  39584. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39585. * @param name Element's name, child elements will append suffixes for their own names.
  39586. * @param urlsOfPhoto defines the url of the photo to display
  39587. * @param options defines an object containing optional or exposed sub element properties
  39588. * @param onError defines a callback called when an error occured while loading the texture
  39589. */
  39590. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39591. if (onError === void 0) { onError = null; }
  39592. var _this = _super.call(this, name, scene) || this;
  39593. _this._useDirectMapping = false;
  39594. /**
  39595. * Observable raised when an error occured while loading the 360 image
  39596. */
  39597. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39598. // set defaults and manage values
  39599. name = name || "photoDome";
  39600. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39601. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39602. if (options.useDirectMapping === undefined) {
  39603. _this._useDirectMapping = true;
  39604. }
  39605. else {
  39606. _this._useDirectMapping = options.useDirectMapping;
  39607. }
  39608. _this._setReady(false);
  39609. // create
  39610. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39611. _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);
  39612. // configure material
  39613. material.opacityFresnel = false;
  39614. material.useEquirectangularFOV = true;
  39615. material.fovMultiplier = 1.0;
  39616. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39617. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39618. if (onError) {
  39619. onError(message, exception);
  39620. }
  39621. });
  39622. _this.photoTexture.onLoadObservable.addOnce(function () {
  39623. _this._setReady(true);
  39624. });
  39625. // configure mesh
  39626. _this._mesh.material = material;
  39627. _this._mesh.parent = _this;
  39628. return _this;
  39629. }
  39630. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39631. /**
  39632. * Gets or sets the texture being displayed on the sphere
  39633. */
  39634. get: function () {
  39635. return this._photoTexture;
  39636. },
  39637. set: function (value) {
  39638. if (this._photoTexture === value) {
  39639. return;
  39640. }
  39641. this._photoTexture = value;
  39642. if (this._useDirectMapping) {
  39643. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39644. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39645. this._material.diffuseTexture = this._photoTexture;
  39646. }
  39647. else {
  39648. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39649. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39650. this._material.reflectionTexture = this._photoTexture;
  39651. }
  39652. },
  39653. enumerable: true,
  39654. configurable: true
  39655. });
  39656. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39657. /**
  39658. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39659. * Also see the options.resolution property.
  39660. */
  39661. get: function () {
  39662. return this._material.fovMultiplier;
  39663. },
  39664. set: function (value) {
  39665. this._material.fovMultiplier = value;
  39666. },
  39667. enumerable: true,
  39668. configurable: true
  39669. });
  39670. /**
  39671. * Releases resources associated with this node.
  39672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39674. */
  39675. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39676. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39677. this._photoTexture.dispose();
  39678. this._mesh.dispose();
  39679. this._material.dispose();
  39680. this.onLoadErrorObservable.clear();
  39681. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39682. };
  39683. return PhotoDome;
  39684. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39685. /***/ }),
  39686. /***/ "./Helpers/sceneHelpers.ts":
  39687. /*!*********************************!*\
  39688. !*** ./Helpers/sceneHelpers.ts ***!
  39689. \*********************************/
  39690. /*! exports provided: _forceSceneHelpersToBundle */
  39691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39692. "use strict";
  39693. __webpack_require__.r(__webpack_exports__);
  39694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39695. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39696. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39697. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39698. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39699. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39700. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39701. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39702. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39703. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39704. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39705. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39706. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39707. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39708. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39709. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39710. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39711. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39712. /** @hidden */
  39713. var _forceSceneHelpersToBundle = true;
  39714. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39715. if (replace === void 0) { replace = false; }
  39716. // Dispose existing light in replace mode.
  39717. if (replace) {
  39718. if (this.lights) {
  39719. for (var i = 0; i < this.lights.length; i++) {
  39720. this.lights[i].dispose();
  39721. }
  39722. }
  39723. }
  39724. // Light
  39725. if (this.lights.length === 0) {
  39726. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39727. }
  39728. };
  39729. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39730. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39731. if (replace === void 0) { replace = false; }
  39732. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39733. // Dispose existing camera in replace mode.
  39734. if (replace) {
  39735. if (this.activeCamera) {
  39736. this.activeCamera.dispose();
  39737. this.activeCamera = null;
  39738. }
  39739. }
  39740. // Camera
  39741. if (!this.activeCamera) {
  39742. var worldExtends = this.getWorldExtends();
  39743. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39744. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39745. var camera;
  39746. var radius = worldSize.length() * 1.5;
  39747. // empty scene scenario!
  39748. if (!isFinite(radius)) {
  39749. radius = 1;
  39750. worldCenter.copyFromFloats(0, 0, 0);
  39751. }
  39752. if (createArcRotateCamera) {
  39753. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39754. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39755. arcRotateCamera.wheelPrecision = 100 / radius;
  39756. camera = arcRotateCamera;
  39757. }
  39758. else {
  39759. var freeCamera = new _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__["FreeCamera"]("default camera", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](worldCenter.x, worldCenter.y, -radius), this);
  39760. freeCamera.setTarget(worldCenter);
  39761. camera = freeCamera;
  39762. }
  39763. camera.minZ = radius * 0.01;
  39764. camera.maxZ = radius * 1000;
  39765. camera.speed = radius * 0.2;
  39766. this.activeCamera = camera;
  39767. var canvas = this.getEngine().getRenderingCanvas();
  39768. if (attachCameraControls && canvas) {
  39769. camera.attachControl(canvas);
  39770. }
  39771. }
  39772. };
  39773. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39774. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39775. if (replace === void 0) { replace = false; }
  39776. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39777. this.createDefaultLight(replace);
  39778. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39779. };
  39780. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39781. if (pbr === void 0) { pbr = false; }
  39782. if (scale === void 0) { scale = 1000; }
  39783. if (blur === void 0) { blur = 0; }
  39784. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39785. if (!environmentTexture) {
  39786. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39787. return null;
  39788. }
  39789. if (setGlobalEnvTexture) {
  39790. if (environmentTexture) {
  39791. this.environmentTexture = environmentTexture;
  39792. }
  39793. }
  39794. // Skybox
  39795. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39796. if (pbr) {
  39797. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39798. hdrSkyboxMaterial.backFaceCulling = false;
  39799. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39800. if (hdrSkyboxMaterial.reflectionTexture) {
  39801. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39802. }
  39803. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39804. hdrSkyboxMaterial.disableLighting = true;
  39805. hdrSkyboxMaterial.twoSidedLighting = true;
  39806. hdrSkybox.infiniteDistance = true;
  39807. hdrSkybox.material = hdrSkyboxMaterial;
  39808. }
  39809. else {
  39810. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39811. skyboxMaterial.backFaceCulling = false;
  39812. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39813. if (skyboxMaterial.reflectionTexture) {
  39814. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39815. }
  39816. skyboxMaterial.disableLighting = true;
  39817. hdrSkybox.infiniteDistance = true;
  39818. hdrSkybox.material = skyboxMaterial;
  39819. }
  39820. hdrSkybox.isPickable = false;
  39821. return hdrSkybox;
  39822. };
  39823. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39824. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39825. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39826. }
  39827. return null;
  39828. };
  39829. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39830. if (webVROptions === void 0) { webVROptions = {}; }
  39831. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39832. };
  39833. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39834. var _this = this;
  39835. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39836. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39837. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39838. .then(function (ui) {
  39839. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39840. return helper;
  39841. });
  39842. });
  39843. };
  39844. /***/ }),
  39845. /***/ "./Helpers/videoDome.ts":
  39846. /*!******************************!*\
  39847. !*** ./Helpers/videoDome.ts ***!
  39848. \******************************/
  39849. /*! exports provided: VideoDome */
  39850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39851. "use strict";
  39852. __webpack_require__.r(__webpack_exports__);
  39853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39854. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39855. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39856. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39857. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39858. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39859. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39860. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39861. /**
  39862. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39863. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39864. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39865. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39866. */
  39867. var VideoDome = /** @class */ (function (_super) {
  39868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39869. /**
  39870. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39871. * @param name Element's name, child elements will append suffixes for their own names.
  39872. * @param urlsOrVideo defines the url(s) or the video element to use
  39873. * @param options An object containing optional or exposed sub element properties
  39874. */
  39875. function VideoDome(name, urlsOrVideo, options, scene) {
  39876. var _this = _super.call(this, name, scene) || this;
  39877. _this._useDirectMapping = false;
  39878. // set defaults and manage values
  39879. name = name || "videoDome";
  39880. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39881. options.clickToPlay = Boolean(options.clickToPlay);
  39882. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39883. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  39884. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39885. if (options.useDirectMapping === undefined) {
  39886. _this._useDirectMapping = true;
  39887. }
  39888. else {
  39889. _this._useDirectMapping = options.useDirectMapping;
  39890. }
  39891. _this._setReady(false);
  39892. // create
  39893. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  39894. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39895. 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);
  39896. _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);
  39897. texture.onLoadObservable.addOnce(function () {
  39898. _this._setReady(true);
  39899. });
  39900. // configure material
  39901. material.useEquirectangularFOV = true;
  39902. material.fovMultiplier = 1.0;
  39903. material.opacityFresnel = false;
  39904. if (_this._useDirectMapping) {
  39905. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39906. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39907. material.diffuseTexture = texture;
  39908. }
  39909. else {
  39910. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39911. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39912. material.reflectionTexture = texture;
  39913. }
  39914. // configure mesh
  39915. _this._mesh.material = material;
  39916. _this._mesh.parent = _this;
  39917. // optional configuration
  39918. if (options.clickToPlay) {
  39919. scene.onPointerUp = function () {
  39920. _this._videoTexture.video.play();
  39921. };
  39922. }
  39923. return _this;
  39924. }
  39925. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  39926. /**
  39927. * Gets the video texture being displayed on the sphere
  39928. */
  39929. get: function () {
  39930. return this._videoTexture;
  39931. },
  39932. enumerable: true,
  39933. configurable: true
  39934. });
  39935. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  39936. /**
  39937. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39938. * Also see the options.resolution property.
  39939. */
  39940. get: function () {
  39941. return this._material.fovMultiplier;
  39942. },
  39943. set: function (value) {
  39944. this._material.fovMultiplier = value;
  39945. },
  39946. enumerable: true,
  39947. configurable: true
  39948. });
  39949. /**
  39950. * Releases resources associated with this node.
  39951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39953. */
  39954. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39955. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39956. this._videoTexture.dispose();
  39957. this._mesh.dispose();
  39958. this._material.dispose();
  39959. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39960. };
  39961. return VideoDome;
  39962. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  39963. /***/ }),
  39964. /***/ "./Instrumentation/engineInstrumentation.ts":
  39965. /*!**************************************************!*\
  39966. !*** ./Instrumentation/engineInstrumentation.ts ***!
  39967. \**************************************************/
  39968. /*! exports provided: EngineInstrumentation */
  39969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39970. "use strict";
  39971. __webpack_require__.r(__webpack_exports__);
  39972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  39973. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39974. /**
  39975. * This class can be used to get instrumentation data from a Babylon engine
  39976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39977. */
  39978. var EngineInstrumentation = /** @class */ (function () {
  39979. /**
  39980. * Instantiates a new engine instrumentation.
  39981. * This class can be used to get instrumentation data from a Babylon engine
  39982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39983. * @param engine Defines the engine to instrument
  39984. */
  39985. function EngineInstrumentation(
  39986. /**
  39987. * Define the instrumented engine.
  39988. */
  39989. engine) {
  39990. this.engine = engine;
  39991. this._captureGPUFrameTime = false;
  39992. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39993. this._captureShaderCompilationTime = false;
  39994. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39995. // Observers
  39996. this._onBeginFrameObserver = null;
  39997. this._onEndFrameObserver = null;
  39998. this._onBeforeShaderCompilationObserver = null;
  39999. this._onAfterShaderCompilationObserver = null;
  40000. }
  40001. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40002. // Properties
  40003. /**
  40004. * Gets the perf counter used for GPU frame time
  40005. */
  40006. get: function () {
  40007. return this._gpuFrameTime;
  40008. },
  40009. enumerable: true,
  40010. configurable: true
  40011. });
  40012. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40013. /**
  40014. * Gets the GPU frame time capture status
  40015. */
  40016. get: function () {
  40017. return this._captureGPUFrameTime;
  40018. },
  40019. /**
  40020. * Enable or disable the GPU frame time capture
  40021. */
  40022. set: function (value) {
  40023. var _this = this;
  40024. if (value === this._captureGPUFrameTime) {
  40025. return;
  40026. }
  40027. this._captureGPUFrameTime = value;
  40028. if (value) {
  40029. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40030. if (!_this._gpuFrameTimeToken) {
  40031. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40032. }
  40033. });
  40034. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40035. if (!_this._gpuFrameTimeToken) {
  40036. return;
  40037. }
  40038. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40039. if (time > -1) {
  40040. _this._gpuFrameTimeToken = null;
  40041. _this._gpuFrameTime.fetchNewFrame();
  40042. _this._gpuFrameTime.addCount(time, true);
  40043. }
  40044. });
  40045. }
  40046. else {
  40047. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40048. this._onBeginFrameObserver = null;
  40049. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40050. this._onEndFrameObserver = null;
  40051. }
  40052. },
  40053. enumerable: true,
  40054. configurable: true
  40055. });
  40056. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40057. /**
  40058. * Gets the perf counter used for shader compilation time
  40059. */
  40060. get: function () {
  40061. return this._shaderCompilationTime;
  40062. },
  40063. enumerable: true,
  40064. configurable: true
  40065. });
  40066. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40067. /**
  40068. * Gets the shader compilation time capture status
  40069. */
  40070. get: function () {
  40071. return this._captureShaderCompilationTime;
  40072. },
  40073. /**
  40074. * Enable or disable the shader compilation time capture
  40075. */
  40076. set: function (value) {
  40077. var _this = this;
  40078. if (value === this._captureShaderCompilationTime) {
  40079. return;
  40080. }
  40081. this._captureShaderCompilationTime = value;
  40082. if (value) {
  40083. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40084. _this._shaderCompilationTime.fetchNewFrame();
  40085. _this._shaderCompilationTime.beginMonitoring();
  40086. });
  40087. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40088. _this._shaderCompilationTime.endMonitoring();
  40089. });
  40090. }
  40091. else {
  40092. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40093. this._onBeforeShaderCompilationObserver = null;
  40094. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40095. this._onAfterShaderCompilationObserver = null;
  40096. }
  40097. },
  40098. enumerable: true,
  40099. configurable: true
  40100. });
  40101. /**
  40102. * Dispose and release associated resources.
  40103. */
  40104. EngineInstrumentation.prototype.dispose = function () {
  40105. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40106. this._onBeginFrameObserver = null;
  40107. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40108. this._onEndFrameObserver = null;
  40109. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40110. this._onBeforeShaderCompilationObserver = null;
  40111. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40112. this._onAfterShaderCompilationObserver = null;
  40113. this.engine = null;
  40114. };
  40115. return EngineInstrumentation;
  40116. }());
  40117. /***/ }),
  40118. /***/ "./Instrumentation/index.ts":
  40119. /*!**********************************!*\
  40120. !*** ./Instrumentation/index.ts ***!
  40121. \**********************************/
  40122. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40124. "use strict";
  40125. __webpack_require__.r(__webpack_exports__);
  40126. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40128. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40130. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40132. /***/ }),
  40133. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40134. /*!*************************************************!*\
  40135. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40136. \*************************************************/
  40137. /*! exports provided: SceneInstrumentation */
  40138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40139. "use strict";
  40140. __webpack_require__.r(__webpack_exports__);
  40141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40142. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40143. /**
  40144. * This class can be used to get instrumentation data from a Babylon engine
  40145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40146. */
  40147. var SceneInstrumentation = /** @class */ (function () {
  40148. /**
  40149. * Instantiates a new scene instrumentation.
  40150. * This class can be used to get instrumentation data from a Babylon engine
  40151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40152. * @param scene Defines the scene to instrument
  40153. */
  40154. function SceneInstrumentation(
  40155. /**
  40156. * Defines the scene to instrument
  40157. */
  40158. scene) {
  40159. var _this = this;
  40160. this.scene = scene;
  40161. this._captureActiveMeshesEvaluationTime = false;
  40162. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40163. this._captureRenderTargetsRenderTime = false;
  40164. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40165. this._captureFrameTime = false;
  40166. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40167. this._captureRenderTime = false;
  40168. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40169. this._captureInterFrameTime = false;
  40170. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40171. this._captureParticlesRenderTime = false;
  40172. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40173. this._captureSpritesRenderTime = false;
  40174. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40175. this._capturePhysicsTime = false;
  40176. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40177. this._captureAnimationsTime = false;
  40178. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40179. this._captureCameraRenderTime = false;
  40180. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40181. // Observers
  40182. this._onBeforeActiveMeshesEvaluationObserver = null;
  40183. this._onAfterActiveMeshesEvaluationObserver = null;
  40184. this._onBeforeRenderTargetsRenderObserver = null;
  40185. this._onAfterRenderTargetsRenderObserver = null;
  40186. this._onAfterRenderObserver = null;
  40187. this._onBeforeDrawPhaseObserver = null;
  40188. this._onAfterDrawPhaseObserver = null;
  40189. this._onBeforeAnimationsObserver = null;
  40190. this._onBeforeParticlesRenderingObserver = null;
  40191. this._onAfterParticlesRenderingObserver = null;
  40192. this._onBeforeSpritesRenderingObserver = null;
  40193. this._onAfterSpritesRenderingObserver = null;
  40194. this._onBeforePhysicsObserver = null;
  40195. this._onAfterPhysicsObserver = null;
  40196. this._onAfterAnimationsObserver = null;
  40197. this._onBeforeCameraRenderObserver = null;
  40198. this._onAfterCameraRenderObserver = null;
  40199. // Before render
  40200. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40201. if (_this._captureActiveMeshesEvaluationTime) {
  40202. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40203. }
  40204. if (_this._captureRenderTargetsRenderTime) {
  40205. _this._renderTargetsRenderTime.fetchNewFrame();
  40206. }
  40207. if (_this._captureFrameTime) {
  40208. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40209. _this._frameTime.beginMonitoring();
  40210. }
  40211. if (_this._captureInterFrameTime) {
  40212. _this._interFrameTime.endMonitoring();
  40213. }
  40214. if (_this._captureParticlesRenderTime) {
  40215. _this._particlesRenderTime.fetchNewFrame();
  40216. }
  40217. if (_this._captureSpritesRenderTime) {
  40218. _this._spritesRenderTime.fetchNewFrame();
  40219. }
  40220. if (_this._captureAnimationsTime) {
  40221. _this._animationsTime.beginMonitoring();
  40222. }
  40223. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40224. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40225. });
  40226. // After render
  40227. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40228. if (_this._captureFrameTime) {
  40229. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40230. _this._frameTime.endMonitoring();
  40231. }
  40232. if (_this._captureRenderTime) {
  40233. _this._renderTime.endMonitoring(false);
  40234. }
  40235. if (_this._captureInterFrameTime) {
  40236. _this._interFrameTime.beginMonitoring();
  40237. }
  40238. });
  40239. }
  40240. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40241. // Properties
  40242. /**
  40243. * Gets the perf counter used for active meshes evaluation time
  40244. */
  40245. get: function () {
  40246. return this._activeMeshesEvaluationTime;
  40247. },
  40248. enumerable: true,
  40249. configurable: true
  40250. });
  40251. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40252. /**
  40253. * Gets the active meshes evaluation time capture status
  40254. */
  40255. get: function () {
  40256. return this._captureActiveMeshesEvaluationTime;
  40257. },
  40258. /**
  40259. * Enable or disable the active meshes evaluation time capture
  40260. */
  40261. set: function (value) {
  40262. var _this = this;
  40263. if (value === this._captureActiveMeshesEvaluationTime) {
  40264. return;
  40265. }
  40266. this._captureActiveMeshesEvaluationTime = value;
  40267. if (value) {
  40268. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40269. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40270. _this._activeMeshesEvaluationTime.beginMonitoring();
  40271. });
  40272. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40273. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40274. _this._activeMeshesEvaluationTime.endMonitoring();
  40275. });
  40276. }
  40277. else {
  40278. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40279. this._onBeforeActiveMeshesEvaluationObserver = null;
  40280. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40281. this._onAfterActiveMeshesEvaluationObserver = null;
  40282. }
  40283. },
  40284. enumerable: true,
  40285. configurable: true
  40286. });
  40287. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40288. /**
  40289. * Gets the perf counter used for render targets render time
  40290. */
  40291. get: function () {
  40292. return this._renderTargetsRenderTime;
  40293. },
  40294. enumerable: true,
  40295. configurable: true
  40296. });
  40297. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40298. /**
  40299. * Gets the render targets render time capture status
  40300. */
  40301. get: function () {
  40302. return this._captureRenderTargetsRenderTime;
  40303. },
  40304. /**
  40305. * Enable or disable the render targets render time capture
  40306. */
  40307. set: function (value) {
  40308. var _this = this;
  40309. if (value === this._captureRenderTargetsRenderTime) {
  40310. return;
  40311. }
  40312. this._captureRenderTargetsRenderTime = value;
  40313. if (value) {
  40314. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40315. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40316. _this._renderTargetsRenderTime.beginMonitoring();
  40317. });
  40318. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40319. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40320. _this._renderTargetsRenderTime.endMonitoring(false);
  40321. });
  40322. }
  40323. else {
  40324. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40325. this._onBeforeRenderTargetsRenderObserver = null;
  40326. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40327. this._onAfterRenderTargetsRenderObserver = null;
  40328. }
  40329. },
  40330. enumerable: true,
  40331. configurable: true
  40332. });
  40333. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40334. /**
  40335. * Gets the perf counter used for particles render time
  40336. */
  40337. get: function () {
  40338. return this._particlesRenderTime;
  40339. },
  40340. enumerable: true,
  40341. configurable: true
  40342. });
  40343. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40344. /**
  40345. * Gets the particles render time capture status
  40346. */
  40347. get: function () {
  40348. return this._captureParticlesRenderTime;
  40349. },
  40350. /**
  40351. * Enable or disable the particles render time capture
  40352. */
  40353. set: function (value) {
  40354. var _this = this;
  40355. if (value === this._captureParticlesRenderTime) {
  40356. return;
  40357. }
  40358. this._captureParticlesRenderTime = value;
  40359. if (value) {
  40360. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40361. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40362. _this._particlesRenderTime.beginMonitoring();
  40363. });
  40364. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40365. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40366. _this._particlesRenderTime.endMonitoring(false);
  40367. });
  40368. }
  40369. else {
  40370. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40371. this._onBeforeParticlesRenderingObserver = null;
  40372. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40373. this._onAfterParticlesRenderingObserver = null;
  40374. }
  40375. },
  40376. enumerable: true,
  40377. configurable: true
  40378. });
  40379. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40380. /**
  40381. * Gets the perf counter used for sprites render time
  40382. */
  40383. get: function () {
  40384. return this._spritesRenderTime;
  40385. },
  40386. enumerable: true,
  40387. configurable: true
  40388. });
  40389. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40390. /**
  40391. * Gets the sprites render time capture status
  40392. */
  40393. get: function () {
  40394. return this._captureSpritesRenderTime;
  40395. },
  40396. /**
  40397. * Enable or disable the sprites render time capture
  40398. */
  40399. set: function (value) {
  40400. var _this = this;
  40401. if (value === this._captureSpritesRenderTime) {
  40402. return;
  40403. }
  40404. this._captureSpritesRenderTime = value;
  40405. if (!this.scene.spriteManagers) {
  40406. return;
  40407. }
  40408. if (value) {
  40409. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40410. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40411. _this._spritesRenderTime.beginMonitoring();
  40412. });
  40413. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40414. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40415. _this._spritesRenderTime.endMonitoring(false);
  40416. });
  40417. }
  40418. else {
  40419. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40420. this._onBeforeSpritesRenderingObserver = null;
  40421. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40422. this._onAfterSpritesRenderingObserver = null;
  40423. }
  40424. },
  40425. enumerable: true,
  40426. configurable: true
  40427. });
  40428. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40429. /**
  40430. * Gets the perf counter used for physics time
  40431. */
  40432. get: function () {
  40433. return this._physicsTime;
  40434. },
  40435. enumerable: true,
  40436. configurable: true
  40437. });
  40438. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40439. /**
  40440. * Gets the physics time capture status
  40441. */
  40442. get: function () {
  40443. return this._capturePhysicsTime;
  40444. },
  40445. /**
  40446. * Enable or disable the physics time capture
  40447. */
  40448. set: function (value) {
  40449. var _this = this;
  40450. if (value === this._capturePhysicsTime) {
  40451. return;
  40452. }
  40453. if (!this.scene.onBeforePhysicsObservable) {
  40454. return;
  40455. }
  40456. this._capturePhysicsTime = value;
  40457. if (value) {
  40458. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40459. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40460. _this._physicsTime.beginMonitoring();
  40461. });
  40462. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40463. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40464. _this._physicsTime.endMonitoring();
  40465. });
  40466. }
  40467. else {
  40468. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40469. this._onBeforePhysicsObserver = null;
  40470. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40471. this._onAfterPhysicsObserver = null;
  40472. }
  40473. },
  40474. enumerable: true,
  40475. configurable: true
  40476. });
  40477. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40478. /**
  40479. * Gets the perf counter used for animations time
  40480. */
  40481. get: function () {
  40482. return this._animationsTime;
  40483. },
  40484. enumerable: true,
  40485. configurable: true
  40486. });
  40487. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40488. /**
  40489. * Gets the animations time capture status
  40490. */
  40491. get: function () {
  40492. return this._captureAnimationsTime;
  40493. },
  40494. /**
  40495. * Enable or disable the animations time capture
  40496. */
  40497. set: function (value) {
  40498. var _this = this;
  40499. if (value === this._captureAnimationsTime) {
  40500. return;
  40501. }
  40502. this._captureAnimationsTime = value;
  40503. if (value) {
  40504. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40505. _this._animationsTime.endMonitoring();
  40506. });
  40507. }
  40508. else {
  40509. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40510. this._onAfterAnimationsObserver = null;
  40511. }
  40512. },
  40513. enumerable: true,
  40514. configurable: true
  40515. });
  40516. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40517. /**
  40518. * Gets the perf counter used for frame time capture
  40519. */
  40520. get: function () {
  40521. return this._frameTime;
  40522. },
  40523. enumerable: true,
  40524. configurable: true
  40525. });
  40526. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40527. /**
  40528. * Gets the frame time capture status
  40529. */
  40530. get: function () {
  40531. return this._captureFrameTime;
  40532. },
  40533. /**
  40534. * Enable or disable the frame time capture
  40535. */
  40536. set: function (value) {
  40537. this._captureFrameTime = value;
  40538. },
  40539. enumerable: true,
  40540. configurable: true
  40541. });
  40542. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40543. /**
  40544. * Gets the perf counter used for inter-frames time capture
  40545. */
  40546. get: function () {
  40547. return this._interFrameTime;
  40548. },
  40549. enumerable: true,
  40550. configurable: true
  40551. });
  40552. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40553. /**
  40554. * Gets the inter-frames time capture status
  40555. */
  40556. get: function () {
  40557. return this._captureInterFrameTime;
  40558. },
  40559. /**
  40560. * Enable or disable the inter-frames time capture
  40561. */
  40562. set: function (value) {
  40563. this._captureInterFrameTime = value;
  40564. },
  40565. enumerable: true,
  40566. configurable: true
  40567. });
  40568. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40569. /**
  40570. * Gets the perf counter used for render time capture
  40571. */
  40572. get: function () {
  40573. return this._renderTime;
  40574. },
  40575. enumerable: true,
  40576. configurable: true
  40577. });
  40578. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40579. /**
  40580. * Gets the render time capture status
  40581. */
  40582. get: function () {
  40583. return this._captureRenderTime;
  40584. },
  40585. /**
  40586. * Enable or disable the render time capture
  40587. */
  40588. set: function (value) {
  40589. var _this = this;
  40590. if (value === this._captureRenderTime) {
  40591. return;
  40592. }
  40593. this._captureRenderTime = value;
  40594. if (value) {
  40595. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40596. _this._renderTime.beginMonitoring();
  40597. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40598. });
  40599. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40600. _this._renderTime.endMonitoring(false);
  40601. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40602. });
  40603. }
  40604. else {
  40605. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40606. this._onBeforeDrawPhaseObserver = null;
  40607. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40608. this._onAfterDrawPhaseObserver = null;
  40609. }
  40610. },
  40611. enumerable: true,
  40612. configurable: true
  40613. });
  40614. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40615. /**
  40616. * Gets the perf counter used for camera render time capture
  40617. */
  40618. get: function () {
  40619. return this._cameraRenderTime;
  40620. },
  40621. enumerable: true,
  40622. configurable: true
  40623. });
  40624. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40625. /**
  40626. * Gets the camera render time capture status
  40627. */
  40628. get: function () {
  40629. return this._captureCameraRenderTime;
  40630. },
  40631. /**
  40632. * Enable or disable the camera render time capture
  40633. */
  40634. set: function (value) {
  40635. var _this = this;
  40636. if (value === this._captureCameraRenderTime) {
  40637. return;
  40638. }
  40639. this._captureCameraRenderTime = value;
  40640. if (value) {
  40641. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40642. _this._cameraRenderTime.beginMonitoring();
  40643. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40644. });
  40645. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40646. _this._cameraRenderTime.endMonitoring(false);
  40647. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40648. });
  40649. }
  40650. else {
  40651. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40652. this._onBeforeCameraRenderObserver = null;
  40653. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40654. this._onAfterCameraRenderObserver = null;
  40655. }
  40656. },
  40657. enumerable: true,
  40658. configurable: true
  40659. });
  40660. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40661. /**
  40662. * Gets the perf counter used for draw calls
  40663. */
  40664. get: function () {
  40665. return this.scene.getEngine()._drawCalls;
  40666. },
  40667. enumerable: true,
  40668. configurable: true
  40669. });
  40670. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40671. /**
  40672. * Gets the perf counter used for texture collisions
  40673. */
  40674. get: function () {
  40675. return this.scene.getEngine()._textureCollisions;
  40676. },
  40677. enumerable: true,
  40678. configurable: true
  40679. });
  40680. /**
  40681. * Dispose and release associated resources.
  40682. */
  40683. SceneInstrumentation.prototype.dispose = function () {
  40684. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40685. this._onAfterRenderObserver = null;
  40686. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40687. this._onBeforeActiveMeshesEvaluationObserver = null;
  40688. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40689. this._onAfterActiveMeshesEvaluationObserver = null;
  40690. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40691. this._onBeforeRenderTargetsRenderObserver = null;
  40692. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40693. this._onAfterRenderTargetsRenderObserver = null;
  40694. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40695. this._onBeforeAnimationsObserver = null;
  40696. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40697. this._onBeforeParticlesRenderingObserver = null;
  40698. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40699. this._onAfterParticlesRenderingObserver = null;
  40700. if (this._onBeforeSpritesRenderingObserver) {
  40701. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40702. this._onBeforeSpritesRenderingObserver = null;
  40703. }
  40704. if (this._onAfterSpritesRenderingObserver) {
  40705. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40706. this._onAfterSpritesRenderingObserver = null;
  40707. }
  40708. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40709. this._onBeforeDrawPhaseObserver = null;
  40710. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40711. this._onAfterDrawPhaseObserver = null;
  40712. if (this._onBeforePhysicsObserver) {
  40713. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40714. this._onBeforePhysicsObserver = null;
  40715. }
  40716. if (this._onAfterPhysicsObserver) {
  40717. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40718. this._onAfterPhysicsObserver = null;
  40719. }
  40720. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40721. this._onAfterAnimationsObserver = null;
  40722. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40723. this._onBeforeCameraRenderObserver = null;
  40724. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40725. this._onAfterCameraRenderObserver = null;
  40726. this.scene = null;
  40727. };
  40728. return SceneInstrumentation;
  40729. }());
  40730. /***/ }),
  40731. /***/ "./Instrumentation/timeToken.ts":
  40732. /*!**************************************!*\
  40733. !*** ./Instrumentation/timeToken.ts ***!
  40734. \**************************************/
  40735. /*! exports provided: _TimeToken */
  40736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40737. "use strict";
  40738. __webpack_require__.r(__webpack_exports__);
  40739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40740. /**
  40741. * @hidden
  40742. **/
  40743. var _TimeToken = /** @class */ (function () {
  40744. function _TimeToken() {
  40745. this._timeElapsedQueryEnded = false;
  40746. }
  40747. return _TimeToken;
  40748. }());
  40749. /***/ }),
  40750. /***/ "./Layers/effectLayer.ts":
  40751. /*!*******************************!*\
  40752. !*** ./Layers/effectLayer.ts ***!
  40753. \*******************************/
  40754. /*! exports provided: EffectLayer */
  40755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40756. "use strict";
  40757. __webpack_require__.r(__webpack_exports__);
  40758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40760. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40761. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40762. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40763. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40764. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40765. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40766. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40767. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40768. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40769. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40770. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40771. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40772. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40773. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  40774. /**
  40775. * The effect layer Helps adding post process effect blended with the main pass.
  40776. *
  40777. * This can be for instance use to generate glow or higlight effects on the scene.
  40778. *
  40779. * The effect layer class can not be used directly and is intented to inherited from to be
  40780. * customized per effects.
  40781. */
  40782. var EffectLayer = /** @class */ (function () {
  40783. /**
  40784. * Instantiates a new effect Layer and references it in the scene.
  40785. * @param name The name of the layer
  40786. * @param scene The scene to use the layer in
  40787. */
  40788. function EffectLayer(
  40789. /** The Friendly of the effect in the scene */
  40790. name, scene) {
  40791. this._vertexBuffers = {};
  40792. this._maxSize = 0;
  40793. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40794. this._shouldRender = true;
  40795. this._postProcesses = [];
  40796. this._textures = [];
  40797. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40798. /**
  40799. * The clear color of the texture used to generate the glow map.
  40800. */
  40801. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40802. /**
  40803. * Specifies wether the highlight layer is enabled or not.
  40804. */
  40805. this.isEnabled = true;
  40806. /**
  40807. * An event triggered when the effect layer has been disposed.
  40808. */
  40809. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40810. /**
  40811. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40812. */
  40813. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40814. /**
  40815. * An event triggered when the generated texture is being merged in the scene.
  40816. */
  40817. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40818. /**
  40819. * An event triggered when the generated texture has been merged in the scene.
  40820. */
  40821. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40822. /**
  40823. * An event triggered when the efffect layer changes its size.
  40824. */
  40825. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40826. this.name = name;
  40827. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40828. EffectLayer._SceneComponentInitialization(this._scene);
  40829. this._engine = this._scene.getEngine();
  40830. this._maxSize = this._engine.getCaps().maxTextureSize;
  40831. this._scene.effectLayers.push(this);
  40832. // Generate Buffers
  40833. this._generateIndexBuffer();
  40834. this._genrateVertexBuffer();
  40835. }
  40836. Object.defineProperty(EffectLayer.prototype, "camera", {
  40837. /**
  40838. * Gets the camera attached to the layer.
  40839. */
  40840. get: function () {
  40841. return this._effectLayerOptions.camera;
  40842. },
  40843. enumerable: true,
  40844. configurable: true
  40845. });
  40846. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40847. /**
  40848. * Gets the rendering group id the layer should render in.
  40849. */
  40850. get: function () {
  40851. return this._effectLayerOptions.renderingGroupId;
  40852. },
  40853. enumerable: true,
  40854. configurable: true
  40855. });
  40856. /**
  40857. * Initializes the effect layer with the required options.
  40858. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40859. */
  40860. EffectLayer.prototype._init = function (options) {
  40861. // Adapt options
  40862. this._effectLayerOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: 0.5, alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, options);
  40863. this._setMainTextureSize();
  40864. this._createMainTexture();
  40865. this._createTextureAndPostProcesses();
  40866. this._mergeEffect = this._createMergeEffect();
  40867. };
  40868. /**
  40869. * Generates the index buffer of the full screen quad blending to the main canvas.
  40870. */
  40871. EffectLayer.prototype._generateIndexBuffer = function () {
  40872. // Indices
  40873. var indices = [];
  40874. indices.push(0);
  40875. indices.push(1);
  40876. indices.push(2);
  40877. indices.push(0);
  40878. indices.push(2);
  40879. indices.push(3);
  40880. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40881. };
  40882. /**
  40883. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  40884. */
  40885. EffectLayer.prototype._genrateVertexBuffer = function () {
  40886. // VBO
  40887. var vertices = [];
  40888. vertices.push(1, 1);
  40889. vertices.push(-1, 1);
  40890. vertices.push(-1, -1);
  40891. vertices.push(1, -1);
  40892. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  40893. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  40894. };
  40895. /**
  40896. * Sets the main texture desired size which is the closest power of two
  40897. * of the engine canvas size.
  40898. */
  40899. EffectLayer.prototype._setMainTextureSize = function () {
  40900. if (this._effectLayerOptions.mainTextureFixedSize) {
  40901. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  40902. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  40903. }
  40904. else {
  40905. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  40906. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  40907. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  40908. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  40909. }
  40910. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  40911. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  40912. };
  40913. /**
  40914. * Creates the main texture for the effect layer.
  40915. */
  40916. EffectLayer.prototype._createMainTexture = function () {
  40917. var _this = this;
  40918. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  40919. width: this._mainTextureDesiredSize.width,
  40920. height: this._mainTextureDesiredSize.height
  40921. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  40922. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  40923. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40924. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40925. this._mainTexture.anisotropicFilteringLevel = 1;
  40926. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  40927. this._mainTexture.renderParticles = false;
  40928. this._mainTexture.renderList = null;
  40929. this._mainTexture.ignoreCameraViewport = true;
  40930. // Custom render function
  40931. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  40932. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  40933. var index;
  40934. var engine = _this._scene.getEngine();
  40935. if (depthOnlySubMeshes.length) {
  40936. engine.setColorWrite(false);
  40937. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  40938. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  40939. }
  40940. engine.setColorWrite(true);
  40941. }
  40942. for (index = 0; index < opaqueSubMeshes.length; index++) {
  40943. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  40944. }
  40945. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  40946. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  40947. }
  40948. for (index = 0; index < transparentSubMeshes.length; index++) {
  40949. _this._renderSubMesh(transparentSubMeshes.data[index]);
  40950. }
  40951. };
  40952. this._mainTexture.onClearObservable.add(function (engine) {
  40953. engine.clear(_this.neutralColor, true, true, true);
  40954. });
  40955. };
  40956. /**
  40957. * Adds specific effects defines.
  40958. * @param defines The defines to add specifics to.
  40959. */
  40960. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  40961. // Nothing to add by default.
  40962. };
  40963. /**
  40964. * Checks for the readiness of the element composing the layer.
  40965. * @param subMesh the mesh to check for
  40966. * @param useInstances specify wether or not to use instances to render the mesh
  40967. * @param emissiveTexture the associated emissive texture used to generate the glow
  40968. * @return true if ready otherwise, false
  40969. */
  40970. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  40971. var material = subMesh.getMaterial();
  40972. if (!material) {
  40973. return false;
  40974. }
  40975. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  40976. return false;
  40977. }
  40978. var defines = [];
  40979. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40980. var mesh = subMesh.getMesh();
  40981. var uv1 = false;
  40982. var uv2 = false;
  40983. // Diffuse
  40984. if (material) {
  40985. var needAlphaTest = material.needAlphaTesting();
  40986. var diffuseTexture = material.getAlphaTestTexture();
  40987. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40988. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40989. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40990. defines.push("#define DIFFUSE");
  40991. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40992. diffuseTexture.coordinatesIndex === 1) {
  40993. defines.push("#define DIFFUSEUV2");
  40994. uv2 = true;
  40995. }
  40996. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40997. defines.push("#define DIFFUSEUV1");
  40998. uv1 = true;
  40999. }
  41000. if (needAlphaTest) {
  41001. defines.push("#define ALPHATEST");
  41002. defines.push("#define ALPHATESTVALUE 0.4");
  41003. }
  41004. }
  41005. var opacityTexture = material.opacityTexture;
  41006. if (opacityTexture) {
  41007. defines.push("#define OPACITY");
  41008. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41009. opacityTexture.coordinatesIndex === 1) {
  41010. defines.push("#define OPACITYUV2");
  41011. uv2 = true;
  41012. }
  41013. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41014. defines.push("#define OPACITYUV1");
  41015. uv1 = true;
  41016. }
  41017. }
  41018. }
  41019. // Emissive
  41020. if (emissiveTexture) {
  41021. defines.push("#define EMISSIVE");
  41022. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41023. emissiveTexture.coordinatesIndex === 1) {
  41024. defines.push("#define EMISSIVEUV2");
  41025. uv2 = true;
  41026. }
  41027. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41028. defines.push("#define EMISSIVEUV1");
  41029. uv1 = true;
  41030. }
  41031. }
  41032. // Vertex
  41033. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41034. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41035. defines.push("#define VERTEXALPHA");
  41036. }
  41037. if (uv1) {
  41038. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41039. defines.push("#define UV1");
  41040. }
  41041. if (uv2) {
  41042. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41043. defines.push("#define UV2");
  41044. }
  41045. // Bones
  41046. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41047. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41048. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41049. if (mesh.numBoneInfluencers > 4) {
  41050. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41051. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41052. }
  41053. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41054. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41055. }
  41056. else {
  41057. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41058. }
  41059. // Morph targets
  41060. var manager = mesh.morphTargetManager;
  41061. var morphInfluencers = 0;
  41062. if (manager) {
  41063. if (manager.numInfluencers > 0) {
  41064. defines.push("#define MORPHTARGETS");
  41065. morphInfluencers = manager.numInfluencers;
  41066. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41067. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41068. }
  41069. }
  41070. // Instances
  41071. if (useInstances) {
  41072. defines.push("#define INSTANCES");
  41073. attribs.push("world0");
  41074. attribs.push("world1");
  41075. attribs.push("world2");
  41076. attribs.push("world3");
  41077. }
  41078. this._addCustomEffectDefines(defines);
  41079. // Get correct effect
  41080. var join = defines.join("\n");
  41081. if (this._cachedDefines !== join) {
  41082. this._cachedDefines = join;
  41083. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41084. "color", "morphTargetInfluences",
  41085. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41086. }
  41087. return this._effectLayerMapGenerationEffect.isReady();
  41088. };
  41089. /**
  41090. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41091. */
  41092. EffectLayer.prototype.render = function () {
  41093. var currentEffect = this._mergeEffect;
  41094. // Check
  41095. if (!currentEffect.isReady()) {
  41096. return;
  41097. }
  41098. for (var i = 0; i < this._postProcesses.length; i++) {
  41099. if (!this._postProcesses[i].isReady()) {
  41100. return;
  41101. }
  41102. }
  41103. var engine = this._scene.getEngine();
  41104. this.onBeforeComposeObservable.notifyObservers(this);
  41105. // Render
  41106. engine.enableEffect(currentEffect);
  41107. engine.setState(false);
  41108. // VBOs
  41109. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41110. // Cache
  41111. var previousAlphaMode = engine.getAlphaMode();
  41112. // Go Blend.
  41113. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41114. // Blends the map on the main canvas.
  41115. this._internalRender(currentEffect);
  41116. // Restore Alpha
  41117. engine.setAlphaMode(previousAlphaMode);
  41118. this.onAfterComposeObservable.notifyObservers(this);
  41119. // Handle size changes.
  41120. var size = this._mainTexture.getSize();
  41121. this._setMainTextureSize();
  41122. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41123. // Recreate RTT and post processes on size change.
  41124. this.onSizeChangedObservable.notifyObservers(this);
  41125. this._disposeTextureAndPostProcesses();
  41126. this._createMainTexture();
  41127. this._createTextureAndPostProcesses();
  41128. }
  41129. };
  41130. /**
  41131. * Determine if a given mesh will be used in the current effect.
  41132. * @param mesh mesh to test
  41133. * @returns true if the mesh will be used
  41134. */
  41135. EffectLayer.prototype.hasMesh = function (mesh) {
  41136. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41137. return true;
  41138. }
  41139. return false;
  41140. };
  41141. /**
  41142. * Returns true if the layer contains information to display, otherwise false.
  41143. * @returns true if the glow layer should be rendered
  41144. */
  41145. EffectLayer.prototype.shouldRender = function () {
  41146. return this.isEnabled && this._shouldRender;
  41147. };
  41148. /**
  41149. * Returns true if the mesh should render, otherwise false.
  41150. * @param mesh The mesh to render
  41151. * @returns true if it should render otherwise false
  41152. */
  41153. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41154. return true;
  41155. };
  41156. /**
  41157. * Returns true if the mesh can be rendered, otherwise false.
  41158. * @param mesh The mesh to render
  41159. * @param material The material used on the mesh
  41160. * @returns true if it can be rendered otherwise false
  41161. */
  41162. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41163. return !material.needAlphaBlendingForMesh(mesh);
  41164. };
  41165. /**
  41166. * Returns true if the mesh should render, otherwise false.
  41167. * @param mesh The mesh to render
  41168. * @returns true if it should render otherwise false
  41169. */
  41170. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41171. return true;
  41172. };
  41173. /**
  41174. * Renders the submesh passed in parameter to the generation map.
  41175. */
  41176. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41177. var _this = this;
  41178. if (!this.shouldRender()) {
  41179. return;
  41180. }
  41181. var material = subMesh.getMaterial();
  41182. var mesh = subMesh.getRenderingMesh();
  41183. var scene = this._scene;
  41184. var engine = scene.getEngine();
  41185. if (!material) {
  41186. return;
  41187. }
  41188. // Do not block in blend mode.
  41189. if (!this._canRenderMesh(mesh, material)) {
  41190. return;
  41191. }
  41192. // Culling
  41193. engine.setState(material.backFaceCulling);
  41194. // Managing instances
  41195. var batch = mesh._getInstancesRenderList(subMesh._id);
  41196. if (batch.mustReturn) {
  41197. return;
  41198. }
  41199. // Early Exit per mesh
  41200. if (!this._shouldRenderMesh(mesh)) {
  41201. return;
  41202. }
  41203. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41204. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41205. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41206. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41207. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41208. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41209. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41210. var needAlphaTest = material.needAlphaTesting();
  41211. var diffuseTexture = material.getAlphaTestTexture();
  41212. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41213. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41214. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41215. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41216. var textureMatrix = diffuseTexture.getTextureMatrix();
  41217. if (textureMatrix) {
  41218. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41219. }
  41220. }
  41221. var opacityTexture = material.opacityTexture;
  41222. if (opacityTexture) {
  41223. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41224. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41225. var textureMatrix = opacityTexture.getTextureMatrix();
  41226. if (textureMatrix) {
  41227. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41228. }
  41229. }
  41230. // Glow emissive only
  41231. if (this._emissiveTextureAndColor.texture) {
  41232. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41233. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41234. }
  41235. // Bones
  41236. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41237. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41238. }
  41239. // Morph targets
  41240. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41241. // Draw
  41242. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41243. }
  41244. else {
  41245. // Need to reset refresh rate of the main map
  41246. this._mainTexture.resetRefreshCounter();
  41247. }
  41248. };
  41249. /**
  41250. * Rebuild the required buffers.
  41251. * @hidden Internal use only.
  41252. */
  41253. EffectLayer.prototype._rebuild = function () {
  41254. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41255. if (vb) {
  41256. vb._rebuild();
  41257. }
  41258. this._generateIndexBuffer();
  41259. };
  41260. /**
  41261. * Dispose only the render target textures and post process.
  41262. */
  41263. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41264. this._mainTexture.dispose();
  41265. for (var i = 0; i < this._postProcesses.length; i++) {
  41266. if (this._postProcesses[i]) {
  41267. this._postProcesses[i].dispose();
  41268. }
  41269. }
  41270. this._postProcesses = [];
  41271. for (var i = 0; i < this._textures.length; i++) {
  41272. if (this._textures[i]) {
  41273. this._textures[i].dispose();
  41274. }
  41275. }
  41276. this._textures = [];
  41277. };
  41278. /**
  41279. * Dispose the highlight layer and free resources.
  41280. */
  41281. EffectLayer.prototype.dispose = function () {
  41282. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41283. if (vertexBuffer) {
  41284. vertexBuffer.dispose();
  41285. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41286. }
  41287. if (this._indexBuffer) {
  41288. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41289. this._indexBuffer = null;
  41290. }
  41291. // Clean textures and post processes
  41292. this._disposeTextureAndPostProcesses();
  41293. // Remove from scene
  41294. var index = this._scene.effectLayers.indexOf(this, 0);
  41295. if (index > -1) {
  41296. this._scene.effectLayers.splice(index, 1);
  41297. }
  41298. // Callback
  41299. this.onDisposeObservable.notifyObservers(this);
  41300. this.onDisposeObservable.clear();
  41301. this.onBeforeRenderMainTextureObservable.clear();
  41302. this.onBeforeComposeObservable.clear();
  41303. this.onAfterComposeObservable.clear();
  41304. this.onSizeChangedObservable.clear();
  41305. };
  41306. /**
  41307. * Gets the class name of the effect layer
  41308. * @returns the string with the class name of the effect layer
  41309. */
  41310. EffectLayer.prototype.getClassName = function () {
  41311. return "EffectLayer";
  41312. };
  41313. /**
  41314. * Creates an effect layer from parsed effect layer data
  41315. * @param parsedEffectLayer defines effect layer data
  41316. * @param scene defines the current scene
  41317. * @param rootUrl defines the root URL containing the effect layer information
  41318. * @returns a parsed effect Layer
  41319. */
  41320. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41321. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41322. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41323. };
  41324. /** @hidden */
  41325. EffectLayer._SceneComponentInitialization = function (_) {
  41326. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  41327. };
  41328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41330. ], EffectLayer.prototype, "name", void 0);
  41331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41333. ], EffectLayer.prototype, "neutralColor", void 0);
  41334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41336. ], EffectLayer.prototype, "isEnabled", void 0);
  41337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41339. ], EffectLayer.prototype, "camera", null);
  41340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41342. ], EffectLayer.prototype, "renderingGroupId", null);
  41343. return EffectLayer;
  41344. }());
  41345. /***/ }),
  41346. /***/ "./Layers/effectLayerSceneComponent.ts":
  41347. /*!*********************************************!*\
  41348. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41349. \*********************************************/
  41350. /*! exports provided: EffectLayerSceneComponent */
  41351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41352. "use strict";
  41353. __webpack_require__.r(__webpack_exports__);
  41354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41355. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41356. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41357. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41358. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41359. // Adds the parser to the scene parsers.
  41360. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41361. if (parsedData.effectLayers) {
  41362. if (!container.effectLayers) {
  41363. container.effectLayers = new Array();
  41364. }
  41365. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41366. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41367. container.effectLayers.push(effectLayer);
  41368. }
  41369. }
  41370. });
  41371. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41372. var index = this.effectLayers.indexOf(toRemove);
  41373. if (index !== -1) {
  41374. this.effectLayers.splice(index, 1);
  41375. }
  41376. return index;
  41377. };
  41378. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41379. this.effectLayers.push(newEffectLayer);
  41380. };
  41381. /**
  41382. * Defines the layer scene component responsible to manage any effect layers
  41383. * in a given scene.
  41384. */
  41385. var EffectLayerSceneComponent = /** @class */ (function () {
  41386. /**
  41387. * Creates a new instance of the component for the given scene
  41388. * @param scene Defines the scene to register the component in
  41389. */
  41390. function EffectLayerSceneComponent(scene) {
  41391. /**
  41392. * The component name helpfull to identify the component in the list of scene components.
  41393. */
  41394. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41395. this._renderEffects = false;
  41396. this._needStencil = false;
  41397. this._previousStencilState = false;
  41398. this.scene = scene;
  41399. this._engine = scene.getEngine();
  41400. scene.effectLayers = new Array();
  41401. }
  41402. /**
  41403. * Registers the component in a given scene
  41404. */
  41405. EffectLayerSceneComponent.prototype.register = function () {
  41406. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41407. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41408. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41409. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41410. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41411. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41412. };
  41413. /**
  41414. * Rebuilds the elements related to this component in case of
  41415. * context lost for instance.
  41416. */
  41417. EffectLayerSceneComponent.prototype.rebuild = function () {
  41418. var layers = this.scene.effectLayers;
  41419. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41420. var effectLayer = layers_1[_i];
  41421. effectLayer._rebuild();
  41422. }
  41423. };
  41424. /**
  41425. * Serializes the component data to the specified json object
  41426. * @param serializationObject The object to serialize to
  41427. */
  41428. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41429. // Effect layers
  41430. serializationObject.effectLayers = [];
  41431. var layers = this.scene.effectLayers;
  41432. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41433. var effectLayer = layers_2[_i];
  41434. if (effectLayer.serialize) {
  41435. serializationObject.effectLayers.push(effectLayer.serialize());
  41436. }
  41437. }
  41438. };
  41439. /**
  41440. * Adds all the element from the container to the scene
  41441. * @param container the container holding the elements
  41442. */
  41443. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41444. var _this = this;
  41445. if (!container.effectLayers) {
  41446. return;
  41447. }
  41448. container.effectLayers.forEach(function (o) {
  41449. _this.scene.addEffectLayer(o);
  41450. });
  41451. };
  41452. /**
  41453. * Removes all the elements in the container from the scene
  41454. * @param container contains the elements to remove
  41455. */
  41456. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41457. var _this = this;
  41458. if (!container.effectLayers) {
  41459. return;
  41460. }
  41461. container.effectLayers.forEach(function (o) {
  41462. _this.scene.removeEffectLayer(o);
  41463. });
  41464. };
  41465. /**
  41466. * Disposes the component and the associated ressources.
  41467. */
  41468. EffectLayerSceneComponent.prototype.dispose = function () {
  41469. var layers = this.scene.effectLayers;
  41470. while (layers.length) {
  41471. layers[0].dispose();
  41472. }
  41473. };
  41474. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41475. var layers = this.scene.effectLayers;
  41476. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41477. var layer = layers_3[_i];
  41478. if (!layer.hasMesh(mesh)) {
  41479. continue;
  41480. }
  41481. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41482. var subMesh = _b[_a];
  41483. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41484. return false;
  41485. }
  41486. }
  41487. }
  41488. return true;
  41489. };
  41490. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41491. this._renderEffects = false;
  41492. this._needStencil = false;
  41493. var layers = this.scene.effectLayers;
  41494. if (layers && layers.length > 0) {
  41495. this._previousStencilState = this._engine.getStencilBuffer();
  41496. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41497. var effectLayer = layers_4[_i];
  41498. if (effectLayer.shouldRender() &&
  41499. (!effectLayer.camera ||
  41500. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41501. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41502. this._renderEffects = true;
  41503. this._needStencil = this._needStencil || effectLayer.needStencil();
  41504. var renderTarget = effectLayer._mainTexture;
  41505. if (renderTarget._shouldRender()) {
  41506. this.scene.incrementRenderId();
  41507. renderTarget.render(false, false);
  41508. }
  41509. }
  41510. }
  41511. this.scene.incrementRenderId();
  41512. }
  41513. };
  41514. EffectLayerSceneComponent.prototype._setStencil = function () {
  41515. // Activate effect Layer stencil
  41516. if (this._needStencil) {
  41517. this._engine.setStencilBuffer(true);
  41518. }
  41519. };
  41520. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41521. // Restore effect Layer stencil
  41522. if (this._needStencil) {
  41523. this._engine.setStencilBuffer(this._previousStencilState);
  41524. }
  41525. };
  41526. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41527. if (this._renderEffects) {
  41528. this._engine.setDepthBuffer(false);
  41529. var layers = this.scene.effectLayers;
  41530. for (var i = 0; i < layers.length; i++) {
  41531. var effectLayer = layers[i];
  41532. if (effectLayer.renderingGroupId === renderingGroupId) {
  41533. if (effectLayer.shouldRender()) {
  41534. effectLayer.render();
  41535. }
  41536. }
  41537. }
  41538. this._engine.setDepthBuffer(true);
  41539. }
  41540. };
  41541. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41542. if (this._renderEffects) {
  41543. this._draw(-1);
  41544. }
  41545. };
  41546. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41547. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41548. this._draw(index);
  41549. }
  41550. };
  41551. return EffectLayerSceneComponent;
  41552. }());
  41553. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41554. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41555. if (!component) {
  41556. component = new EffectLayerSceneComponent(scene);
  41557. scene._addComponent(component);
  41558. }
  41559. };
  41560. /***/ }),
  41561. /***/ "./Layers/glowLayer.ts":
  41562. /*!*****************************!*\
  41563. !*** ./Layers/glowLayer.ts ***!
  41564. \*****************************/
  41565. /*! exports provided: GlowLayer */
  41566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41567. "use strict";
  41568. __webpack_require__.r(__webpack_exports__);
  41569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41571. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41572. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41574. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41575. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41576. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41577. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41578. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41579. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41580. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41581. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41582. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41583. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41584. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41585. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41586. for (var index = 0; index < this.effectLayers.length; index++) {
  41587. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41588. return this.effectLayers[index];
  41589. }
  41590. }
  41591. return null;
  41592. };
  41593. /**
  41594. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41595. *
  41596. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41597. * glowy meshes to your scene.
  41598. *
  41599. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41600. */
  41601. var GlowLayer = /** @class */ (function (_super) {
  41602. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41603. /**
  41604. * Instantiates a new glow Layer and references it to the scene.
  41605. * @param name The name of the layer
  41606. * @param scene The scene to use the layer in
  41607. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41608. */
  41609. function GlowLayer(name, scene, options) {
  41610. var _this = _super.call(this, name, scene) || this;
  41611. _this._intensity = 1.0;
  41612. _this._includedOnlyMeshes = [];
  41613. _this._excludedMeshes = [];
  41614. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41615. // Adapt options
  41616. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41617. // Initialize the layer
  41618. _this._init({
  41619. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41620. camera: _this._options.camera,
  41621. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41622. mainTextureRatio: _this._options.mainTextureRatio,
  41623. renderingGroupId: _this._options.renderingGroupId
  41624. });
  41625. return _this;
  41626. }
  41627. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41628. /**
  41629. * Gets the kernel size of the blur.
  41630. */
  41631. get: function () {
  41632. return this._horizontalBlurPostprocess1.kernel;
  41633. },
  41634. /**
  41635. * Sets the kernel size of the blur.
  41636. */
  41637. set: function (value) {
  41638. this._horizontalBlurPostprocess1.kernel = value;
  41639. this._verticalBlurPostprocess1.kernel = value;
  41640. this._horizontalBlurPostprocess2.kernel = value;
  41641. this._verticalBlurPostprocess2.kernel = value;
  41642. },
  41643. enumerable: true,
  41644. configurable: true
  41645. });
  41646. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41647. /**
  41648. * Gets the glow intensity.
  41649. */
  41650. get: function () {
  41651. return this._intensity;
  41652. },
  41653. /**
  41654. * Sets the glow intensity.
  41655. */
  41656. set: function (value) {
  41657. this._intensity = value;
  41658. },
  41659. enumerable: true,
  41660. configurable: true
  41661. });
  41662. /**
  41663. * Get the effect name of the layer.
  41664. * @return The effect name
  41665. */
  41666. GlowLayer.prototype.getEffectName = function () {
  41667. return GlowLayer.EffectName;
  41668. };
  41669. /**
  41670. * Create the merge effect. This is the shader use to blit the information back
  41671. * to the main canvas at the end of the scene rendering.
  41672. */
  41673. GlowLayer.prototype._createMergeEffect = function () {
  41674. // Effect
  41675. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41676. };
  41677. /**
  41678. * Creates the render target textures and post processes used in the glow layer.
  41679. */
  41680. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41681. var _this = this;
  41682. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41683. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41684. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41685. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41686. var textureType = 0;
  41687. if (this._engine.getCaps().textureHalfFloatRender) {
  41688. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41689. }
  41690. else {
  41691. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41692. }
  41693. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41694. width: blurTextureWidth,
  41695. height: blurTextureHeight
  41696. }, this._scene, false, true, textureType);
  41697. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41698. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41699. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41700. this._blurTexture1.renderParticles = false;
  41701. this._blurTexture1.ignoreCameraViewport = true;
  41702. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41703. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41704. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41705. width: blurTextureWidth2,
  41706. height: blurTextureHeight2
  41707. }, this._scene, false, true, textureType);
  41708. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41709. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41710. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41711. this._blurTexture2.renderParticles = false;
  41712. this._blurTexture2.ignoreCameraViewport = true;
  41713. this._textures = [this._blurTexture1, this._blurTexture2];
  41714. this._horizontalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerHBP1", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  41715. width: blurTextureWidth,
  41716. height: blurTextureHeight
  41717. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41718. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41719. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41720. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41721. effect.setTexture("textureSampler", _this._mainTexture);
  41722. });
  41723. this._verticalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerVBP1", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  41724. width: blurTextureWidth,
  41725. height: blurTextureHeight
  41726. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41727. this._horizontalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerHBP2", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  41728. width: blurTextureWidth2,
  41729. height: blurTextureHeight2
  41730. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41731. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41732. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41733. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41734. effect.setTexture("textureSampler", _this._blurTexture1);
  41735. });
  41736. this._verticalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerVBP2", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  41737. width: blurTextureWidth2,
  41738. height: blurTextureHeight2
  41739. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41740. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41741. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41742. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41743. this._mainTexture.samples = this._options.mainTextureSamples;
  41744. this._mainTexture.onAfterUnbindObservable.add(function () {
  41745. var internalTexture = _this._blurTexture1.getInternalTexture();
  41746. if (internalTexture) {
  41747. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41748. internalTexture = _this._blurTexture2.getInternalTexture();
  41749. if (internalTexture) {
  41750. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41751. }
  41752. }
  41753. });
  41754. // Prevent autoClear.
  41755. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41756. };
  41757. /**
  41758. * Checks for the readiness of the element composing the layer.
  41759. * @param subMesh the mesh to check for
  41760. * @param useInstances specify wether or not to use instances to render the mesh
  41761. * @param emissiveTexture the associated emissive texture used to generate the glow
  41762. * @return true if ready otherwise, false
  41763. */
  41764. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41765. var material = subMesh.getMaterial();
  41766. var mesh = subMesh.getRenderingMesh();
  41767. if (!material || !mesh) {
  41768. return false;
  41769. }
  41770. var emissiveTexture = material.emissiveTexture;
  41771. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41772. };
  41773. /**
  41774. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41775. */
  41776. GlowLayer.prototype.needStencil = function () {
  41777. return false;
  41778. };
  41779. /**
  41780. * Returns true if the mesh can be rendered, otherwise false.
  41781. * @param mesh The mesh to render
  41782. * @param material The material used on the mesh
  41783. * @returns true if it can be rendered otherwise false
  41784. */
  41785. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41786. return true;
  41787. };
  41788. /**
  41789. * Implementation specific of rendering the generating effect on the main canvas.
  41790. * @param effect The effect used to render through
  41791. */
  41792. GlowLayer.prototype._internalRender = function (effect) {
  41793. // Texture
  41794. effect.setTexture("textureSampler", this._blurTexture1);
  41795. effect.setTexture("textureSampler2", this._blurTexture2);
  41796. effect.setFloat("offset", this._intensity);
  41797. // Cache
  41798. var engine = this._engine;
  41799. var previousStencilBuffer = engine.getStencilBuffer();
  41800. // Draw order
  41801. engine.setStencilBuffer(false);
  41802. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41803. // Draw order
  41804. engine.setStencilBuffer(previousStencilBuffer);
  41805. };
  41806. /**
  41807. * Sets the required values for both the emissive texture and and the main color.
  41808. */
  41809. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41810. var textureLevel = 1.0;
  41811. if (this.customEmissiveTextureSelector) {
  41812. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41813. }
  41814. else {
  41815. if (material) {
  41816. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41817. if (this._emissiveTextureAndColor.texture) {
  41818. textureLevel = this._emissiveTextureAndColor.texture.level;
  41819. }
  41820. }
  41821. else {
  41822. this._emissiveTextureAndColor.texture = null;
  41823. }
  41824. }
  41825. if (this.customEmissiveColorSelector) {
  41826. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41827. }
  41828. else {
  41829. if (material.emissiveColor) {
  41830. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41831. }
  41832. else {
  41833. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41834. }
  41835. }
  41836. };
  41837. /**
  41838. * Returns true if the mesh should render, otherwise false.
  41839. * @param mesh The mesh to render
  41840. * @returns true if it should render otherwise false
  41841. */
  41842. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41843. return this.hasMesh(mesh);
  41844. };
  41845. /**
  41846. * Adds specific effects defines.
  41847. * @param defines The defines to add specifics to.
  41848. */
  41849. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41850. defines.push("#define GLOW");
  41851. };
  41852. /**
  41853. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41854. * @param mesh The mesh to exclude from the glow layer
  41855. */
  41856. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41857. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41858. this._excludedMeshes.push(mesh.uniqueId);
  41859. }
  41860. };
  41861. /**
  41862. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41863. * @param mesh The mesh to remove
  41864. */
  41865. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41866. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41867. if (index !== -1) {
  41868. this._excludedMeshes.splice(index, 1);
  41869. }
  41870. };
  41871. /**
  41872. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41873. * @param mesh The mesh to include in the glow layer
  41874. */
  41875. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41876. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41877. this._includedOnlyMeshes.push(mesh.uniqueId);
  41878. }
  41879. };
  41880. /**
  41881. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41882. * @param mesh The mesh to remove
  41883. */
  41884. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  41885. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  41886. if (index !== -1) {
  41887. this._includedOnlyMeshes.splice(index, 1);
  41888. }
  41889. };
  41890. /**
  41891. * Determine if a given mesh will be used in the glow layer
  41892. * @param mesh The mesh to test
  41893. * @returns true if the mesh will be highlighted by the current glow layer
  41894. */
  41895. GlowLayer.prototype.hasMesh = function (mesh) {
  41896. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41897. return false;
  41898. }
  41899. // Included Mesh
  41900. if (this._includedOnlyMeshes.length) {
  41901. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  41902. }
  41903. // Excluded Mesh
  41904. if (this._excludedMeshes.length) {
  41905. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  41906. }
  41907. return true;
  41908. };
  41909. /**
  41910. * Free any resources and references associated to a mesh.
  41911. * Internal use
  41912. * @param mesh The mesh to free.
  41913. * @hidden
  41914. */
  41915. GlowLayer.prototype._disposeMesh = function (mesh) {
  41916. this.removeIncludedOnlyMesh(mesh);
  41917. this.removeExcludedMesh(mesh);
  41918. };
  41919. /**
  41920. * Gets the class name of the effect layer
  41921. * @returns the string with the class name of the effect layer
  41922. */
  41923. GlowLayer.prototype.getClassName = function () {
  41924. return "GlowLayer";
  41925. };
  41926. /**
  41927. * Serializes this glow layer
  41928. * @returns a serialized glow layer object
  41929. */
  41930. GlowLayer.prototype.serialize = function () {
  41931. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41932. serializationObject.customType = "BABYLON.GlowLayer";
  41933. var index;
  41934. // Included meshes
  41935. serializationObject.includedMeshes = [];
  41936. if (this._includedOnlyMeshes.length) {
  41937. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  41938. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  41939. if (mesh) {
  41940. serializationObject.includedMeshes.push(mesh.id);
  41941. }
  41942. }
  41943. }
  41944. // Excluded meshes
  41945. serializationObject.excludedMeshes = [];
  41946. if (this._excludedMeshes.length) {
  41947. for (index = 0; index < this._excludedMeshes.length; index++) {
  41948. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  41949. if (mesh) {
  41950. serializationObject.excludedMeshes.push(mesh.id);
  41951. }
  41952. }
  41953. }
  41954. return serializationObject;
  41955. };
  41956. /**
  41957. * Creates a Glow Layer from parsed glow layer data
  41958. * @param parsedGlowLayer defines glow layer data
  41959. * @param scene defines the current scene
  41960. * @param rootUrl defines the root URL containing the glow layer information
  41961. * @returns a parsed Glow Layer
  41962. */
  41963. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  41964. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  41965. var index;
  41966. // Excluded meshes
  41967. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  41968. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  41969. if (mesh) {
  41970. gl.addExcludedMesh(mesh);
  41971. }
  41972. }
  41973. // Included meshes
  41974. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  41975. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  41976. if (mesh) {
  41977. gl.addIncludedOnlyMesh(mesh);
  41978. }
  41979. }
  41980. return gl;
  41981. };
  41982. /**
  41983. * Effect Name of the layer.
  41984. */
  41985. GlowLayer.EffectName = "GlowLayer";
  41986. /**
  41987. * The default blur kernel size used for the glow.
  41988. */
  41989. GlowLayer.DefaultBlurKernelSize = 32;
  41990. /**
  41991. * The default texture size ratio used for the glow.
  41992. */
  41993. GlowLayer.DefaultTextureRatio = 0.5;
  41994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41996. ], GlowLayer.prototype, "blurKernelSize", null);
  41997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41999. ], GlowLayer.prototype, "intensity", null);
  42000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42002. ], GlowLayer.prototype, "_options", void 0);
  42003. return GlowLayer;
  42004. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42005. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42006. /***/ }),
  42007. /***/ "./Layers/highlightLayer.ts":
  42008. /*!**********************************!*\
  42009. !*** ./Layers/highlightLayer.ts ***!
  42010. \**********************************/
  42011. /*! exports provided: HighlightLayer */
  42012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42013. "use strict";
  42014. __webpack_require__.r(__webpack_exports__);
  42015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42017. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42018. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42019. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42020. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42021. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42022. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42023. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42024. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42025. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42026. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42027. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42028. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42029. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42030. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42031. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42032. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42033. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42034. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42035. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42036. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42037. for (var index = 0; index < this.effectLayers.length; index++) {
  42038. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42039. return this.effectLayers[index];
  42040. }
  42041. }
  42042. return null;
  42043. };
  42044. /**
  42045. * Special Glow Blur post process only blurring the alpha channel
  42046. * It enforces keeping the most luminous color in the color channel.
  42047. */
  42048. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42049. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42050. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42051. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42052. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42053. _this.direction = direction;
  42054. _this.kernel = kernel;
  42055. _this.onApplyObservable.add(function (effect) {
  42056. effect.setFloat2("screenSize", _this.width, _this.height);
  42057. effect.setVector2("direction", _this.direction);
  42058. effect.setFloat("blurWidth", _this.kernel);
  42059. });
  42060. return _this;
  42061. }
  42062. return GlowBlurPostProcess;
  42063. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42064. /**
  42065. * The highlight layer Helps adding a glow effect around a mesh.
  42066. *
  42067. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42068. * glowy meshes to your scene.
  42069. *
  42070. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42071. */
  42072. var HighlightLayer = /** @class */ (function (_super) {
  42073. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42074. /**
  42075. * Instantiates a new highlight Layer and references it to the scene..
  42076. * @param name The name of the layer
  42077. * @param scene The scene to use the layer in
  42078. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42079. */
  42080. function HighlightLayer(name, scene, options) {
  42081. var _this = _super.call(this, name, scene) || this;
  42082. _this.name = name;
  42083. /**
  42084. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42085. */
  42086. _this.innerGlow = true;
  42087. /**
  42088. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42089. */
  42090. _this.outerGlow = true;
  42091. /**
  42092. * An event triggered when the highlight layer is being blurred.
  42093. */
  42094. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42095. /**
  42096. * An event triggered when the highlight layer has been blurred.
  42097. */
  42098. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42099. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42100. _this._meshes = {};
  42101. _this._excludedMeshes = {};
  42102. _this.neutralColor = HighlightLayer.NeutralColor;
  42103. // Warn on stencil
  42104. if (!_this._engine.isStencilEnable) {
  42105. _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 }");
  42106. }
  42107. // Adapt options
  42108. _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);
  42109. // Initialize the layer
  42110. _this._init({
  42111. alphaBlendingMode: _this._options.alphaBlendingMode,
  42112. camera: _this._options.camera,
  42113. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42114. mainTextureRatio: _this._options.mainTextureRatio,
  42115. renderingGroupId: _this._options.renderingGroupId
  42116. });
  42117. // Do not render as long as no meshes have been added
  42118. _this._shouldRender = false;
  42119. return _this;
  42120. }
  42121. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42122. /**
  42123. * Gets the horizontal size of the blur.
  42124. */
  42125. get: function () {
  42126. return this._horizontalBlurPostprocess.kernel;
  42127. },
  42128. /**
  42129. * Specifies the horizontal size of the blur.
  42130. */
  42131. set: function (value) {
  42132. this._horizontalBlurPostprocess.kernel = value;
  42133. },
  42134. enumerable: true,
  42135. configurable: true
  42136. });
  42137. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42138. /**
  42139. * Gets the vertical size of the blur.
  42140. */
  42141. get: function () {
  42142. return this._verticalBlurPostprocess.kernel;
  42143. },
  42144. /**
  42145. * Specifies the vertical size of the blur.
  42146. */
  42147. set: function (value) {
  42148. this._verticalBlurPostprocess.kernel = value;
  42149. },
  42150. enumerable: true,
  42151. configurable: true
  42152. });
  42153. /**
  42154. * Get the effect name of the layer.
  42155. * @return The effect name
  42156. */
  42157. HighlightLayer.prototype.getEffectName = function () {
  42158. return HighlightLayer.EffectName;
  42159. };
  42160. /**
  42161. * Create the merge effect. This is the shader use to blit the information back
  42162. * to the main canvas at the end of the scene rendering.
  42163. */
  42164. HighlightLayer.prototype._createMergeEffect = function () {
  42165. // Effect
  42166. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42167. };
  42168. /**
  42169. * Creates the render target textures and post processes used in the highlight layer.
  42170. */
  42171. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42172. var _this = this;
  42173. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42174. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42175. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42176. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42177. var textureType = 0;
  42178. if (this._engine.getCaps().textureHalfFloatRender) {
  42179. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42180. }
  42181. else {
  42182. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42183. }
  42184. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42185. width: blurTextureWidth,
  42186. height: blurTextureHeight
  42187. }, this._scene, false, true, textureType);
  42188. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42189. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42190. this._blurTexture.anisotropicFilteringLevel = 16;
  42191. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42192. this._blurTexture.renderParticles = false;
  42193. this._blurTexture.ignoreCameraViewport = true;
  42194. this._textures = [this._blurTexture];
  42195. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42196. 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());
  42197. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42198. effect.setTexture("textureSampler", _this._mainTexture);
  42199. });
  42200. this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](1.0, 0), this._options.blurHorizontalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  42201. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42202. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42203. });
  42204. this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](0, 1.0), this._options.blurVerticalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  42205. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42206. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42207. });
  42208. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42209. }
  42210. else {
  42211. this._horizontalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerHBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](1.0, 0), this._options.blurHorizontalSize / 2, {
  42212. width: blurTextureWidth,
  42213. height: blurTextureHeight
  42214. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42215. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42216. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42217. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42218. effect.setTexture("textureSampler", _this._mainTexture);
  42219. });
  42220. this._verticalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerVBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](0, 1.0), this._options.blurVerticalSize / 2, {
  42221. width: blurTextureWidth,
  42222. height: blurTextureHeight
  42223. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42224. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42225. }
  42226. this._mainTexture.onAfterUnbindObservable.add(function () {
  42227. _this.onBeforeBlurObservable.notifyObservers(_this);
  42228. var internalTexture = _this._blurTexture.getInternalTexture();
  42229. if (internalTexture) {
  42230. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42231. }
  42232. _this.onAfterBlurObservable.notifyObservers(_this);
  42233. });
  42234. // Prevent autoClear.
  42235. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42236. };
  42237. /**
  42238. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42239. */
  42240. HighlightLayer.prototype.needStencil = function () {
  42241. return true;
  42242. };
  42243. /**
  42244. * Checks for the readiness of the element composing the layer.
  42245. * @param subMesh the mesh to check for
  42246. * @param useInstances specify wether or not to use instances to render the mesh
  42247. * @param emissiveTexture the associated emissive texture used to generate the glow
  42248. * @return true if ready otherwise, false
  42249. */
  42250. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42251. var material = subMesh.getMaterial();
  42252. var mesh = subMesh.getRenderingMesh();
  42253. if (!material || !mesh || !this._meshes) {
  42254. return false;
  42255. }
  42256. var emissiveTexture = null;
  42257. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42258. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42259. emissiveTexture = material.emissiveTexture;
  42260. }
  42261. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42262. };
  42263. /**
  42264. * Implementation specific of rendering the generating effect on the main canvas.
  42265. * @param effect The effect used to render through
  42266. */
  42267. HighlightLayer.prototype._internalRender = function (effect) {
  42268. // Texture
  42269. effect.setTexture("textureSampler", this._blurTexture);
  42270. // Cache
  42271. var engine = this._engine;
  42272. var previousStencilBuffer = engine.getStencilBuffer();
  42273. var previousStencilFunction = engine.getStencilFunction();
  42274. var previousStencilMask = engine.getStencilMask();
  42275. var previousStencilOperationPass = engine.getStencilOperationPass();
  42276. var previousStencilOperationFail = engine.getStencilOperationFail();
  42277. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42278. var previousStencilReference = engine.getStencilFunctionReference();
  42279. // Stencil operations
  42280. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42281. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42282. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42283. // Draw order
  42284. engine.setStencilMask(0x00);
  42285. engine.setStencilBuffer(true);
  42286. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42287. // 2 passes inner outer
  42288. if (this.outerGlow) {
  42289. effect.setFloat("offset", 0);
  42290. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42291. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42292. }
  42293. if (this.innerGlow) {
  42294. effect.setFloat("offset", 1);
  42295. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42296. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42297. }
  42298. // Restore Cache
  42299. engine.setStencilFunction(previousStencilFunction);
  42300. engine.setStencilMask(previousStencilMask);
  42301. engine.setStencilBuffer(previousStencilBuffer);
  42302. engine.setStencilOperationPass(previousStencilOperationPass);
  42303. engine.setStencilOperationFail(previousStencilOperationFail);
  42304. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42305. engine.setStencilFunctionReference(previousStencilReference);
  42306. };
  42307. /**
  42308. * Returns true if the layer contains information to display, otherwise false.
  42309. */
  42310. HighlightLayer.prototype.shouldRender = function () {
  42311. if (_super.prototype.shouldRender.call(this)) {
  42312. return this._meshes ? true : false;
  42313. }
  42314. return false;
  42315. };
  42316. /**
  42317. * Returns true if the mesh should render, otherwise false.
  42318. * @param mesh The mesh to render
  42319. * @returns true if it should render otherwise false
  42320. */
  42321. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42322. // Excluded Mesh
  42323. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42324. return false;
  42325. }
  42326. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42327. return false;
  42328. }
  42329. return true;
  42330. };
  42331. /**
  42332. * Sets the required values for both the emissive texture and and the main color.
  42333. */
  42334. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42335. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42336. if (highlightLayerMesh) {
  42337. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42338. }
  42339. else {
  42340. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42341. }
  42342. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42343. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42344. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42345. }
  42346. else {
  42347. this._emissiveTextureAndColor.texture = null;
  42348. }
  42349. };
  42350. /**
  42351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42352. * @param mesh The mesh to exclude from the highlight layer
  42353. */
  42354. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42355. if (!this._excludedMeshes) {
  42356. return;
  42357. }
  42358. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42359. if (!meshExcluded) {
  42360. this._excludedMeshes[mesh.uniqueId] = {
  42361. mesh: mesh,
  42362. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42363. mesh.getEngine().setStencilBuffer(false);
  42364. }),
  42365. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42366. mesh.getEngine().setStencilBuffer(true);
  42367. }),
  42368. };
  42369. }
  42370. };
  42371. /**
  42372. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42373. * @param mesh The mesh to highlight
  42374. */
  42375. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42376. if (!this._excludedMeshes) {
  42377. return;
  42378. }
  42379. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42380. if (meshExcluded) {
  42381. if (meshExcluded.beforeBind) {
  42382. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42383. }
  42384. if (meshExcluded.afterRender) {
  42385. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42386. }
  42387. }
  42388. this._excludedMeshes[mesh.uniqueId] = null;
  42389. };
  42390. /**
  42391. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42392. * @param mesh mesh to test
  42393. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42394. */
  42395. HighlightLayer.prototype.hasMesh = function (mesh) {
  42396. if (!this._meshes) {
  42397. return false;
  42398. }
  42399. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42400. return false;
  42401. }
  42402. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42403. };
  42404. /**
  42405. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42406. * @param mesh The mesh to highlight
  42407. * @param color The color of the highlight
  42408. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42409. */
  42410. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42411. var _this = this;
  42412. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42413. if (!this._meshes) {
  42414. return;
  42415. }
  42416. var meshHighlight = this._meshes[mesh.uniqueId];
  42417. if (meshHighlight) {
  42418. meshHighlight.color = color;
  42419. }
  42420. else {
  42421. this._meshes[mesh.uniqueId] = {
  42422. mesh: mesh,
  42423. color: color,
  42424. // Lambda required for capture due to Observable this context
  42425. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42426. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42427. _this._defaultStencilReference(mesh);
  42428. }
  42429. else {
  42430. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42431. }
  42432. }),
  42433. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42434. glowEmissiveOnly: glowEmissiveOnly
  42435. };
  42436. mesh.onDisposeObservable.add(function () {
  42437. _this._disposeMesh(mesh);
  42438. });
  42439. }
  42440. this._shouldRender = true;
  42441. };
  42442. /**
  42443. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42444. * @param mesh The mesh to highlight
  42445. */
  42446. HighlightLayer.prototype.removeMesh = function (mesh) {
  42447. if (!this._meshes) {
  42448. return;
  42449. }
  42450. var meshHighlight = this._meshes[mesh.uniqueId];
  42451. if (meshHighlight) {
  42452. if (meshHighlight.observerHighlight) {
  42453. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42454. }
  42455. if (meshHighlight.observerDefault) {
  42456. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42457. }
  42458. delete this._meshes[mesh.uniqueId];
  42459. }
  42460. this._shouldRender = false;
  42461. for (var meshHighlightToCheck in this._meshes) {
  42462. if (this._meshes[meshHighlightToCheck]) {
  42463. this._shouldRender = true;
  42464. break;
  42465. }
  42466. }
  42467. };
  42468. /**
  42469. * Force the stencil to the normal expected value for none glowing parts
  42470. */
  42471. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42472. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42473. };
  42474. /**
  42475. * Free any resources and references associated to a mesh.
  42476. * Internal use
  42477. * @param mesh The mesh to free.
  42478. * @hidden
  42479. */
  42480. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42481. this.removeMesh(mesh);
  42482. this.removeExcludedMesh(mesh);
  42483. };
  42484. /**
  42485. * Dispose the highlight layer and free resources.
  42486. */
  42487. HighlightLayer.prototype.dispose = function () {
  42488. if (this._meshes) {
  42489. // Clean mesh references
  42490. for (var id in this._meshes) {
  42491. var meshHighlight = this._meshes[id];
  42492. if (meshHighlight && meshHighlight.mesh) {
  42493. if (meshHighlight.observerHighlight) {
  42494. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42495. }
  42496. if (meshHighlight.observerDefault) {
  42497. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42498. }
  42499. }
  42500. }
  42501. this._meshes = null;
  42502. }
  42503. if (this._excludedMeshes) {
  42504. for (var id in this._excludedMeshes) {
  42505. var meshHighlight = this._excludedMeshes[id];
  42506. if (meshHighlight) {
  42507. if (meshHighlight.beforeBind) {
  42508. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42509. }
  42510. if (meshHighlight.afterRender) {
  42511. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42512. }
  42513. }
  42514. }
  42515. this._excludedMeshes = null;
  42516. }
  42517. _super.prototype.dispose.call(this);
  42518. };
  42519. /**
  42520. * Gets the class name of the effect layer
  42521. * @returns the string with the class name of the effect layer
  42522. */
  42523. HighlightLayer.prototype.getClassName = function () {
  42524. return "HighlightLayer";
  42525. };
  42526. /**
  42527. * Serializes this Highlight layer
  42528. * @returns a serialized Highlight layer object
  42529. */
  42530. HighlightLayer.prototype.serialize = function () {
  42531. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42532. serializationObject.customType = "BABYLON.HighlightLayer";
  42533. // Highlighted meshes
  42534. serializationObject.meshes = [];
  42535. if (this._meshes) {
  42536. for (var m in this._meshes) {
  42537. var mesh = this._meshes[m];
  42538. if (mesh) {
  42539. serializationObject.meshes.push({
  42540. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42541. color: mesh.color.asArray(),
  42542. meshId: mesh.mesh.id
  42543. });
  42544. }
  42545. }
  42546. }
  42547. // Excluded meshes
  42548. serializationObject.excludedMeshes = [];
  42549. if (this._excludedMeshes) {
  42550. for (var e in this._excludedMeshes) {
  42551. var excludedMesh = this._excludedMeshes[e];
  42552. if (excludedMesh) {
  42553. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42554. }
  42555. }
  42556. }
  42557. return serializationObject;
  42558. };
  42559. /**
  42560. * Creates a Highlight layer from parsed Highlight layer data
  42561. * @param parsedHightlightLayer defines the Highlight layer data
  42562. * @param scene defines the current scene
  42563. * @param rootUrl defines the root URL containing the Highlight layer information
  42564. * @returns a parsed Highlight layer
  42565. */
  42566. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42567. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42568. var index;
  42569. // Excluded meshes
  42570. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42571. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42572. if (mesh) {
  42573. hl.addExcludedMesh(mesh);
  42574. }
  42575. }
  42576. // Included meshes
  42577. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42578. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42579. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42580. if (mesh) {
  42581. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42582. }
  42583. }
  42584. return hl;
  42585. };
  42586. /**
  42587. * Effect Name of the highlight layer.
  42588. */
  42589. HighlightLayer.EffectName = "HighlightLayer";
  42590. /**
  42591. * The neutral color used during the preparation of the glow effect.
  42592. * This is black by default as the blend operation is a blend operation.
  42593. */
  42594. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42595. /**
  42596. * Stencil value used for glowing meshes.
  42597. */
  42598. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42599. /**
  42600. * Stencil value used for the other meshes in the scene.
  42601. */
  42602. HighlightLayer.NormalMeshStencilReference = 0x01;
  42603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42604. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42605. ], HighlightLayer.prototype, "innerGlow", void 0);
  42606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42608. ], HighlightLayer.prototype, "outerGlow", void 0);
  42609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42611. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42614. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42617. ], HighlightLayer.prototype, "_options", void 0);
  42618. return HighlightLayer;
  42619. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42620. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42621. /***/ }),
  42622. /***/ "./Layers/index.ts":
  42623. /*!*************************!*\
  42624. !*** ./Layers/index.ts ***!
  42625. \*************************/
  42626. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42628. "use strict";
  42629. __webpack_require__.r(__webpack_exports__);
  42630. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42632. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42634. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42636. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42638. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42640. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42642. /***/ }),
  42643. /***/ "./Layers/layer.ts":
  42644. /*!*************************!*\
  42645. !*** ./Layers/layer.ts ***!
  42646. \*************************/
  42647. /*! exports provided: Layer */
  42648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42649. "use strict";
  42650. __webpack_require__.r(__webpack_exports__);
  42651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42652. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42654. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42655. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42656. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42657. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42658. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42659. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42660. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42661. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42662. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42663. /**
  42664. * This represents a full screen 2d layer.
  42665. * This can be useful to display a picture in the background of your scene for instance.
  42666. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42667. */
  42668. var Layer = /** @class */ (function () {
  42669. /**
  42670. * Instantiates a new layer.
  42671. * This represents a full screen 2d layer.
  42672. * This can be useful to display a picture in the background of your scene for instance.
  42673. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42674. * @param name Define the name of the layer in the scene
  42675. * @param imgUrl Define the url of the texture to display in the layer
  42676. * @param scene Define the scene the layer belongs to
  42677. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42678. * @param color Defines a color for the layer
  42679. */
  42680. function Layer(
  42681. /**
  42682. * Define the name of the layer.
  42683. */
  42684. name, imgUrl, scene, isBackground, color) {
  42685. this.name = name;
  42686. /**
  42687. * Define the scale of the layer in order to zoom in out of the texture.
  42688. */
  42689. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42690. /**
  42691. * Define an offset for the layer in order to shift the texture.
  42692. */
  42693. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42694. /**
  42695. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42696. */
  42697. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42698. /**
  42699. * Define a mask to restrict the layer to only some of the scene cameras.
  42700. */
  42701. this.layerMask = 0x0FFFFFFF;
  42702. /**
  42703. * Define the list of render target the layer is visible into.
  42704. */
  42705. this.renderTargetTextures = [];
  42706. /**
  42707. * Define if the layer is only used in renderTarget or if it also
  42708. * renders in the main frame buffer of the canvas.
  42709. */
  42710. this.renderOnlyInRenderTargetTextures = false;
  42711. this._vertexBuffers = {};
  42712. /**
  42713. * An event triggered when the layer is disposed.
  42714. */
  42715. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42716. /**
  42717. * An event triggered before rendering the scene
  42718. */
  42719. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42720. /**
  42721. * An event triggered after rendering the scene
  42722. */
  42723. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42724. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42725. this.isBackground = isBackground === undefined ? true : isBackground;
  42726. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42727. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42728. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42729. if (!layerComponent) {
  42730. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42731. this._scene._addComponent(layerComponent);
  42732. }
  42733. this._scene.layers.push(this);
  42734. var engine = this._scene.getEngine();
  42735. // VBO
  42736. var vertices = [];
  42737. vertices.push(1, 1);
  42738. vertices.push(-1, 1);
  42739. vertices.push(-1, -1);
  42740. vertices.push(1, -1);
  42741. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42742. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42743. this._createIndexBuffer();
  42744. // Effects
  42745. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42746. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42747. }
  42748. Object.defineProperty(Layer.prototype, "onDispose", {
  42749. /**
  42750. * Back compatibility with callback before the onDisposeObservable existed.
  42751. * The set callback will be triggered when the layer has been disposed.
  42752. */
  42753. set: function (callback) {
  42754. if (this._onDisposeObserver) {
  42755. this.onDisposeObservable.remove(this._onDisposeObserver);
  42756. }
  42757. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42758. },
  42759. enumerable: true,
  42760. configurable: true
  42761. });
  42762. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42763. /**
  42764. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42765. * The set callback will be triggered just before rendering the layer.
  42766. */
  42767. set: function (callback) {
  42768. if (this._onBeforeRenderObserver) {
  42769. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42770. }
  42771. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42772. },
  42773. enumerable: true,
  42774. configurable: true
  42775. });
  42776. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42777. /**
  42778. * Back compatibility with callback before the onAfterRenderObservable existed.
  42779. * The set callback will be triggered just after rendering the layer.
  42780. */
  42781. set: function (callback) {
  42782. if (this._onAfterRenderObserver) {
  42783. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42784. }
  42785. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42786. },
  42787. enumerable: true,
  42788. configurable: true
  42789. });
  42790. Layer.prototype._createIndexBuffer = function () {
  42791. var engine = this._scene.getEngine();
  42792. // Indices
  42793. var indices = [];
  42794. indices.push(0);
  42795. indices.push(1);
  42796. indices.push(2);
  42797. indices.push(0);
  42798. indices.push(2);
  42799. indices.push(3);
  42800. this._indexBuffer = engine.createIndexBuffer(indices);
  42801. };
  42802. /** @hidden */
  42803. Layer.prototype._rebuild = function () {
  42804. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42805. if (vb) {
  42806. vb._rebuild();
  42807. }
  42808. this._createIndexBuffer();
  42809. };
  42810. /**
  42811. * Renders the layer in the scene.
  42812. */
  42813. Layer.prototype.render = function () {
  42814. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42815. // Check
  42816. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42817. return;
  42818. }
  42819. var engine = this._scene.getEngine();
  42820. this.onBeforeRenderObservable.notifyObservers(this);
  42821. // Render
  42822. engine.enableEffect(currentEffect);
  42823. engine.setState(false);
  42824. // Texture
  42825. currentEffect.setTexture("textureSampler", this.texture);
  42826. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42827. // Color
  42828. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42829. // Scale / offset
  42830. currentEffect.setVector2("offset", this.offset);
  42831. currentEffect.setVector2("scale", this.scale);
  42832. // VBOs
  42833. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42834. // Draw order
  42835. if (!this.alphaTest) {
  42836. engine.setAlphaMode(this.alphaBlendingMode);
  42837. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42838. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42839. }
  42840. else {
  42841. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42842. }
  42843. this.onAfterRenderObservable.notifyObservers(this);
  42844. };
  42845. /**
  42846. * Disposes and releases the associated ressources.
  42847. */
  42848. Layer.prototype.dispose = function () {
  42849. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42850. if (vertexBuffer) {
  42851. vertexBuffer.dispose();
  42852. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42853. }
  42854. if (this._indexBuffer) {
  42855. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42856. this._indexBuffer = null;
  42857. }
  42858. if (this.texture) {
  42859. this.texture.dispose();
  42860. this.texture = null;
  42861. }
  42862. // Clean RTT list
  42863. this.renderTargetTextures = [];
  42864. // Remove from scene
  42865. var index = this._scene.layers.indexOf(this);
  42866. this._scene.layers.splice(index, 1);
  42867. // Callback
  42868. this.onDisposeObservable.notifyObservers(this);
  42869. this.onDisposeObservable.clear();
  42870. this.onAfterRenderObservable.clear();
  42871. this.onBeforeRenderObservable.clear();
  42872. };
  42873. return Layer;
  42874. }());
  42875. /***/ }),
  42876. /***/ "./Layers/layerSceneComponent.ts":
  42877. /*!***************************************!*\
  42878. !*** ./Layers/layerSceneComponent.ts ***!
  42879. \***************************************/
  42880. /*! exports provided: LayerSceneComponent */
  42881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42882. "use strict";
  42883. __webpack_require__.r(__webpack_exports__);
  42884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  42885. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42886. /**
  42887. * Defines the layer scene component responsible to manage any layers
  42888. * in a given scene.
  42889. */
  42890. var LayerSceneComponent = /** @class */ (function () {
  42891. /**
  42892. * Creates a new instance of the component for the given scene
  42893. * @param scene Defines the scene to register the component in
  42894. */
  42895. function LayerSceneComponent(scene) {
  42896. /**
  42897. * The component name helpfull to identify the component in the list of scene components.
  42898. */
  42899. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  42900. this.scene = scene;
  42901. this._engine = scene.getEngine();
  42902. scene.layers = new Array();
  42903. }
  42904. /**
  42905. * Registers the component in a given scene
  42906. */
  42907. LayerSceneComponent.prototype.register = function () {
  42908. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  42909. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  42910. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  42911. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  42912. };
  42913. /**
  42914. * Rebuilds the elements related to this component in case of
  42915. * context lost for instance.
  42916. */
  42917. LayerSceneComponent.prototype.rebuild = function () {
  42918. var layers = this.scene.layers;
  42919. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42920. var layer = layers_1[_i];
  42921. layer._rebuild();
  42922. }
  42923. };
  42924. /**
  42925. * Disposes the component and the associated ressources.
  42926. */
  42927. LayerSceneComponent.prototype.dispose = function () {
  42928. var layers = this.scene.layers;
  42929. while (layers.length) {
  42930. layers[0].dispose();
  42931. }
  42932. };
  42933. LayerSceneComponent.prototype._draw = function (predicate) {
  42934. var layers = this.scene.layers;
  42935. if (layers.length) {
  42936. this._engine.setDepthBuffer(false);
  42937. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42938. var layer = layers_2[_i];
  42939. if (predicate(layer)) {
  42940. layer.render();
  42941. }
  42942. }
  42943. this._engine.setDepthBuffer(true);
  42944. }
  42945. };
  42946. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  42947. return !layer.renderOnlyInRenderTargetTextures &&
  42948. layer.isBackground === isBackground &&
  42949. ((layer.layerMask & cameraLayerMask) !== 0);
  42950. };
  42951. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  42952. var _this = this;
  42953. this._draw(function (layer) {
  42954. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  42955. });
  42956. };
  42957. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  42958. var _this = this;
  42959. this._draw(function (layer) {
  42960. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  42961. });
  42962. };
  42963. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  42964. return (layer.renderTargetTextures.length > 0) &&
  42965. layer.isBackground === isBackground &&
  42966. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  42967. ((layer.layerMask & cameraLayerMask) !== 0);
  42968. };
  42969. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  42970. var _this = this;
  42971. this._draw(function (layer) {
  42972. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  42973. });
  42974. };
  42975. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  42976. var _this = this;
  42977. this._draw(function (layer) {
  42978. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  42979. });
  42980. };
  42981. return LayerSceneComponent;
  42982. }());
  42983. /***/ }),
  42984. /***/ "./Legacy/legacy.ts":
  42985. /*!**************************!*\
  42986. !*** ./Legacy/legacy.ts ***!
  42987. \**************************/
  42988. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  42989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42990. "use strict";
  42991. __webpack_require__.r(__webpack_exports__);
  42992. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  42993. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  42994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  42995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  42996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  42997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  42998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  42999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43508. /**
  43509. * Legacy support, defining window.BABYLON (global variable).
  43510. *
  43511. * This is the entry point for the UMD module.
  43512. * The entry point for a future ESM package should be index.ts
  43513. */
  43514. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43515. if (typeof globalObject !== "undefined") {
  43516. globalObject.BABYLON = BABYLON;
  43517. globalObject.BABYLON = globalObject.BABYLON || {};
  43518. var BABYLON = globalObject.BABYLON;
  43519. BABYLON.Debug = BABYLON.Debug || {};
  43520. var keys = [];
  43521. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43522. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43523. keys.push(key);
  43524. }
  43525. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43526. // Prevent Reassignment.
  43527. if (keys.indexOf(key) > -1) {
  43528. continue;
  43529. }
  43530. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43531. }
  43532. }
  43533. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43534. /***/ }),
  43535. /***/ "./LensFlares/index.ts":
  43536. /*!*****************************!*\
  43537. !*** ./LensFlares/index.ts ***!
  43538. \*****************************/
  43539. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43541. "use strict";
  43542. __webpack_require__.r(__webpack_exports__);
  43543. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43545. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43547. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43549. /***/ }),
  43550. /***/ "./LensFlares/lensFlare.ts":
  43551. /*!*********************************!*\
  43552. !*** ./LensFlares/lensFlare.ts ***!
  43553. \*********************************/
  43554. /*! exports provided: LensFlare */
  43555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43556. "use strict";
  43557. __webpack_require__.r(__webpack_exports__);
  43558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43559. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43560. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43561. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43562. /**
  43563. * This represents one of the lens effect in a `lensFlareSystem`.
  43564. * It controls one of the indiviual texture used in the effect.
  43565. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43566. */
  43567. var LensFlare = /** @class */ (function () {
  43568. /**
  43569. * Instantiates a new Lens Flare.
  43570. * This represents one of the lens effect in a `lensFlareSystem`.
  43571. * It controls one of the indiviual texture used in the effect.
  43572. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43573. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43574. * @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.
  43575. * @param color Define the lens color
  43576. * @param imgUrl Define the lens texture url
  43577. * @param system Define the `lensFlareSystem` this flare is part of
  43578. */
  43579. function LensFlare(
  43580. /**
  43581. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43582. */
  43583. size,
  43584. /**
  43585. * 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.
  43586. */
  43587. position, color, imgUrl, system) {
  43588. this.size = size;
  43589. this.position = position;
  43590. /**
  43591. * Define the alpha mode to render this particular lens.
  43592. */
  43593. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43594. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43595. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43596. this._system = system;
  43597. system.lensFlares.push(this);
  43598. }
  43599. /**
  43600. * Creates a new Lens Flare.
  43601. * This represents one of the lens effect in a `lensFlareSystem`.
  43602. * It controls one of the indiviual texture used in the effect.
  43603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43604. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43605. * @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.
  43606. * @param color Define the lens color
  43607. * @param imgUrl Define the lens texture url
  43608. * @param system Define the `lensFlareSystem` this flare is part of
  43609. * @returns The newly created Lens Flare
  43610. */
  43611. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43612. return new LensFlare(size, position, color, imgUrl, system);
  43613. };
  43614. /**
  43615. * Dispose and release the lens flare with its associated resources.
  43616. */
  43617. LensFlare.prototype.dispose = function () {
  43618. if (this.texture) {
  43619. this.texture.dispose();
  43620. }
  43621. // Remove from scene
  43622. var index = this._system.lensFlares.indexOf(this);
  43623. this._system.lensFlares.splice(index, 1);
  43624. };
  43625. return LensFlare;
  43626. }());
  43627. /***/ }),
  43628. /***/ "./LensFlares/lensFlareSystem.ts":
  43629. /*!***************************************!*\
  43630. !*** ./LensFlares/lensFlareSystem.ts ***!
  43631. \***************************************/
  43632. /*! exports provided: LensFlareSystem */
  43633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43634. "use strict";
  43635. __webpack_require__.r(__webpack_exports__);
  43636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43637. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43638. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43639. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43640. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43641. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43642. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43643. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43644. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43645. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43646. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43647. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43648. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43649. /**
  43650. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43651. * It is usually composed of several `lensFlare`.
  43652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43653. */
  43654. var LensFlareSystem = /** @class */ (function () {
  43655. /**
  43656. * Instantiates a lens flare system.
  43657. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43658. * It is usually composed of several `lensFlare`.
  43659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43660. * @param name Define the name of the lens flare system in the scene
  43661. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43662. * @param scene Define the scene the lens flare system belongs to
  43663. */
  43664. function LensFlareSystem(
  43665. /**
  43666. * Define the name of the lens flare system
  43667. */
  43668. name, emitter, scene) {
  43669. this.name = name;
  43670. /**
  43671. * List of lens flares used in this system.
  43672. */
  43673. this.lensFlares = new Array();
  43674. /**
  43675. * Define a limit from the border the lens flare can be visible.
  43676. */
  43677. this.borderLimit = 300;
  43678. /**
  43679. * Define a viewport border we do not want to see the lens flare in.
  43680. */
  43681. this.viewportBorder = 0;
  43682. /**
  43683. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43684. */
  43685. this.layerMask = 0x0FFFFFFF;
  43686. this._vertexBuffers = {};
  43687. this._isEnabled = true;
  43688. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43689. LensFlareSystem._SceneComponentInitialization(this._scene);
  43690. this._emitter = emitter;
  43691. this.id = name;
  43692. scene.lensFlareSystems.push(this);
  43693. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43694. var engine = scene.getEngine();
  43695. // VBO
  43696. var vertices = [];
  43697. vertices.push(1, 1);
  43698. vertices.push(-1, 1);
  43699. vertices.push(-1, -1);
  43700. vertices.push(1, -1);
  43701. 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);
  43702. // Indices
  43703. var indices = [];
  43704. indices.push(0);
  43705. indices.push(1);
  43706. indices.push(2);
  43707. indices.push(0);
  43708. indices.push(2);
  43709. indices.push(3);
  43710. this._indexBuffer = engine.createIndexBuffer(indices);
  43711. // Effects
  43712. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43713. }
  43714. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43715. /**
  43716. * Define if the lens flare system is enabled.
  43717. */
  43718. get: function () {
  43719. return this._isEnabled;
  43720. },
  43721. set: function (value) {
  43722. this._isEnabled = value;
  43723. },
  43724. enumerable: true,
  43725. configurable: true
  43726. });
  43727. /**
  43728. * Get the scene the effects belongs to.
  43729. * @returns the scene holding the lens flare system
  43730. */
  43731. LensFlareSystem.prototype.getScene = function () {
  43732. return this._scene;
  43733. };
  43734. /**
  43735. * Get the emitter of the lens flare system.
  43736. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43737. * @returns the emitter of the lens flare system
  43738. */
  43739. LensFlareSystem.prototype.getEmitter = function () {
  43740. return this._emitter;
  43741. };
  43742. /**
  43743. * Set the emitter of the lens flare system.
  43744. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43745. * @param newEmitter Define the new emitter of the system
  43746. */
  43747. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43748. this._emitter = newEmitter;
  43749. };
  43750. /**
  43751. * Get the lens flare system emitter position.
  43752. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43753. * @returns the position
  43754. */
  43755. LensFlareSystem.prototype.getEmitterPosition = function () {
  43756. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43757. };
  43758. /**
  43759. * @hidden
  43760. */
  43761. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43762. var position = this.getEmitterPosition();
  43763. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43764. this._positionX = position.x;
  43765. this._positionY = position.y;
  43766. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43767. if (this.viewportBorder > 0) {
  43768. globalViewport.x -= this.viewportBorder;
  43769. globalViewport.y -= this.viewportBorder;
  43770. globalViewport.width += this.viewportBorder * 2;
  43771. globalViewport.height += this.viewportBorder * 2;
  43772. position.x += this.viewportBorder;
  43773. position.y += this.viewportBorder;
  43774. this._positionX += this.viewportBorder;
  43775. this._positionY += this.viewportBorder;
  43776. }
  43777. if (position.z > 0) {
  43778. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43779. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43780. return true;
  43781. }
  43782. }
  43783. return true;
  43784. }
  43785. return false;
  43786. };
  43787. /** @hidden */
  43788. LensFlareSystem.prototype._isVisible = function () {
  43789. if (!this._isEnabled || !this._scene.activeCamera) {
  43790. return false;
  43791. }
  43792. var emitterPosition = this.getEmitterPosition();
  43793. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43794. var distance = direction.length();
  43795. direction.normalize();
  43796. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43797. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43798. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43799. };
  43800. /**
  43801. * @hidden
  43802. */
  43803. LensFlareSystem.prototype.render = function () {
  43804. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43805. return false;
  43806. }
  43807. var engine = this._scene.getEngine();
  43808. var viewport = this._scene.activeCamera.viewport;
  43809. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43810. // Position
  43811. if (!this.computeEffectivePosition(globalViewport)) {
  43812. return false;
  43813. }
  43814. // Visibility
  43815. if (!this._isVisible()) {
  43816. return false;
  43817. }
  43818. // Intensity
  43819. var awayX;
  43820. var awayY;
  43821. if (this._positionX < this.borderLimit + globalViewport.x) {
  43822. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43823. }
  43824. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43825. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43826. }
  43827. else {
  43828. awayX = 0;
  43829. }
  43830. if (this._positionY < this.borderLimit + globalViewport.y) {
  43831. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43832. }
  43833. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43834. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43835. }
  43836. else {
  43837. awayY = 0;
  43838. }
  43839. var away = (awayX > awayY) ? awayX : awayY;
  43840. away -= this.viewportBorder;
  43841. if (away > this.borderLimit) {
  43842. away = this.borderLimit;
  43843. }
  43844. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43845. if (intensity < 0) {
  43846. return false;
  43847. }
  43848. if (intensity > 1.0) {
  43849. intensity = 1.0;
  43850. }
  43851. if (this.viewportBorder > 0) {
  43852. globalViewport.x += this.viewportBorder;
  43853. globalViewport.y += this.viewportBorder;
  43854. globalViewport.width -= this.viewportBorder * 2;
  43855. globalViewport.height -= this.viewportBorder * 2;
  43856. this._positionX -= this.viewportBorder;
  43857. this._positionY -= this.viewportBorder;
  43858. }
  43859. // Position
  43860. var centerX = globalViewport.x + globalViewport.width / 2;
  43861. var centerY = globalViewport.y + globalViewport.height / 2;
  43862. var distX = centerX - this._positionX;
  43863. var distY = centerY - this._positionY;
  43864. // Effects
  43865. engine.enableEffect(this._effect);
  43866. engine.setState(false);
  43867. engine.setDepthBuffer(false);
  43868. // VBOs
  43869. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43870. // Flares
  43871. for (var index = 0; index < this.lensFlares.length; index++) {
  43872. var flare = this.lensFlares[index];
  43873. engine.setAlphaMode(flare.alphaMode);
  43874. var x = centerX - (distX * flare.position);
  43875. var y = centerY - (distY * flare.position);
  43876. var cw = flare.size;
  43877. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43878. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43879. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43880. var viewportMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);
  43881. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43882. // Texture
  43883. this._effect.setTexture("textureSampler", flare.texture);
  43884. // Color
  43885. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  43886. // Draw order
  43887. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43888. }
  43889. engine.setDepthBuffer(true);
  43890. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43891. return true;
  43892. };
  43893. /**
  43894. * Dispose and release the lens flare with its associated resources.
  43895. */
  43896. LensFlareSystem.prototype.dispose = function () {
  43897. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  43898. if (vertexBuffer) {
  43899. vertexBuffer.dispose();
  43900. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  43901. }
  43902. if (this._indexBuffer) {
  43903. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43904. this._indexBuffer = null;
  43905. }
  43906. while (this.lensFlares.length) {
  43907. this.lensFlares[0].dispose();
  43908. }
  43909. // Remove from scene
  43910. var index = this._scene.lensFlareSystems.indexOf(this);
  43911. this._scene.lensFlareSystems.splice(index, 1);
  43912. };
  43913. /**
  43914. * Parse a lens flare system from a JSON repressentation
  43915. * @param parsedLensFlareSystem Define the JSON to parse
  43916. * @param scene Define the scene the parsed system should be instantiated in
  43917. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43918. * @returns the parsed system
  43919. */
  43920. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  43921. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  43922. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  43923. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  43924. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  43925. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  43926. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  43927. var parsedFlare = parsedLensFlareSystem.flares[index];
  43928. _lensFlare__WEBPACK_IMPORTED_MODULE_7__["LensFlare"].AddFlare(parsedFlare.size, parsedFlare.position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFlare.color), parsedFlare.textureName ? rootUrl + parsedFlare.textureName : "", lensFlareSystem);
  43929. }
  43930. return lensFlareSystem;
  43931. };
  43932. /**
  43933. * Serialize the current Lens Flare System into a JSON representation.
  43934. * @returns the serialized JSON
  43935. */
  43936. LensFlareSystem.prototype.serialize = function () {
  43937. var serializationObject = {};
  43938. serializationObject.id = this.id;
  43939. serializationObject.name = this.name;
  43940. serializationObject.emitterId = this.getEmitter().id;
  43941. serializationObject.borderLimit = this.borderLimit;
  43942. serializationObject.flares = [];
  43943. for (var index = 0; index < this.lensFlares.length; index++) {
  43944. var flare = this.lensFlares[index];
  43945. serializationObject.flares.push({
  43946. size: flare.size,
  43947. position: flare.position,
  43948. color: flare.color.asArray(),
  43949. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  43950. });
  43951. }
  43952. return serializationObject;
  43953. };
  43954. /** @hidden */
  43955. LensFlareSystem._SceneComponentInitialization = function (_) {
  43956. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  43957. };
  43958. return LensFlareSystem;
  43959. }());
  43960. /***/ }),
  43961. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  43962. /*!*****************************************************!*\
  43963. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  43964. \*****************************************************/
  43965. /*! exports provided: LensFlareSystemSceneComponent */
  43966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43967. "use strict";
  43968. __webpack_require__.r(__webpack_exports__);
  43969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  43970. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43971. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43972. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43973. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43974. // Adds the parser to the scene parsers.
  43975. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  43976. // Lens flares
  43977. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  43978. if (!container.lensFlareSystems) {
  43979. container.lensFlareSystems = new Array();
  43980. }
  43981. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  43982. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  43983. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  43984. container.lensFlareSystems.push(lf);
  43985. }
  43986. }
  43987. });
  43988. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  43989. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43990. if (this.lensFlareSystems[index].name === name) {
  43991. return this.lensFlareSystems[index];
  43992. }
  43993. }
  43994. return null;
  43995. };
  43996. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  43997. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43998. if (this.lensFlareSystems[index].id === id) {
  43999. return this.lensFlareSystems[index];
  44000. }
  44001. }
  44002. return null;
  44003. };
  44004. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44005. var index = this.lensFlareSystems.indexOf(toRemove);
  44006. if (index !== -1) {
  44007. this.lensFlareSystems.splice(index, 1);
  44008. }
  44009. return index;
  44010. };
  44011. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44012. this.lensFlareSystems.push(newLensFlareSystem);
  44013. };
  44014. /**
  44015. * Defines the lens flare scene component responsible to manage any lens flares
  44016. * in a given scene.
  44017. */
  44018. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44019. /**
  44020. * Creates a new instance of the component for the given scene
  44021. * @param scene Defines the scene to register the component in
  44022. */
  44023. function LensFlareSystemSceneComponent(scene) {
  44024. /**
  44025. * The component name helpfull to identify the component in the list of scene components.
  44026. */
  44027. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44028. this.scene = scene;
  44029. scene.lensFlareSystems = new Array();
  44030. }
  44031. /**
  44032. * Registers the component in a given scene
  44033. */
  44034. LensFlareSystemSceneComponent.prototype.register = function () {
  44035. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44036. };
  44037. /**
  44038. * Rebuilds the elements related to this component in case of
  44039. * context lost for instance.
  44040. */
  44041. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44042. // Nothing to do for lens flare
  44043. };
  44044. /**
  44045. * Adds all the element from the container to the scene
  44046. * @param container the container holding the elements
  44047. */
  44048. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44049. var _this = this;
  44050. if (!container.lensFlareSystems) {
  44051. return;
  44052. }
  44053. container.lensFlareSystems.forEach(function (o) {
  44054. _this.scene.addLensFlareSystem(o);
  44055. });
  44056. };
  44057. /**
  44058. * Removes all the elements in the container from the scene
  44059. * @param container contains the elements to remove
  44060. */
  44061. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44062. var _this = this;
  44063. if (!container.lensFlareSystems) {
  44064. return;
  44065. }
  44066. container.lensFlareSystems.forEach(function (o) {
  44067. _this.scene.removeLensFlareSystem(o);
  44068. });
  44069. };
  44070. /**
  44071. * Serializes the component data to the specified json object
  44072. * @param serializationObject The object to serialize to
  44073. */
  44074. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44075. // Lens flares
  44076. serializationObject.lensFlareSystems = [];
  44077. var lensFlareSystems = this.scene.lensFlareSystems;
  44078. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44079. var lensFlareSystem = lensFlareSystems_1[_i];
  44080. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44081. }
  44082. };
  44083. /**
  44084. * Disposes the component and the associated ressources.
  44085. */
  44086. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44087. var lensFlareSystems = this.scene.lensFlareSystems;
  44088. while (lensFlareSystems.length) {
  44089. lensFlareSystems[0].dispose();
  44090. }
  44091. };
  44092. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44093. // Lens flares
  44094. if (this.scene.lensFlaresEnabled) {
  44095. var lensFlareSystems = this.scene.lensFlareSystems;
  44096. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44097. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44098. var lensFlareSystem = lensFlareSystems_2[_i];
  44099. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44100. lensFlareSystem.render();
  44101. }
  44102. }
  44103. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44104. }
  44105. };
  44106. return LensFlareSystemSceneComponent;
  44107. }());
  44108. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44109. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44110. if (!component) {
  44111. component = new LensFlareSystemSceneComponent(scene);
  44112. scene._addComponent(component);
  44113. }
  44114. };
  44115. /***/ }),
  44116. /***/ "./Lights/Shadows/index.ts":
  44117. /*!*********************************!*\
  44118. !*** ./Lights/Shadows/index.ts ***!
  44119. \*********************************/
  44120. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44122. "use strict";
  44123. __webpack_require__.r(__webpack_exports__);
  44124. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44126. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44128. /***/ }),
  44129. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44130. /*!*******************************************!*\
  44131. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44132. \*******************************************/
  44133. /*! exports provided: ShadowGenerator */
  44134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44135. "use strict";
  44136. __webpack_require__.r(__webpack_exports__);
  44137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44140. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44141. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44142. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44143. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44144. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44145. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44146. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44147. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44148. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44149. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44150. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44151. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44152. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44153. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44154. /**
  44155. * Default implementation IShadowGenerator.
  44156. * This is the main object responsible of generating shadows in the framework.
  44157. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44158. */
  44159. var ShadowGenerator = /** @class */ (function () {
  44160. /**
  44161. * Creates a ShadowGenerator object.
  44162. * A ShadowGenerator is the required tool to use the shadows.
  44163. * Each light casting shadows needs to use its own ShadowGenerator.
  44164. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44165. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44166. * @param light The light object generating the shadows.
  44167. * @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.
  44168. */
  44169. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44170. /**
  44171. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44172. */
  44173. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44174. this._bias = 0.00005;
  44175. this._normalBias = 0;
  44176. this._blurBoxOffset = 1;
  44177. this._blurScale = 2;
  44178. this._blurKernel = 1;
  44179. this._useKernelBlur = false;
  44180. this._filter = ShadowGenerator.FILTER_NONE;
  44181. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44182. this._contactHardeningLightSizeUVRatio = 0.1;
  44183. this._darkness = 0;
  44184. this._transparencyShadow = false;
  44185. /**
  44186. * Controls the extent to which the shadows fade out at the edge of the frustum
  44187. * Used only by directionals and spots
  44188. */
  44189. this.frustumEdgeFalloff = 0;
  44190. /**
  44191. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44192. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44193. * It might on the other hand introduce peter panning.
  44194. */
  44195. this.forceBackFacesOnly = false;
  44196. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44197. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44198. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44199. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44200. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44201. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44202. this._currentFaceIndex = 0;
  44203. this._currentFaceIndexCache = 0;
  44204. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44205. this._mapSize = mapSize;
  44206. this._light = light;
  44207. this._scene = light.getScene();
  44208. light._shadowGenerator = this;
  44209. ShadowGenerator._SceneComponentInitialization(this._scene);
  44210. // Texture type fallback from float to int if not supported.
  44211. var caps = this._scene.getEngine().getCaps();
  44212. if (!usefulFloatFirst) {
  44213. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44214. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44215. }
  44216. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44217. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44218. }
  44219. else {
  44220. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44221. }
  44222. }
  44223. else {
  44224. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44225. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44226. }
  44227. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44228. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44229. }
  44230. else {
  44231. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44232. }
  44233. }
  44234. this._initializeGenerator();
  44235. this._applyFilterValues();
  44236. }
  44237. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44238. /**
  44239. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44240. */
  44241. get: function () {
  44242. return this._bias;
  44243. },
  44244. /**
  44245. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44246. */
  44247. set: function (bias) {
  44248. this._bias = bias;
  44249. },
  44250. enumerable: true,
  44251. configurable: true
  44252. });
  44253. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44254. /**
  44255. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44256. */
  44257. get: function () {
  44258. return this._normalBias;
  44259. },
  44260. /**
  44261. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44262. */
  44263. set: function (normalBias) {
  44264. this._normalBias = normalBias;
  44265. },
  44266. enumerable: true,
  44267. configurable: true
  44268. });
  44269. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44270. /**
  44271. * Gets the blur box offset: offset applied during the blur pass.
  44272. * Only useful if useKernelBlur = false
  44273. */
  44274. get: function () {
  44275. return this._blurBoxOffset;
  44276. },
  44277. /**
  44278. * Sets the blur box offset: offset applied during the blur pass.
  44279. * Only useful if useKernelBlur = false
  44280. */
  44281. set: function (value) {
  44282. if (this._blurBoxOffset === value) {
  44283. return;
  44284. }
  44285. this._blurBoxOffset = value;
  44286. this._disposeBlurPostProcesses();
  44287. },
  44288. enumerable: true,
  44289. configurable: true
  44290. });
  44291. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44292. /**
  44293. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44294. * 2 means half of the size.
  44295. */
  44296. get: function () {
  44297. return this._blurScale;
  44298. },
  44299. /**
  44300. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44301. * 2 means half of the size.
  44302. */
  44303. set: function (value) {
  44304. if (this._blurScale === value) {
  44305. return;
  44306. }
  44307. this._blurScale = value;
  44308. this._disposeBlurPostProcesses();
  44309. },
  44310. enumerable: true,
  44311. configurable: true
  44312. });
  44313. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44314. /**
  44315. * Gets the blur kernel: kernel size of the blur pass.
  44316. * Only useful if useKernelBlur = true
  44317. */
  44318. get: function () {
  44319. return this._blurKernel;
  44320. },
  44321. /**
  44322. * Sets the blur kernel: kernel size of the blur pass.
  44323. * Only useful if useKernelBlur = true
  44324. */
  44325. set: function (value) {
  44326. if (this._blurKernel === value) {
  44327. return;
  44328. }
  44329. this._blurKernel = value;
  44330. this._disposeBlurPostProcesses();
  44331. },
  44332. enumerable: true,
  44333. configurable: true
  44334. });
  44335. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44336. /**
  44337. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44338. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44339. */
  44340. get: function () {
  44341. return this._useKernelBlur;
  44342. },
  44343. /**
  44344. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44345. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44346. */
  44347. set: function (value) {
  44348. if (this._useKernelBlur === value) {
  44349. return;
  44350. }
  44351. this._useKernelBlur = value;
  44352. this._disposeBlurPostProcesses();
  44353. },
  44354. enumerable: true,
  44355. configurable: true
  44356. });
  44357. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44358. /**
  44359. * Gets the depth scale used in ESM mode.
  44360. */
  44361. get: function () {
  44362. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44363. },
  44364. /**
  44365. * Sets the depth scale used in ESM mode.
  44366. * This can override the scale stored on the light.
  44367. */
  44368. set: function (value) {
  44369. this._depthScale = value;
  44370. },
  44371. enumerable: true,
  44372. configurable: true
  44373. });
  44374. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44375. /**
  44376. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44377. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44378. */
  44379. get: function () {
  44380. return this._filter;
  44381. },
  44382. /**
  44383. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44384. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44385. */
  44386. set: function (value) {
  44387. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44388. if (this._light.needCube()) {
  44389. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44390. this.useExponentialShadowMap = true;
  44391. return;
  44392. }
  44393. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44394. this.useCloseExponentialShadowMap = true;
  44395. return;
  44396. }
  44397. // PCF on cubemap would also be expensive
  44398. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44399. this.usePoissonSampling = true;
  44400. return;
  44401. }
  44402. }
  44403. // Weblg1 fallback for PCF.
  44404. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44405. if (this._scene.getEngine().webGLVersion === 1) {
  44406. this.usePoissonSampling = true;
  44407. return;
  44408. }
  44409. }
  44410. if (this._filter === value) {
  44411. return;
  44412. }
  44413. this._filter = value;
  44414. this._disposeBlurPostProcesses();
  44415. this._applyFilterValues();
  44416. this._light._markMeshesAsLightDirty();
  44417. },
  44418. enumerable: true,
  44419. configurable: true
  44420. });
  44421. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44422. /**
  44423. * Gets if the current filter is set to Poisson Sampling.
  44424. */
  44425. get: function () {
  44426. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44427. },
  44428. /**
  44429. * Sets the current filter to Poisson Sampling.
  44430. */
  44431. set: function (value) {
  44432. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44433. return;
  44434. }
  44435. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44436. },
  44437. enumerable: true,
  44438. configurable: true
  44439. });
  44440. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44441. /**
  44442. * Gets if the current filter is set to ESM.
  44443. */
  44444. get: function () {
  44445. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44446. },
  44447. /**
  44448. * Sets the current filter is to ESM.
  44449. */
  44450. set: function (value) {
  44451. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44452. return;
  44453. }
  44454. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44455. },
  44456. enumerable: true,
  44457. configurable: true
  44458. });
  44459. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44460. /**
  44461. * Gets if the current filter is set to filtered ESM.
  44462. */
  44463. get: function () {
  44464. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44465. },
  44466. /**
  44467. * Gets if the current filter is set to filtered ESM.
  44468. */
  44469. set: function (value) {
  44470. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44471. return;
  44472. }
  44473. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44474. },
  44475. enumerable: true,
  44476. configurable: true
  44477. });
  44478. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44479. /**
  44480. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44481. * exponential to prevent steep falloff artifacts).
  44482. */
  44483. get: function () {
  44484. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44485. },
  44486. /**
  44487. * Sets the current filter to "close ESM" (using the inverse of the
  44488. * exponential to prevent steep falloff artifacts).
  44489. */
  44490. set: function (value) {
  44491. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44492. return;
  44493. }
  44494. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44495. },
  44496. enumerable: true,
  44497. configurable: true
  44498. });
  44499. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44500. /**
  44501. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44502. * exponential to prevent steep falloff artifacts).
  44503. */
  44504. get: function () {
  44505. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44506. },
  44507. /**
  44508. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44509. * exponential to prevent steep falloff artifacts).
  44510. */
  44511. set: function (value) {
  44512. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44513. return;
  44514. }
  44515. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44516. },
  44517. enumerable: true,
  44518. configurable: true
  44519. });
  44520. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44521. /**
  44522. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44523. */
  44524. get: function () {
  44525. return this.filter === ShadowGenerator.FILTER_PCF;
  44526. },
  44527. /**
  44528. * Sets the current filter to "PCF" (percentage closer filtering).
  44529. */
  44530. set: function (value) {
  44531. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44532. return;
  44533. }
  44534. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44535. },
  44536. enumerable: true,
  44537. configurable: true
  44538. });
  44539. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44540. /**
  44541. * Gets the PCF or PCSS Quality.
  44542. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44543. */
  44544. get: function () {
  44545. return this._filteringQuality;
  44546. },
  44547. /**
  44548. * Sets the PCF or PCSS Quality.
  44549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44550. */
  44551. set: function (filteringQuality) {
  44552. this._filteringQuality = filteringQuality;
  44553. },
  44554. enumerable: true,
  44555. configurable: true
  44556. });
  44557. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44558. /**
  44559. * Gets if the current filter is set to "PCSS" (contact hardening).
  44560. */
  44561. get: function () {
  44562. return this.filter === ShadowGenerator.FILTER_PCSS;
  44563. },
  44564. /**
  44565. * Sets the current filter to "PCSS" (contact hardening).
  44566. */
  44567. set: function (value) {
  44568. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44569. return;
  44570. }
  44571. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44572. },
  44573. enumerable: true,
  44574. configurable: true
  44575. });
  44576. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44577. /**
  44578. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44579. * Using a ratio helps keeping shape stability independently of the map size.
  44580. *
  44581. * It does not account for the light projection as it was having too much
  44582. * instability during the light setup or during light position changes.
  44583. *
  44584. * Only valid if useContactHardeningShadow is true.
  44585. */
  44586. get: function () {
  44587. return this._contactHardeningLightSizeUVRatio;
  44588. },
  44589. /**
  44590. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44591. * Using a ratio helps keeping shape stability independently of the map size.
  44592. *
  44593. * It does not account for the light projection as it was having too much
  44594. * instability during the light setup or during light position changes.
  44595. *
  44596. * Only valid if useContactHardeningShadow is true.
  44597. */
  44598. set: function (contactHardeningLightSizeUVRatio) {
  44599. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44600. },
  44601. enumerable: true,
  44602. configurable: true
  44603. });
  44604. /**
  44605. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44606. * 0 means strongest and 1 would means no shadow.
  44607. * @returns the darkness.
  44608. */
  44609. ShadowGenerator.prototype.getDarkness = function () {
  44610. return this._darkness;
  44611. };
  44612. /**
  44613. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44614. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44615. * @returns the shadow generator allowing fluent coding.
  44616. */
  44617. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44618. if (darkness >= 1.0) {
  44619. this._darkness = 1.0;
  44620. }
  44621. else if (darkness <= 0.0) {
  44622. this._darkness = 0.0;
  44623. }
  44624. else {
  44625. this._darkness = darkness;
  44626. }
  44627. return this;
  44628. };
  44629. /**
  44630. * Sets the ability to have transparent shadow (boolean).
  44631. * @param transparent True if transparent else False
  44632. * @returns the shadow generator allowing fluent coding
  44633. */
  44634. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44635. this._transparencyShadow = transparent;
  44636. return this;
  44637. };
  44638. /**
  44639. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44640. * @returns The render target texture if present otherwise, null
  44641. */
  44642. ShadowGenerator.prototype.getShadowMap = function () {
  44643. return this._shadowMap;
  44644. };
  44645. /**
  44646. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44647. * @returns The render target texture if the shadow map is present otherwise, null
  44648. */
  44649. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44650. if (this._shadowMap2) {
  44651. return this._shadowMap2;
  44652. }
  44653. return this._shadowMap;
  44654. };
  44655. /**
  44656. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44657. * @param mesh Mesh to add
  44658. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44659. * @returns the Shadow Generator itself
  44660. */
  44661. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44662. if (includeDescendants === void 0) { includeDescendants = true; }
  44663. var _a;
  44664. if (!this._shadowMap) {
  44665. return this;
  44666. }
  44667. if (!this._shadowMap.renderList) {
  44668. this._shadowMap.renderList = [];
  44669. }
  44670. this._shadowMap.renderList.push(mesh);
  44671. if (includeDescendants) {
  44672. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44673. }
  44674. return this;
  44675. };
  44676. /**
  44677. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44678. * @param mesh Mesh to remove
  44679. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44680. * @returns the Shadow Generator itself
  44681. */
  44682. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44683. if (includeDescendants === void 0) { includeDescendants = true; }
  44684. if (!this._shadowMap || !this._shadowMap.renderList) {
  44685. return this;
  44686. }
  44687. var index = this._shadowMap.renderList.indexOf(mesh);
  44688. if (index !== -1) {
  44689. this._shadowMap.renderList.splice(index, 1);
  44690. }
  44691. if (includeDescendants) {
  44692. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44693. var child = _a[_i];
  44694. this.removeShadowCaster(child);
  44695. }
  44696. }
  44697. return this;
  44698. };
  44699. /**
  44700. * Returns the associated light object.
  44701. * @returns the light generating the shadow
  44702. */
  44703. ShadowGenerator.prototype.getLight = function () {
  44704. return this._light;
  44705. };
  44706. ShadowGenerator.prototype._initializeGenerator = function () {
  44707. this._light._markMeshesAsLightDirty();
  44708. this._initializeShadowMap();
  44709. };
  44710. ShadowGenerator.prototype._initializeShadowMap = function () {
  44711. var _this = this;
  44712. // Render target
  44713. var engine = this._scene.getEngine();
  44714. if (engine.webGLVersion > 1) {
  44715. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube(), undefined, false, false);
  44716. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44717. }
  44718. else {
  44719. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube());
  44720. }
  44721. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44722. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44723. this._shadowMap.anisotropicFilteringLevel = 1;
  44724. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44725. this._shadowMap.renderParticles = false;
  44726. this._shadowMap.ignoreCameraViewport = true;
  44727. // Record Face Index before render.
  44728. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44729. _this._currentFaceIndex = faceIndex;
  44730. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44731. engine.setColorWrite(false);
  44732. }
  44733. });
  44734. // Custom render function.
  44735. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44736. // Blur if required afer render.
  44737. this._shadowMap.onAfterUnbindObservable.add(function () {
  44738. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44739. engine.setColorWrite(true);
  44740. }
  44741. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44742. return;
  44743. }
  44744. var shadowMap = _this.getShadowMapForRendering();
  44745. if (shadowMap) {
  44746. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44747. }
  44748. });
  44749. // Clear according to the chosen filter.
  44750. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44751. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44752. this._shadowMap.onClearObservable.add(function (engine) {
  44753. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44754. engine.clear(clearOne, false, true, false);
  44755. }
  44756. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44757. engine.clear(clearZero, true, true, false);
  44758. }
  44759. else {
  44760. engine.clear(clearOne, true, true, false);
  44761. }
  44762. });
  44763. };
  44764. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44765. var _this = this;
  44766. var engine = this._scene.getEngine();
  44767. var targetSize = this._mapSize / this.blurScale;
  44768. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44769. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44770. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44771. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44772. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44773. }
  44774. if (this.useKernelBlur) {
  44775. this._kernelBlurXPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurX", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  44776. this._kernelBlurXPostprocess.width = targetSize;
  44777. this._kernelBlurXPostprocess.height = targetSize;
  44778. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44779. effect.setTexture("textureSampler", _this._shadowMap);
  44780. });
  44781. this._kernelBlurYPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurY", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  44782. this._kernelBlurXPostprocess.autoClear = false;
  44783. this._kernelBlurYPostprocess.autoClear = false;
  44784. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44785. this._kernelBlurXPostprocess.packedFloat = true;
  44786. this._kernelBlurYPostprocess.packedFloat = true;
  44787. }
  44788. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44789. }
  44790. else {
  44791. this._boxBlurPostprocess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__["PostProcess"](this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, "#define OFFSET " + this._blurBoxOffset, this._textureType);
  44792. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44793. effect.setFloat2("screenSize", targetSize, targetSize);
  44794. effect.setTexture("textureSampler", _this._shadowMap);
  44795. });
  44796. this._boxBlurPostprocess.autoClear = false;
  44797. this._blurPostProcesses = [this._boxBlurPostprocess];
  44798. }
  44799. };
  44800. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44801. var index;
  44802. var engine = this._scene.getEngine();
  44803. if (depthOnlySubMeshes.length) {
  44804. engine.setColorWrite(false);
  44805. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44806. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44807. }
  44808. engine.setColorWrite(true);
  44809. }
  44810. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44811. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44812. }
  44813. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44814. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44815. }
  44816. if (this._transparencyShadow) {
  44817. for (index = 0; index < transparentSubMeshes.length; index++) {
  44818. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44819. }
  44820. }
  44821. };
  44822. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44823. var _this = this;
  44824. var mesh = subMesh.getRenderingMesh();
  44825. var scene = this._scene;
  44826. var engine = scene.getEngine();
  44827. var material = subMesh.getMaterial();
  44828. if (!material || subMesh.verticesCount === 0) {
  44829. return;
  44830. }
  44831. // Culling
  44832. engine.setState(material.backFaceCulling);
  44833. // Managing instances
  44834. var batch = mesh._getInstancesRenderList(subMesh._id);
  44835. if (batch.mustReturn) {
  44836. return;
  44837. }
  44838. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44839. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44840. engine.enableEffect(this._effect);
  44841. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44842. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44843. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44844. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44845. this._effect.setVector3("lightData", this._cachedDirection);
  44846. }
  44847. else {
  44848. this._effect.setVector3("lightData", this._cachedPosition);
  44849. }
  44850. if (scene.activeCamera) {
  44851. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44852. }
  44853. // Alpha test
  44854. if (material && material.needAlphaTesting()) {
  44855. var alphaTexture = material.getAlphaTestTexture();
  44856. if (alphaTexture) {
  44857. this._effect.setTexture("diffuseSampler", alphaTexture);
  44858. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44859. }
  44860. }
  44861. // Bones
  44862. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44863. var skeleton = mesh.skeleton;
  44864. if (skeleton.isUsingTextureForMatrices) {
  44865. var boneTexture = skeleton.getTransformMatrixTexture();
  44866. if (!boneTexture) {
  44867. return;
  44868. }
  44869. this._effect.setTexture("boneSampler", boneTexture);
  44870. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44871. }
  44872. else {
  44873. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44874. }
  44875. }
  44876. // Morph targets
  44877. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44878. if (this.forceBackFacesOnly) {
  44879. engine.setState(true, 0, false, true);
  44880. }
  44881. // Observable
  44882. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  44883. // Draw
  44884. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  44885. if (this.forceBackFacesOnly) {
  44886. engine.setState(true, 0, false, false);
  44887. }
  44888. }
  44889. else {
  44890. // Need to reset refresh rate of the shadowMap
  44891. if (this._shadowMap) {
  44892. this._shadowMap.resetRefreshCounter();
  44893. }
  44894. }
  44895. };
  44896. ShadowGenerator.prototype._applyFilterValues = function () {
  44897. if (!this._shadowMap) {
  44898. return;
  44899. }
  44900. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  44901. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  44902. }
  44903. else {
  44904. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44905. }
  44906. };
  44907. /**
  44908. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44909. * @param onCompiled Callback triggered at the and of the effects compilation
  44910. * @param options Sets of optional options forcing the compilation with different modes
  44911. */
  44912. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  44913. var _this = this;
  44914. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  44915. var shadowMap = this.getShadowMap();
  44916. if (!shadowMap) {
  44917. if (onCompiled) {
  44918. onCompiled(this);
  44919. }
  44920. return;
  44921. }
  44922. var renderList = shadowMap.renderList;
  44923. if (!renderList) {
  44924. if (onCompiled) {
  44925. onCompiled(this);
  44926. }
  44927. return;
  44928. }
  44929. var subMeshes = new Array();
  44930. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  44931. var mesh = renderList_1[_i];
  44932. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  44933. }
  44934. if (subMeshes.length === 0) {
  44935. if (onCompiled) {
  44936. onCompiled(this);
  44937. }
  44938. return;
  44939. }
  44940. var currentIndex = 0;
  44941. var checkReady = function () {
  44942. if (!_this._scene || !_this._scene.getEngine()) {
  44943. return;
  44944. }
  44945. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  44946. currentIndex++;
  44947. if (currentIndex >= subMeshes.length) {
  44948. if (onCompiled) {
  44949. onCompiled(_this);
  44950. }
  44951. return;
  44952. }
  44953. }
  44954. setTimeout(checkReady, 16);
  44955. };
  44956. checkReady();
  44957. };
  44958. /**
  44959. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44960. * @param options Sets of optional options forcing the compilation with different modes
  44961. * @returns A promise that resolves when the compilation completes
  44962. */
  44963. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  44964. var _this = this;
  44965. return new Promise(function (resolve) {
  44966. _this.forceCompilation(function () {
  44967. resolve();
  44968. }, options);
  44969. });
  44970. };
  44971. /**
  44972. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44973. * @param subMesh The submesh we want to render in the shadow map
  44974. * @param useInstances Defines wether will draw in the map using instances
  44975. * @returns true if ready otherwise, false
  44976. */
  44977. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  44978. var defines = [];
  44979. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44980. defines.push("#define FLOAT");
  44981. }
  44982. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44983. defines.push("#define ESM");
  44984. }
  44985. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  44986. defines.push("#define DEPTHTEXTURE");
  44987. }
  44988. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  44989. var mesh = subMesh.getMesh();
  44990. var material = subMesh.getMaterial();
  44991. // Normal bias.
  44992. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  44993. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  44994. defines.push("#define NORMAL");
  44995. if (mesh.nonUniformScaling) {
  44996. defines.push("#define NONUNIFORMSCALING");
  44997. }
  44998. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44999. defines.push("#define DIRECTIONINLIGHTDATA");
  45000. }
  45001. }
  45002. // Alpha test
  45003. if (material && material.needAlphaTesting()) {
  45004. var alphaTexture = material.getAlphaTestTexture();
  45005. if (alphaTexture) {
  45006. defines.push("#define ALPHATEST");
  45007. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45008. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45009. defines.push("#define UV1");
  45010. }
  45011. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45012. if (alphaTexture.coordinatesIndex === 1) {
  45013. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45014. defines.push("#define UV2");
  45015. }
  45016. }
  45017. }
  45018. }
  45019. // Bones
  45020. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45021. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45022. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45023. if (mesh.numBoneInfluencers > 4) {
  45024. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45025. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45026. }
  45027. var skeleton = mesh.skeleton;
  45028. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45029. if (skeleton.isUsingTextureForMatrices) {
  45030. defines.push("#define BONETEXTURE");
  45031. }
  45032. else {
  45033. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45034. }
  45035. }
  45036. else {
  45037. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45038. }
  45039. // Morph targets
  45040. var manager = mesh.morphTargetManager;
  45041. var morphInfluencers = 0;
  45042. if (manager) {
  45043. if (manager.numInfluencers > 0) {
  45044. defines.push("#define MORPHTARGETS");
  45045. morphInfluencers = manager.numInfluencers;
  45046. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45047. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45048. }
  45049. }
  45050. // Instances
  45051. if (useInstances) {
  45052. defines.push("#define INSTANCES");
  45053. attribs.push("world0");
  45054. attribs.push("world1");
  45055. attribs.push("world2");
  45056. attribs.push("world3");
  45057. }
  45058. if (this.customShaderOptions) {
  45059. if (this.customShaderOptions.defines) {
  45060. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45061. var define = _a[_i];
  45062. if (defines.indexOf(define) === -1) {
  45063. defines.push(define);
  45064. }
  45065. }
  45066. }
  45067. }
  45068. // Get correct effect
  45069. var join = defines.join("\n");
  45070. if (this._cachedDefines !== join) {
  45071. this._cachedDefines = join;
  45072. var shaderName = "shadowMap";
  45073. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45074. var samplers = ["diffuseSampler", "boneSampler"];
  45075. // Custom shader?
  45076. if (this.customShaderOptions) {
  45077. shaderName = this.customShaderOptions.shaderName;
  45078. if (this.customShaderOptions.attributes) {
  45079. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45080. var attrib = _c[_b];
  45081. if (attribs.indexOf(attrib) === -1) {
  45082. attribs.push(attrib);
  45083. }
  45084. }
  45085. }
  45086. if (this.customShaderOptions.uniforms) {
  45087. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45088. var uniform = _e[_d];
  45089. if (uniforms.indexOf(uniform) === -1) {
  45090. uniforms.push(uniform);
  45091. }
  45092. }
  45093. }
  45094. if (this.customShaderOptions.samplers) {
  45095. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45096. var sampler = _g[_f];
  45097. if (samplers.indexOf(sampler) === -1) {
  45098. samplers.push(sampler);
  45099. }
  45100. }
  45101. }
  45102. }
  45103. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45104. }
  45105. if (!this._effect.isReady()) {
  45106. return false;
  45107. }
  45108. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45109. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45110. this._initializeBlurRTTAndPostProcesses();
  45111. }
  45112. }
  45113. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45114. return false;
  45115. }
  45116. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45117. return false;
  45118. }
  45119. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45120. return false;
  45121. }
  45122. return true;
  45123. };
  45124. /**
  45125. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45126. * @param defines Defines of the material we want to update
  45127. * @param lightIndex Index of the light in the enabled light list of the material
  45128. */
  45129. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45130. var scene = this._scene;
  45131. var light = this._light;
  45132. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45133. return;
  45134. }
  45135. defines["SHADOW" + lightIndex] = true;
  45136. if (this.useContactHardeningShadow) {
  45137. defines["SHADOWPCSS" + lightIndex] = true;
  45138. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45139. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45140. }
  45141. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45142. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45143. }
  45144. // else default to high.
  45145. }
  45146. if (this.usePercentageCloserFiltering) {
  45147. defines["SHADOWPCF" + lightIndex] = true;
  45148. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45149. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45150. }
  45151. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45152. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45153. }
  45154. // else default to high.
  45155. }
  45156. else if (this.usePoissonSampling) {
  45157. defines["SHADOWPOISSON" + lightIndex] = true;
  45158. }
  45159. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45160. defines["SHADOWESM" + lightIndex] = true;
  45161. }
  45162. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45163. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45164. }
  45165. if (light.needCube()) {
  45166. defines["SHADOWCUBE" + lightIndex] = true;
  45167. }
  45168. };
  45169. /**
  45170. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45171. * defined in the generator but impacting the effect).
  45172. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45173. * @param effect The effect we are binfing the information for
  45174. */
  45175. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45176. var light = this._light;
  45177. var scene = this._scene;
  45178. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45179. return;
  45180. }
  45181. var camera = scene.activeCamera;
  45182. if (!camera) {
  45183. return;
  45184. }
  45185. var shadowMap = this.getShadowMap();
  45186. if (!shadowMap) {
  45187. return;
  45188. }
  45189. if (!light.needCube()) {
  45190. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45191. }
  45192. // Only PCF uses depth stencil texture.
  45193. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45194. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45195. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45196. }
  45197. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45198. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45199. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45200. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45201. }
  45202. else {
  45203. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45204. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45205. }
  45206. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45207. };
  45208. /**
  45209. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45210. * (eq to shadow prjection matrix * light transform matrix)
  45211. * @returns The transform matrix used to create the shadow map
  45212. */
  45213. ShadowGenerator.prototype.getTransformMatrix = function () {
  45214. var scene = this._scene;
  45215. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45216. return this._transformMatrix;
  45217. }
  45218. this._currentRenderID = scene.getRenderId();
  45219. this._currentFaceIndexCache = this._currentFaceIndex;
  45220. var lightPosition = this._light.position;
  45221. if (this._light.computeTransformedInformation()) {
  45222. lightPosition = this._light.transformedPosition;
  45223. }
  45224. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45225. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45226. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45227. }
  45228. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45229. this._cachedPosition.copyFrom(lightPosition);
  45230. this._cachedDirection.copyFrom(this._lightDirection);
  45231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45232. var shadowMap = this.getShadowMap();
  45233. if (shadowMap) {
  45234. var renderList = shadowMap.renderList;
  45235. if (renderList) {
  45236. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45237. }
  45238. }
  45239. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45240. }
  45241. return this._transformMatrix;
  45242. };
  45243. /**
  45244. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45245. * Cube and 2D textures for instance.
  45246. */
  45247. ShadowGenerator.prototype.recreateShadowMap = function () {
  45248. var shadowMap = this._shadowMap;
  45249. if (!shadowMap) {
  45250. return;
  45251. }
  45252. // Track render list.
  45253. var renderList = shadowMap.renderList;
  45254. // Clean up existing data.
  45255. this._disposeRTTandPostProcesses();
  45256. // Reinitializes.
  45257. this._initializeGenerator();
  45258. // Reaffect the filter to ensure a correct fallback if necessary.
  45259. this.filter = this.filter;
  45260. // Reaffect the filter.
  45261. this._applyFilterValues();
  45262. // Reaffect Render List.
  45263. this._shadowMap.renderList = renderList;
  45264. };
  45265. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45266. if (this._shadowMap2) {
  45267. this._shadowMap2.dispose();
  45268. this._shadowMap2 = null;
  45269. }
  45270. if (this._boxBlurPostprocess) {
  45271. this._boxBlurPostprocess.dispose();
  45272. this._boxBlurPostprocess = null;
  45273. }
  45274. if (this._kernelBlurXPostprocess) {
  45275. this._kernelBlurXPostprocess.dispose();
  45276. this._kernelBlurXPostprocess = null;
  45277. }
  45278. if (this._kernelBlurYPostprocess) {
  45279. this._kernelBlurYPostprocess.dispose();
  45280. this._kernelBlurYPostprocess = null;
  45281. }
  45282. this._blurPostProcesses = [];
  45283. };
  45284. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45285. if (this._shadowMap) {
  45286. this._shadowMap.dispose();
  45287. this._shadowMap = null;
  45288. }
  45289. this._disposeBlurPostProcesses();
  45290. };
  45291. /**
  45292. * Disposes the ShadowGenerator.
  45293. * Returns nothing.
  45294. */
  45295. ShadowGenerator.prototype.dispose = function () {
  45296. this._disposeRTTandPostProcesses();
  45297. if (this._light) {
  45298. this._light._shadowGenerator = null;
  45299. this._light._markMeshesAsLightDirty();
  45300. }
  45301. };
  45302. /**
  45303. * Serializes the shadow generator setup to a json object.
  45304. * @returns The serialized JSON object
  45305. */
  45306. ShadowGenerator.prototype.serialize = function () {
  45307. var serializationObject = {};
  45308. var shadowMap = this.getShadowMap();
  45309. if (!shadowMap) {
  45310. return serializationObject;
  45311. }
  45312. serializationObject.lightId = this._light.id;
  45313. serializationObject.mapSize = shadowMap.getRenderSize();
  45314. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45315. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45316. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45317. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45318. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45319. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45320. serializationObject.depthScale = this.depthScale;
  45321. serializationObject.darkness = this.getDarkness();
  45322. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45323. serializationObject.blurKernel = this.blurKernel;
  45324. serializationObject.blurScale = this.blurScale;
  45325. serializationObject.useKernelBlur = this.useKernelBlur;
  45326. serializationObject.transparencyShadow = this._transparencyShadow;
  45327. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45328. serializationObject.bias = this.bias;
  45329. serializationObject.normalBias = this.normalBias;
  45330. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45331. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45332. serializationObject.filteringQuality = this.filteringQuality;
  45333. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45334. serializationObject.renderList = [];
  45335. if (shadowMap.renderList) {
  45336. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45337. var mesh = shadowMap.renderList[meshIndex];
  45338. serializationObject.renderList.push(mesh.id);
  45339. }
  45340. }
  45341. return serializationObject;
  45342. };
  45343. /**
  45344. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45345. * @param parsedShadowGenerator The JSON object to parse
  45346. * @param scene The scene to create the shadow map for
  45347. * @returns The parsed shadow generator
  45348. */
  45349. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45350. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45351. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45352. var shadowMap = shadowGenerator.getShadowMap();
  45353. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45354. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45355. meshes.forEach(function (mesh) {
  45356. if (!shadowMap) {
  45357. return;
  45358. }
  45359. if (!shadowMap.renderList) {
  45360. shadowMap.renderList = [];
  45361. }
  45362. shadowMap.renderList.push(mesh);
  45363. });
  45364. }
  45365. if (parsedShadowGenerator.usePoissonSampling) {
  45366. shadowGenerator.usePoissonSampling = true;
  45367. }
  45368. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45369. shadowGenerator.useExponentialShadowMap = true;
  45370. }
  45371. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45372. shadowGenerator.useBlurExponentialShadowMap = true;
  45373. }
  45374. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45375. shadowGenerator.useCloseExponentialShadowMap = true;
  45376. }
  45377. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45378. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45379. }
  45380. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45381. shadowGenerator.usePercentageCloserFiltering = true;
  45382. }
  45383. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45384. shadowGenerator.useContactHardeningShadow = true;
  45385. }
  45386. if (parsedShadowGenerator.filteringQuality) {
  45387. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45388. }
  45389. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45390. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45391. }
  45392. // Backward compat
  45393. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45394. shadowGenerator.useExponentialShadowMap = true;
  45395. }
  45396. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45397. shadowGenerator.useBlurExponentialShadowMap = true;
  45398. }
  45399. if (parsedShadowGenerator.depthScale) {
  45400. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45401. }
  45402. if (parsedShadowGenerator.blurScale) {
  45403. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45404. }
  45405. if (parsedShadowGenerator.blurBoxOffset) {
  45406. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45407. }
  45408. if (parsedShadowGenerator.useKernelBlur) {
  45409. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45410. }
  45411. if (parsedShadowGenerator.blurKernel) {
  45412. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45413. }
  45414. if (parsedShadowGenerator.bias !== undefined) {
  45415. shadowGenerator.bias = parsedShadowGenerator.bias;
  45416. }
  45417. if (parsedShadowGenerator.normalBias !== undefined) {
  45418. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45419. }
  45420. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45421. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45422. }
  45423. if (parsedShadowGenerator.darkness) {
  45424. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45425. }
  45426. if (parsedShadowGenerator.transparencyShadow) {
  45427. shadowGenerator.setTransparencyShadow(true);
  45428. }
  45429. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45430. return shadowGenerator;
  45431. };
  45432. /**
  45433. * Shadow generator mode None: no filtering applied.
  45434. */
  45435. ShadowGenerator.FILTER_NONE = 0;
  45436. /**
  45437. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45439. */
  45440. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45441. /**
  45442. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45443. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45444. */
  45445. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45446. /**
  45447. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45448. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45449. */
  45450. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45451. /**
  45452. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45453. * edge artifacts on steep falloff.
  45454. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45455. */
  45456. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45457. /**
  45458. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45459. * edge artifacts on steep falloff.
  45460. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45461. */
  45462. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45463. /**
  45464. * Shadow generator mode PCF: Percentage Closer Filtering
  45465. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45466. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45467. */
  45468. ShadowGenerator.FILTER_PCF = 6;
  45469. /**
  45470. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45471. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45472. * Contact Hardening
  45473. */
  45474. ShadowGenerator.FILTER_PCSS = 7;
  45475. /**
  45476. * Reserved for PCF and PCSS
  45477. * Highest Quality.
  45478. *
  45479. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45480. *
  45481. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45482. */
  45483. ShadowGenerator.QUALITY_HIGH = 0;
  45484. /**
  45485. * Reserved for PCF and PCSS
  45486. * Good tradeoff for quality/perf cross devices
  45487. *
  45488. * Execute PCF on a 3*3 kernel.
  45489. *
  45490. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45491. */
  45492. ShadowGenerator.QUALITY_MEDIUM = 1;
  45493. /**
  45494. * Reserved for PCF and PCSS
  45495. * The lowest quality but the fastest.
  45496. *
  45497. * Execute PCF on a 1*1 kernel.
  45498. *
  45499. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45500. */
  45501. ShadowGenerator.QUALITY_LOW = 2;
  45502. /** @hidden */
  45503. ShadowGenerator._SceneComponentInitialization = function (_) {
  45504. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  45505. };
  45506. return ShadowGenerator;
  45507. }());
  45508. /***/ }),
  45509. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45510. /*!*********************************************************!*\
  45511. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45512. \*********************************************************/
  45513. /*! exports provided: ShadowGeneratorSceneComponent */
  45514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45515. "use strict";
  45516. __webpack_require__.r(__webpack_exports__);
  45517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45518. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45519. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45520. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45521. // Adds the parser to the scene parsers.
  45522. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45523. // Shadows
  45524. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45525. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45526. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45527. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45528. // SG would be available on their associated lights
  45529. }
  45530. }
  45531. });
  45532. /**
  45533. * Defines the shadow generator component responsible to manage any shadow generators
  45534. * in a given scene.
  45535. */
  45536. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45537. /**
  45538. * Creates a new instance of the component for the given scene
  45539. * @param scene Defines the scene to register the component in
  45540. */
  45541. function ShadowGeneratorSceneComponent(scene) {
  45542. /**
  45543. * The component name helpfull to identify the component in the list of scene components.
  45544. */
  45545. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45546. this.scene = scene;
  45547. }
  45548. /**
  45549. * Registers the component in a given scene
  45550. */
  45551. ShadowGeneratorSceneComponent.prototype.register = function () {
  45552. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45553. };
  45554. /**
  45555. * Rebuilds the elements related to this component in case of
  45556. * context lost for instance.
  45557. */
  45558. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45559. // Nothing To Do Here.
  45560. };
  45561. /**
  45562. * Serializes the component data to the specified json object
  45563. * @param serializationObject The object to serialize to
  45564. */
  45565. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45566. // Shadows
  45567. serializationObject.shadowGenerators = [];
  45568. var lights = this.scene.lights;
  45569. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45570. var light = lights_1[_i];
  45571. var shadowGenerator = light.getShadowGenerator();
  45572. if (shadowGenerator) {
  45573. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45574. }
  45575. }
  45576. };
  45577. /**
  45578. * Adds all the element from the container to the scene
  45579. * @param container the container holding the elements
  45580. */
  45581. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45582. // Nothing To Do Here. (directly attached to a light)
  45583. };
  45584. /**
  45585. * Removes all the elements in the container from the scene
  45586. * @param container contains the elements to remove
  45587. */
  45588. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45589. // Nothing To Do Here. (directly attached to a light)
  45590. };
  45591. /**
  45592. * Rebuilds the elements related to this component in case of
  45593. * context lost for instance.
  45594. */
  45595. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45596. // Nothing To Do Here.
  45597. };
  45598. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45599. // Shadows
  45600. var scene = this.scene;
  45601. if (this.scene.shadowsEnabled) {
  45602. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45603. var light = scene.lights[lightIndex];
  45604. var shadowGenerator = light.getShadowGenerator();
  45605. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45606. var shadowMap = (shadowGenerator.getShadowMap());
  45607. if (scene.textures.indexOf(shadowMap) !== -1) {
  45608. renderTargets.push(shadowMap);
  45609. }
  45610. }
  45611. }
  45612. }
  45613. };
  45614. return ShadowGeneratorSceneComponent;
  45615. }());
  45616. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45617. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45618. if (!component) {
  45619. component = new ShadowGeneratorSceneComponent(scene);
  45620. scene._addComponent(component);
  45621. }
  45622. };
  45623. /***/ }),
  45624. /***/ "./Lights/directionalLight.ts":
  45625. /*!************************************!*\
  45626. !*** ./Lights/directionalLight.ts ***!
  45627. \************************************/
  45628. /*! exports provided: DirectionalLight */
  45629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45630. "use strict";
  45631. __webpack_require__.r(__webpack_exports__);
  45632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45633. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45634. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45635. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45636. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45637. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45638. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45639. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45640. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45641. });
  45642. /**
  45643. * A directional light is defined by a direction (what a surprise!).
  45644. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45645. * 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.
  45646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45647. */
  45648. var DirectionalLight = /** @class */ (function (_super) {
  45649. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45650. /**
  45651. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45652. * The directional light is emitted from everywhere in the given direction.
  45653. * It can cast shadows.
  45654. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45655. * @param name The friendly name of the light
  45656. * @param direction The direction of the light
  45657. * @param scene The scene the light belongs to
  45658. */
  45659. function DirectionalLight(name, direction, scene) {
  45660. var _this = _super.call(this, name, scene) || this;
  45661. _this._shadowFrustumSize = 0;
  45662. _this._shadowOrthoScale = 0.1;
  45663. /**
  45664. * Automatically compute the projection matrix to best fit (including all the casters)
  45665. * on each frame.
  45666. */
  45667. _this.autoUpdateExtends = true;
  45668. // Cache
  45669. _this._orthoLeft = Number.MAX_VALUE;
  45670. _this._orthoRight = Number.MIN_VALUE;
  45671. _this._orthoTop = Number.MIN_VALUE;
  45672. _this._orthoBottom = Number.MAX_VALUE;
  45673. _this.position = direction.scale(-1.0);
  45674. _this.direction = direction;
  45675. return _this;
  45676. }
  45677. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45678. /**
  45679. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45680. */
  45681. get: function () {
  45682. return this._shadowFrustumSize;
  45683. },
  45684. /**
  45685. * Specifies a fix frustum size for the shadow generation.
  45686. */
  45687. set: function (value) {
  45688. this._shadowFrustumSize = value;
  45689. this.forceProjectionMatrixCompute();
  45690. },
  45691. enumerable: true,
  45692. configurable: true
  45693. });
  45694. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45695. /**
  45696. * Gets the shadow projection scale against the optimal computed one.
  45697. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45698. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45699. */
  45700. get: function () {
  45701. return this._shadowOrthoScale;
  45702. },
  45703. /**
  45704. * Sets the shadow projection scale against the optimal computed one.
  45705. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45706. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45707. */
  45708. set: function (value) {
  45709. this._shadowOrthoScale = value;
  45710. this.forceProjectionMatrixCompute();
  45711. },
  45712. enumerable: true,
  45713. configurable: true
  45714. });
  45715. /**
  45716. * Returns the string "DirectionalLight".
  45717. * @return The class name
  45718. */
  45719. DirectionalLight.prototype.getClassName = function () {
  45720. return "DirectionalLight";
  45721. };
  45722. /**
  45723. * Returns the integer 1.
  45724. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45725. */
  45726. DirectionalLight.prototype.getTypeID = function () {
  45727. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45728. };
  45729. /**
  45730. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45731. * Returns the DirectionalLight Shadow projection matrix.
  45732. */
  45733. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45734. if (this.shadowFrustumSize > 0) {
  45735. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45736. }
  45737. else {
  45738. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45739. }
  45740. };
  45741. /**
  45742. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45743. * Returns the DirectionalLight Shadow projection matrix.
  45744. */
  45745. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45746. var activeCamera = this.getScene().activeCamera;
  45747. if (!activeCamera) {
  45748. return;
  45749. }
  45750. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  45751. };
  45752. /**
  45753. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45754. * Returns the DirectionalLight Shadow projection matrix.
  45755. */
  45756. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45757. var activeCamera = this.getScene().activeCamera;
  45758. if (!activeCamera) {
  45759. return;
  45760. }
  45761. // Check extends
  45762. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45763. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45764. this._orthoLeft = Number.MAX_VALUE;
  45765. this._orthoRight = Number.MIN_VALUE;
  45766. this._orthoTop = Number.MIN_VALUE;
  45767. this._orthoBottom = Number.MAX_VALUE;
  45768. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45769. var mesh = renderList[meshIndex];
  45770. if (!mesh) {
  45771. continue;
  45772. }
  45773. var boundingInfo = mesh.getBoundingInfo();
  45774. var boundingBox = boundingInfo.boundingBox;
  45775. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45776. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45777. if (tempVector3.x < this._orthoLeft) {
  45778. this._orthoLeft = tempVector3.x;
  45779. }
  45780. if (tempVector3.y < this._orthoBottom) {
  45781. this._orthoBottom = tempVector3.y;
  45782. }
  45783. if (tempVector3.x > this._orthoRight) {
  45784. this._orthoRight = tempVector3.x;
  45785. }
  45786. if (tempVector3.y > this._orthoTop) {
  45787. this._orthoTop = tempVector3.y;
  45788. }
  45789. }
  45790. }
  45791. }
  45792. var xOffset = this._orthoRight - this._orthoLeft;
  45793. var yOffset = this._orthoTop - this._orthoBottom;
  45794. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale, this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  45795. };
  45796. DirectionalLight.prototype._buildUniformLayout = function () {
  45797. this._uniformBuffer.addUniform("vLightData", 4);
  45798. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45799. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45800. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45801. this._uniformBuffer.addUniform("depthValues", 2);
  45802. this._uniformBuffer.create();
  45803. };
  45804. /**
  45805. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45806. * @param effect The effect to update
  45807. * @param lightIndex The index of the light in the effect to update
  45808. * @returns The directional light
  45809. */
  45810. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45811. if (this.computeTransformedInformation()) {
  45812. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45813. return this;
  45814. }
  45815. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45816. return this;
  45817. };
  45818. /**
  45819. * Gets the minZ used for shadow according to both the scene and the light.
  45820. *
  45821. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45822. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45823. * @param activeCamera The camera we are returning the min for
  45824. * @returns the depth min z
  45825. */
  45826. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45827. return 1;
  45828. };
  45829. /**
  45830. * Gets the maxZ used for shadow according to both the scene and the light.
  45831. *
  45832. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45833. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45834. * @param activeCamera The camera we are returning the max for
  45835. * @returns the depth max z
  45836. */
  45837. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45838. return 1;
  45839. };
  45840. /**
  45841. * Prepares the list of defines specific to the light type.
  45842. * @param defines the list of defines
  45843. * @param lightIndex defines the index of the light for the effect
  45844. */
  45845. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45846. defines["DIRLIGHT" + lightIndex] = true;
  45847. };
  45848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45850. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45853. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45856. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45857. return DirectionalLight;
  45858. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45859. /***/ }),
  45860. /***/ "./Lights/hemisphericLight.ts":
  45861. /*!************************************!*\
  45862. !*** ./Lights/hemisphericLight.ts ***!
  45863. \************************************/
  45864. /*! exports provided: HemisphericLight */
  45865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45866. "use strict";
  45867. __webpack_require__.r(__webpack_exports__);
  45868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45870. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45871. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45872. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45873. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45874. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45875. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45876. });
  45877. /**
  45878. * The HemisphericLight simulates the ambient environment light,
  45879. * so the passed direction is the light reflection direction, not the incoming direction.
  45880. */
  45881. var HemisphericLight = /** @class */ (function (_super) {
  45882. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  45883. /**
  45884. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  45885. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  45886. * The HemisphericLight can't cast shadows.
  45887. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45888. * @param name The friendly name of the light
  45889. * @param direction The direction of the light reflection
  45890. * @param scene The scene the light belongs to
  45891. */
  45892. function HemisphericLight(name, direction, scene) {
  45893. var _this = _super.call(this, name, scene) || this;
  45894. /**
  45895. * The groundColor is the light in the opposite direction to the one specified during creation.
  45896. * 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.
  45897. */
  45898. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  45899. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  45900. return _this;
  45901. }
  45902. HemisphericLight.prototype._buildUniformLayout = function () {
  45903. this._uniformBuffer.addUniform("vLightData", 4);
  45904. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45905. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45906. this._uniformBuffer.addUniform("vLightGround", 3);
  45907. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45908. this._uniformBuffer.addUniform("depthValues", 2);
  45909. this._uniformBuffer.create();
  45910. };
  45911. /**
  45912. * Returns the string "HemisphericLight".
  45913. * @return The class name
  45914. */
  45915. HemisphericLight.prototype.getClassName = function () {
  45916. return "HemisphericLight";
  45917. };
  45918. /**
  45919. * Sets the HemisphericLight direction towards the passed target (Vector3).
  45920. * Returns the updated direction.
  45921. * @param target The target the direction should point to
  45922. * @return The computed direction
  45923. */
  45924. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  45925. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  45926. return this.direction;
  45927. };
  45928. /**
  45929. * Returns the shadow generator associated to the light.
  45930. * @returns Always null for hemispheric lights because it does not support shadows.
  45931. */
  45932. HemisphericLight.prototype.getShadowGenerator = function () {
  45933. return null;
  45934. };
  45935. /**
  45936. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  45937. * @param effect The effect to update
  45938. * @param lightIndex The index of the light in the effect to update
  45939. * @returns The hemispheric light
  45940. */
  45941. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  45942. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  45943. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  45944. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  45945. return this;
  45946. };
  45947. /**
  45948. * Computes the world matrix of the node
  45949. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  45950. * @param useWasUpdatedFlag defines a reserved property
  45951. * @returns the world matrix
  45952. */
  45953. HemisphericLight.prototype.computeWorldMatrix = function () {
  45954. if (!this._worldMatrix) {
  45955. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  45956. }
  45957. return this._worldMatrix;
  45958. };
  45959. /**
  45960. * Returns the integer 3.
  45961. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45962. */
  45963. HemisphericLight.prototype.getTypeID = function () {
  45964. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  45965. };
  45966. /**
  45967. * Prepares the list of defines specific to the light type.
  45968. * @param defines the list of defines
  45969. * @param lightIndex defines the index of the light for the effect
  45970. */
  45971. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45972. defines["HEMILIGHT" + lightIndex] = true;
  45973. };
  45974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45976. ], HemisphericLight.prototype, "groundColor", void 0);
  45977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  45979. ], HemisphericLight.prototype, "direction", void 0);
  45980. return HemisphericLight;
  45981. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  45982. /***/ }),
  45983. /***/ "./Lights/index.ts":
  45984. /*!*************************!*\
  45985. !*** ./Lights/index.ts ***!
  45986. \*************************/
  45987. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  45988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45989. "use strict";
  45990. __webpack_require__.r(__webpack_exports__);
  45991. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45993. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  45995. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  45996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  45997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  45998. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  45999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46000. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46002. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46004. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46006. /***/ }),
  46007. /***/ "./Lights/light.ts":
  46008. /*!*************************!*\
  46009. !*** ./Lights/light.ts ***!
  46010. \*************************/
  46011. /*! exports provided: Light */
  46012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46013. "use strict";
  46014. __webpack_require__.r(__webpack_exports__);
  46015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46017. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46018. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46019. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46020. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46021. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46022. /**
  46023. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46024. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46025. * 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.
  46026. */
  46027. var Light = /** @class */ (function (_super) {
  46028. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46029. /**
  46030. * Creates a Light object in the scene.
  46031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46032. * @param name The firendly name of the light
  46033. * @param scene The scene the light belongs too
  46034. */
  46035. function Light(name, scene) {
  46036. var _this = _super.call(this, name, scene) || this;
  46037. /**
  46038. * Diffuse gives the basic color to an object.
  46039. */
  46040. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46041. /**
  46042. * Specular produces a highlight color on an object.
  46043. * Note: This is note affecting PBR materials.
  46044. */
  46045. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46046. /**
  46047. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46048. * falling off base on range or angle.
  46049. * This can be set to any values in Light.FALLOFF_x.
  46050. *
  46051. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46052. * other types of materials.
  46053. */
  46054. _this.falloffType = Light.FALLOFF_DEFAULT;
  46055. /**
  46056. * Strength of the light.
  46057. * Note: By default it is define in the framework own unit.
  46058. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46059. */
  46060. _this.intensity = 1.0;
  46061. _this._range = Number.MAX_VALUE;
  46062. _this._inverseSquaredRange = 0;
  46063. /**
  46064. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46065. * of light.
  46066. */
  46067. _this._photometricScale = 1.0;
  46068. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46069. _this._radius = 0.00001;
  46070. /**
  46071. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46072. * exceeding the number allowed of the materials.
  46073. */
  46074. _this.renderPriority = 0;
  46075. _this._shadowEnabled = true;
  46076. _this._excludeWithLayerMask = 0;
  46077. _this._includeOnlyWithLayerMask = 0;
  46078. _this._lightmapMode = 0;
  46079. /**
  46080. * @hidden Internal use only.
  46081. */
  46082. _this._excludedMeshesIds = new Array();
  46083. /**
  46084. * @hidden Internal use only.
  46085. */
  46086. _this._includedOnlyMeshesIds = new Array();
  46087. /** @hidden */
  46088. _this._isLight = true;
  46089. _this.getScene().addLight(_this);
  46090. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46091. _this._buildUniformLayout();
  46092. _this.includedOnlyMeshes = new Array();
  46093. _this.excludedMeshes = new Array();
  46094. _this._resyncMeshes();
  46095. return _this;
  46096. }
  46097. Object.defineProperty(Light.prototype, "range", {
  46098. /**
  46099. * Defines how far from the source the light is impacting in scene units.
  46100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46101. */
  46102. get: function () {
  46103. return this._range;
  46104. },
  46105. /**
  46106. * Defines how far from the source the light is impacting in scene units.
  46107. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46108. */
  46109. set: function (value) {
  46110. this._range = value;
  46111. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46112. },
  46113. enumerable: true,
  46114. configurable: true
  46115. });
  46116. Object.defineProperty(Light.prototype, "intensityMode", {
  46117. /**
  46118. * Gets the photometric scale used to interpret the intensity.
  46119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46120. */
  46121. get: function () {
  46122. return this._intensityMode;
  46123. },
  46124. /**
  46125. * Sets the photometric scale used to interpret the intensity.
  46126. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46127. */
  46128. set: function (value) {
  46129. this._intensityMode = value;
  46130. this._computePhotometricScale();
  46131. },
  46132. enumerable: true,
  46133. configurable: true
  46134. });
  46135. Object.defineProperty(Light.prototype, "radius", {
  46136. /**
  46137. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46138. */
  46139. get: function () {
  46140. return this._radius;
  46141. },
  46142. /**
  46143. * sets the light radius used by PBR Materials to simulate soft area lights.
  46144. */
  46145. set: function (value) {
  46146. this._radius = value;
  46147. this._computePhotometricScale();
  46148. },
  46149. enumerable: true,
  46150. configurable: true
  46151. });
  46152. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46153. /**
  46154. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46155. * the current shadow generator.
  46156. */
  46157. get: function () {
  46158. return this._shadowEnabled;
  46159. },
  46160. /**
  46161. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46162. * the current shadow generator.
  46163. */
  46164. set: function (value) {
  46165. if (this._shadowEnabled === value) {
  46166. return;
  46167. }
  46168. this._shadowEnabled = value;
  46169. this._markMeshesAsLightDirty();
  46170. },
  46171. enumerable: true,
  46172. configurable: true
  46173. });
  46174. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46175. /**
  46176. * Gets the only meshes impacted by this light.
  46177. */
  46178. get: function () {
  46179. return this._includedOnlyMeshes;
  46180. },
  46181. /**
  46182. * Sets the only meshes impacted by this light.
  46183. */
  46184. set: function (value) {
  46185. this._includedOnlyMeshes = value;
  46186. this._hookArrayForIncludedOnly(value);
  46187. },
  46188. enumerable: true,
  46189. configurable: true
  46190. });
  46191. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46192. /**
  46193. * Gets the meshes not impacted by this light.
  46194. */
  46195. get: function () {
  46196. return this._excludedMeshes;
  46197. },
  46198. /**
  46199. * Sets the meshes not impacted by this light.
  46200. */
  46201. set: function (value) {
  46202. this._excludedMeshes = value;
  46203. this._hookArrayForExcluded(value);
  46204. },
  46205. enumerable: true,
  46206. configurable: true
  46207. });
  46208. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46209. /**
  46210. * Gets the layer id use to find what meshes are not impacted by the light.
  46211. * Inactive if 0
  46212. */
  46213. get: function () {
  46214. return this._excludeWithLayerMask;
  46215. },
  46216. /**
  46217. * Sets the layer id use to find what meshes are not impacted by the light.
  46218. * Inactive if 0
  46219. */
  46220. set: function (value) {
  46221. this._excludeWithLayerMask = value;
  46222. this._resyncMeshes();
  46223. },
  46224. enumerable: true,
  46225. configurable: true
  46226. });
  46227. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46228. /**
  46229. * Gets the layer id use to find what meshes are impacted by the light.
  46230. * Inactive if 0
  46231. */
  46232. get: function () {
  46233. return this._includeOnlyWithLayerMask;
  46234. },
  46235. /**
  46236. * Sets the layer id use to find what meshes are impacted by the light.
  46237. * Inactive if 0
  46238. */
  46239. set: function (value) {
  46240. this._includeOnlyWithLayerMask = value;
  46241. this._resyncMeshes();
  46242. },
  46243. enumerable: true,
  46244. configurable: true
  46245. });
  46246. Object.defineProperty(Light.prototype, "lightmapMode", {
  46247. /**
  46248. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46249. */
  46250. get: function () {
  46251. return this._lightmapMode;
  46252. },
  46253. /**
  46254. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46255. */
  46256. set: function (value) {
  46257. if (this._lightmapMode === value) {
  46258. return;
  46259. }
  46260. this._lightmapMode = value;
  46261. this._markMeshesAsLightDirty();
  46262. },
  46263. enumerable: true,
  46264. configurable: true
  46265. });
  46266. /**
  46267. * Returns the string "Light".
  46268. * @returns the class name
  46269. */
  46270. Light.prototype.getClassName = function () {
  46271. return "Light";
  46272. };
  46273. /**
  46274. * Converts the light information to a readable string for debug purpose.
  46275. * @param fullDetails Supports for multiple levels of logging within scene loading
  46276. * @returns the human readable light info
  46277. */
  46278. Light.prototype.toString = function (fullDetails) {
  46279. var ret = "Name: " + this.name;
  46280. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46281. if (this.animations) {
  46282. for (var i = 0; i < this.animations.length; i++) {
  46283. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46284. }
  46285. }
  46286. if (fullDetails) {
  46287. }
  46288. return ret;
  46289. };
  46290. /** @hidden */
  46291. Light.prototype._syncParentEnabledState = function () {
  46292. _super.prototype._syncParentEnabledState.call(this);
  46293. this._resyncMeshes();
  46294. };
  46295. /**
  46296. * Set the enabled state of this node.
  46297. * @param value - the new enabled state
  46298. */
  46299. Light.prototype.setEnabled = function (value) {
  46300. _super.prototype.setEnabled.call(this, value);
  46301. this._resyncMeshes();
  46302. };
  46303. /**
  46304. * Returns the Light associated shadow generator if any.
  46305. * @return the associated shadow generator.
  46306. */
  46307. Light.prototype.getShadowGenerator = function () {
  46308. return this._shadowGenerator;
  46309. };
  46310. /**
  46311. * Returns a Vector3, the absolute light position in the World.
  46312. * @returns the world space position of the light
  46313. */
  46314. Light.prototype.getAbsolutePosition = function () {
  46315. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46316. };
  46317. /**
  46318. * Specifies if the light will affect the passed mesh.
  46319. * @param mesh The mesh to test against the light
  46320. * @return true the mesh is affected otherwise, false.
  46321. */
  46322. Light.prototype.canAffectMesh = function (mesh) {
  46323. if (!mesh) {
  46324. return true;
  46325. }
  46326. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46327. return false;
  46328. }
  46329. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46330. return false;
  46331. }
  46332. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46333. return false;
  46334. }
  46335. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46336. return false;
  46337. }
  46338. return true;
  46339. };
  46340. /**
  46341. * Sort function to order lights for rendering.
  46342. * @param a First Light object to compare to second.
  46343. * @param b Second Light object to compare first.
  46344. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46345. */
  46346. Light.CompareLightsPriority = function (a, b) {
  46347. //shadow-casting lights have priority over non-shadow-casting lights
  46348. //the renderPrioirty is a secondary sort criterion
  46349. if (a.shadowEnabled !== b.shadowEnabled) {
  46350. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46351. }
  46352. return b.renderPriority - a.renderPriority;
  46353. };
  46354. /**
  46355. * Releases resources associated with this node.
  46356. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46357. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46358. */
  46359. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46360. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46361. if (this._shadowGenerator) {
  46362. this._shadowGenerator.dispose();
  46363. this._shadowGenerator = null;
  46364. }
  46365. // Animations
  46366. this.getScene().stopAnimation(this);
  46367. // Remove from meshes
  46368. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46369. var mesh = _a[_i];
  46370. mesh._removeLightSource(this);
  46371. }
  46372. this._uniformBuffer.dispose();
  46373. // Remove from scene
  46374. this.getScene().removeLight(this);
  46375. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46376. };
  46377. /**
  46378. * Returns the light type ID (integer).
  46379. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46380. */
  46381. Light.prototype.getTypeID = function () {
  46382. return 0;
  46383. };
  46384. /**
  46385. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46386. * @returns the scaled intensity in intensity mode unit
  46387. */
  46388. Light.prototype.getScaledIntensity = function () {
  46389. return this._photometricScale * this.intensity;
  46390. };
  46391. /**
  46392. * Returns a new Light object, named "name", from the current one.
  46393. * @param name The name of the cloned light
  46394. * @returns the new created light
  46395. */
  46396. Light.prototype.clone = function (name) {
  46397. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46398. if (!constructor) {
  46399. return null;
  46400. }
  46401. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46402. };
  46403. /**
  46404. * Serializes the current light into a Serialization object.
  46405. * @returns the serialized object.
  46406. */
  46407. Light.prototype.serialize = function () {
  46408. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46409. // Type
  46410. serializationObject.type = this.getTypeID();
  46411. // Parent
  46412. if (this.parent) {
  46413. serializationObject.parentId = this.parent.id;
  46414. }
  46415. // Inclusion / exclusions
  46416. if (this.excludedMeshes.length > 0) {
  46417. serializationObject.excludedMeshesIds = [];
  46418. this.excludedMeshes.forEach(function (mesh) {
  46419. serializationObject.excludedMeshesIds.push(mesh.id);
  46420. });
  46421. }
  46422. if (this.includedOnlyMeshes.length > 0) {
  46423. serializationObject.includedOnlyMeshesIds = [];
  46424. this.includedOnlyMeshes.forEach(function (mesh) {
  46425. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46426. });
  46427. }
  46428. // Animations
  46429. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46430. serializationObject.ranges = this.serializeAnimationRanges();
  46431. return serializationObject;
  46432. };
  46433. /**
  46434. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46435. * This new light is named "name" and added to the passed scene.
  46436. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46437. * @param name The friendly name of the light
  46438. * @param scene The scene the new light will belong to
  46439. * @returns the constructor function
  46440. */
  46441. Light.GetConstructorFromName = function (type, name, scene) {
  46442. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46443. if (constructorFunc) {
  46444. return constructorFunc;
  46445. }
  46446. // Default to no light for none present once.
  46447. return null;
  46448. };
  46449. /**
  46450. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46451. * @param parsedLight The JSON representation of the light
  46452. * @param scene The scene to create the parsed light in
  46453. * @returns the created light after parsing
  46454. */
  46455. Light.Parse = function (parsedLight, scene) {
  46456. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46457. if (!constructor) {
  46458. return null;
  46459. }
  46460. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46461. // Inclusion / exclusions
  46462. if (parsedLight.excludedMeshesIds) {
  46463. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46464. }
  46465. if (parsedLight.includedOnlyMeshesIds) {
  46466. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46467. }
  46468. // Parent
  46469. if (parsedLight.parentId) {
  46470. light._waitingParentId = parsedLight.parentId;
  46471. }
  46472. // Animations
  46473. if (parsedLight.animations) {
  46474. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46475. var parsedAnimation = parsedLight.animations[animationIndex];
  46476. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46477. if (internalClass) {
  46478. light.animations.push(internalClass.Parse(parsedAnimation));
  46479. }
  46480. }
  46481. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46482. }
  46483. if (parsedLight.autoAnimate) {
  46484. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46485. }
  46486. return light;
  46487. };
  46488. Light.prototype._hookArrayForExcluded = function (array) {
  46489. var _this = this;
  46490. var oldPush = array.push;
  46491. array.push = function () {
  46492. var items = [];
  46493. for (var _i = 0; _i < arguments.length; _i++) {
  46494. items[_i] = arguments[_i];
  46495. }
  46496. var result = oldPush.apply(array, items);
  46497. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46498. var item = items_1[_a];
  46499. item._resyncLighSource(_this);
  46500. }
  46501. return result;
  46502. };
  46503. var oldSplice = array.splice;
  46504. array.splice = function (index, deleteCount) {
  46505. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46506. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46507. var item = deleted_1[_i];
  46508. item._resyncLighSource(_this);
  46509. }
  46510. return deleted;
  46511. };
  46512. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46513. var item = array_1[_i];
  46514. item._resyncLighSource(this);
  46515. }
  46516. };
  46517. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46518. var _this = this;
  46519. var oldPush = array.push;
  46520. array.push = function () {
  46521. var items = [];
  46522. for (var _i = 0; _i < arguments.length; _i++) {
  46523. items[_i] = arguments[_i];
  46524. }
  46525. var result = oldPush.apply(array, items);
  46526. _this._resyncMeshes();
  46527. return result;
  46528. };
  46529. var oldSplice = array.splice;
  46530. array.splice = function (index, deleteCount) {
  46531. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46532. _this._resyncMeshes();
  46533. return deleted;
  46534. };
  46535. this._resyncMeshes();
  46536. };
  46537. Light.prototype._resyncMeshes = function () {
  46538. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46539. var mesh = _a[_i];
  46540. mesh._resyncLighSource(this);
  46541. }
  46542. };
  46543. /**
  46544. * Forces the meshes to update their light related information in their rendering used effects
  46545. * @hidden Internal Use Only
  46546. */
  46547. Light.prototype._markMeshesAsLightDirty = function () {
  46548. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46549. var mesh = _a[_i];
  46550. if (mesh._lightSources.indexOf(this) !== -1) {
  46551. mesh._markSubMeshesAsLightDirty();
  46552. }
  46553. }
  46554. };
  46555. /**
  46556. * Recomputes the cached photometric scale if needed.
  46557. */
  46558. Light.prototype._computePhotometricScale = function () {
  46559. this._photometricScale = this._getPhotometricScale();
  46560. this.getScene().resetCachedMaterial();
  46561. };
  46562. /**
  46563. * Returns the Photometric Scale according to the light type and intensity mode.
  46564. */
  46565. Light.prototype._getPhotometricScale = function () {
  46566. var photometricScale = 0.0;
  46567. var lightTypeID = this.getTypeID();
  46568. //get photometric mode
  46569. var photometricMode = this.intensityMode;
  46570. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46571. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46572. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46573. }
  46574. else {
  46575. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46576. }
  46577. }
  46578. //compute photometric scale
  46579. switch (lightTypeID) {
  46580. case Light.LIGHTTYPEID_POINTLIGHT:
  46581. case Light.LIGHTTYPEID_SPOTLIGHT:
  46582. switch (photometricMode) {
  46583. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46584. photometricScale = 1.0 / (4.0 * Math.PI);
  46585. break;
  46586. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46587. photometricScale = 1.0;
  46588. break;
  46589. case Light.INTENSITYMODE_LUMINANCE:
  46590. photometricScale = this.radius * this.radius;
  46591. break;
  46592. }
  46593. break;
  46594. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46595. switch (photometricMode) {
  46596. case Light.INTENSITYMODE_ILLUMINANCE:
  46597. photometricScale = 1.0;
  46598. break;
  46599. case Light.INTENSITYMODE_LUMINANCE:
  46600. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46601. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46602. var apexAngleRadians = this.radius;
  46603. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46604. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46605. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46606. photometricScale = solidAngle;
  46607. break;
  46608. }
  46609. break;
  46610. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46611. // No fall off in hemisperic light.
  46612. photometricScale = 1.0;
  46613. break;
  46614. }
  46615. return photometricScale;
  46616. };
  46617. /**
  46618. * Reorder the light in the scene according to their defined priority.
  46619. * @hidden Internal Use Only
  46620. */
  46621. Light.prototype._reorderLightsInScene = function () {
  46622. var scene = this.getScene();
  46623. if (this._renderPriority != 0) {
  46624. scene.requireLightSorting = true;
  46625. }
  46626. this.getScene().sortLightsByPriority();
  46627. };
  46628. /**
  46629. * Falloff Default: light is falling off following the material specification:
  46630. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46631. */
  46632. Light.FALLOFF_DEFAULT = 0;
  46633. /**
  46634. * Falloff Physical: light is falling off following the inverse squared distance law.
  46635. */
  46636. Light.FALLOFF_PHYSICAL = 1;
  46637. /**
  46638. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46639. * to enhance interoperability with other engines.
  46640. */
  46641. Light.FALLOFF_GLTF = 2;
  46642. /**
  46643. * Falloff Standard: light is falling off like in the standard material
  46644. * to enhance interoperability with other materials.
  46645. */
  46646. Light.FALLOFF_STANDARD = 3;
  46647. //lightmapMode Consts
  46648. /**
  46649. * If every light affecting the material is in this lightmapMode,
  46650. * material.lightmapTexture adds or multiplies
  46651. * (depends on material.useLightmapAsShadowmap)
  46652. * after every other light calculations.
  46653. */
  46654. Light.LIGHTMAP_DEFAULT = 0;
  46655. /**
  46656. * material.lightmapTexture as only diffuse lighting from this light
  46657. * adds only specular lighting from this light
  46658. * adds dynamic shadows
  46659. */
  46660. Light.LIGHTMAP_SPECULAR = 1;
  46661. /**
  46662. * material.lightmapTexture as only lighting
  46663. * no light calculation from this light
  46664. * only adds dynamic shadows from this light
  46665. */
  46666. Light.LIGHTMAP_SHADOWSONLY = 2;
  46667. // Intensity Mode Consts
  46668. /**
  46669. * Each light type uses the default quantity according to its type:
  46670. * point/spot lights use luminous intensity
  46671. * directional lights use illuminance
  46672. */
  46673. Light.INTENSITYMODE_AUTOMATIC = 0;
  46674. /**
  46675. * lumen (lm)
  46676. */
  46677. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46678. /**
  46679. * candela (lm/sr)
  46680. */
  46681. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46682. /**
  46683. * lux (lm/m^2)
  46684. */
  46685. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46686. /**
  46687. * nit (cd/m^2)
  46688. */
  46689. Light.INTENSITYMODE_LUMINANCE = 4;
  46690. // Light types ids const.
  46691. /**
  46692. * Light type const id of the point light.
  46693. */
  46694. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46695. /**
  46696. * Light type const id of the directional light.
  46697. */
  46698. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46699. /**
  46700. * Light type const id of the spot light.
  46701. */
  46702. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46703. /**
  46704. * Light type const id of the hemispheric light.
  46705. */
  46706. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46709. ], Light.prototype, "diffuse", void 0);
  46710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46712. ], Light.prototype, "specular", void 0);
  46713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46715. ], Light.prototype, "falloffType", void 0);
  46716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46718. ], Light.prototype, "intensity", void 0);
  46719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46721. ], Light.prototype, "range", null);
  46722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46724. ], Light.prototype, "intensityMode", null);
  46725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46727. ], Light.prototype, "radius", null);
  46728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46730. ], Light.prototype, "_renderPriority", void 0);
  46731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46733. ], Light.prototype, "renderPriority", void 0);
  46734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46736. ], Light.prototype, "_shadowEnabled", void 0);
  46737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46739. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46742. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46745. ], Light.prototype, "_lightmapMode", void 0);
  46746. return Light;
  46747. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46748. /***/ }),
  46749. /***/ "./Lights/pointLight.ts":
  46750. /*!******************************!*\
  46751. !*** ./Lights/pointLight.ts ***!
  46752. \******************************/
  46753. /*! exports provided: PointLight */
  46754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46755. "use strict";
  46756. __webpack_require__.r(__webpack_exports__);
  46757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46759. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46760. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46761. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46762. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46763. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46764. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46765. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46766. });
  46767. /**
  46768. * A point light is a light defined by an unique point in world space.
  46769. * The light is emitted in every direction from this point.
  46770. * A good example of a point light is a standard light bulb.
  46771. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46772. */
  46773. var PointLight = /** @class */ (function (_super) {
  46774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46775. /**
  46776. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46777. * A PointLight emits the light in every direction.
  46778. * It can cast shadows.
  46779. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46780. * ```javascript
  46781. * var pointLight = new PointLight("pl", camera.position, scene);
  46782. * ```
  46783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46784. * @param name The light friendly name
  46785. * @param position The position of the point light in the scene
  46786. * @param scene The scene the lights belongs to
  46787. */
  46788. function PointLight(name, position, scene) {
  46789. var _this = _super.call(this, name, scene) || this;
  46790. _this._shadowAngle = Math.PI / 2;
  46791. _this.position = position;
  46792. return _this;
  46793. }
  46794. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46795. /**
  46796. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46797. * This specifies what angle the shadow will use to be created.
  46798. *
  46799. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46800. */
  46801. get: function () {
  46802. return this._shadowAngle;
  46803. },
  46804. /**
  46805. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46806. * This specifies what angle the shadow will use to be created.
  46807. *
  46808. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46809. */
  46810. set: function (value) {
  46811. this._shadowAngle = value;
  46812. this.forceProjectionMatrixCompute();
  46813. },
  46814. enumerable: true,
  46815. configurable: true
  46816. });
  46817. Object.defineProperty(PointLight.prototype, "direction", {
  46818. /**
  46819. * Gets the direction if it has been set.
  46820. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46821. */
  46822. get: function () {
  46823. return this._direction;
  46824. },
  46825. /**
  46826. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46827. */
  46828. set: function (value) {
  46829. var previousNeedCube = this.needCube();
  46830. this._direction = value;
  46831. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46832. this._shadowGenerator.recreateShadowMap();
  46833. }
  46834. },
  46835. enumerable: true,
  46836. configurable: true
  46837. });
  46838. /**
  46839. * Returns the string "PointLight"
  46840. * @returns the class name
  46841. */
  46842. PointLight.prototype.getClassName = function () {
  46843. return "PointLight";
  46844. };
  46845. /**
  46846. * Returns the integer 0.
  46847. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46848. */
  46849. PointLight.prototype.getTypeID = function () {
  46850. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46851. };
  46852. /**
  46853. * Specifies wether or not the shadowmap should be a cube texture.
  46854. * @returns true if the shadowmap needs to be a cube texture.
  46855. */
  46856. PointLight.prototype.needCube = function () {
  46857. return !this.direction;
  46858. };
  46859. /**
  46860. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46861. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46862. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46863. */
  46864. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46865. if (this.direction) {
  46866. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46867. }
  46868. else {
  46869. switch (faceIndex) {
  46870. case 0:
  46871. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46872. case 1:
  46873. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46874. case 2:
  46875. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46876. case 3:
  46877. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46878. case 4:
  46879. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46880. case 5:
  46881. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46882. }
  46883. }
  46884. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46885. };
  46886. /**
  46887. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46888. * - fov = PI / 2
  46889. * - aspect ratio : 1.0
  46890. * - z-near and far equal to the active camera minZ and maxZ.
  46891. * Returns the PointLight.
  46892. */
  46893. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46894. var activeCamera = this.getScene().activeCamera;
  46895. if (!activeCamera) {
  46896. return;
  46897. }
  46898. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46899. };
  46900. PointLight.prototype._buildUniformLayout = function () {
  46901. this._uniformBuffer.addUniform("vLightData", 4);
  46902. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46903. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46904. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46905. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46906. this._uniformBuffer.addUniform("depthValues", 2);
  46907. this._uniformBuffer.create();
  46908. };
  46909. /**
  46910. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46911. * @param effect The effect to update
  46912. * @param lightIndex The index of the light in the effect to update
  46913. * @returns The point light
  46914. */
  46915. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  46916. if (this.computeTransformedInformation()) {
  46917. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  46918. }
  46919. else {
  46920. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  46921. }
  46922. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  46923. return this;
  46924. };
  46925. /**
  46926. * Prepares the list of defines specific to the light type.
  46927. * @param defines the list of defines
  46928. * @param lightIndex defines the index of the light for the effect
  46929. */
  46930. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46931. defines["POINTLIGHT" + lightIndex] = true;
  46932. };
  46933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46935. ], PointLight.prototype, "shadowAngle", null);
  46936. return PointLight;
  46937. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46938. /***/ }),
  46939. /***/ "./Lights/shadowLight.ts":
  46940. /*!*******************************!*\
  46941. !*** ./Lights/shadowLight.ts ***!
  46942. \*******************************/
  46943. /*! exports provided: ShadowLight */
  46944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46945. "use strict";
  46946. __webpack_require__.r(__webpack_exports__);
  46947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  46948. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46949. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46950. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46951. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46952. /**
  46953. * Base implementation IShadowLight
  46954. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  46955. */
  46956. var ShadowLight = /** @class */ (function (_super) {
  46957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  46958. function ShadowLight() {
  46959. var _this = _super !== null && _super.apply(this, arguments) || this;
  46960. _this._needProjectionMatrixCompute = true;
  46961. return _this;
  46962. }
  46963. ShadowLight.prototype._setPosition = function (value) {
  46964. this._position = value;
  46965. };
  46966. Object.defineProperty(ShadowLight.prototype, "position", {
  46967. /**
  46968. * Sets the position the shadow will be casted from. Also use as the light position for both
  46969. * point and spot lights.
  46970. */
  46971. get: function () {
  46972. return this._position;
  46973. },
  46974. /**
  46975. * Sets the position the shadow will be casted from. Also use as the light position for both
  46976. * point and spot lights.
  46977. */
  46978. set: function (value) {
  46979. this._setPosition(value);
  46980. },
  46981. enumerable: true,
  46982. configurable: true
  46983. });
  46984. ShadowLight.prototype._setDirection = function (value) {
  46985. this._direction = value;
  46986. };
  46987. Object.defineProperty(ShadowLight.prototype, "direction", {
  46988. /**
  46989. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  46990. * Also use as the light direction on spot and directional lights.
  46991. */
  46992. get: function () {
  46993. return this._direction;
  46994. },
  46995. /**
  46996. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  46997. * Also use as the light direction on spot and directional lights.
  46998. */
  46999. set: function (value) {
  47000. this._setDirection(value);
  47001. },
  47002. enumerable: true,
  47003. configurable: true
  47004. });
  47005. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47006. /**
  47007. * Gets the shadow projection clipping minimum z value.
  47008. */
  47009. get: function () {
  47010. return this._shadowMinZ;
  47011. },
  47012. /**
  47013. * Sets the shadow projection clipping minimum z value.
  47014. */
  47015. set: function (value) {
  47016. this._shadowMinZ = value;
  47017. this.forceProjectionMatrixCompute();
  47018. },
  47019. enumerable: true,
  47020. configurable: true
  47021. });
  47022. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47023. /**
  47024. * Sets the shadow projection clipping maximum z value.
  47025. */
  47026. get: function () {
  47027. return this._shadowMaxZ;
  47028. },
  47029. /**
  47030. * Gets the shadow projection clipping maximum z value.
  47031. */
  47032. set: function (value) {
  47033. this._shadowMaxZ = value;
  47034. this.forceProjectionMatrixCompute();
  47035. },
  47036. enumerable: true,
  47037. configurable: true
  47038. });
  47039. /**
  47040. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47041. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47042. */
  47043. ShadowLight.prototype.computeTransformedInformation = function () {
  47044. if (this.parent && this.parent.getWorldMatrix) {
  47045. if (!this.transformedPosition) {
  47046. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47047. }
  47048. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47049. // In case the direction is present.
  47050. if (this.direction) {
  47051. if (!this.transformedDirection) {
  47052. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47053. }
  47054. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47055. }
  47056. return true;
  47057. }
  47058. return false;
  47059. };
  47060. /**
  47061. * Return the depth scale used for the shadow map.
  47062. * @returns the depth scale.
  47063. */
  47064. ShadowLight.prototype.getDepthScale = function () {
  47065. return 50.0;
  47066. };
  47067. /**
  47068. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47069. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47070. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47071. */
  47072. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47073. return this.transformedDirection ? this.transformedDirection : this.direction;
  47074. };
  47075. /**
  47076. * Returns the ShadowLight absolute position in the World.
  47077. * @returns the position vector in world space
  47078. */
  47079. ShadowLight.prototype.getAbsolutePosition = function () {
  47080. return this.transformedPosition ? this.transformedPosition : this.position;
  47081. };
  47082. /**
  47083. * Sets the ShadowLight direction toward the passed target.
  47084. * @param target The point tot target in local space
  47085. * @returns the updated ShadowLight direction
  47086. */
  47087. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47088. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47089. return this.direction;
  47090. };
  47091. /**
  47092. * Returns the light rotation in euler definition.
  47093. * @returns the x y z rotation in local space.
  47094. */
  47095. ShadowLight.prototype.getRotation = function () {
  47096. this.direction.normalize();
  47097. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47098. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47099. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47100. };
  47101. /**
  47102. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47103. * @returns true if a cube texture needs to be use
  47104. */
  47105. ShadowLight.prototype.needCube = function () {
  47106. return false;
  47107. };
  47108. /**
  47109. * Detects if the projection matrix requires to be recomputed this frame.
  47110. * @returns true if it requires to be recomputed otherwise, false.
  47111. */
  47112. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47113. return this._needProjectionMatrixCompute;
  47114. };
  47115. /**
  47116. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47117. */
  47118. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47119. this._needProjectionMatrixCompute = true;
  47120. };
  47121. /** @hidden */
  47122. ShadowLight.prototype._initCache = function () {
  47123. _super.prototype._initCache.call(this);
  47124. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47125. };
  47126. /** @hidden */
  47127. ShadowLight.prototype._isSynchronized = function () {
  47128. if (!this._cache.position.equals(this.position)) {
  47129. return false;
  47130. }
  47131. return true;
  47132. };
  47133. /**
  47134. * Computes the world matrix of the node
  47135. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47136. * @returns the world matrix
  47137. */
  47138. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47139. if (!force && this.isSynchronized()) {
  47140. this._currentRenderId = this.getScene().getRenderId();
  47141. return this._worldMatrix;
  47142. }
  47143. this._updateCache();
  47144. this._cache.position.copyFrom(this.position);
  47145. if (!this._worldMatrix) {
  47146. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47147. }
  47148. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47149. if (this.parent && this.parent.getWorldMatrix) {
  47150. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47151. this._markSyncedWithParent();
  47152. }
  47153. // Cache the determinant
  47154. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47155. return this._worldMatrix;
  47156. };
  47157. /**
  47158. * Gets the minZ used for shadow according to both the scene and the light.
  47159. * @param activeCamera The camera we are returning the min for
  47160. * @returns the depth min z
  47161. */
  47162. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47163. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47164. };
  47165. /**
  47166. * Gets the maxZ used for shadow according to both the scene and the light.
  47167. * @param activeCamera The camera we are returning the max for
  47168. * @returns the depth max z
  47169. */
  47170. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47171. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47172. };
  47173. /**
  47174. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47175. * @param matrix The materix to updated with the projection information
  47176. * @param viewMatrix The transform matrix of the light
  47177. * @param renderList The list of mesh to render in the map
  47178. * @returns The current light
  47179. */
  47180. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47181. if (this.customProjectionMatrixBuilder) {
  47182. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47183. }
  47184. else {
  47185. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47186. }
  47187. return this;
  47188. };
  47189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47191. ], ShadowLight.prototype, "position", null);
  47192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47194. ], ShadowLight.prototype, "direction", null);
  47195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47197. ], ShadowLight.prototype, "shadowMinZ", null);
  47198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47200. ], ShadowLight.prototype, "shadowMaxZ", null);
  47201. return ShadowLight;
  47202. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47203. /***/ }),
  47204. /***/ "./Lights/spotLight.ts":
  47205. /*!*****************************!*\
  47206. !*** ./Lights/spotLight.ts ***!
  47207. \*****************************/
  47208. /*! exports provided: SpotLight */
  47209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47210. "use strict";
  47211. __webpack_require__.r(__webpack_exports__);
  47212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47213. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47214. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47215. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47216. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47217. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47218. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47219. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47220. return function () { return new SpotLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), 0, 0, scene); };
  47221. });
  47222. /**
  47223. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47224. * These values define a cone of light starting from the position, emitting toward the direction.
  47225. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47226. * and the exponent defines the speed of the decay of the light with distance (reach).
  47227. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47228. */
  47229. var SpotLight = /** @class */ (function (_super) {
  47230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47231. /**
  47232. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47233. * It can cast shadows.
  47234. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47235. * @param name The light friendly name
  47236. * @param position The position of the spot light in the scene
  47237. * @param direction The direction of the light in the scene
  47238. * @param angle The cone angle of the light in Radians
  47239. * @param exponent The light decay speed with the distance from the emission spot
  47240. * @param scene The scene the lights belongs to
  47241. */
  47242. function SpotLight(name, position, direction, angle, exponent, scene) {
  47243. var _this = _super.call(this, name, scene) || this;
  47244. _this._innerAngle = 0;
  47245. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47246. _this._projectionTextureLightNear = 1e-6;
  47247. _this._projectionTextureLightFar = 1000.0;
  47248. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47249. _this._projectionTextureViewLightDirty = true;
  47250. _this._projectionTextureProjectionLightDirty = true;
  47251. _this._projectionTextureDirty = true;
  47252. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47253. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47254. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47255. _this._projectionTextureScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValues(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
  47256. _this.position = position;
  47257. _this.direction = direction;
  47258. _this.angle = angle;
  47259. _this.exponent = exponent;
  47260. return _this;
  47261. }
  47262. Object.defineProperty(SpotLight.prototype, "angle", {
  47263. /**
  47264. * Gets the cone angle of the spot light in Radians.
  47265. */
  47266. get: function () {
  47267. return this._angle;
  47268. },
  47269. /**
  47270. * Sets the cone angle of the spot light in Radians.
  47271. */
  47272. set: function (value) {
  47273. this._angle = value;
  47274. this._cosHalfAngle = Math.cos(value * 0.5);
  47275. this._projectionTextureProjectionLightDirty = true;
  47276. this.forceProjectionMatrixCompute();
  47277. this._computeAngleValues();
  47278. },
  47279. enumerable: true,
  47280. configurable: true
  47281. });
  47282. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47283. /**
  47284. * Only used in gltf falloff mode, this defines the angle where
  47285. * the directional falloff will start before cutting at angle which could be seen
  47286. * as outer angle.
  47287. */
  47288. get: function () {
  47289. return this._innerAngle;
  47290. },
  47291. /**
  47292. * Only used in gltf falloff mode, this defines the angle where
  47293. * the directional falloff will start before cutting at angle which could be seen
  47294. * as outer angle.
  47295. */
  47296. set: function (value) {
  47297. this._innerAngle = value;
  47298. this._computeAngleValues();
  47299. },
  47300. enumerable: true,
  47301. configurable: true
  47302. });
  47303. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47304. /**
  47305. * Allows scaling the angle of the light for shadow generation only.
  47306. */
  47307. get: function () {
  47308. return this._shadowAngleScale;
  47309. },
  47310. /**
  47311. * Allows scaling the angle of the light for shadow generation only.
  47312. */
  47313. set: function (value) {
  47314. this._shadowAngleScale = value;
  47315. this.forceProjectionMatrixCompute();
  47316. },
  47317. enumerable: true,
  47318. configurable: true
  47319. });
  47320. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47321. /**
  47322. * Allows reading the projecton texture
  47323. */
  47324. get: function () {
  47325. return this._projectionTextureMatrix;
  47326. },
  47327. enumerable: true,
  47328. configurable: true
  47329. });
  47330. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47331. /**
  47332. * Gets the near clip of the Spotlight for texture projection.
  47333. */
  47334. get: function () {
  47335. return this._projectionTextureLightNear;
  47336. },
  47337. /**
  47338. * Sets the near clip of the Spotlight for texture projection.
  47339. */
  47340. set: function (value) {
  47341. this._projectionTextureLightNear = value;
  47342. this._projectionTextureProjectionLightDirty = true;
  47343. },
  47344. enumerable: true,
  47345. configurable: true
  47346. });
  47347. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47348. /**
  47349. * Gets the far clip of the Spotlight for texture projection.
  47350. */
  47351. get: function () {
  47352. return this._projectionTextureLightFar;
  47353. },
  47354. /**
  47355. * Sets the far clip of the Spotlight for texture projection.
  47356. */
  47357. set: function (value) {
  47358. this._projectionTextureLightFar = value;
  47359. this._projectionTextureProjectionLightDirty = true;
  47360. },
  47361. enumerable: true,
  47362. configurable: true
  47363. });
  47364. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47365. /**
  47366. * Gets the Up vector of the Spotlight for texture projection.
  47367. */
  47368. get: function () {
  47369. return this._projectionTextureUpDirection;
  47370. },
  47371. /**
  47372. * Sets the Up vector of the Spotlight for texture projection.
  47373. */
  47374. set: function (value) {
  47375. this._projectionTextureUpDirection = value;
  47376. this._projectionTextureProjectionLightDirty = true;
  47377. },
  47378. enumerable: true,
  47379. configurable: true
  47380. });
  47381. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47382. /**
  47383. * Gets the projection texture of the light.
  47384. */
  47385. get: function () {
  47386. return this._projectionTexture;
  47387. },
  47388. /**
  47389. * Sets the projection texture of the light.
  47390. */
  47391. set: function (value) {
  47392. this._projectionTexture = value;
  47393. this._projectionTextureDirty = true;
  47394. },
  47395. enumerable: true,
  47396. configurable: true
  47397. });
  47398. /**
  47399. * Returns the string "SpotLight".
  47400. * @returns the class name
  47401. */
  47402. SpotLight.prototype.getClassName = function () {
  47403. return "SpotLight";
  47404. };
  47405. /**
  47406. * Returns the integer 2.
  47407. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47408. */
  47409. SpotLight.prototype.getTypeID = function () {
  47410. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47411. };
  47412. /**
  47413. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47414. */
  47415. SpotLight.prototype._setDirection = function (value) {
  47416. _super.prototype._setDirection.call(this, value);
  47417. this._projectionTextureViewLightDirty = true;
  47418. };
  47419. /**
  47420. * Overrides the position setter to recompute the projection texture view light Matrix.
  47421. */
  47422. SpotLight.prototype._setPosition = function (value) {
  47423. _super.prototype._setPosition.call(this, value);
  47424. this._projectionTextureViewLightDirty = true;
  47425. };
  47426. /**
  47427. * 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.
  47428. * Returns the SpotLight.
  47429. */
  47430. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47431. var activeCamera = this.getScene().activeCamera;
  47432. if (!activeCamera) {
  47433. return;
  47434. }
  47435. this._shadowAngleScale = this._shadowAngleScale || 1;
  47436. var angle = this._shadowAngleScale * this._angle;
  47437. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47438. };
  47439. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47440. this._projectionTextureViewLightDirty = false;
  47441. this._projectionTextureDirty = true;
  47442. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47443. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47444. };
  47445. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47446. this._projectionTextureProjectionLightDirty = false;
  47447. this._projectionTextureDirty = true;
  47448. var light_far = this.projectionTextureLightFar;
  47449. var light_near = this.projectionTextureLightNear;
  47450. var P = light_far / (light_far - light_near);
  47451. var Q = -P * light_near;
  47452. var S = 1.0 / Math.tan(this._angle / 2.0);
  47453. var A = 1.0;
  47454. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValuesToRef(S / A, 0.0, 0.0, 0.0, 0.0, S, 0.0, 0.0, 0.0, 0.0, P, 1.0, 0.0, 0.0, Q, 0.0, this._projectionTextureProjectionLightMatrix);
  47455. };
  47456. /**
  47457. * Main function for light texture projection matrix computing.
  47458. */
  47459. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47460. this._projectionTextureDirty = false;
  47461. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47462. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47463. };
  47464. SpotLight.prototype._buildUniformLayout = function () {
  47465. this._uniformBuffer.addUniform("vLightData", 4);
  47466. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47467. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47468. this._uniformBuffer.addUniform("vLightDirection", 3);
  47469. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47470. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47471. this._uniformBuffer.addUniform("depthValues", 2);
  47472. this._uniformBuffer.create();
  47473. };
  47474. SpotLight.prototype._computeAngleValues = function () {
  47475. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47476. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47477. };
  47478. /**
  47479. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47480. * @param effect The effect to update
  47481. * @param lightIndex The index of the light in the effect to update
  47482. * @returns The spot light
  47483. */
  47484. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47485. var normalizeDirection;
  47486. if (this.computeTransformedInformation()) {
  47487. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47488. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47489. }
  47490. else {
  47491. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47492. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47493. }
  47494. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47495. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47496. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47497. if (this._projectionTextureViewLightDirty) {
  47498. this._computeProjectionTextureViewLightMatrix();
  47499. }
  47500. if (this._projectionTextureProjectionLightDirty) {
  47501. this._computeProjectionTextureProjectionLightMatrix();
  47502. }
  47503. if (this._projectionTextureDirty) {
  47504. this._computeProjectionTextureMatrix();
  47505. }
  47506. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47507. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47508. }
  47509. return this;
  47510. };
  47511. /**
  47512. * Disposes the light and the associated resources.
  47513. */
  47514. SpotLight.prototype.dispose = function () {
  47515. _super.prototype.dispose.call(this);
  47516. if (this._projectionTexture) {
  47517. this._projectionTexture.dispose();
  47518. }
  47519. };
  47520. /**
  47521. * Prepares the list of defines specific to the light type.
  47522. * @param defines the list of defines
  47523. * @param lightIndex defines the index of the light for the effect
  47524. */
  47525. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47526. defines["SPOTLIGHT" + lightIndex] = true;
  47527. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47528. };
  47529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47531. ], SpotLight.prototype, "angle", null);
  47532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47534. ], SpotLight.prototype, "innerAngle", null);
  47535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47537. ], SpotLight.prototype, "shadowAngleScale", null);
  47538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47540. ], SpotLight.prototype, "exponent", void 0);
  47541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47543. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47546. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47549. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47552. ], SpotLight.prototype, "_projectionTexture", void 0);
  47553. return SpotLight;
  47554. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47555. /***/ }),
  47556. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47557. /*!**********************************************!*\
  47558. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47559. \**********************************************/
  47560. /*! exports provided: _BabylonLoaderRegistered */
  47561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47562. "use strict";
  47563. __webpack_require__.r(__webpack_exports__);
  47564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47565. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47566. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47567. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47568. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47569. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47570. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47571. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47572. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47573. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47574. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47575. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47576. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47577. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47578. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47579. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47580. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47581. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47582. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47583. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47584. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47585. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47586. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47587. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47588. /** @hidden */
  47589. var _BabylonLoaderRegistered = true;
  47590. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47591. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47592. var parsedMaterial = parsedData.materials[index];
  47593. if (parsedMaterial.id === id) {
  47594. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47595. }
  47596. }
  47597. return null;
  47598. };
  47599. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47600. for (var i in names) {
  47601. if (mesh.name === names[i]) {
  47602. hierarchyIds.push(mesh.id);
  47603. return true;
  47604. }
  47605. }
  47606. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47607. hierarchyIds.push(mesh.id);
  47608. return true;
  47609. }
  47610. return false;
  47611. };
  47612. var logOperation = function (operation, producer) {
  47613. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47614. };
  47615. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47616. if (addToScene === void 0) { addToScene = false; }
  47617. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47618. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47619. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47620. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47621. // and avoid problems with multiple concurrent .babylon loads.
  47622. var log = "importScene has failed JSON parse";
  47623. try {
  47624. var parsedData = JSON.parse(data);
  47625. log = "";
  47626. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47627. var index;
  47628. var cache;
  47629. // Lights
  47630. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47631. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47632. var parsedLight = parsedData.lights[index];
  47633. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47634. if (light) {
  47635. container.lights.push(light);
  47636. log += (index === 0 ? "\n\tLights:" : "");
  47637. log += "\n\t\t" + light.toString(fullDetails);
  47638. }
  47639. }
  47640. }
  47641. // Reflection probes
  47642. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47643. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47644. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47645. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47646. if (reflectionProbe) {
  47647. container.reflectionProbes.push(reflectionProbe);
  47648. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47649. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47650. }
  47651. }
  47652. }
  47653. // Animations
  47654. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47655. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47656. var parsedAnimation = parsedData.animations[index];
  47657. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47658. if (internalClass) {
  47659. var animation = internalClass.Parse(parsedAnimation);
  47660. scene.animations.push(animation);
  47661. container.animations.push(animation);
  47662. log += (index === 0 ? "\n\tAnimations:" : "");
  47663. log += "\n\t\t" + animation.toString(fullDetails);
  47664. }
  47665. }
  47666. }
  47667. // Materials
  47668. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47669. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47670. var parsedMaterial = parsedData.materials[index];
  47671. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47672. container.materials.push(mat);
  47673. log += (index === 0 ? "\n\tMaterials:" : "");
  47674. log += "\n\t\t" + mat.toString(fullDetails);
  47675. }
  47676. }
  47677. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47678. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47679. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47680. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47681. container.multiMaterials.push(mmat);
  47682. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47683. log += "\n\t\t" + mmat.toString(fullDetails);
  47684. }
  47685. }
  47686. // Morph targets
  47687. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47688. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47689. var managerData = _a[_i];
  47690. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47691. }
  47692. }
  47693. // Skeletons
  47694. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47695. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47696. var parsedSkeleton = parsedData.skeletons[index];
  47697. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47698. container.skeletons.push(skeleton);
  47699. log += (index === 0 ? "\n\tSkeletons:" : "");
  47700. log += "\n\t\t" + skeleton.toString(fullDetails);
  47701. }
  47702. }
  47703. // Geometries
  47704. var geometries = parsedData.geometries;
  47705. if (geometries !== undefined && geometries !== null) {
  47706. var addedGeometry = new Array();
  47707. // VertexData
  47708. var vertexData = geometries.vertexData;
  47709. if (vertexData !== undefined && vertexData !== null) {
  47710. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47711. var parsedVertexData = vertexData[index];
  47712. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47713. }
  47714. }
  47715. addedGeometry.forEach(function (g) {
  47716. if (g) {
  47717. container.geometries.push(g);
  47718. }
  47719. });
  47720. }
  47721. // Transform nodes
  47722. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47723. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47724. var parsedTransformNode = parsedData.transformNodes[index];
  47725. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47726. container.transformNodes.push(node);
  47727. }
  47728. }
  47729. // Meshes
  47730. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47731. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47732. var parsedMesh = parsedData.meshes[index];
  47733. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47734. container.meshes.push(mesh);
  47735. log += (index === 0 ? "\n\tMeshes:" : "");
  47736. log += "\n\t\t" + mesh.toString(fullDetails);
  47737. }
  47738. }
  47739. // Cameras
  47740. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47741. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47742. var parsedCamera = parsedData.cameras[index];
  47743. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47744. container.cameras.push(camera);
  47745. log += (index === 0 ? "\n\tCameras:" : "");
  47746. log += "\n\t\t" + camera.toString(fullDetails);
  47747. }
  47748. }
  47749. // Animation Groups
  47750. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47751. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47752. var parsedAnimationGroup = parsedData.animationGroups[index];
  47753. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47754. container.animationGroups.push(animationGroup);
  47755. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47756. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47757. }
  47758. }
  47759. // Browsing all the graph to connect the dots
  47760. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47761. var camera = scene.cameras[index];
  47762. if (camera._waitingParentId) {
  47763. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47764. camera._waitingParentId = null;
  47765. }
  47766. }
  47767. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47768. var light_1 = scene.lights[index];
  47769. if (light_1 && light_1._waitingParentId) {
  47770. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47771. light_1._waitingParentId = null;
  47772. }
  47773. }
  47774. // Connect parents & children and parse actions
  47775. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47776. var transformNode = scene.transformNodes[index];
  47777. if (transformNode._waitingParentId) {
  47778. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47779. transformNode._waitingParentId = null;
  47780. }
  47781. }
  47782. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47783. var mesh = scene.meshes[index];
  47784. if (mesh._waitingParentId) {
  47785. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47786. mesh._waitingParentId = null;
  47787. }
  47788. }
  47789. // freeze world matrix application
  47790. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47791. var currentMesh = scene.meshes[index];
  47792. if (currentMesh._waitingFreezeWorldMatrix) {
  47793. currentMesh.freezeWorldMatrix();
  47794. currentMesh._waitingFreezeWorldMatrix = null;
  47795. }
  47796. else {
  47797. currentMesh.computeWorldMatrix(true);
  47798. }
  47799. }
  47800. // Lights exclusions / inclusions
  47801. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47802. var light_2 = scene.lights[index];
  47803. // Excluded check
  47804. if (light_2._excludedMeshesIds.length > 0) {
  47805. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47806. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47807. if (excludedMesh) {
  47808. light_2.excludedMeshes.push(excludedMesh);
  47809. }
  47810. }
  47811. light_2._excludedMeshesIds = [];
  47812. }
  47813. // Included check
  47814. if (light_2._includedOnlyMeshesIds.length > 0) {
  47815. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47816. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47817. if (includedOnlyMesh) {
  47818. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47819. }
  47820. }
  47821. light_2._includedOnlyMeshesIds = [];
  47822. }
  47823. }
  47824. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47825. // Actions (scene) Done last as it can access other objects.
  47826. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47827. var mesh = scene.meshes[index];
  47828. if (mesh._waitingActions) {
  47829. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47830. mesh._waitingActions = null;
  47831. }
  47832. }
  47833. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47834. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47835. }
  47836. if (!addToScene) {
  47837. container.removeAllFromScene();
  47838. }
  47839. }
  47840. catch (err) {
  47841. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47842. if (onError) {
  47843. onError(msg, err);
  47844. }
  47845. else {
  47846. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47847. throw err;
  47848. }
  47849. }
  47850. finally {
  47851. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47852. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47853. }
  47854. }
  47855. return container;
  47856. };
  47857. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  47858. name: "babylon.js",
  47859. extensions: ".babylon",
  47860. canDirectLoad: function (data) {
  47861. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47862. return true;
  47863. }
  47864. return false;
  47865. },
  47866. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47867. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47868. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47869. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47870. // and avoid problems with multiple concurrent .babylon loads.
  47871. var log = "importMesh has failed JSON parse";
  47872. try {
  47873. var parsedData = JSON.parse(data);
  47874. log = "";
  47875. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47876. if (!meshesNames) {
  47877. meshesNames = null;
  47878. }
  47879. else if (!Array.isArray(meshesNames)) {
  47880. meshesNames = [meshesNames];
  47881. }
  47882. var hierarchyIds = new Array();
  47883. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47884. var loadedSkeletonsIds = [];
  47885. var loadedMaterialsIds = [];
  47886. var index;
  47887. var cache;
  47888. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47889. var parsedMesh = parsedData.meshes[index];
  47890. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  47891. if (meshesNames !== null) {
  47892. // Remove found mesh name from list.
  47893. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  47894. }
  47895. //Geometry?
  47896. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  47897. //does the file contain geometries?
  47898. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  47899. //find the correct geometry and add it to the scene
  47900. var found = false;
  47901. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  47902. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  47903. return;
  47904. }
  47905. else {
  47906. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  47907. if (parsedGeometryData.id === parsedMesh.geometryId) {
  47908. switch (geometryType) {
  47909. case "vertexData":
  47910. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  47911. break;
  47912. }
  47913. found = true;
  47914. }
  47915. });
  47916. }
  47917. });
  47918. if (found === false) {
  47919. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  47920. }
  47921. }
  47922. }
  47923. // Material ?
  47924. if (parsedMesh.materialId) {
  47925. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  47926. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47927. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  47928. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  47929. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  47930. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  47931. var subMatId = parsedMultiMaterial.materials[matIndex];
  47932. loadedMaterialsIds.push(subMatId);
  47933. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  47934. if (mat) {
  47935. log += "\n\tMaterial " + mat.toString(fullDetails);
  47936. }
  47937. }
  47938. loadedMaterialsIds.push(parsedMultiMaterial.id);
  47939. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47940. if (mmat) {
  47941. materialFound = true;
  47942. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  47943. }
  47944. break;
  47945. }
  47946. }
  47947. }
  47948. if (materialFound === false) {
  47949. loadedMaterialsIds.push(parsedMesh.materialId);
  47950. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  47951. if (!mat) {
  47952. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  47953. }
  47954. else {
  47955. log += "\n\tMaterial " + mat.toString(fullDetails);
  47956. }
  47957. }
  47958. }
  47959. // Skeleton ?
  47960. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47961. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  47962. if (skeletonAlreadyLoaded === false) {
  47963. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  47964. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  47965. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  47966. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47967. skeletons.push(skeleton);
  47968. loadedSkeletonsIds.push(parsedSkeleton.id);
  47969. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  47970. }
  47971. }
  47972. }
  47973. }
  47974. // Morph targets ?
  47975. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47976. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47977. var managerData = _a[_i];
  47978. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  47979. }
  47980. }
  47981. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47982. meshes.push(mesh);
  47983. log += "\n\tMesh " + mesh.toString(fullDetails);
  47984. }
  47985. }
  47986. // Connecting parents
  47987. var currentMesh;
  47988. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47989. currentMesh = scene.meshes[index];
  47990. if (currentMesh._waitingParentId) {
  47991. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  47992. currentMesh._waitingParentId = null;
  47993. }
  47994. }
  47995. // freeze and compute world matrix application
  47996. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47997. currentMesh = scene.meshes[index];
  47998. if (currentMesh._waitingFreezeWorldMatrix) {
  47999. currentMesh.freezeWorldMatrix();
  48000. currentMesh._waitingFreezeWorldMatrix = null;
  48001. }
  48002. else {
  48003. currentMesh.computeWorldMatrix(true);
  48004. }
  48005. }
  48006. }
  48007. // Particles
  48008. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48009. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48010. if (parser) {
  48011. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48012. var parsedParticleSystem = parsedData.particleSystems[index];
  48013. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48014. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48015. }
  48016. }
  48017. }
  48018. }
  48019. return true;
  48020. }
  48021. catch (err) {
  48022. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48023. if (onError) {
  48024. onError(msg, err);
  48025. }
  48026. else {
  48027. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48028. throw err;
  48029. }
  48030. }
  48031. finally {
  48032. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48033. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  48034. }
  48035. }
  48036. return false;
  48037. },
  48038. load: function (scene, data, rootUrl, onError) {
  48039. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48040. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48041. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48042. // and avoid problems with multiple concurrent .babylon loads.
  48043. var log = "importScene has failed JSON parse";
  48044. try {
  48045. var parsedData = JSON.parse(data);
  48046. log = "";
  48047. // Scene
  48048. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48049. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48050. }
  48051. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48052. scene.autoClear = parsedData.autoClear;
  48053. }
  48054. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48055. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48056. }
  48057. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48058. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48059. }
  48060. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48061. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48062. }
  48063. // Fog
  48064. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48065. scene.fogMode = parsedData.fogMode;
  48066. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48067. scene.fogStart = parsedData.fogStart;
  48068. scene.fogEnd = parsedData.fogEnd;
  48069. scene.fogDensity = parsedData.fogDensity;
  48070. log += "\tFog mode for scene: ";
  48071. switch (scene.fogMode) {
  48072. // getters not compiling, so using hardcoded
  48073. case 1:
  48074. log += "exp\n";
  48075. break;
  48076. case 2:
  48077. log += "exp2\n";
  48078. break;
  48079. case 3:
  48080. log += "linear\n";
  48081. break;
  48082. }
  48083. }
  48084. //Physics
  48085. if (parsedData.physicsEnabled) {
  48086. var physicsPlugin;
  48087. if (parsedData.physicsEngine === "cannon") {
  48088. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48089. }
  48090. else if (parsedData.physicsEngine === "oimo") {
  48091. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48092. }
  48093. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48094. //else - default engine, which is currently oimo
  48095. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48096. scene.enablePhysics(physicsGravity, physicsPlugin);
  48097. }
  48098. // Metadata
  48099. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48100. scene.metadata = parsedData.metadata;
  48101. }
  48102. //collisions, if defined. otherwise, default is true
  48103. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48104. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48105. }
  48106. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48107. if (!container) {
  48108. return false;
  48109. }
  48110. if (parsedData.autoAnimate) {
  48111. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48112. }
  48113. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48114. scene.setActiveCameraByID(parsedData.activeCameraID);
  48115. }
  48116. // Environment texture
  48117. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48118. // PBR needed for both HDR texture (gamma space) & a sky box
  48119. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48120. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48121. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48122. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48123. if (parsedData.environmentTextureRotationY) {
  48124. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48125. }
  48126. scene.environmentTexture = hdrTexture;
  48127. }
  48128. else {
  48129. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48130. if (parsedData.environmentTextureRotationY) {
  48131. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48132. }
  48133. scene.environmentTexture = cubeTexture;
  48134. }
  48135. if (parsedData.createDefaultSkybox === true) {
  48136. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48137. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48138. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48139. }
  48140. }
  48141. // Finish
  48142. return true;
  48143. }
  48144. catch (err) {
  48145. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48146. if (onError) {
  48147. onError(msg, err);
  48148. }
  48149. else {
  48150. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48151. throw err;
  48152. }
  48153. }
  48154. finally {
  48155. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48156. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  48157. }
  48158. }
  48159. return false;
  48160. },
  48161. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48162. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48163. return container;
  48164. }
  48165. });
  48166. /***/ }),
  48167. /***/ "./Loading/Plugins/index.ts":
  48168. /*!**********************************!*\
  48169. !*** ./Loading/Plugins/index.ts ***!
  48170. \**********************************/
  48171. /*! exports provided: _BabylonLoaderRegistered */
  48172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48173. "use strict";
  48174. __webpack_require__.r(__webpack_exports__);
  48175. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48177. /***/ }),
  48178. /***/ "./Loading/index.ts":
  48179. /*!**************************!*\
  48180. !*** ./Loading/index.ts ***!
  48181. \**************************/
  48182. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48184. "use strict";
  48185. __webpack_require__.r(__webpack_exports__);
  48186. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48188. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48190. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48193. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48195. /***/ }),
  48196. /***/ "./Loading/loadingScreen.ts":
  48197. /*!**********************************!*\
  48198. !*** ./Loading/loadingScreen.ts ***!
  48199. \**********************************/
  48200. /*! exports provided: DefaultLoadingScreen */
  48201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48202. "use strict";
  48203. __webpack_require__.r(__webpack_exports__);
  48204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48205. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48206. /**
  48207. * Class used for the default loading screen
  48208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48209. */
  48210. var DefaultLoadingScreen = /** @class */ (function () {
  48211. /**
  48212. * Creates a new default loading screen
  48213. * @param _renderingCanvas defines the canvas used to render the scene
  48214. * @param _loadingText defines the default text to display
  48215. * @param _loadingDivBackgroundColor defines the default background color
  48216. */
  48217. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48218. if (_loadingText === void 0) { _loadingText = ""; }
  48219. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48220. var _this = this;
  48221. this._renderingCanvas = _renderingCanvas;
  48222. this._loadingText = _loadingText;
  48223. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48224. // Resize
  48225. this._resizeLoadingUI = function () {
  48226. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48227. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48228. if (!_this._loadingDiv) {
  48229. return;
  48230. }
  48231. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48232. _this._loadingDiv.style.left = canvasRect.left + "px";
  48233. _this._loadingDiv.style.top = canvasRect.top + "px";
  48234. _this._loadingDiv.style.width = canvasRect.width + "px";
  48235. _this._loadingDiv.style.height = canvasRect.height + "px";
  48236. };
  48237. }
  48238. /**
  48239. * Function called to display the loading screen
  48240. */
  48241. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48242. if (this._loadingDiv) {
  48243. // Do not add a loading screen if there is already one
  48244. return;
  48245. }
  48246. this._loadingDiv = document.createElement("div");
  48247. this._loadingDiv.id = "babylonjsLoadingDiv";
  48248. this._loadingDiv.style.opacity = "0";
  48249. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48250. this._loadingDiv.style.pointerEvents = "none";
  48251. // Loading text
  48252. this._loadingTextDiv = document.createElement("div");
  48253. this._loadingTextDiv.style.position = "absolute";
  48254. this._loadingTextDiv.style.left = "0";
  48255. this._loadingTextDiv.style.top = "50%";
  48256. this._loadingTextDiv.style.marginTop = "80px";
  48257. this._loadingTextDiv.style.width = "100%";
  48258. this._loadingTextDiv.style.height = "20px";
  48259. this._loadingTextDiv.style.fontFamily = "Arial";
  48260. this._loadingTextDiv.style.fontSize = "14px";
  48261. this._loadingTextDiv.style.color = "white";
  48262. this._loadingTextDiv.style.textAlign = "center";
  48263. this._loadingTextDiv.innerHTML = "Loading";
  48264. this._loadingDiv.appendChild(this._loadingTextDiv);
  48265. //set the predefined text
  48266. this._loadingTextDiv.innerHTML = this._loadingText;
  48267. // Generating keyframes
  48268. var style = document.createElement('style');
  48269. style.type = 'text/css';
  48270. 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 }";
  48271. style.innerHTML = keyFrames;
  48272. document.getElementsByTagName('head')[0].appendChild(style);
  48273. // Loading img
  48274. var imgBack = new Image();
  48275. imgBack.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC";
  48276. imgBack.style.position = "absolute";
  48277. imgBack.style.left = "50%";
  48278. imgBack.style.top = "50%";
  48279. imgBack.style.marginLeft = "-60px";
  48280. imgBack.style.marginTop = "-60px";
  48281. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48282. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48283. imgBack.style.transformOrigin = "50% 50%";
  48284. imgBack.style.webkitTransformOrigin = "50% 50%";
  48285. this._loadingDiv.appendChild(imgBack);
  48286. this._resizeLoadingUI();
  48287. window.addEventListener("resize", this._resizeLoadingUI);
  48288. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48289. document.body.appendChild(this._loadingDiv);
  48290. this._loadingDiv.style.opacity = "1";
  48291. };
  48292. /**
  48293. * Function called to hide the loading screen
  48294. */
  48295. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48296. var _this = this;
  48297. if (!this._loadingDiv) {
  48298. return;
  48299. }
  48300. var onTransitionEnd = function () {
  48301. if (!_this._loadingDiv) {
  48302. return;
  48303. }
  48304. if (_this._loadingDiv.parentElement) {
  48305. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48306. }
  48307. window.removeEventListener("resize", _this._resizeLoadingUI);
  48308. _this._loadingDiv = null;
  48309. };
  48310. this._loadingDiv.style.opacity = "0";
  48311. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48312. };
  48313. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48314. get: function () {
  48315. return this._loadingText;
  48316. },
  48317. /**
  48318. * Gets or sets the text to display while loading
  48319. */
  48320. set: function (text) {
  48321. this._loadingText = text;
  48322. if (this._loadingTextDiv) {
  48323. this._loadingTextDiv.innerHTML = this._loadingText;
  48324. }
  48325. },
  48326. enumerable: true,
  48327. configurable: true
  48328. });
  48329. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48330. /**
  48331. * Gets or sets the color to use for the background
  48332. */
  48333. get: function () {
  48334. return this._loadingDivBackgroundColor;
  48335. },
  48336. set: function (color) {
  48337. this._loadingDivBackgroundColor = color;
  48338. if (!this._loadingDiv) {
  48339. return;
  48340. }
  48341. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48342. },
  48343. enumerable: true,
  48344. configurable: true
  48345. });
  48346. return DefaultLoadingScreen;
  48347. }());
  48348. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48349. /***/ }),
  48350. /***/ "./Loading/sceneLoader.ts":
  48351. /*!********************************!*\
  48352. !*** ./Loading/sceneLoader.ts ***!
  48353. \********************************/
  48354. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48356. "use strict";
  48357. __webpack_require__.r(__webpack_exports__);
  48358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48360. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48361. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48362. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48363. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48364. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48365. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48366. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48367. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48368. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48369. /**
  48370. * Class used to represent data loading progression
  48371. */
  48372. var SceneLoaderProgressEvent = /** @class */ (function () {
  48373. /**
  48374. * Create a new progress event
  48375. * @param lengthComputable defines if data length to load can be evaluated
  48376. * @param loaded defines the loaded data length
  48377. * @param total defines the data length to load
  48378. */
  48379. function SceneLoaderProgressEvent(
  48380. /** defines if data length to load can be evaluated */
  48381. lengthComputable,
  48382. /** defines the loaded data length */
  48383. loaded,
  48384. /** defines the data length to load */
  48385. total) {
  48386. this.lengthComputable = lengthComputable;
  48387. this.loaded = loaded;
  48388. this.total = total;
  48389. }
  48390. /**
  48391. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48392. * @param event defines the source event
  48393. * @returns a new SceneLoaderProgressEvent
  48394. */
  48395. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48396. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48397. };
  48398. return SceneLoaderProgressEvent;
  48399. }());
  48400. /**
  48401. * Class used to load scene from various file formats using registered plugins
  48402. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48403. */
  48404. var SceneLoader = /** @class */ (function () {
  48405. function SceneLoader() {
  48406. }
  48407. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48408. /**
  48409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48410. */
  48411. get: function () {
  48412. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48413. },
  48414. set: function (value) {
  48415. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48416. },
  48417. enumerable: true,
  48418. configurable: true
  48419. });
  48420. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48421. /**
  48422. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48423. */
  48424. get: function () {
  48425. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48426. },
  48427. set: function (value) {
  48428. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48429. },
  48430. enumerable: true,
  48431. configurable: true
  48432. });
  48433. Object.defineProperty(SceneLoader, "loggingLevel", {
  48434. /**
  48435. * Defines the current logging level (while loading the scene)
  48436. * @ignorenaming
  48437. */
  48438. get: function () {
  48439. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48440. },
  48441. set: function (value) {
  48442. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48443. },
  48444. enumerable: true,
  48445. configurable: true
  48446. });
  48447. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48448. /**
  48449. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48450. */
  48451. get: function () {
  48452. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48453. },
  48454. set: function (value) {
  48455. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48456. },
  48457. enumerable: true,
  48458. configurable: true
  48459. });
  48460. SceneLoader._getDefaultPlugin = function () {
  48461. return SceneLoader._registeredPlugins[".babylon"];
  48462. };
  48463. SceneLoader._getPluginForExtension = function (extension) {
  48464. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48465. if (registeredPlugin) {
  48466. return registeredPlugin;
  48467. }
  48468. _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");
  48469. return SceneLoader._getDefaultPlugin();
  48470. };
  48471. SceneLoader._getPluginForDirectLoad = function (data) {
  48472. for (var extension in SceneLoader._registeredPlugins) {
  48473. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48474. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48475. return SceneLoader._registeredPlugins[extension];
  48476. }
  48477. }
  48478. return SceneLoader._getDefaultPlugin();
  48479. };
  48480. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48481. var queryStringPosition = sceneFilename.indexOf("?");
  48482. if (queryStringPosition !== -1) {
  48483. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48484. }
  48485. var dotPosition = sceneFilename.lastIndexOf(".");
  48486. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48487. return SceneLoader._getPluginForExtension(extension);
  48488. };
  48489. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48490. SceneLoader._getDirectLoad = function (sceneFilename) {
  48491. if (sceneFilename.substr(0, 5) === "data:") {
  48492. return sceneFilename.substr(5);
  48493. }
  48494. return null;
  48495. };
  48496. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48497. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48498. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48499. var plugin;
  48500. if (registeredPlugin.plugin.createPlugin) {
  48501. plugin = registeredPlugin.plugin.createPlugin();
  48502. }
  48503. else {
  48504. plugin = registeredPlugin.plugin;
  48505. }
  48506. if (!plugin) {
  48507. 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.";
  48508. }
  48509. var useArrayBuffer = registeredPlugin.isBinary;
  48510. var offlineProvider;
  48511. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48512. var dataCallback = function (data, responseURL) {
  48513. if (scene.isDisposed) {
  48514. onError("Scene has been disposed");
  48515. return;
  48516. }
  48517. scene.offlineProvider = offlineProvider;
  48518. onSuccess(plugin, data, responseURL);
  48519. };
  48520. var request = null;
  48521. var pluginDisposed = false;
  48522. var onDisposeObservable = plugin.onDisposeObservable;
  48523. if (onDisposeObservable) {
  48524. onDisposeObservable.add(function () {
  48525. pluginDisposed = true;
  48526. if (request) {
  48527. request.abort();
  48528. request = null;
  48529. }
  48530. onDispose();
  48531. });
  48532. }
  48533. var manifestChecked = function () {
  48534. if (pluginDisposed) {
  48535. return;
  48536. }
  48537. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48538. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48539. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48540. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48541. });
  48542. };
  48543. if (directLoad) {
  48544. dataCallback(directLoad);
  48545. return plugin;
  48546. }
  48547. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48548. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48549. var engine = scene.getEngine();
  48550. var canUseOfflineSupport = engine.enableOfflineSupport;
  48551. if (canUseOfflineSupport) {
  48552. // Also check for exceptions
  48553. var exceptionFound = false;
  48554. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48555. var regex = _a[_i];
  48556. if (regex.test(fileInfo.url)) {
  48557. exceptionFound = true;
  48558. break;
  48559. }
  48560. }
  48561. canUseOfflineSupport = !exceptionFound;
  48562. }
  48563. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48564. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48565. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48566. }
  48567. else {
  48568. manifestChecked();
  48569. }
  48570. }
  48571. // Loading file from disk via input file or drag'n'drop
  48572. else {
  48573. if (file) {
  48574. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48575. }
  48576. else {
  48577. onError("Unable to find file named " + fileInfo.name);
  48578. }
  48579. }
  48580. return plugin;
  48581. };
  48582. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48583. var url;
  48584. var name;
  48585. var file = null;
  48586. if (!sceneFilename) {
  48587. url = rootUrl;
  48588. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48589. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48590. }
  48591. else if (sceneFilename.lastModified) {
  48592. var sceneFile = sceneFilename;
  48593. url = rootUrl + sceneFile.name;
  48594. name = sceneFile.name;
  48595. file = sceneFile;
  48596. }
  48597. else {
  48598. var filename = sceneFilename;
  48599. if (filename.substr(0, 1) === "/") {
  48600. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48601. return null;
  48602. }
  48603. url = rootUrl + filename;
  48604. name = filename;
  48605. }
  48606. return {
  48607. url: url,
  48608. rootUrl: rootUrl,
  48609. name: name,
  48610. file: file
  48611. };
  48612. };
  48613. // Public functions
  48614. /**
  48615. * Gets a plugin that can load the given extension
  48616. * @param extension defines the extension to load
  48617. * @returns a plugin or null if none works
  48618. */
  48619. SceneLoader.GetPluginForExtension = function (extension) {
  48620. return SceneLoader._getPluginForExtension(extension).plugin;
  48621. };
  48622. /**
  48623. * Gets a boolean indicating that the given extension can be loaded
  48624. * @param extension defines the extension to load
  48625. * @returns true if the extension is supported
  48626. */
  48627. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48628. return !!SceneLoader._registeredPlugins[extension];
  48629. };
  48630. /**
  48631. * Adds a new plugin to the list of registered plugins
  48632. * @param plugin defines the plugin to add
  48633. */
  48634. SceneLoader.RegisterPlugin = function (plugin) {
  48635. if (typeof plugin.extensions === "string") {
  48636. var extension = plugin.extensions;
  48637. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48638. plugin: plugin,
  48639. isBinary: false
  48640. };
  48641. }
  48642. else {
  48643. var extensions = plugin.extensions;
  48644. Object.keys(extensions).forEach(function (extension) {
  48645. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48646. plugin: plugin,
  48647. isBinary: extensions[extension].isBinary
  48648. };
  48649. });
  48650. }
  48651. };
  48652. /**
  48653. * Import meshes into a scene
  48654. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48655. * @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)
  48656. * @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)
  48657. * @param scene the instance of BABYLON.Scene to append to
  48658. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48659. * @param onProgress a callback with a progress event for each file being loaded
  48660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48661. * @param pluginExtension the extension used to determine the plugin
  48662. * @returns The loaded plugin
  48663. */
  48664. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48665. if (sceneFilename === void 0) { sceneFilename = ""; }
  48666. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48667. if (onSuccess === void 0) { onSuccess = null; }
  48668. if (onProgress === void 0) { onProgress = null; }
  48669. if (onError === void 0) { onError = null; }
  48670. if (pluginExtension === void 0) { pluginExtension = null; }
  48671. if (!scene) {
  48672. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48673. return null;
  48674. }
  48675. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48676. if (!fileInfo) {
  48677. return null;
  48678. }
  48679. var loadingToken = {};
  48680. scene._addPendingData(loadingToken);
  48681. var disposeHandler = function () {
  48682. scene._removePendingData(loadingToken);
  48683. };
  48684. var errorHandler = function (message, exception) {
  48685. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48686. if (onError) {
  48687. onError(scene, errorMessage, exception);
  48688. }
  48689. else {
  48690. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48691. // should the exception be thrown?
  48692. }
  48693. disposeHandler();
  48694. };
  48695. var progressHandler = onProgress ? function (event) {
  48696. try {
  48697. onProgress(event);
  48698. }
  48699. catch (e) {
  48700. errorHandler("Error in onProgress callback", e);
  48701. }
  48702. } : undefined;
  48703. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48704. scene.importedMeshesFiles.push(fileInfo.url);
  48705. if (onSuccess) {
  48706. try {
  48707. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48708. }
  48709. catch (e) {
  48710. errorHandler("Error in onSuccess callback", e);
  48711. }
  48712. }
  48713. scene._removePendingData(loadingToken);
  48714. };
  48715. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48716. if (plugin.rewriteRootURL) {
  48717. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48718. }
  48719. if (plugin.importMesh) {
  48720. var syncedPlugin = plugin;
  48721. var meshes = new Array();
  48722. var particleSystems = new Array();
  48723. var skeletons = new Array();
  48724. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48725. return;
  48726. }
  48727. scene.loadingPluginName = plugin.name;
  48728. successHandler(meshes, particleSystems, skeletons, []);
  48729. }
  48730. else {
  48731. var asyncedPlugin = plugin;
  48732. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48733. scene.loadingPluginName = plugin.name;
  48734. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48735. }).catch(function (error) {
  48736. errorHandler(error.message, error);
  48737. });
  48738. }
  48739. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48740. };
  48741. /**
  48742. * Import meshes into a scene
  48743. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48744. * @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)
  48745. * @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)
  48746. * @param scene the instance of BABYLON.Scene to append to
  48747. * @param onProgress a callback with a progress event for each file being loaded
  48748. * @param pluginExtension the extension used to determine the plugin
  48749. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48750. */
  48751. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48752. if (sceneFilename === void 0) { sceneFilename = ""; }
  48753. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48754. if (onProgress === void 0) { onProgress = null; }
  48755. if (pluginExtension === void 0) { pluginExtension = null; }
  48756. return new Promise(function (resolve, reject) {
  48757. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48758. resolve({
  48759. meshes: meshes,
  48760. particleSystems: particleSystems,
  48761. skeletons: skeletons,
  48762. animationGroups: animationGroups
  48763. });
  48764. }, onProgress, function (scene, message, exception) {
  48765. reject(exception || new Error(message));
  48766. }, pluginExtension);
  48767. });
  48768. };
  48769. /**
  48770. * Load a scene
  48771. * @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)
  48772. * @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)
  48773. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48774. * @param onSuccess a callback with the scene when import succeeds
  48775. * @param onProgress a callback with a progress event for each file being loaded
  48776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48777. * @param pluginExtension the extension used to determine the plugin
  48778. * @returns The loaded plugin
  48779. */
  48780. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48781. if (sceneFilename === void 0) { sceneFilename = ""; }
  48782. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48783. if (onSuccess === void 0) { onSuccess = null; }
  48784. if (onProgress === void 0) { onProgress = null; }
  48785. if (onError === void 0) { onError = null; }
  48786. if (pluginExtension === void 0) { pluginExtension = null; }
  48787. if (!engine) {
  48788. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48789. return null;
  48790. }
  48791. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48792. };
  48793. /**
  48794. * Load a scene
  48795. * @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)
  48796. * @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)
  48797. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48798. * @param onProgress a callback with a progress event for each file being loaded
  48799. * @param pluginExtension the extension used to determine the plugin
  48800. * @returns The loaded scene
  48801. */
  48802. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48803. if (sceneFilename === void 0) { sceneFilename = ""; }
  48804. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48805. if (onProgress === void 0) { onProgress = null; }
  48806. if (pluginExtension === void 0) { pluginExtension = null; }
  48807. return new Promise(function (resolve, reject) {
  48808. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48809. resolve(scene);
  48810. }, onProgress, function (scene, message, exception) {
  48811. reject(exception || new Error(message));
  48812. }, pluginExtension);
  48813. });
  48814. };
  48815. /**
  48816. * Append a scene
  48817. * @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)
  48818. * @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)
  48819. * @param scene is the instance of BABYLON.Scene to append to
  48820. * @param onSuccess a callback with the scene when import succeeds
  48821. * @param onProgress a callback with a progress event for each file being loaded
  48822. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48823. * @param pluginExtension the extension used to determine the plugin
  48824. * @returns The loaded plugin
  48825. */
  48826. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48827. if (sceneFilename === void 0) { sceneFilename = ""; }
  48828. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48829. if (onSuccess === void 0) { onSuccess = null; }
  48830. if (onProgress === void 0) { onProgress = null; }
  48831. if (onError === void 0) { onError = null; }
  48832. if (pluginExtension === void 0) { pluginExtension = null; }
  48833. if (!scene) {
  48834. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48835. return null;
  48836. }
  48837. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48838. if (!fileInfo) {
  48839. return null;
  48840. }
  48841. if (SceneLoader.ShowLoadingScreen) {
  48842. scene.getEngine().displayLoadingUI();
  48843. }
  48844. var loadingToken = {};
  48845. scene._addPendingData(loadingToken);
  48846. var disposeHandler = function () {
  48847. scene._removePendingData(loadingToken);
  48848. scene.getEngine().hideLoadingUI();
  48849. };
  48850. var errorHandler = function (message, exception) {
  48851. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48852. if (onError) {
  48853. onError(scene, errorMessage, exception);
  48854. }
  48855. else {
  48856. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48857. // should the exception be thrown?
  48858. }
  48859. disposeHandler();
  48860. };
  48861. var progressHandler = onProgress ? function (event) {
  48862. try {
  48863. onProgress(event);
  48864. }
  48865. catch (e) {
  48866. errorHandler("Error in onProgress callback", e);
  48867. }
  48868. } : undefined;
  48869. var successHandler = function () {
  48870. if (onSuccess) {
  48871. try {
  48872. onSuccess(scene);
  48873. }
  48874. catch (e) {
  48875. errorHandler("Error in onSuccess callback", e);
  48876. }
  48877. }
  48878. scene._removePendingData(loadingToken);
  48879. };
  48880. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48881. if (plugin.load) {
  48882. var syncedPlugin = plugin;
  48883. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  48884. return;
  48885. }
  48886. scene.loadingPluginName = plugin.name;
  48887. successHandler();
  48888. }
  48889. else {
  48890. var asyncedPlugin = plugin;
  48891. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  48892. scene.loadingPluginName = plugin.name;
  48893. successHandler();
  48894. }).catch(function (error) {
  48895. errorHandler(error.message, error);
  48896. });
  48897. }
  48898. if (SceneLoader.ShowLoadingScreen) {
  48899. scene.executeWhenReady(function () {
  48900. scene.getEngine().hideLoadingUI();
  48901. });
  48902. }
  48903. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48904. };
  48905. /**
  48906. * Append a scene
  48907. * @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)
  48908. * @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)
  48909. * @param scene is the instance of BABYLON.Scene to append to
  48910. * @param onProgress a callback with a progress event for each file being loaded
  48911. * @param pluginExtension the extension used to determine the plugin
  48912. * @returns The given scene
  48913. */
  48914. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48915. if (sceneFilename === void 0) { sceneFilename = ""; }
  48916. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48917. if (onProgress === void 0) { onProgress = null; }
  48918. if (pluginExtension === void 0) { pluginExtension = null; }
  48919. return new Promise(function (resolve, reject) {
  48920. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  48921. resolve(scene);
  48922. }, onProgress, function (scene, message, exception) {
  48923. reject(exception || new Error(message));
  48924. }, pluginExtension);
  48925. });
  48926. };
  48927. /**
  48928. * Load a scene into an asset container
  48929. * @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)
  48930. * @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)
  48931. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48932. * @param onSuccess a callback with the scene when import succeeds
  48933. * @param onProgress a callback with a progress event for each file being loaded
  48934. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48935. * @param pluginExtension the extension used to determine the plugin
  48936. * @returns The loaded plugin
  48937. */
  48938. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48939. if (sceneFilename === void 0) { sceneFilename = ""; }
  48940. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48941. if (onSuccess === void 0) { onSuccess = null; }
  48942. if (onProgress === void 0) { onProgress = null; }
  48943. if (onError === void 0) { onError = null; }
  48944. if (pluginExtension === void 0) { pluginExtension = null; }
  48945. if (!scene) {
  48946. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  48947. return null;
  48948. }
  48949. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48950. if (!fileInfo) {
  48951. return null;
  48952. }
  48953. var loadingToken = {};
  48954. scene._addPendingData(loadingToken);
  48955. var disposeHandler = function () {
  48956. scene._removePendingData(loadingToken);
  48957. };
  48958. var errorHandler = function (message, exception) {
  48959. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  48960. if (onError) {
  48961. onError(scene, errorMessage, exception);
  48962. }
  48963. else {
  48964. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48965. // should the exception be thrown?
  48966. }
  48967. disposeHandler();
  48968. };
  48969. var progressHandler = onProgress ? function (event) {
  48970. try {
  48971. onProgress(event);
  48972. }
  48973. catch (e) {
  48974. errorHandler("Error in onProgress callback", e);
  48975. }
  48976. } : undefined;
  48977. var successHandler = function (assets) {
  48978. if (onSuccess) {
  48979. try {
  48980. onSuccess(assets);
  48981. }
  48982. catch (e) {
  48983. errorHandler("Error in onSuccess callback", e);
  48984. }
  48985. }
  48986. scene._removePendingData(loadingToken);
  48987. };
  48988. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48989. if (plugin.loadAssetContainer) {
  48990. var syncedPlugin = plugin;
  48991. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  48992. if (!assetContainer) {
  48993. return;
  48994. }
  48995. scene.loadingPluginName = plugin.name;
  48996. successHandler(assetContainer);
  48997. }
  48998. else if (plugin.loadAssetContainerAsync) {
  48999. var asyncedPlugin = plugin;
  49000. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49001. scene.loadingPluginName = plugin.name;
  49002. successHandler(assetContainer);
  49003. }).catch(function (error) {
  49004. errorHandler(error.message, error);
  49005. });
  49006. }
  49007. else {
  49008. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49009. }
  49010. if (SceneLoader.ShowLoadingScreen) {
  49011. scene.executeWhenReady(function () {
  49012. scene.getEngine().hideLoadingUI();
  49013. });
  49014. }
  49015. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49016. };
  49017. /**
  49018. * Load a scene into an asset container
  49019. * @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)
  49020. * @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)
  49021. * @param scene is the instance of Scene to append to
  49022. * @param onProgress a callback with a progress event for each file being loaded
  49023. * @param pluginExtension the extension used to determine the plugin
  49024. * @returns The loaded asset container
  49025. */
  49026. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49027. if (sceneFilename === void 0) { sceneFilename = ""; }
  49028. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49029. if (onProgress === void 0) { onProgress = null; }
  49030. if (pluginExtension === void 0) { pluginExtension = null; }
  49031. return new Promise(function (resolve, reject) {
  49032. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49033. resolve(assetContainer);
  49034. }, onProgress, function (scene, message, exception) {
  49035. reject(exception || new Error(message));
  49036. }, pluginExtension);
  49037. });
  49038. };
  49039. /**
  49040. * No logging while loading
  49041. */
  49042. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49043. /**
  49044. * Minimal logging while loading
  49045. */
  49046. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49047. /**
  49048. * Summary logging while loading
  49049. */
  49050. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49051. /**
  49052. * Detailled logging while loading
  49053. */
  49054. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49055. // Members
  49056. /**
  49057. * Event raised when a plugin is used to load a scene
  49058. */
  49059. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49060. SceneLoader._registeredPlugins = {};
  49061. return SceneLoader;
  49062. }());
  49063. /***/ }),
  49064. /***/ "./Loading/sceneLoaderFlags.ts":
  49065. /*!*************************************!*\
  49066. !*** ./Loading/sceneLoaderFlags.ts ***!
  49067. \*************************************/
  49068. /*! exports provided: SceneLoaderFlags */
  49069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49070. "use strict";
  49071. __webpack_require__.r(__webpack_exports__);
  49072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49073. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49074. /**
  49075. * Class used to represent data loading progression
  49076. */
  49077. var SceneLoaderFlags = /** @class */ (function () {
  49078. function SceneLoaderFlags() {
  49079. }
  49080. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49081. /**
  49082. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49083. */
  49084. get: function () {
  49085. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49086. },
  49087. set: function (value) {
  49088. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49089. },
  49090. enumerable: true,
  49091. configurable: true
  49092. });
  49093. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49094. /**
  49095. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49096. */
  49097. get: function () {
  49098. return SceneLoaderFlags._ShowLoadingScreen;
  49099. },
  49100. set: function (value) {
  49101. SceneLoaderFlags._ShowLoadingScreen = value;
  49102. },
  49103. enumerable: true,
  49104. configurable: true
  49105. });
  49106. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49107. /**
  49108. * Defines the current logging level (while loading the scene)
  49109. * @ignorenaming
  49110. */
  49111. get: function () {
  49112. return SceneLoaderFlags._loggingLevel;
  49113. },
  49114. set: function (value) {
  49115. SceneLoaderFlags._loggingLevel = value;
  49116. },
  49117. enumerable: true,
  49118. configurable: true
  49119. });
  49120. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49121. /**
  49122. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49123. */
  49124. get: function () {
  49125. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49126. },
  49127. set: function (value) {
  49128. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49129. },
  49130. enumerable: true,
  49131. configurable: true
  49132. });
  49133. // Flags
  49134. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49135. SceneLoaderFlags._ShowLoadingScreen = true;
  49136. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49137. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49138. return SceneLoaderFlags;
  49139. }());
  49140. /***/ }),
  49141. /***/ "./Materials/Background/backgroundMaterial.ts":
  49142. /*!****************************************************!*\
  49143. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49144. \****************************************************/
  49145. /*! exports provided: BackgroundMaterial */
  49146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49147. "use strict";
  49148. __webpack_require__.r(__webpack_exports__);
  49149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49150. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49151. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49152. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49153. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49155. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49156. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49157. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49158. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49159. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49160. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49161. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49162. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49163. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49164. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49165. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49166. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49167. /**
  49168. * Background material defines definition.
  49169. * @hidden Mainly internal Use
  49170. */
  49171. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49173. /**
  49174. * Constructor of the defines.
  49175. */
  49176. function BackgroundMaterialDefines() {
  49177. var _this = _super.call(this) || this;
  49178. /**
  49179. * True if the diffuse texture is in use.
  49180. */
  49181. _this.DIFFUSE = false;
  49182. /**
  49183. * The direct UV channel to use.
  49184. */
  49185. _this.DIFFUSEDIRECTUV = 0;
  49186. /**
  49187. * True if the diffuse texture is in gamma space.
  49188. */
  49189. _this.GAMMADIFFUSE = false;
  49190. /**
  49191. * True if the diffuse texture has opacity in the alpha channel.
  49192. */
  49193. _this.DIFFUSEHASALPHA = false;
  49194. /**
  49195. * True if you want the material to fade to transparent at grazing angle.
  49196. */
  49197. _this.OPACITYFRESNEL = false;
  49198. /**
  49199. * True if an extra blur needs to be added in the reflection.
  49200. */
  49201. _this.REFLECTIONBLUR = false;
  49202. /**
  49203. * True if you want the material to fade to reflection at grazing angle.
  49204. */
  49205. _this.REFLECTIONFRESNEL = false;
  49206. /**
  49207. * True if you want the material to falloff as far as you move away from the scene center.
  49208. */
  49209. _this.REFLECTIONFALLOFF = false;
  49210. /**
  49211. * False if the current Webgl implementation does not support the texture lod extension.
  49212. */
  49213. _this.TEXTURELODSUPPORT = false;
  49214. /**
  49215. * True to ensure the data are premultiplied.
  49216. */
  49217. _this.PREMULTIPLYALPHA = false;
  49218. /**
  49219. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49220. */
  49221. _this.USERGBCOLOR = false;
  49222. /**
  49223. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49224. * stays aligned with the desired configuration.
  49225. */
  49226. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49227. /**
  49228. * True to add noise in order to reduce the banding effect.
  49229. */
  49230. _this.NOISE = false;
  49231. /**
  49232. * is the reflection texture in BGR color scheme?
  49233. * Mainly used to solve a bug in ios10 video tag
  49234. */
  49235. _this.REFLECTIONBGR = false;
  49236. _this.IMAGEPROCESSING = false;
  49237. _this.VIGNETTE = false;
  49238. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49239. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49240. _this.TONEMAPPING = false;
  49241. _this.TONEMAPPING_ACES = false;
  49242. _this.CONTRAST = false;
  49243. _this.COLORCURVES = false;
  49244. _this.COLORGRADING = false;
  49245. _this.COLORGRADING3D = false;
  49246. _this.SAMPLER3DGREENDEPTH = false;
  49247. _this.SAMPLER3DBGRMAP = false;
  49248. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49249. _this.EXPOSURE = false;
  49250. // Reflection.
  49251. _this.REFLECTION = false;
  49252. _this.REFLECTIONMAP_3D = false;
  49253. _this.REFLECTIONMAP_SPHERICAL = false;
  49254. _this.REFLECTIONMAP_PLANAR = false;
  49255. _this.REFLECTIONMAP_CUBIC = false;
  49256. _this.REFLECTIONMAP_PROJECTION = false;
  49257. _this.REFLECTIONMAP_SKYBOX = false;
  49258. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49259. _this.REFLECTIONMAP_EXPLICIT = false;
  49260. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49261. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49262. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49263. _this.INVERTCUBICMAP = false;
  49264. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49265. _this.LODINREFLECTIONALPHA = false;
  49266. _this.GAMMAREFLECTION = false;
  49267. _this.RGBDREFLECTION = false;
  49268. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49269. // Default BJS.
  49270. _this.MAINUV1 = false;
  49271. _this.MAINUV2 = false;
  49272. _this.UV1 = false;
  49273. _this.UV2 = false;
  49274. _this.CLIPPLANE = false;
  49275. _this.CLIPPLANE2 = false;
  49276. _this.CLIPPLANE3 = false;
  49277. _this.CLIPPLANE4 = false;
  49278. _this.POINTSIZE = false;
  49279. _this.FOG = false;
  49280. _this.NORMAL = false;
  49281. _this.NUM_BONE_INFLUENCERS = 0;
  49282. _this.BonesPerMesh = 0;
  49283. _this.INSTANCES = false;
  49284. _this.SHADOWFLOAT = false;
  49285. _this.rebuild();
  49286. return _this;
  49287. }
  49288. return BackgroundMaterialDefines;
  49289. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49290. /**
  49291. * Background material used to create an efficient environement around your scene.
  49292. */
  49293. var BackgroundMaterial = /** @class */ (function (_super) {
  49294. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49295. /**
  49296. * Instantiates a Background Material in the given scene
  49297. * @param name The friendly name of the material
  49298. * @param scene The scene to add the material to
  49299. */
  49300. function BackgroundMaterial(name, scene) {
  49301. var _this = _super.call(this, name, scene) || this;
  49302. /**
  49303. * Key light Color (multiply against the environement texture)
  49304. */
  49305. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49306. _this._primaryColorShadowLevel = 0;
  49307. _this._primaryColorHighlightLevel = 0;
  49308. /**
  49309. * Reflection Texture used in the material.
  49310. * Should be author in a specific way for the best result (refer to the documentation).
  49311. */
  49312. _this.reflectionTexture = null;
  49313. /**
  49314. * Reflection Texture level of blur.
  49315. *
  49316. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49317. * texture twice.
  49318. */
  49319. _this.reflectionBlur = 0;
  49320. /**
  49321. * Diffuse Texture used in the material.
  49322. * Should be author in a specific way for the best result (refer to the documentation).
  49323. */
  49324. _this.diffuseTexture = null;
  49325. _this._shadowLights = null;
  49326. /**
  49327. * Specify the list of lights casting shadow on the material.
  49328. * All scene shadow lights will be included if null.
  49329. */
  49330. _this.shadowLights = null;
  49331. /**
  49332. * Helps adjusting the shadow to a softer level if required.
  49333. * 0 means black shadows and 1 means no shadows.
  49334. */
  49335. _this.shadowLevel = 0;
  49336. /**
  49337. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49338. * It is usually zero but might be interesting to modify according to your setup.
  49339. */
  49340. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49341. /**
  49342. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49343. * This helps ensuring a nice transition when the camera goes under the ground.
  49344. */
  49345. _this.opacityFresnel = true;
  49346. /**
  49347. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49348. * This helps adding a mirror texture on the ground.
  49349. */
  49350. _this.reflectionFresnel = false;
  49351. /**
  49352. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49353. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49354. */
  49355. _this.reflectionFalloffDistance = 0.0;
  49356. /**
  49357. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49358. */
  49359. _this.reflectionAmount = 1.0;
  49360. /**
  49361. * This specifies the weight of the reflection at grazing angle.
  49362. */
  49363. _this.reflectionReflectance0 = 0.05;
  49364. /**
  49365. * This specifies the weight of the reflection at a perpendicular point of view.
  49366. */
  49367. _this.reflectionReflectance90 = 0.5;
  49368. /**
  49369. * Helps to directly use the maps channels instead of their level.
  49370. */
  49371. _this.useRGBColor = true;
  49372. /**
  49373. * This helps reducing the banding effect that could occur on the background.
  49374. */
  49375. _this.enableNoise = false;
  49376. _this._fovMultiplier = 1.0;
  49377. /**
  49378. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49379. */
  49380. _this.useEquirectangularFOV = false;
  49381. _this._maxSimultaneousLights = 4;
  49382. /**
  49383. * Number of Simultaneous lights allowed on the material.
  49384. */
  49385. _this.maxSimultaneousLights = 4;
  49386. /**
  49387. * Keep track of the image processing observer to allow dispose and replace.
  49388. */
  49389. _this._imageProcessingObserver = null;
  49390. /**
  49391. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49392. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49393. */
  49394. _this.switchToBGR = false;
  49395. // Temp values kept as cache in the material.
  49396. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49397. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49398. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49399. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49400. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49401. // Setup the default processing configuration to the scene.
  49402. _this._attachImageProcessingConfiguration(null);
  49403. _this.getRenderTargetTextures = function () {
  49404. _this._renderTargets.reset();
  49405. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49406. _this._renderTargets.push(_this._diffuseTexture);
  49407. }
  49408. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49409. _this._renderTargets.push(_this._reflectionTexture);
  49410. }
  49411. return _this._renderTargets;
  49412. };
  49413. return _this;
  49414. }
  49415. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49416. /**
  49417. * Experimental Internal Use Only.
  49418. *
  49419. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49420. * This acts as a helper to set the primary color to a more "human friendly" value.
  49421. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49422. * output color as close as possible from the chosen value.
  49423. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49424. * part of lighting setup.)
  49425. */
  49426. get: function () {
  49427. return this.__perceptualColor;
  49428. },
  49429. set: function (value) {
  49430. this.__perceptualColor = value;
  49431. this._computePrimaryColorFromPerceptualColor();
  49432. this._markAllSubMeshesAsLightsDirty();
  49433. },
  49434. enumerable: true,
  49435. configurable: true
  49436. });
  49437. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49438. /**
  49439. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49440. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49441. */
  49442. get: function () {
  49443. return this._primaryColorShadowLevel;
  49444. },
  49445. set: function (value) {
  49446. this._primaryColorShadowLevel = value;
  49447. this._computePrimaryColors();
  49448. this._markAllSubMeshesAsLightsDirty();
  49449. },
  49450. enumerable: true,
  49451. configurable: true
  49452. });
  49453. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49454. /**
  49455. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49456. * The primary color is used at the level chosen to define what the white area would look.
  49457. */
  49458. get: function () {
  49459. return this._primaryColorHighlightLevel;
  49460. },
  49461. set: function (value) {
  49462. this._primaryColorHighlightLevel = value;
  49463. this._computePrimaryColors();
  49464. this._markAllSubMeshesAsLightsDirty();
  49465. },
  49466. enumerable: true,
  49467. configurable: true
  49468. });
  49469. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49470. /**
  49471. * Sets the reflection reflectance fresnel values according to the default standard
  49472. * empirically know to work well :-)
  49473. */
  49474. set: function (value) {
  49475. var reflectionWeight = value;
  49476. if (reflectionWeight < 0.5) {
  49477. reflectionWeight = reflectionWeight * 2.0;
  49478. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49479. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49480. }
  49481. else {
  49482. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49483. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49484. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49485. }
  49486. },
  49487. enumerable: true,
  49488. configurable: true
  49489. });
  49490. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49491. /**
  49492. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49493. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49494. * Recommended to be keep at 1.0 except for special cases.
  49495. */
  49496. get: function () {
  49497. return this._fovMultiplier;
  49498. },
  49499. set: function (value) {
  49500. if (isNaN(value)) {
  49501. value = 1.0;
  49502. }
  49503. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49504. },
  49505. enumerable: true,
  49506. configurable: true
  49507. });
  49508. /**
  49509. * Attaches a new image processing configuration to the PBR Material.
  49510. * @param configuration (if null the scene configuration will be use)
  49511. */
  49512. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49513. var _this = this;
  49514. if (configuration === this._imageProcessingConfiguration) {
  49515. return;
  49516. }
  49517. // Detaches observer.
  49518. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49519. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49520. }
  49521. // Pick the scene configuration if needed.
  49522. if (!configuration) {
  49523. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49524. }
  49525. else {
  49526. this._imageProcessingConfiguration = configuration;
  49527. }
  49528. // Attaches observer.
  49529. if (this._imageProcessingConfiguration) {
  49530. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49531. _this._computePrimaryColorFromPerceptualColor();
  49532. _this._markAllSubMeshesAsImageProcessingDirty();
  49533. });
  49534. }
  49535. };
  49536. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49537. /**
  49538. * Gets the image processing configuration used either in this material.
  49539. */
  49540. get: function () {
  49541. return this._imageProcessingConfiguration;
  49542. },
  49543. /**
  49544. * Sets the Default image processing configuration used either in the this material.
  49545. *
  49546. * If sets to null, the scene one is in use.
  49547. */
  49548. set: function (value) {
  49549. this._attachImageProcessingConfiguration(value);
  49550. // Ensure the effect will be rebuilt.
  49551. this._markAllSubMeshesAsTexturesDirty();
  49552. },
  49553. enumerable: true,
  49554. configurable: true
  49555. });
  49556. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49557. /**
  49558. * Gets wether the color curves effect is enabled.
  49559. */
  49560. get: function () {
  49561. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49562. },
  49563. /**
  49564. * Sets wether the color curves effect is enabled.
  49565. */
  49566. set: function (value) {
  49567. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49568. },
  49569. enumerable: true,
  49570. configurable: true
  49571. });
  49572. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49573. /**
  49574. * Gets wether the color grading effect is enabled.
  49575. */
  49576. get: function () {
  49577. return this.imageProcessingConfiguration.colorGradingEnabled;
  49578. },
  49579. /**
  49580. * Gets wether the color grading effect is enabled.
  49581. */
  49582. set: function (value) {
  49583. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49584. },
  49585. enumerable: true,
  49586. configurable: true
  49587. });
  49588. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49589. /**
  49590. * Gets wether tonemapping is enabled or not.
  49591. */
  49592. get: function () {
  49593. return this._imageProcessingConfiguration.toneMappingEnabled;
  49594. },
  49595. /**
  49596. * Sets wether tonemapping is enabled or not
  49597. */
  49598. set: function (value) {
  49599. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49600. },
  49601. enumerable: true,
  49602. configurable: true
  49603. });
  49604. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49605. /**
  49606. * The camera exposure used on this material.
  49607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49608. * This corresponds to a photographic exposure.
  49609. */
  49610. get: function () {
  49611. return this._imageProcessingConfiguration.exposure;
  49612. },
  49613. /**
  49614. * The camera exposure used on this material.
  49615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49616. * This corresponds to a photographic exposure.
  49617. */
  49618. set: function (value) {
  49619. this._imageProcessingConfiguration.exposure = value;
  49620. },
  49621. enumerable: true,
  49622. configurable: true
  49623. });
  49624. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49625. /**
  49626. * Gets The camera contrast used on this material.
  49627. */
  49628. get: function () {
  49629. return this._imageProcessingConfiguration.contrast;
  49630. },
  49631. /**
  49632. * Sets The camera contrast used on this material.
  49633. */
  49634. set: function (value) {
  49635. this._imageProcessingConfiguration.contrast = value;
  49636. },
  49637. enumerable: true,
  49638. configurable: true
  49639. });
  49640. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49641. /**
  49642. * Gets the Color Grading 2D Lookup Texture.
  49643. */
  49644. get: function () {
  49645. return this._imageProcessingConfiguration.colorGradingTexture;
  49646. },
  49647. /**
  49648. * Sets the Color Grading 2D Lookup Texture.
  49649. */
  49650. set: function (value) {
  49651. this.imageProcessingConfiguration.colorGradingTexture = value;
  49652. },
  49653. enumerable: true,
  49654. configurable: true
  49655. });
  49656. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49657. /**
  49658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49660. * 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;
  49661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49662. */
  49663. get: function () {
  49664. return this.imageProcessingConfiguration.colorCurves;
  49665. },
  49666. /**
  49667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49669. * 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;
  49670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49671. */
  49672. set: function (value) {
  49673. this.imageProcessingConfiguration.colorCurves = value;
  49674. },
  49675. enumerable: true,
  49676. configurable: true
  49677. });
  49678. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49679. /**
  49680. * Gets a boolean indicating that current material needs to register RTT
  49681. */
  49682. get: function () {
  49683. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49684. return true;
  49685. }
  49686. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49687. return true;
  49688. }
  49689. return false;
  49690. },
  49691. enumerable: true,
  49692. configurable: true
  49693. });
  49694. /**
  49695. * The entire material has been created in order to prevent overdraw.
  49696. * @returns false
  49697. */
  49698. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49699. return true;
  49700. };
  49701. /**
  49702. * The entire material has been created in order to prevent overdraw.
  49703. * @returns true if blending is enable
  49704. */
  49705. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49706. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49707. };
  49708. /**
  49709. * Checks wether the material is ready to be rendered for a given mesh.
  49710. * @param mesh The mesh to render
  49711. * @param subMesh The submesh to check against
  49712. * @param useInstances Specify wether or not the material is used with instances
  49713. * @returns true if all the dependencies are ready (Textures, Effects...)
  49714. */
  49715. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49716. var _this = this;
  49717. if (useInstances === void 0) { useInstances = false; }
  49718. if (subMesh.effect && this.isFrozen) {
  49719. if (this._wasPreviouslyReady) {
  49720. return true;
  49721. }
  49722. }
  49723. if (!subMesh._materialDefines) {
  49724. subMesh._materialDefines = new BackgroundMaterialDefines();
  49725. }
  49726. var scene = this.getScene();
  49727. var defines = subMesh._materialDefines;
  49728. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49729. if (defines._renderId === scene.getRenderId()) {
  49730. return true;
  49731. }
  49732. }
  49733. var engine = scene.getEngine();
  49734. // Lights
  49735. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49736. defines._needNormals = true;
  49737. // Textures
  49738. if (defines._areTexturesDirty) {
  49739. defines._needUVs = false;
  49740. if (scene.texturesEnabled) {
  49741. if (scene.getEngine().getCaps().textureLOD) {
  49742. defines.TEXTURELODSUPPORT = true;
  49743. }
  49744. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49745. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49746. return false;
  49747. }
  49748. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49749. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49750. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49751. defines.OPACITYFRESNEL = this._opacityFresnel;
  49752. }
  49753. else {
  49754. defines.DIFFUSE = false;
  49755. defines.DIFFUSEHASALPHA = false;
  49756. defines.GAMMADIFFUSE = false;
  49757. defines.OPACITYFRESNEL = false;
  49758. }
  49759. var reflectionTexture = this._reflectionTexture;
  49760. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49761. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49762. return false;
  49763. }
  49764. defines.REFLECTION = true;
  49765. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49766. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49767. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49768. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49769. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49770. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49771. defines.REFLECTIONBGR = this.switchToBGR;
  49772. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49773. defines.INVERTCUBICMAP = true;
  49774. }
  49775. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49776. switch (reflectionTexture.coordinatesMode) {
  49777. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49778. defines.REFLECTIONMAP_EXPLICIT = true;
  49779. break;
  49780. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49781. defines.REFLECTIONMAP_PLANAR = true;
  49782. break;
  49783. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49784. defines.REFLECTIONMAP_PROJECTION = true;
  49785. break;
  49786. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49787. defines.REFLECTIONMAP_SKYBOX = true;
  49788. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49789. break;
  49790. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49791. defines.REFLECTIONMAP_SPHERICAL = true;
  49792. break;
  49793. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49794. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49795. break;
  49796. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49797. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49798. break;
  49799. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49800. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49801. break;
  49802. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49803. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49804. default:
  49805. defines.REFLECTIONMAP_CUBIC = true;
  49806. break;
  49807. }
  49808. if (this.reflectionFresnel) {
  49809. defines.REFLECTIONFRESNEL = true;
  49810. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49811. this._reflectionControls.x = this.reflectionAmount;
  49812. this._reflectionControls.y = this.reflectionReflectance0;
  49813. this._reflectionControls.z = this.reflectionReflectance90;
  49814. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49815. }
  49816. else {
  49817. defines.REFLECTIONFRESNEL = false;
  49818. defines.REFLECTIONFALLOFF = false;
  49819. }
  49820. }
  49821. else {
  49822. defines.REFLECTION = false;
  49823. defines.REFLECTIONFRESNEL = false;
  49824. defines.REFLECTIONFALLOFF = false;
  49825. defines.REFLECTIONBLUR = false;
  49826. defines.REFLECTIONMAP_3D = false;
  49827. defines.REFLECTIONMAP_SPHERICAL = false;
  49828. defines.REFLECTIONMAP_PLANAR = false;
  49829. defines.REFLECTIONMAP_CUBIC = false;
  49830. defines.REFLECTIONMAP_PROJECTION = false;
  49831. defines.REFLECTIONMAP_SKYBOX = false;
  49832. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49833. defines.REFLECTIONMAP_EXPLICIT = false;
  49834. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49835. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49836. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49837. defines.INVERTCUBICMAP = false;
  49838. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49839. defines.LODINREFLECTIONALPHA = false;
  49840. defines.GAMMAREFLECTION = false;
  49841. defines.RGBDREFLECTION = false;
  49842. }
  49843. }
  49844. 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);
  49845. defines.USERGBCOLOR = this._useRGBColor;
  49846. defines.NOISE = this._enableNoise;
  49847. }
  49848. if (defines._areLightsDirty) {
  49849. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49850. }
  49851. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49852. if (!this._imageProcessingConfiguration.isReady()) {
  49853. return false;
  49854. }
  49855. this._imageProcessingConfiguration.prepareDefines(defines);
  49856. }
  49857. // Misc.
  49858. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49859. // Values that need to be evaluated on every frame
  49860. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49861. // Attribs
  49862. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49863. if (mesh) {
  49864. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49865. mesh.createNormals(true);
  49866. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49867. }
  49868. }
  49869. }
  49870. // Get correct effect
  49871. if (defines.isDirty) {
  49872. defines.markAsProcessed();
  49873. scene.resetCachedMaterial();
  49874. // Fallbacks
  49875. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49876. if (defines.FOG) {
  49877. fallbacks.addFallback(0, "FOG");
  49878. }
  49879. if (defines.POINTSIZE) {
  49880. fallbacks.addFallback(1, "POINTSIZE");
  49881. }
  49882. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  49883. if (defines.NUM_BONE_INFLUENCERS > 0) {
  49884. fallbacks.addCPUSkinningFallback(0, mesh);
  49885. }
  49886. //Attributes
  49887. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  49888. if (defines.NORMAL) {
  49889. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  49890. }
  49891. if (defines.UV1) {
  49892. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  49893. }
  49894. if (defines.UV2) {
  49895. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  49896. }
  49897. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  49898. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  49899. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  49900. "vFogInfos", "vFogColor", "pointSize",
  49901. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  49902. "vPrimaryColor", "vPrimaryColorShadow",
  49903. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  49904. "shadowLevel", "alpha",
  49905. "vBackgroundCenter", "vReflectionControl",
  49906. "vDiffuseInfos", "diffuseMatrix",
  49907. ];
  49908. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  49909. var uniformBuffers = ["Material", "Scene"];
  49910. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  49911. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  49912. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  49913. }
  49914. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  49915. uniformsNames: uniforms,
  49916. uniformBuffersNames: uniformBuffers,
  49917. samplers: samplers,
  49918. defines: defines,
  49919. maxSimultaneousLights: this._maxSimultaneousLights
  49920. });
  49921. var onCompiled = function (effect) {
  49922. if (_this.onCompiled) {
  49923. _this.onCompiled(effect);
  49924. }
  49925. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  49926. };
  49927. var join = defines.toString();
  49928. subMesh.setEffect(scene.getEngine().createEffect("background", {
  49929. attributes: attribs,
  49930. uniformsNames: uniforms,
  49931. uniformBuffersNames: uniformBuffers,
  49932. samplers: samplers,
  49933. defines: join,
  49934. fallbacks: fallbacks,
  49935. onCompiled: onCompiled,
  49936. onError: this.onError,
  49937. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  49938. }, engine), defines);
  49939. this.buildUniformLayout();
  49940. }
  49941. if (!subMesh.effect || !subMesh.effect.isReady()) {
  49942. return false;
  49943. }
  49944. defines._renderId = scene.getRenderId();
  49945. this._wasPreviouslyReady = true;
  49946. return true;
  49947. };
  49948. /**
  49949. * Compute the primary color according to the chosen perceptual color.
  49950. */
  49951. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  49952. if (!this.__perceptualColor) {
  49953. return;
  49954. }
  49955. this._primaryColor.copyFrom(this.__perceptualColor);
  49956. // Revert gamma space.
  49957. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  49958. // Revert image processing configuration.
  49959. if (this._imageProcessingConfiguration) {
  49960. // Revert Exposure.
  49961. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  49962. }
  49963. this._computePrimaryColors();
  49964. };
  49965. /**
  49966. * Compute the highlights and shadow colors according to their chosen levels.
  49967. */
  49968. BackgroundMaterial.prototype._computePrimaryColors = function () {
  49969. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  49970. return;
  49971. }
  49972. // Find the highlight color based on the configuration.
  49973. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  49974. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  49975. // Find the shadow color based on the configuration.
  49976. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  49977. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  49978. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  49979. };
  49980. /**
  49981. * Build the uniform buffer used in the material.
  49982. */
  49983. BackgroundMaterial.prototype.buildUniformLayout = function () {
  49984. // Order is important !
  49985. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  49986. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  49987. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  49988. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  49989. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  49990. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  49991. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  49992. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  49993. this._uniformBuffer.addUniform("pointSize", 1);
  49994. this._uniformBuffer.addUniform("shadowLevel", 1);
  49995. this._uniformBuffer.addUniform("alpha", 1);
  49996. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  49997. this._uniformBuffer.addUniform("vReflectionControl", 4);
  49998. this._uniformBuffer.create();
  49999. };
  50000. /**
  50001. * Unbind the material.
  50002. */
  50003. BackgroundMaterial.prototype.unbind = function () {
  50004. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50005. this._uniformBuffer.setTexture("diffuseSampler", null);
  50006. }
  50007. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50008. this._uniformBuffer.setTexture("reflectionSampler", null);
  50009. }
  50010. _super.prototype.unbind.call(this);
  50011. };
  50012. /**
  50013. * Bind only the world matrix to the material.
  50014. * @param world The world matrix to bind.
  50015. */
  50016. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50017. this._activeEffect.setMatrix("world", world);
  50018. };
  50019. /**
  50020. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50021. * @param world The world matrix to bind.
  50022. * @param subMesh The submesh to bind for.
  50023. */
  50024. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50025. var scene = this.getScene();
  50026. var defines = subMesh._materialDefines;
  50027. if (!defines) {
  50028. return;
  50029. }
  50030. var effect = subMesh.effect;
  50031. if (!effect) {
  50032. return;
  50033. }
  50034. this._activeEffect = effect;
  50035. // Matrices
  50036. this.bindOnlyWorldMatrix(world);
  50037. // Bones
  50038. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50039. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50040. if (mustRebind) {
  50041. this._uniformBuffer.bindToEffect(effect, "Material");
  50042. this.bindViewProjection(effect);
  50043. var reflectionTexture = this._reflectionTexture;
  50044. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50045. // Texture uniforms
  50046. if (scene.texturesEnabled) {
  50047. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50048. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50049. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50050. }
  50051. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50052. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50053. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50054. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50055. }
  50056. }
  50057. if (this.shadowLevel > 0) {
  50058. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50059. }
  50060. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50061. // Point size
  50062. if (this.pointsCloud) {
  50063. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50064. }
  50065. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50066. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50067. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50068. }
  50069. else {
  50070. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50071. }
  50072. }
  50073. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50074. // Textures
  50075. if (scene.texturesEnabled) {
  50076. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50077. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50078. }
  50079. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50080. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50081. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50082. }
  50083. else if (!defines.REFLECTIONBLUR) {
  50084. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50085. }
  50086. else {
  50087. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50088. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50089. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50090. }
  50091. if (defines.REFLECTIONFRESNEL) {
  50092. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50093. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50094. }
  50095. }
  50096. }
  50097. // Clip plane
  50098. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50099. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50100. }
  50101. if (mustRebind || !this.isFrozen) {
  50102. if (scene.lightsEnabled) {
  50103. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50104. }
  50105. // View
  50106. this.bindView(effect);
  50107. // Fog
  50108. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50109. // image processing
  50110. if (this._imageProcessingConfiguration) {
  50111. this._imageProcessingConfiguration.bind(this._activeEffect);
  50112. }
  50113. }
  50114. this._uniformBuffer.update();
  50115. this._afterBind(mesh, this._activeEffect);
  50116. };
  50117. /**
  50118. * Dispose the material.
  50119. * @param forceDisposeEffect Force disposal of the associated effect.
  50120. * @param forceDisposeTextures Force disposal of the associated textures.
  50121. */
  50122. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50123. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50124. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50125. if (forceDisposeTextures) {
  50126. if (this.diffuseTexture) {
  50127. this.diffuseTexture.dispose();
  50128. }
  50129. if (this.reflectionTexture) {
  50130. this.reflectionTexture.dispose();
  50131. }
  50132. }
  50133. this._renderTargets.dispose();
  50134. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50135. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50136. }
  50137. _super.prototype.dispose.call(this, forceDisposeEffect);
  50138. };
  50139. /**
  50140. * Clones the material.
  50141. * @param name The cloned name.
  50142. * @returns The cloned material.
  50143. */
  50144. BackgroundMaterial.prototype.clone = function (name) {
  50145. var _this = this;
  50146. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50147. };
  50148. /**
  50149. * Serializes the current material to its JSON representation.
  50150. * @returns The JSON representation.
  50151. */
  50152. BackgroundMaterial.prototype.serialize = function () {
  50153. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50154. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50155. return serializationObject;
  50156. };
  50157. /**
  50158. * Gets the class name of the material
  50159. * @returns "BackgroundMaterial"
  50160. */
  50161. BackgroundMaterial.prototype.getClassName = function () {
  50162. return "BackgroundMaterial";
  50163. };
  50164. /**
  50165. * Parse a JSON input to create back a background material.
  50166. * @param source The JSON data to parse
  50167. * @param scene The scene to create the parsed material in
  50168. * @param rootUrl The root url of the assets the material depends upon
  50169. * @returns the instantiated BackgroundMaterial.
  50170. */
  50171. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50172. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50173. };
  50174. /**
  50175. * Standard reflectance value at parallel view angle.
  50176. */
  50177. BackgroundMaterial.StandardReflectance0 = 0.05;
  50178. /**
  50179. * Standard reflectance value at grazing angle.
  50180. */
  50181. BackgroundMaterial.StandardReflectance90 = 0.5;
  50182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50184. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50187. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50190. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50193. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50196. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50199. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50202. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50205. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50208. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50211. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50214. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50217. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50220. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50223. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50226. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50229. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50232. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50235. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50238. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50241. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50244. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50247. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50250. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50253. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50256. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50259. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50262. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50265. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50268. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50271. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50274. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50277. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50280. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50283. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50286. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50289. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50290. return BackgroundMaterial;
  50291. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50292. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50293. /***/ }),
  50294. /***/ "./Materials/Background/index.ts":
  50295. /*!***************************************!*\
  50296. !*** ./Materials/Background/index.ts ***!
  50297. \***************************************/
  50298. /*! exports provided: BackgroundMaterial */
  50299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50300. "use strict";
  50301. __webpack_require__.r(__webpack_exports__);
  50302. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50304. /***/ }),
  50305. /***/ "./Materials/PBR/index.ts":
  50306. /*!********************************!*\
  50307. !*** ./Materials/PBR/index.ts ***!
  50308. \********************************/
  50309. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50311. "use strict";
  50312. __webpack_require__.r(__webpack_exports__);
  50313. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50315. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50317. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50319. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50321. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50323. /***/ }),
  50324. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50325. /*!******************************************!*\
  50326. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50327. \******************************************/
  50328. /*! exports provided: PBRBaseMaterial */
  50329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50330. "use strict";
  50331. __webpack_require__.r(__webpack_exports__);
  50332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50333. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50334. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50335. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50336. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50337. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50338. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50339. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50340. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50341. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50343. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50344. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50345. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50346. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50347. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50348. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50349. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50350. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50351. /**
  50352. * Manages the defines for the PBR Material.
  50353. * @hiddenChildren
  50354. */
  50355. var PBRMaterialDefines = /** @class */ (function (_super) {
  50356. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50357. /**
  50358. * Initializes the PBR Material defines.
  50359. */
  50360. function PBRMaterialDefines() {
  50361. var _this = _super.call(this) || this;
  50362. _this.PBR = true;
  50363. _this.MAINUV1 = false;
  50364. _this.MAINUV2 = false;
  50365. _this.UV1 = false;
  50366. _this.UV2 = false;
  50367. _this.ALBEDO = false;
  50368. _this.ALBEDODIRECTUV = 0;
  50369. _this.VERTEXCOLOR = false;
  50370. _this.AMBIENT = false;
  50371. _this.AMBIENTDIRECTUV = 0;
  50372. _this.AMBIENTINGRAYSCALE = false;
  50373. _this.OPACITY = false;
  50374. _this.VERTEXALPHA = false;
  50375. _this.OPACITYDIRECTUV = 0;
  50376. _this.OPACITYRGB = false;
  50377. _this.ALPHATEST = false;
  50378. _this.DEPTHPREPASS = false;
  50379. _this.ALPHABLEND = false;
  50380. _this.ALPHAFROMALBEDO = false;
  50381. _this.ALPHATESTVALUE = "0.5";
  50382. _this.SPECULAROVERALPHA = false;
  50383. _this.RADIANCEOVERALPHA = false;
  50384. _this.ALPHAFRESNEL = false;
  50385. _this.LINEARALPHAFRESNEL = false;
  50386. _this.PREMULTIPLYALPHA = false;
  50387. _this.EMISSIVE = false;
  50388. _this.EMISSIVEDIRECTUV = 0;
  50389. _this.REFLECTIVITY = false;
  50390. _this.REFLECTIVITYDIRECTUV = 0;
  50391. _this.SPECULARTERM = false;
  50392. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50393. _this.MICROSURFACEAUTOMATIC = false;
  50394. _this.LODBASEDMICROSFURACE = false;
  50395. _this.MICROSURFACEMAP = false;
  50396. _this.MICROSURFACEMAPDIRECTUV = 0;
  50397. _this.METALLICWORKFLOW = false;
  50398. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50399. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50400. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50401. _this.AOSTOREINMETALMAPRED = false;
  50402. _this.ENVIRONMENTBRDF = false;
  50403. _this.NORMAL = false;
  50404. _this.TANGENT = false;
  50405. _this.BUMP = false;
  50406. _this.BUMPDIRECTUV = 0;
  50407. _this.OBJECTSPACE_NORMALMAP = false;
  50408. _this.PARALLAX = false;
  50409. _this.PARALLAXOCCLUSION = false;
  50410. _this.NORMALXYSCALE = true;
  50411. _this.LIGHTMAP = false;
  50412. _this.LIGHTMAPDIRECTUV = 0;
  50413. _this.USELIGHTMAPASSHADOWMAP = false;
  50414. _this.GAMMALIGHTMAP = false;
  50415. _this.REFLECTION = false;
  50416. _this.REFLECTIONMAP_3D = false;
  50417. _this.REFLECTIONMAP_SPHERICAL = false;
  50418. _this.REFLECTIONMAP_PLANAR = false;
  50419. _this.REFLECTIONMAP_CUBIC = false;
  50420. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50421. _this.REFLECTIONMAP_PROJECTION = false;
  50422. _this.REFLECTIONMAP_SKYBOX = false;
  50423. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50424. _this.REFLECTIONMAP_EXPLICIT = false;
  50425. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50426. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50427. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50428. _this.INVERTCUBICMAP = false;
  50429. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50430. _this.USESPHERICALINVERTEX = false;
  50431. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50432. _this.LODINREFLECTIONALPHA = false;
  50433. _this.GAMMAREFLECTION = false;
  50434. _this.RGBDREFLECTION = false;
  50435. _this.RADIANCEOCCLUSION = false;
  50436. _this.HORIZONOCCLUSION = false;
  50437. _this.REFRACTION = false;
  50438. _this.REFRACTIONMAP_3D = false;
  50439. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50440. _this.LODINREFRACTIONALPHA = false;
  50441. _this.GAMMAREFRACTION = false;
  50442. _this.RGBDREFRACTION = false;
  50443. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50444. _this.INSTANCES = false;
  50445. _this.NUM_BONE_INFLUENCERS = 0;
  50446. _this.BonesPerMesh = 0;
  50447. _this.BONETEXTURE = false;
  50448. _this.NONUNIFORMSCALING = false;
  50449. _this.MORPHTARGETS = false;
  50450. _this.MORPHTARGETS_NORMAL = false;
  50451. _this.MORPHTARGETS_TANGENT = false;
  50452. _this.NUM_MORPH_INFLUENCERS = 0;
  50453. _this.IMAGEPROCESSING = false;
  50454. _this.VIGNETTE = false;
  50455. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50456. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50457. _this.TONEMAPPING = false;
  50458. _this.TONEMAPPING_ACES = false;
  50459. _this.CONTRAST = false;
  50460. _this.COLORCURVES = false;
  50461. _this.COLORGRADING = false;
  50462. _this.COLORGRADING3D = false;
  50463. _this.SAMPLER3DGREENDEPTH = false;
  50464. _this.SAMPLER3DBGRMAP = false;
  50465. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50466. _this.EXPOSURE = false;
  50467. _this.USEPHYSICALLIGHTFALLOFF = false;
  50468. _this.USEGLTFLIGHTFALLOFF = false;
  50469. _this.TWOSIDEDLIGHTING = false;
  50470. _this.SHADOWFLOAT = false;
  50471. _this.CLIPPLANE = false;
  50472. _this.CLIPPLANE2 = false;
  50473. _this.CLIPPLANE3 = false;
  50474. _this.CLIPPLANE4 = false;
  50475. _this.POINTSIZE = false;
  50476. _this.FOG = false;
  50477. _this.LOGARITHMICDEPTH = false;
  50478. _this.FORCENORMALFORWARD = false;
  50479. _this.SPECULARAA = false;
  50480. _this.UNLIT = false;
  50481. _this.rebuild();
  50482. return _this;
  50483. }
  50484. /**
  50485. * Resets the PBR Material defines.
  50486. */
  50487. PBRMaterialDefines.prototype.reset = function () {
  50488. _super.prototype.reset.call(this);
  50489. this.ALPHATESTVALUE = "0.5";
  50490. this.PBR = true;
  50491. };
  50492. return PBRMaterialDefines;
  50493. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  50494. /**
  50495. * The Physically based material base class of BJS.
  50496. *
  50497. * This offers the main features of a standard PBR material.
  50498. * For more information, please refer to the documentation :
  50499. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50500. */
  50501. var PBRBaseMaterial = /** @class */ (function (_super) {
  50502. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50503. /**
  50504. * Instantiates a new PBRMaterial instance.
  50505. *
  50506. * @param name The material name
  50507. * @param scene The scene the material will be use in.
  50508. */
  50509. function PBRBaseMaterial(name, scene) {
  50510. var _this = _super.call(this, name, scene) || this;
  50511. /**
  50512. * Intensity of the direct lights e.g. the four lights available in your scene.
  50513. * This impacts both the direct diffuse and specular highlights.
  50514. */
  50515. _this._directIntensity = 1.0;
  50516. /**
  50517. * Intensity of the emissive part of the material.
  50518. * This helps controlling the emissive effect without modifying the emissive color.
  50519. */
  50520. _this._emissiveIntensity = 1.0;
  50521. /**
  50522. * Intensity of the environment e.g. how much the environment will light the object
  50523. * either through harmonics for rough material or through the refelction for shiny ones.
  50524. */
  50525. _this._environmentIntensity = 1.0;
  50526. /**
  50527. * This is a special control allowing the reduction of the specular highlights coming from the
  50528. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50529. */
  50530. _this._specularIntensity = 1.0;
  50531. /**
  50532. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50533. */
  50534. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50535. /**
  50536. * Debug Control allowing disabling the bump map on this material.
  50537. */
  50538. _this._disableBumpMap = false;
  50539. /**
  50540. * AKA Occlusion Texture Intensity in other nomenclature.
  50541. */
  50542. _this._ambientTextureStrength = 1.0;
  50543. /**
  50544. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50545. * 1 means it completely occludes it
  50546. * 0 mean it has no impact
  50547. */
  50548. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50549. /**
  50550. * The color of a material in ambient lighting.
  50551. */
  50552. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50553. /**
  50554. * AKA Diffuse Color in other nomenclature.
  50555. */
  50556. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50557. /**
  50558. * AKA Specular Color in other nomenclature.
  50559. */
  50560. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50561. /**
  50562. * The color applied when light is reflected from a material.
  50563. */
  50564. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50565. /**
  50566. * The color applied when light is emitted from a material.
  50567. */
  50568. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50569. /**
  50570. * AKA Glossiness in other nomenclature.
  50571. */
  50572. _this._microSurface = 0.9;
  50573. /**
  50574. * source material index of refraction (IOR)' / 'destination material IOR.
  50575. */
  50576. _this._indexOfRefraction = 0.66;
  50577. /**
  50578. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50579. */
  50580. _this._invertRefractionY = false;
  50581. /**
  50582. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50583. * Materials half opaque for instance using refraction could benefit from this control.
  50584. */
  50585. _this._linkRefractionWithTransparency = false;
  50586. /**
  50587. * Specifies that the material will use the light map as a show map.
  50588. */
  50589. _this._useLightmapAsShadowmap = false;
  50590. /**
  50591. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50592. * makes the reflect vector face the model (under horizon).
  50593. */
  50594. _this._useHorizonOcclusion = true;
  50595. /**
  50596. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50597. * too much the area relying on ambient texture to define their ambient occlusion.
  50598. */
  50599. _this._useRadianceOcclusion = true;
  50600. /**
  50601. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50602. */
  50603. _this._useAlphaFromAlbedoTexture = false;
  50604. /**
  50605. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50607. */
  50608. _this._useSpecularOverAlpha = true;
  50609. /**
  50610. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50611. */
  50612. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50613. /**
  50614. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50615. */
  50616. _this._useRoughnessFromMetallicTextureAlpha = true;
  50617. /**
  50618. * Specifies if the metallic texture contains the roughness information in its green channel.
  50619. */
  50620. _this._useRoughnessFromMetallicTextureGreen = false;
  50621. /**
  50622. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50623. */
  50624. _this._useMetallnessFromMetallicTextureBlue = false;
  50625. /**
  50626. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50627. */
  50628. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50629. /**
  50630. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50631. */
  50632. _this._useAmbientInGrayScale = false;
  50633. /**
  50634. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50635. * The material will try to infer what glossiness each pixel should be.
  50636. */
  50637. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50638. /**
  50639. * Defines the falloff type used in this material.
  50640. * It by default is Physical.
  50641. */
  50642. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50643. /**
  50644. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50645. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50646. */
  50647. _this._useRadianceOverAlpha = true;
  50648. /**
  50649. * Allows using an object space normal map (instead of tangent space).
  50650. */
  50651. _this._useObjectSpaceNormalMap = false;
  50652. /**
  50653. * Allows using the bump map in parallax mode.
  50654. */
  50655. _this._useParallax = false;
  50656. /**
  50657. * Allows using the bump map in parallax occlusion mode.
  50658. */
  50659. _this._useParallaxOcclusion = false;
  50660. /**
  50661. * Controls the scale bias of the parallax mode.
  50662. */
  50663. _this._parallaxScaleBias = 0.05;
  50664. /**
  50665. * If sets to true, disables all the lights affecting the material.
  50666. */
  50667. _this._disableLighting = false;
  50668. /**
  50669. * Number of Simultaneous lights allowed on the material.
  50670. */
  50671. _this._maxSimultaneousLights = 4;
  50672. /**
  50673. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50674. */
  50675. _this._invertNormalMapX = false;
  50676. /**
  50677. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50678. */
  50679. _this._invertNormalMapY = false;
  50680. /**
  50681. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50682. */
  50683. _this._twoSidedLighting = false;
  50684. /**
  50685. * Defines the alpha limits in alpha test mode.
  50686. */
  50687. _this._alphaCutOff = 0.4;
  50688. /**
  50689. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50690. */
  50691. _this._forceAlphaTest = false;
  50692. /**
  50693. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50694. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50695. */
  50696. _this._useAlphaFresnel = false;
  50697. /**
  50698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50699. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50700. */
  50701. _this._useLinearAlphaFresnel = false;
  50702. /**
  50703. * The transparency mode of the material.
  50704. */
  50705. _this._transparencyMode = null;
  50706. /**
  50707. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50708. * from cos thetav and roughness:
  50709. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50710. */
  50711. _this._environmentBRDFTexture = null;
  50712. /**
  50713. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50714. */
  50715. _this._forceIrradianceInFragment = false;
  50716. /**
  50717. * Force normal to face away from face.
  50718. */
  50719. _this._forceNormalForward = false;
  50720. /**
  50721. * Enables specular anti aliasing in the PBR shader.
  50722. * It will both interacts on the Geometry for analytical and IBL lighting.
  50723. * It also prefilter the roughness map based on the bump values.
  50724. */
  50725. _this._enableSpecularAntiAliasing = false;
  50726. /**
  50727. * Stores the available render targets.
  50728. */
  50729. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50730. /**
  50731. * Sets the global ambient color for the material used in lighting calculations.
  50732. */
  50733. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50734. /**
  50735. * If set to true, no lighting calculations will be applied.
  50736. */
  50737. _this._unlit = false;
  50738. // Setup the default processing configuration to the scene.
  50739. _this._attachImageProcessingConfiguration(null);
  50740. _this.getRenderTargetTextures = function () {
  50741. _this._renderTargets.reset();
  50742. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50743. _this._renderTargets.push(_this._reflectionTexture);
  50744. }
  50745. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50746. _this._renderTargets.push(_this._refractionTexture);
  50747. }
  50748. return _this._renderTargets;
  50749. };
  50750. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50751. return _this;
  50752. }
  50753. /**
  50754. * Attaches a new image processing configuration to the PBR Material.
  50755. * @param configuration
  50756. */
  50757. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50758. var _this = this;
  50759. if (configuration === this._imageProcessingConfiguration) {
  50760. return;
  50761. }
  50762. // Detaches observer.
  50763. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50764. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50765. }
  50766. // Pick the scene configuration if needed.
  50767. if (!configuration) {
  50768. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50769. }
  50770. else {
  50771. this._imageProcessingConfiguration = configuration;
  50772. }
  50773. // Attaches observer.
  50774. if (this._imageProcessingConfiguration) {
  50775. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50776. _this._markAllSubMeshesAsImageProcessingDirty();
  50777. });
  50778. }
  50779. };
  50780. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50781. /**
  50782. * Gets a boolean indicating that current material needs to register RTT
  50783. */
  50784. get: function () {
  50785. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50786. return true;
  50787. }
  50788. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50789. return true;
  50790. }
  50791. return false;
  50792. },
  50793. enumerable: true,
  50794. configurable: true
  50795. });
  50796. /**
  50797. * Gets the name of the material class.
  50798. */
  50799. PBRBaseMaterial.prototype.getClassName = function () {
  50800. return "PBRBaseMaterial";
  50801. };
  50802. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50803. /**
  50804. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50805. */
  50806. get: function () {
  50807. return this._useLogarithmicDepth;
  50808. },
  50809. /**
  50810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50811. */
  50812. set: function (value) {
  50813. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50814. },
  50815. enumerable: true,
  50816. configurable: true
  50817. });
  50818. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50819. /**
  50820. * Gets the current transparency mode.
  50821. */
  50822. get: function () {
  50823. return this._transparencyMode;
  50824. },
  50825. /**
  50826. * Sets the transparency mode of the material.
  50827. *
  50828. * | Value | Type | Description |
  50829. * | ----- | ----------------------------------- | ----------- |
  50830. * | 0 | OPAQUE | |
  50831. * | 1 | ALPHATEST | |
  50832. * | 2 | ALPHABLEND | |
  50833. * | 3 | ALPHATESTANDBLEND | |
  50834. *
  50835. */
  50836. set: function (value) {
  50837. if (this._transparencyMode === value) {
  50838. return;
  50839. }
  50840. this._transparencyMode = value;
  50841. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50842. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50843. },
  50844. enumerable: true,
  50845. configurable: true
  50846. });
  50847. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50848. /**
  50849. * Returns true if alpha blending should be disabled.
  50850. */
  50851. get: function () {
  50852. return (this._linkRefractionWithTransparency ||
  50853. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50854. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50855. },
  50856. enumerable: true,
  50857. configurable: true
  50858. });
  50859. /**
  50860. * Specifies whether or not this material should be rendered in alpha blend mode.
  50861. */
  50862. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50863. if (this._disableAlphaBlending) {
  50864. return false;
  50865. }
  50866. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50867. };
  50868. /**
  50869. * Specifies if the mesh will require alpha blending.
  50870. * @param mesh - BJS mesh.
  50871. */
  50872. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50873. if (this._disableAlphaBlending) {
  50874. return false;
  50875. }
  50876. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50877. };
  50878. /**
  50879. * Specifies whether or not this material should be rendered in alpha test mode.
  50880. */
  50881. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50882. if (this._forceAlphaTest) {
  50883. return true;
  50884. }
  50885. if (this._linkRefractionWithTransparency) {
  50886. return false;
  50887. }
  50888. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50889. };
  50890. /**
  50891. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50892. */
  50893. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  50894. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  50895. };
  50896. /**
  50897. * Gets the texture used for the alpha test.
  50898. */
  50899. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  50900. return this._albedoTexture;
  50901. };
  50902. /**
  50903. * Specifies that the submesh is ready to be used.
  50904. * @param mesh - BJS mesh.
  50905. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50906. * @param useInstances - Specifies that instances should be used.
  50907. * @returns - boolean indicating that the submesh is ready or not.
  50908. */
  50909. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50910. if (subMesh.effect && this.isFrozen) {
  50911. if (this._wasPreviouslyReady) {
  50912. return true;
  50913. }
  50914. }
  50915. if (!subMesh._materialDefines) {
  50916. subMesh._materialDefines = new PBRMaterialDefines();
  50917. }
  50918. var defines = subMesh._materialDefines;
  50919. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50920. if (defines._renderId === this.getScene().getRenderId()) {
  50921. return true;
  50922. }
  50923. }
  50924. var scene = this.getScene();
  50925. var engine = scene.getEngine();
  50926. if (defines._areTexturesDirty) {
  50927. if (scene.texturesEnabled) {
  50928. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50929. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  50930. return false;
  50931. }
  50932. }
  50933. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50934. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  50935. return false;
  50936. }
  50937. }
  50938. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50939. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  50940. return false;
  50941. }
  50942. }
  50943. var reflectionTexture = this._getReflectionTexture();
  50944. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50945. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50946. return false;
  50947. }
  50948. }
  50949. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50950. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  50951. return false;
  50952. }
  50953. }
  50954. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50955. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  50956. return false;
  50957. }
  50958. }
  50959. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50960. if (this._metallicTexture) {
  50961. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  50962. return false;
  50963. }
  50964. }
  50965. else if (this._reflectivityTexture) {
  50966. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  50967. return false;
  50968. }
  50969. }
  50970. if (this._microSurfaceTexture) {
  50971. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  50972. return false;
  50973. }
  50974. }
  50975. }
  50976. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50977. // Bump texture cannot be not blocking.
  50978. if (!this._bumpTexture.isReady()) {
  50979. return false;
  50980. }
  50981. }
  50982. var refractionTexture = this._getRefractionTexture();
  50983. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50984. if (!refractionTexture.isReadyOrNotBlocking()) {
  50985. return false;
  50986. }
  50987. }
  50988. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50989. // This is blocking.
  50990. if (!this._environmentBRDFTexture.isReady()) {
  50991. return false;
  50992. }
  50993. }
  50994. }
  50995. }
  50996. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50997. if (!this._imageProcessingConfiguration.isReady()) {
  50998. return false;
  50999. }
  51000. }
  51001. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51002. mesh.createNormals(true);
  51003. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51004. }
  51005. var previousEffect = subMesh.effect;
  51006. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51007. if (effect) {
  51008. // Use previous effect while new one is compiling
  51009. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51010. effect = previousEffect;
  51011. defines.markAsUnprocessed();
  51012. }
  51013. else {
  51014. scene.resetCachedMaterial();
  51015. subMesh.setEffect(effect, defines);
  51016. this.buildUniformLayout();
  51017. }
  51018. }
  51019. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51020. return false;
  51021. }
  51022. defines._renderId = scene.getRenderId();
  51023. this._wasPreviouslyReady = true;
  51024. return true;
  51025. };
  51026. /**
  51027. * Specifies if the material uses metallic roughness workflow.
  51028. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51029. */
  51030. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  51031. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  51032. return true;
  51033. }
  51034. return false;
  51035. };
  51036. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  51037. if (onCompiled === void 0) { onCompiled = null; }
  51038. if (onError === void 0) { onError = null; }
  51039. if (useInstances === void 0) { useInstances = null; }
  51040. if (useClipPlane === void 0) { useClipPlane = null; }
  51041. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  51042. if (!defines.isDirty) {
  51043. return null;
  51044. }
  51045. defines.markAsProcessed();
  51046. var scene = this.getScene();
  51047. var engine = scene.getEngine();
  51048. // Fallbacks
  51049. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  51050. var fallbackRank = 0;
  51051. if (defines.USESPHERICALINVERTEX) {
  51052. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  51053. }
  51054. if (defines.FOG) {
  51055. fallbacks.addFallback(fallbackRank, "FOG");
  51056. }
  51057. if (defines.SPECULARAA) {
  51058. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  51059. }
  51060. if (defines.POINTSIZE) {
  51061. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  51062. }
  51063. if (defines.LOGARITHMICDEPTH) {
  51064. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  51065. }
  51066. if (defines.PARALLAX) {
  51067. fallbacks.addFallback(fallbackRank, "PARALLAX");
  51068. }
  51069. if (defines.PARALLAXOCCLUSION) {
  51070. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  51071. }
  51072. if (defines.ENVIRONMENTBRDF) {
  51073. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  51074. }
  51075. if (defines.TANGENT) {
  51076. fallbacks.addFallback(fallbackRank++, "TANGENT");
  51077. }
  51078. if (defines.BUMP) {
  51079. fallbacks.addFallback(fallbackRank++, "BUMP");
  51080. }
  51081. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  51082. if (defines.SPECULARTERM) {
  51083. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  51084. }
  51085. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  51086. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  51087. }
  51088. if (defines.LIGHTMAP) {
  51089. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  51090. }
  51091. if (defines.NORMAL) {
  51092. fallbacks.addFallback(fallbackRank++, "NORMAL");
  51093. }
  51094. if (defines.AMBIENT) {
  51095. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  51096. }
  51097. if (defines.EMISSIVE) {
  51098. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  51099. }
  51100. if (defines.VERTEXCOLOR) {
  51101. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  51102. }
  51103. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51104. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  51105. }
  51106. if (defines.MORPHTARGETS) {
  51107. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  51108. }
  51109. //Attributes
  51110. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  51111. if (defines.NORMAL) {
  51112. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  51113. }
  51114. if (defines.TANGENT) {
  51115. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  51116. }
  51117. if (defines.UV1) {
  51118. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  51119. }
  51120. if (defines.UV2) {
  51121. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  51122. }
  51123. if (defines.VERTEXCOLOR) {
  51124. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  51125. }
  51126. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51127. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51128. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  51129. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  51130. "vFogInfos", "vFogColor", "pointSize",
  51131. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  51132. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  51133. "mBones",
  51134. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  51135. "vLightingIntensity",
  51136. "logarithmicDepthConstant",
  51137. "vSphericalX", "vSphericalY", "vSphericalZ",
  51138. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  51139. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  51140. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  51141. "vTangentSpaceParams", "boneTextureWidth"
  51142. ];
  51143. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  51144. "bumpSampler", "lightmapSampler", "opacitySampler",
  51145. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  51146. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  51147. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  51148. var uniformBuffers = ["Material", "Scene"];
  51149. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  51150. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51151. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51152. }
  51153. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51154. uniformsNames: uniforms,
  51155. uniformBuffersNames: uniformBuffers,
  51156. samplers: samplers,
  51157. defines: defines,
  51158. maxSimultaneousLights: this._maxSimultaneousLights
  51159. });
  51160. var join = defines.toString();
  51161. return engine.createEffect("pbr", {
  51162. attributes: attribs,
  51163. uniformsNames: uniforms,
  51164. uniformBuffersNames: uniformBuffers,
  51165. samplers: samplers,
  51166. defines: join,
  51167. fallbacks: fallbacks,
  51168. onCompiled: onCompiled,
  51169. onError: onError,
  51170. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  51171. }, engine);
  51172. };
  51173. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51174. if (useInstances === void 0) { useInstances = null; }
  51175. if (useClipPlane === void 0) { useClipPlane = null; }
  51176. var scene = this.getScene();
  51177. var engine = scene.getEngine();
  51178. // Lights
  51179. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51180. defines._needNormals = true;
  51181. // Textures
  51182. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51183. if (defines._areTexturesDirty) {
  51184. defines._needUVs = false;
  51185. if (scene.texturesEnabled) {
  51186. if (scene.getEngine().getCaps().textureLOD) {
  51187. defines.LODBASEDMICROSFURACE = true;
  51188. }
  51189. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51190. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51191. }
  51192. else {
  51193. defines.ALBEDO = false;
  51194. }
  51195. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51196. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51197. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51198. }
  51199. else {
  51200. defines.AMBIENT = false;
  51201. }
  51202. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51203. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51204. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51205. }
  51206. else {
  51207. defines.OPACITY = false;
  51208. }
  51209. var reflectionTexture = this._getReflectionTexture();
  51210. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51211. defines.REFLECTION = true;
  51212. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51213. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51214. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51215. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51216. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  51217. defines.INVERTCUBICMAP = true;
  51218. }
  51219. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51220. defines.REFLECTIONMAP_CUBIC = false;
  51221. defines.REFLECTIONMAP_EXPLICIT = false;
  51222. defines.REFLECTIONMAP_PLANAR = false;
  51223. defines.REFLECTIONMAP_PROJECTION = false;
  51224. defines.REFLECTIONMAP_SKYBOX = false;
  51225. defines.REFLECTIONMAP_SPHERICAL = false;
  51226. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51227. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51228. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51229. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51230. switch (reflectionTexture.coordinatesMode) {
  51231. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  51232. defines.REFLECTIONMAP_EXPLICIT = true;
  51233. break;
  51234. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  51235. defines.REFLECTIONMAP_PLANAR = true;
  51236. break;
  51237. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  51238. defines.REFLECTIONMAP_PROJECTION = true;
  51239. break;
  51240. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  51241. defines.REFLECTIONMAP_SKYBOX = true;
  51242. break;
  51243. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  51244. defines.REFLECTIONMAP_SPHERICAL = true;
  51245. break;
  51246. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  51247. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51248. break;
  51249. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51250. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51251. break;
  51252. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51253. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51254. break;
  51255. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  51256. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  51257. default:
  51258. defines.REFLECTIONMAP_CUBIC = true;
  51259. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51260. break;
  51261. }
  51262. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  51263. if (reflectionTexture.sphericalPolynomial) {
  51264. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51265. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51266. defines.USESPHERICALINVERTEX = false;
  51267. }
  51268. else {
  51269. defines.USESPHERICALINVERTEX = true;
  51270. }
  51271. }
  51272. }
  51273. else {
  51274. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51275. }
  51276. }
  51277. else {
  51278. defines.REFLECTION = false;
  51279. defines.REFLECTIONMAP_3D = false;
  51280. defines.REFLECTIONMAP_SPHERICAL = false;
  51281. defines.REFLECTIONMAP_PLANAR = false;
  51282. defines.REFLECTIONMAP_CUBIC = false;
  51283. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51284. defines.REFLECTIONMAP_PROJECTION = false;
  51285. defines.REFLECTIONMAP_SKYBOX = false;
  51286. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51287. defines.REFLECTIONMAP_EXPLICIT = false;
  51288. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51289. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51290. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51291. defines.INVERTCUBICMAP = false;
  51292. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51293. defines.USESPHERICALINVERTEX = false;
  51294. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51295. defines.LODINREFLECTIONALPHA = false;
  51296. defines.GAMMAREFLECTION = false;
  51297. defines.RGBDREFLECTION = false;
  51298. }
  51299. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51300. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51301. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51302. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51303. }
  51304. else {
  51305. defines.LIGHTMAP = false;
  51306. }
  51307. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51308. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51309. }
  51310. else {
  51311. defines.EMISSIVE = false;
  51312. }
  51313. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51314. if (this._metallicTexture) {
  51315. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51316. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51317. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51318. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51319. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51320. }
  51321. else if (this._reflectivityTexture) {
  51322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51323. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51324. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51325. }
  51326. else {
  51327. defines.REFLECTIVITY = false;
  51328. }
  51329. if (this._microSurfaceTexture) {
  51330. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51331. }
  51332. else {
  51333. defines.MICROSURFACEMAP = false;
  51334. }
  51335. }
  51336. else {
  51337. defines.REFLECTIVITY = false;
  51338. defines.MICROSURFACEMAP = false;
  51339. }
  51340. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51341. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51342. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51343. defines.PARALLAX = true;
  51344. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51345. }
  51346. else {
  51347. defines.PARALLAX = false;
  51348. }
  51349. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51350. }
  51351. else {
  51352. defines.BUMP = false;
  51353. }
  51354. var refractionTexture = this._getRefractionTexture();
  51355. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51356. defines.REFRACTION = true;
  51357. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51358. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51359. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51360. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51361. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51362. if (this._linkRefractionWithTransparency) {
  51363. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51364. }
  51365. }
  51366. else {
  51367. defines.REFRACTION = false;
  51368. }
  51369. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51370. defines.ENVIRONMENTBRDF = true;
  51371. }
  51372. else {
  51373. defines.ENVIRONMENTBRDF = false;
  51374. }
  51375. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51376. defines.ALPHAFROMALBEDO = true;
  51377. }
  51378. else {
  51379. defines.ALPHAFROMALBEDO = false;
  51380. }
  51381. }
  51382. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51383. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51384. defines.USEPHYSICALLIGHTFALLOFF = false;
  51385. defines.USEGLTFLIGHTFALLOFF = false;
  51386. }
  51387. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51388. defines.USEPHYSICALLIGHTFALLOFF = false;
  51389. defines.USEGLTFLIGHTFALLOFF = true;
  51390. }
  51391. else {
  51392. defines.USEPHYSICALLIGHTFALLOFF = true;
  51393. defines.USEGLTFLIGHTFALLOFF = false;
  51394. }
  51395. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51396. if (!this.backFaceCulling && this._twoSidedLighting) {
  51397. defines.TWOSIDEDLIGHTING = true;
  51398. }
  51399. else {
  51400. defines.TWOSIDEDLIGHTING = false;
  51401. }
  51402. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51403. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  51404. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51405. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51406. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51407. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51408. }
  51409. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51410. this._imageProcessingConfiguration.prepareDefines(defines);
  51411. }
  51412. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51413. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51414. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51415. // Misc.
  51416. if (defines._areMiscDirty) {
  51417. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51418. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51419. }
  51420. // Values that need to be evaluated on every frame
  51421. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51422. // Attribs
  51423. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51424. };
  51425. /**
  51426. * Force shader compilation
  51427. */
  51428. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51429. var _this = this;
  51430. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51431. var defines = new PBRMaterialDefines();
  51432. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51433. if (effect.isReady()) {
  51434. if (onCompiled) {
  51435. onCompiled(this);
  51436. }
  51437. }
  51438. else {
  51439. effect.onCompileObservable.add(function () {
  51440. if (onCompiled) {
  51441. onCompiled(_this);
  51442. }
  51443. });
  51444. }
  51445. };
  51446. /**
  51447. * Initializes the uniform buffer layout for the shader.
  51448. */
  51449. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51450. // Order is important !
  51451. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51452. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51453. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51454. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51455. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51456. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51457. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51458. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51459. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51460. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51461. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51462. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51463. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51464. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51465. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51466. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51467. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51468. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51469. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51470. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51471. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51472. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51473. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51474. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51475. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51476. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51477. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51478. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51479. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51480. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51481. this._uniformBuffer.addUniform("pointSize", 1);
  51482. this._uniformBuffer.create();
  51483. };
  51484. /**
  51485. * Unbinds the textures.
  51486. */
  51487. PBRBaseMaterial.prototype.unbind = function () {
  51488. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51489. this._uniformBuffer.setTexture("reflectionSampler", null);
  51490. }
  51491. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51492. this._uniformBuffer.setTexture("refractionSampler", null);
  51493. }
  51494. _super.prototype.unbind.call(this);
  51495. };
  51496. /**
  51497. * Binds the submesh data.
  51498. * @param world - The world matrix.
  51499. * @param mesh - The BJS mesh.
  51500. * @param subMesh - A submesh of the BJS mesh.
  51501. */
  51502. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51503. var scene = this.getScene();
  51504. var defines = subMesh._materialDefines;
  51505. if (!defines) {
  51506. return;
  51507. }
  51508. var effect = subMesh.effect;
  51509. if (!effect) {
  51510. return;
  51511. }
  51512. this._activeEffect = effect;
  51513. // Matrices
  51514. this.bindOnlyWorldMatrix(world);
  51515. // Normal Matrix
  51516. if (defines.OBJECTSPACE_NORMALMAP) {
  51517. world.toNormalMatrix(this._normalMatrix);
  51518. this.bindOnlyNormalMatrix(this._normalMatrix);
  51519. }
  51520. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51521. // Bones
  51522. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51523. var reflectionTexture = null;
  51524. if (mustRebind) {
  51525. this._uniformBuffer.bindToEffect(effect, "Material");
  51526. this.bindViewProjection(effect);
  51527. reflectionTexture = this._getReflectionTexture();
  51528. var refractionTexture = this._getRefractionTexture();
  51529. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51530. // Texture uniforms
  51531. if (scene.texturesEnabled) {
  51532. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51533. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51534. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51535. }
  51536. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51537. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51538. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51539. }
  51540. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51541. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51542. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51543. }
  51544. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51545. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51546. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51547. if (reflectionTexture.boundingBoxSize) {
  51548. var cubeTexture = reflectionTexture;
  51549. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51550. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51551. }
  51552. var polynomials = reflectionTexture.sphericalPolynomial;
  51553. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51554. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51555. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51556. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51557. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51558. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51559. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51560. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51561. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51562. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51563. }
  51564. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51565. }
  51566. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51567. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51568. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51569. }
  51570. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51571. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51572. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51573. }
  51574. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51575. if (this._metallicTexture) {
  51576. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51577. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51578. }
  51579. else if (this._reflectivityTexture) {
  51580. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51581. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51582. }
  51583. if (this._microSurfaceTexture) {
  51584. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51585. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51586. }
  51587. }
  51588. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51589. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51590. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51591. if (scene._mirroredCameraPosition) {
  51592. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51593. }
  51594. else {
  51595. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51596. }
  51597. }
  51598. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51599. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51600. var depth = 1.0;
  51601. if (!refractionTexture.isCube) {
  51602. if (refractionTexture.depth) {
  51603. depth = refractionTexture.depth;
  51604. }
  51605. }
  51606. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51607. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51608. }
  51609. }
  51610. // Point size
  51611. if (this.pointsCloud) {
  51612. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51613. }
  51614. // Colors
  51615. if (defines.METALLICWORKFLOW) {
  51616. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51617. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51618. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51619. }
  51620. else {
  51621. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51622. }
  51623. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51624. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51625. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51626. // Misc
  51627. this._lightingInfos.x = this._directIntensity;
  51628. this._lightingInfos.y = this._emissiveIntensity;
  51629. this._lightingInfos.z = this._environmentIntensity;
  51630. this._lightingInfos.w = this._specularIntensity;
  51631. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51632. }
  51633. // Textures
  51634. if (scene.texturesEnabled) {
  51635. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51636. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51637. }
  51638. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51639. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51640. }
  51641. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51642. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51643. }
  51644. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51645. if (defines.LODBASEDMICROSFURACE) {
  51646. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51647. }
  51648. else {
  51649. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51650. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51651. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51652. }
  51653. }
  51654. if (defines.ENVIRONMENTBRDF) {
  51655. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51656. }
  51657. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51658. if (defines.LODBASEDMICROSFURACE) {
  51659. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51660. }
  51661. else {
  51662. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51663. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51664. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51665. }
  51666. }
  51667. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51668. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51669. }
  51670. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51671. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51672. }
  51673. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51674. if (this._metallicTexture) {
  51675. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51676. }
  51677. else if (this._reflectivityTexture) {
  51678. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51679. }
  51680. if (this._microSurfaceTexture) {
  51681. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51682. }
  51683. }
  51684. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51685. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51686. }
  51687. }
  51688. // Clip plane
  51689. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51690. // Colors
  51691. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51692. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51693. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51694. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51695. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51696. }
  51697. if (mustRebind || !this.isFrozen) {
  51698. // Lights
  51699. if (scene.lightsEnabled && !this._disableLighting) {
  51700. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51701. }
  51702. // View
  51703. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51704. this.bindView(effect);
  51705. }
  51706. // Fog
  51707. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51708. // Morph targets
  51709. if (defines.NUM_MORPH_INFLUENCERS) {
  51710. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51711. }
  51712. // image processing
  51713. this._imageProcessingConfiguration.bind(this._activeEffect);
  51714. // Log. depth
  51715. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51716. }
  51717. this._uniformBuffer.update();
  51718. this._afterBind(mesh, this._activeEffect);
  51719. };
  51720. /**
  51721. * Returns the animatable textures.
  51722. * @returns - Array of animatable textures.
  51723. */
  51724. PBRBaseMaterial.prototype.getAnimatables = function () {
  51725. var results = [];
  51726. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51727. results.push(this._albedoTexture);
  51728. }
  51729. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51730. results.push(this._ambientTexture);
  51731. }
  51732. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51733. results.push(this._opacityTexture);
  51734. }
  51735. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51736. results.push(this._reflectionTexture);
  51737. }
  51738. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51739. results.push(this._emissiveTexture);
  51740. }
  51741. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51742. results.push(this._metallicTexture);
  51743. }
  51744. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51745. results.push(this._reflectivityTexture);
  51746. }
  51747. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51748. results.push(this._bumpTexture);
  51749. }
  51750. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51751. results.push(this._lightmapTexture);
  51752. }
  51753. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51754. results.push(this._refractionTexture);
  51755. }
  51756. return results;
  51757. };
  51758. /**
  51759. * Returns the texture used for reflections.
  51760. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51761. */
  51762. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51763. if (this._reflectionTexture) {
  51764. return this._reflectionTexture;
  51765. }
  51766. return this.getScene().environmentTexture;
  51767. };
  51768. /**
  51769. * Returns the texture used for refraction or null if none is used.
  51770. * @returns - Refection texture if present. If no refraction texture and refraction
  51771. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51772. */
  51773. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51774. if (this._refractionTexture) {
  51775. return this._refractionTexture;
  51776. }
  51777. if (this._linkRefractionWithTransparency) {
  51778. return this.getScene().environmentTexture;
  51779. }
  51780. return null;
  51781. };
  51782. /**
  51783. * Disposes the resources of the material.
  51784. * @param forceDisposeEffect - Forces the disposal of effects.
  51785. * @param forceDisposeTextures - Forces the disposal of all textures.
  51786. */
  51787. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51788. if (forceDisposeTextures) {
  51789. if (this._albedoTexture) {
  51790. this._albedoTexture.dispose();
  51791. }
  51792. if (this._ambientTexture) {
  51793. this._ambientTexture.dispose();
  51794. }
  51795. if (this._opacityTexture) {
  51796. this._opacityTexture.dispose();
  51797. }
  51798. if (this._reflectionTexture) {
  51799. this._reflectionTexture.dispose();
  51800. }
  51801. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51802. this._environmentBRDFTexture.dispose();
  51803. }
  51804. if (this._emissiveTexture) {
  51805. this._emissiveTexture.dispose();
  51806. }
  51807. if (this._metallicTexture) {
  51808. this._metallicTexture.dispose();
  51809. }
  51810. if (this._reflectivityTexture) {
  51811. this._reflectivityTexture.dispose();
  51812. }
  51813. if (this._bumpTexture) {
  51814. this._bumpTexture.dispose();
  51815. }
  51816. if (this._lightmapTexture) {
  51817. this._lightmapTexture.dispose();
  51818. }
  51819. if (this._refractionTexture) {
  51820. this._refractionTexture.dispose();
  51821. }
  51822. }
  51823. this._renderTargets.dispose();
  51824. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51825. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51826. }
  51827. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51828. };
  51829. /**
  51830. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51831. */
  51832. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51833. /**
  51834. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51835. */
  51836. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51837. /**
  51838. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51839. */
  51840. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51841. /**
  51842. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51843. * They are also discarded below the alpha cutoff threshold to improve performances.
  51844. */
  51845. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51846. /**
  51847. * Defines the default value of how much AO map is occluding the analytical lights
  51848. * (point spot...).
  51849. */
  51850. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51851. /**
  51852. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51853. */
  51854. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51855. /**
  51856. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51857. * to enhance interoperability with other engines.
  51858. */
  51859. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51860. /**
  51861. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51862. * to enhance interoperability with other materials.
  51863. */
  51864. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51867. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51870. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51873. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51874. return PBRBaseMaterial;
  51875. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51876. /***/ }),
  51877. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51878. /*!************************************************!*\
  51879. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51880. \************************************************/
  51881. /*! exports provided: PBRBaseSimpleMaterial */
  51882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51883. "use strict";
  51884. __webpack_require__.r(__webpack_exports__);
  51885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  51886. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51887. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51888. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51889. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51890. /**
  51891. * The Physically based simple base material of BJS.
  51892. *
  51893. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51894. * It is used as the base class for both the specGloss and metalRough conventions.
  51895. */
  51896. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  51897. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  51898. /**
  51899. * Instantiates a new PBRMaterial instance.
  51900. *
  51901. * @param name The material name
  51902. * @param scene The scene the material will be use in.
  51903. */
  51904. function PBRBaseSimpleMaterial(name, scene) {
  51905. var _this = _super.call(this, name, scene) || this;
  51906. /**
  51907. * Number of Simultaneous lights allowed on the material.
  51908. */
  51909. _this.maxSimultaneousLights = 4;
  51910. /**
  51911. * If sets to true, disables all the lights affecting the material.
  51912. */
  51913. _this.disableLighting = false;
  51914. /**
  51915. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51916. */
  51917. _this.invertNormalMapX = false;
  51918. /**
  51919. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51920. */
  51921. _this.invertNormalMapY = false;
  51922. /**
  51923. * Emissivie color used to self-illuminate the model.
  51924. */
  51925. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  51926. /**
  51927. * Occlusion Channel Strenght.
  51928. */
  51929. _this.occlusionStrength = 1.0;
  51930. /**
  51931. * If true, the light map contains occlusion information instead of lighting info.
  51932. */
  51933. _this.useLightmapAsShadowmap = false;
  51934. _this._useAlphaFromAlbedoTexture = true;
  51935. _this._useAmbientInGrayScale = true;
  51936. return _this;
  51937. }
  51938. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  51939. /**
  51940. * Gets the current double sided mode.
  51941. */
  51942. get: function () {
  51943. return this._twoSidedLighting;
  51944. },
  51945. /**
  51946. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51947. */
  51948. set: function (value) {
  51949. if (this._twoSidedLighting === value) {
  51950. return;
  51951. }
  51952. this._twoSidedLighting = value;
  51953. this.backFaceCulling = !value;
  51954. this._markAllSubMeshesAsTexturesDirty();
  51955. },
  51956. enumerable: true,
  51957. configurable: true
  51958. });
  51959. /**
  51960. * Return the active textures of the material.
  51961. */
  51962. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  51963. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51964. if (this.environmentTexture) {
  51965. activeTextures.push(this.environmentTexture);
  51966. }
  51967. if (this.normalTexture) {
  51968. activeTextures.push(this.normalTexture);
  51969. }
  51970. if (this.emissiveTexture) {
  51971. activeTextures.push(this.emissiveTexture);
  51972. }
  51973. if (this.occlusionTexture) {
  51974. activeTextures.push(this.occlusionTexture);
  51975. }
  51976. if (this.lightmapTexture) {
  51977. activeTextures.push(this.lightmapTexture);
  51978. }
  51979. return activeTextures;
  51980. };
  51981. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  51982. if (_super.prototype.hasTexture.call(this, texture)) {
  51983. return true;
  51984. }
  51985. if (this.lightmapTexture === texture) {
  51986. return true;
  51987. }
  51988. return false;
  51989. };
  51990. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  51991. return "PBRBaseSimpleMaterial";
  51992. };
  51993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51996. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  51997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52000. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  52001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  52004. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  52005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52008. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  52009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52012. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  52013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  52016. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  52017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52020. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  52021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52024. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  52025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  52028. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  52029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  52032. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  52033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  52036. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  52037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52039. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  52040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52043. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  52044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52047. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52048. return PBRBaseSimpleMaterial;
  52049. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  52050. /***/ }),
  52051. /***/ "./Materials/PBR/pbrMaterial.ts":
  52052. /*!**************************************!*\
  52053. !*** ./Materials/PBR/pbrMaterial.ts ***!
  52054. \**************************************/
  52055. /*! exports provided: PBRMaterial */
  52056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52057. "use strict";
  52058. __webpack_require__.r(__webpack_exports__);
  52059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  52060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52061. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52062. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  52063. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52064. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52065. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52066. /**
  52067. * The Physically based material of BJS.
  52068. *
  52069. * This offers the main features of a standard PBR material.
  52070. * For more information, please refer to the documentation :
  52071. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52072. */
  52073. var PBRMaterial = /** @class */ (function (_super) {
  52074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  52075. /**
  52076. * Instantiates a new PBRMaterial instance.
  52077. *
  52078. * @param name The material name
  52079. * @param scene The scene the material will be use in.
  52080. */
  52081. function PBRMaterial(name, scene) {
  52082. var _this = _super.call(this, name, scene) || this;
  52083. /**
  52084. * Intensity of the direct lights e.g. the four lights available in your scene.
  52085. * This impacts both the direct diffuse and specular highlights.
  52086. */
  52087. _this.directIntensity = 1.0;
  52088. /**
  52089. * Intensity of the emissive part of the material.
  52090. * This helps controlling the emissive effect without modifying the emissive color.
  52091. */
  52092. _this.emissiveIntensity = 1.0;
  52093. /**
  52094. * Intensity of the environment e.g. how much the environment will light the object
  52095. * either through harmonics for rough material or through the refelction for shiny ones.
  52096. */
  52097. _this.environmentIntensity = 1.0;
  52098. /**
  52099. * This is a special control allowing the reduction of the specular highlights coming from the
  52100. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52101. */
  52102. _this.specularIntensity = 1.0;
  52103. /**
  52104. * Debug Control allowing disabling the bump map on this material.
  52105. */
  52106. _this.disableBumpMap = false;
  52107. /**
  52108. * AKA Occlusion Texture Intensity in other nomenclature.
  52109. */
  52110. _this.ambientTextureStrength = 1.0;
  52111. /**
  52112. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52113. * 1 means it completely occludes it
  52114. * 0 mean it has no impact
  52115. */
  52116. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52117. /**
  52118. * The color of a material in ambient lighting.
  52119. */
  52120. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52121. /**
  52122. * AKA Diffuse Color in other nomenclature.
  52123. */
  52124. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52125. /**
  52126. * AKA Specular Color in other nomenclature.
  52127. */
  52128. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52129. /**
  52130. * The color reflected from the material.
  52131. */
  52132. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  52133. /**
  52134. * The color emitted from the material.
  52135. */
  52136. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52137. /**
  52138. * AKA Glossiness in other nomenclature.
  52139. */
  52140. _this.microSurface = 1.0;
  52141. /**
  52142. * source material index of refraction (IOR)' / 'destination material IOR.
  52143. */
  52144. _this.indexOfRefraction = 0.66;
  52145. /**
  52146. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52147. */
  52148. _this.invertRefractionY = false;
  52149. /**
  52150. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52151. * Materials half opaque for instance using refraction could benefit from this control.
  52152. */
  52153. _this.linkRefractionWithTransparency = false;
  52154. /**
  52155. * If true, the light map contains occlusion information instead of lighting info.
  52156. */
  52157. _this.useLightmapAsShadowmap = false;
  52158. /**
  52159. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52160. */
  52161. _this.useAlphaFromAlbedoTexture = false;
  52162. /**
  52163. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52164. */
  52165. _this.forceAlphaTest = false;
  52166. /**
  52167. * Defines the alpha limits in alpha test mode.
  52168. */
  52169. _this.alphaCutOff = 0.4;
  52170. /**
  52171. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52172. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52173. */
  52174. _this.useSpecularOverAlpha = true;
  52175. /**
  52176. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52177. */
  52178. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52179. /**
  52180. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52181. */
  52182. _this.useRoughnessFromMetallicTextureAlpha = true;
  52183. /**
  52184. * Specifies if the metallic texture contains the roughness information in its green channel.
  52185. */
  52186. _this.useRoughnessFromMetallicTextureGreen = false;
  52187. /**
  52188. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52189. */
  52190. _this.useMetallnessFromMetallicTextureBlue = false;
  52191. /**
  52192. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52193. */
  52194. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52195. /**
  52196. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52197. */
  52198. _this.useAmbientInGrayScale = false;
  52199. /**
  52200. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52201. * The material will try to infer what glossiness each pixel should be.
  52202. */
  52203. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52204. /**
  52205. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52206. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52207. */
  52208. _this.useRadianceOverAlpha = true;
  52209. /**
  52210. * Allows using an object space normal map (instead of tangent space).
  52211. */
  52212. _this.useObjectSpaceNormalMap = false;
  52213. /**
  52214. * Allows using the bump map in parallax mode.
  52215. */
  52216. _this.useParallax = false;
  52217. /**
  52218. * Allows using the bump map in parallax occlusion mode.
  52219. */
  52220. _this.useParallaxOcclusion = false;
  52221. /**
  52222. * Controls the scale bias of the parallax mode.
  52223. */
  52224. _this.parallaxScaleBias = 0.05;
  52225. /**
  52226. * If sets to true, disables all the lights affecting the material.
  52227. */
  52228. _this.disableLighting = false;
  52229. /**
  52230. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52231. */
  52232. _this.forceIrradianceInFragment = false;
  52233. /**
  52234. * Number of Simultaneous lights allowed on the material.
  52235. */
  52236. _this.maxSimultaneousLights = 4;
  52237. /**
  52238. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52239. */
  52240. _this.invertNormalMapX = false;
  52241. /**
  52242. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52243. */
  52244. _this.invertNormalMapY = false;
  52245. /**
  52246. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52247. */
  52248. _this.twoSidedLighting = false;
  52249. /**
  52250. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52251. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52252. */
  52253. _this.useAlphaFresnel = false;
  52254. /**
  52255. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52256. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52257. */
  52258. _this.useLinearAlphaFresnel = false;
  52259. /**
  52260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52261. * And/Or occlude the blended part.
  52262. */
  52263. _this.environmentBRDFTexture = null;
  52264. /**
  52265. * Force normal to face away from face.
  52266. */
  52267. _this.forceNormalForward = false;
  52268. /**
  52269. * Enables specular anti aliasing in the PBR shader.
  52270. * It will both interacts on the Geometry for analytical and IBL lighting.
  52271. * It also prefilter the roughness map based on the bump values.
  52272. */
  52273. _this.enableSpecularAntiAliasing = false;
  52274. /**
  52275. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52276. * makes the reflect vector face the model (under horizon).
  52277. */
  52278. _this.useHorizonOcclusion = true;
  52279. /**
  52280. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52281. * too much the area relying on ambient texture to define their ambient occlusion.
  52282. */
  52283. _this.useRadianceOcclusion = true;
  52284. /**
  52285. * If set to true, no lighting calculations will be applied.
  52286. */
  52287. _this.unlit = false;
  52288. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52289. return _this;
  52290. }
  52291. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52292. /**
  52293. * BJS is using an harcoded light falloff based on a manually sets up range.
  52294. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52295. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52296. */
  52297. get: function () {
  52298. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52299. },
  52300. /**
  52301. * BJS is using an harcoded light falloff based on a manually sets up range.
  52302. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52303. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52304. */
  52305. set: function (value) {
  52306. if (value !== this.usePhysicalLightFalloff) {
  52307. // Ensure the effect will be rebuilt.
  52308. this._markAllSubMeshesAsTexturesDirty();
  52309. if (value) {
  52310. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52311. }
  52312. else {
  52313. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52314. }
  52315. }
  52316. },
  52317. enumerable: true,
  52318. configurable: true
  52319. });
  52320. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52321. /**
  52322. * In order to support the falloff compatibility with gltf, a special mode has been added
  52323. * to reproduce the gltf light falloff.
  52324. */
  52325. get: function () {
  52326. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52327. },
  52328. /**
  52329. * In order to support the falloff compatibility with gltf, a special mode has been added
  52330. * to reproduce the gltf light falloff.
  52331. */
  52332. set: function (value) {
  52333. if (value !== this.useGLTFLightFalloff) {
  52334. // Ensure the effect will be rebuilt.
  52335. this._markAllSubMeshesAsTexturesDirty();
  52336. if (value) {
  52337. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52338. }
  52339. else {
  52340. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52341. }
  52342. }
  52343. },
  52344. enumerable: true,
  52345. configurable: true
  52346. });
  52347. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  52348. /**
  52349. * Gets the image processing configuration used either in this material.
  52350. */
  52351. get: function () {
  52352. return this._imageProcessingConfiguration;
  52353. },
  52354. /**
  52355. * Sets the Default image processing configuration used either in the this material.
  52356. *
  52357. * If sets to null, the scene one is in use.
  52358. */
  52359. set: function (value) {
  52360. this._attachImageProcessingConfiguration(value);
  52361. // Ensure the effect will be rebuilt.
  52362. this._markAllSubMeshesAsTexturesDirty();
  52363. },
  52364. enumerable: true,
  52365. configurable: true
  52366. });
  52367. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  52368. /**
  52369. * Gets wether the color curves effect is enabled.
  52370. */
  52371. get: function () {
  52372. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52373. },
  52374. /**
  52375. * Sets wether the color curves effect is enabled.
  52376. */
  52377. set: function (value) {
  52378. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52379. },
  52380. enumerable: true,
  52381. configurable: true
  52382. });
  52383. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  52384. /**
  52385. * Gets wether the color grading effect is enabled.
  52386. */
  52387. get: function () {
  52388. return this.imageProcessingConfiguration.colorGradingEnabled;
  52389. },
  52390. /**
  52391. * Gets wether the color grading effect is enabled.
  52392. */
  52393. set: function (value) {
  52394. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52395. },
  52396. enumerable: true,
  52397. configurable: true
  52398. });
  52399. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  52400. /**
  52401. * Gets wether tonemapping is enabled or not.
  52402. */
  52403. get: function () {
  52404. return this._imageProcessingConfiguration.toneMappingEnabled;
  52405. },
  52406. /**
  52407. * Sets wether tonemapping is enabled or not
  52408. */
  52409. set: function (value) {
  52410. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52411. },
  52412. enumerable: true,
  52413. configurable: true
  52414. });
  52415. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  52416. /**
  52417. * The camera exposure used on this material.
  52418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52419. * This corresponds to a photographic exposure.
  52420. */
  52421. get: function () {
  52422. return this._imageProcessingConfiguration.exposure;
  52423. },
  52424. /**
  52425. * The camera exposure used on this material.
  52426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52427. * This corresponds to a photographic exposure.
  52428. */
  52429. set: function (value) {
  52430. this._imageProcessingConfiguration.exposure = value;
  52431. },
  52432. enumerable: true,
  52433. configurable: true
  52434. });
  52435. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  52436. /**
  52437. * Gets The camera contrast used on this material.
  52438. */
  52439. get: function () {
  52440. return this._imageProcessingConfiguration.contrast;
  52441. },
  52442. /**
  52443. * Sets The camera contrast used on this material.
  52444. */
  52445. set: function (value) {
  52446. this._imageProcessingConfiguration.contrast = value;
  52447. },
  52448. enumerable: true,
  52449. configurable: true
  52450. });
  52451. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  52452. /**
  52453. * Gets the Color Grading 2D Lookup Texture.
  52454. */
  52455. get: function () {
  52456. return this._imageProcessingConfiguration.colorGradingTexture;
  52457. },
  52458. /**
  52459. * Sets the Color Grading 2D Lookup Texture.
  52460. */
  52461. set: function (value) {
  52462. this._imageProcessingConfiguration.colorGradingTexture = value;
  52463. },
  52464. enumerable: true,
  52465. configurable: true
  52466. });
  52467. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  52468. /**
  52469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52471. * 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;
  52472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52473. */
  52474. get: function () {
  52475. return this._imageProcessingConfiguration.colorCurves;
  52476. },
  52477. /**
  52478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52480. * 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;
  52481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52482. */
  52483. set: function (value) {
  52484. this._imageProcessingConfiguration.colorCurves = value;
  52485. },
  52486. enumerable: true,
  52487. configurable: true
  52488. });
  52489. /**
  52490. * Returns the name of this material class.
  52491. */
  52492. PBRMaterial.prototype.getClassName = function () {
  52493. return "PBRMaterial";
  52494. };
  52495. /**
  52496. * Returns an array of the actively used textures.
  52497. * @returns - Array of BaseTextures
  52498. */
  52499. PBRMaterial.prototype.getActiveTextures = function () {
  52500. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52501. if (this._albedoTexture) {
  52502. activeTextures.push(this._albedoTexture);
  52503. }
  52504. if (this._ambientTexture) {
  52505. activeTextures.push(this._ambientTexture);
  52506. }
  52507. if (this._opacityTexture) {
  52508. activeTextures.push(this._opacityTexture);
  52509. }
  52510. if (this._reflectionTexture) {
  52511. activeTextures.push(this._reflectionTexture);
  52512. }
  52513. if (this._emissiveTexture) {
  52514. activeTextures.push(this._emissiveTexture);
  52515. }
  52516. if (this._reflectivityTexture) {
  52517. activeTextures.push(this._reflectivityTexture);
  52518. }
  52519. if (this._metallicTexture) {
  52520. activeTextures.push(this._metallicTexture);
  52521. }
  52522. if (this._microSurfaceTexture) {
  52523. activeTextures.push(this._microSurfaceTexture);
  52524. }
  52525. if (this._bumpTexture) {
  52526. activeTextures.push(this._bumpTexture);
  52527. }
  52528. if (this._lightmapTexture) {
  52529. activeTextures.push(this._lightmapTexture);
  52530. }
  52531. if (this._refractionTexture) {
  52532. activeTextures.push(this._refractionTexture);
  52533. }
  52534. return activeTextures;
  52535. };
  52536. /**
  52537. * Checks to see if a texture is used in the material.
  52538. * @param texture - Base texture to use.
  52539. * @returns - Boolean specifying if a texture is used in the material.
  52540. */
  52541. PBRMaterial.prototype.hasTexture = function (texture) {
  52542. if (_super.prototype.hasTexture.call(this, texture)) {
  52543. return true;
  52544. }
  52545. if (this._albedoTexture === texture) {
  52546. return true;
  52547. }
  52548. if (this._ambientTexture === texture) {
  52549. return true;
  52550. }
  52551. if (this._opacityTexture === texture) {
  52552. return true;
  52553. }
  52554. if (this._reflectionTexture === texture) {
  52555. return true;
  52556. }
  52557. if (this._reflectivityTexture === texture) {
  52558. return true;
  52559. }
  52560. if (this._metallicTexture === texture) {
  52561. return true;
  52562. }
  52563. if (this._microSurfaceTexture === texture) {
  52564. return true;
  52565. }
  52566. if (this._bumpTexture === texture) {
  52567. return true;
  52568. }
  52569. if (this._lightmapTexture === texture) {
  52570. return true;
  52571. }
  52572. if (this._refractionTexture === texture) {
  52573. return true;
  52574. }
  52575. return false;
  52576. };
  52577. /**
  52578. * Makes a duplicate of the current material.
  52579. * @param name - name to use for the new material.
  52580. */
  52581. PBRMaterial.prototype.clone = function (name) {
  52582. var _this = this;
  52583. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52584. clone.id = name;
  52585. clone.name = name;
  52586. return clone;
  52587. };
  52588. /**
  52589. * Serializes this PBR Material.
  52590. * @returns - An object with the serialized material.
  52591. */
  52592. PBRMaterial.prototype.serialize = function () {
  52593. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52594. serializationObject.customType = "BABYLON.PBRMaterial";
  52595. return serializationObject;
  52596. };
  52597. // Statics
  52598. /**
  52599. * Parses a PBR Material from a serialized object.
  52600. * @param source - Serialized object.
  52601. * @param scene - BJS scene instance.
  52602. * @param rootUrl - url for the scene object
  52603. * @returns - PBRMaterial
  52604. */
  52605. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52606. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52607. };
  52608. /**
  52609. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52610. */
  52611. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52612. /**
  52613. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52614. */
  52615. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52616. /**
  52617. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52618. */
  52619. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52620. /**
  52621. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52622. * They are also discarded below the alpha cutoff threshold to improve performances.
  52623. */
  52624. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52625. /**
  52626. * Defines the default value of how much AO map is occluding the analytical lights
  52627. * (point spot...).
  52628. */
  52629. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52633. ], PBRMaterial.prototype, "directIntensity", void 0);
  52634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52637. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  52638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52641. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  52642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52645. ], PBRMaterial.prototype, "specularIntensity", void 0);
  52646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52649. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  52650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52653. ], PBRMaterial.prototype, "albedoTexture", void 0);
  52654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52657. ], PBRMaterial.prototype, "ambientTexture", void 0);
  52658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52661. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  52662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52665. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  52666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52669. ], PBRMaterial.prototype, "opacityTexture", void 0);
  52670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52673. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  52674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52677. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  52678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52681. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  52682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52685. ], PBRMaterial.prototype, "metallicTexture", void 0);
  52686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52689. ], PBRMaterial.prototype, "metallic", void 0);
  52690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52693. ], PBRMaterial.prototype, "roughness", void 0);
  52694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52697. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  52698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52701. ], PBRMaterial.prototype, "bumpTexture", void 0);
  52702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52705. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  52706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52709. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52713. ], PBRMaterial.prototype, "ambientColor", void 0);
  52714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52717. ], PBRMaterial.prototype, "albedoColor", void 0);
  52718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52721. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52725. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52729. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52733. ], PBRMaterial.prototype, "microSurface", void 0);
  52734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52737. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52739. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52741. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52745. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52749. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52753. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52757. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52761. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52765. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52769. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52770. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52771. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52773. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52777. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52781. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52785. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52789. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52793. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52796. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52799. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52803. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  52804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52807. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52811. ], PBRMaterial.prototype, "useParallax", void 0);
  52812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52815. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52819. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52823. ], PBRMaterial.prototype, "disableLighting", void 0);
  52824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52827. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52831. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52835. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52839. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52843. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52847. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52851. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52855. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52859. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52863. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52867. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52871. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52875. ], PBRMaterial.prototype, "unlit", void 0);
  52876. return PBRMaterial;
  52877. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52878. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52879. /***/ }),
  52880. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52881. /*!*******************************************************!*\
  52882. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  52883. \*******************************************************/
  52884. /*! exports provided: PBRMetallicRoughnessMaterial */
  52885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52886. "use strict";
  52887. __webpack_require__.r(__webpack_exports__);
  52888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  52889. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52890. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52891. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52892. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52893. /**
  52894. * The PBR material of BJS following the metal roughness convention.
  52895. *
  52896. * This fits to the PBR convention in the GLTF definition:
  52897. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52898. */
  52899. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  52900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  52901. /**
  52902. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52903. *
  52904. * @param name The material name
  52905. * @param scene The scene the material will be use in.
  52906. */
  52907. function PBRMetallicRoughnessMaterial(name, scene) {
  52908. var _this = _super.call(this, name, scene) || this;
  52909. _this._useRoughnessFromMetallicTextureAlpha = false;
  52910. _this._useRoughnessFromMetallicTextureGreen = true;
  52911. _this._useMetallnessFromMetallicTextureBlue = true;
  52912. _this.metallic = 1.0;
  52913. _this.roughness = 1.0;
  52914. return _this;
  52915. }
  52916. /**
  52917. * Return the currrent class name of the material.
  52918. */
  52919. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  52920. return "PBRMetallicRoughnessMaterial";
  52921. };
  52922. /**
  52923. * Return the active textures of the material.
  52924. */
  52925. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  52926. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52927. if (this.baseTexture) {
  52928. activeTextures.push(this.baseTexture);
  52929. }
  52930. if (this.metallicRoughnessTexture) {
  52931. activeTextures.push(this.metallicRoughnessTexture);
  52932. }
  52933. return activeTextures;
  52934. };
  52935. /**
  52936. * Checks to see if a texture is used in the material.
  52937. * @param texture - Base texture to use.
  52938. * @returns - Boolean specifying if a texture is used in the material.
  52939. */
  52940. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  52941. if (_super.prototype.hasTexture.call(this, texture)) {
  52942. return true;
  52943. }
  52944. if (this.baseTexture === texture) {
  52945. return true;
  52946. }
  52947. if (this.metallicRoughnessTexture === texture) {
  52948. return true;
  52949. }
  52950. return false;
  52951. };
  52952. /**
  52953. * Makes a duplicate of the current material.
  52954. * @param name - name to use for the new material.
  52955. */
  52956. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  52957. var _this = this;
  52958. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  52959. clone.id = name;
  52960. clone.name = name;
  52961. return clone;
  52962. };
  52963. /**
  52964. * Serialize the material to a parsable JSON object.
  52965. */
  52966. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  52967. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52968. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  52969. return serializationObject;
  52970. };
  52971. /**
  52972. * Parses a JSON object correponding to the serialize function.
  52973. */
  52974. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  52975. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  52976. };
  52977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  52979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52980. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  52981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52984. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  52985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52988. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  52989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52992. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  52993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  52996. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  52997. return PBRMetallicRoughnessMaterial;
  52998. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52999. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  53000. /***/ }),
  53001. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  53002. /*!********************************************************!*\
  53003. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  53004. \********************************************************/
  53005. /*! exports provided: PBRSpecularGlossinessMaterial */
  53006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53007. "use strict";
  53008. __webpack_require__.r(__webpack_exports__);
  53009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  53010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53011. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53012. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53013. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53014. /**
  53015. * The PBR material of BJS following the specular glossiness convention.
  53016. *
  53017. * This fits to the PBR convention in the GLTF definition:
  53018. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53019. */
  53020. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  53021. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  53022. /**
  53023. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53024. *
  53025. * @param name The material name
  53026. * @param scene The scene the material will be use in.
  53027. */
  53028. function PBRSpecularGlossinessMaterial(name, scene) {
  53029. var _this = _super.call(this, name, scene) || this;
  53030. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  53031. return _this;
  53032. }
  53033. /**
  53034. * Return the currrent class name of the material.
  53035. */
  53036. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  53037. return "PBRSpecularGlossinessMaterial";
  53038. };
  53039. /**
  53040. * Return the active textures of the material.
  53041. */
  53042. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  53043. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53044. if (this.diffuseTexture) {
  53045. activeTextures.push(this.diffuseTexture);
  53046. }
  53047. if (this.specularGlossinessTexture) {
  53048. activeTextures.push(this.specularGlossinessTexture);
  53049. }
  53050. return activeTextures;
  53051. };
  53052. /**
  53053. * Checks to see if a texture is used in the material.
  53054. * @param texture - Base texture to use.
  53055. * @returns - Boolean specifying if a texture is used in the material.
  53056. */
  53057. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  53058. if (_super.prototype.hasTexture.call(this, texture)) {
  53059. return true;
  53060. }
  53061. if (this.diffuseTexture === texture) {
  53062. return true;
  53063. }
  53064. if (this.specularGlossinessTexture === texture) {
  53065. return true;
  53066. }
  53067. return false;
  53068. };
  53069. /**
  53070. * Makes a duplicate of the current material.
  53071. * @param name - name to use for the new material.
  53072. */
  53073. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  53074. var _this = this;
  53075. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  53076. clone.id = name;
  53077. clone.name = name;
  53078. return clone;
  53079. };
  53080. /**
  53081. * Serialize the material to a parsable JSON object.
  53082. */
  53083. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  53084. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53085. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  53086. return serializationObject;
  53087. };
  53088. /**
  53089. * Parses a JSON object correponding to the serialize function.
  53090. */
  53091. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  53092. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  53093. };
  53094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  53096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53097. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  53098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53101. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  53102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  53104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  53105. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  53106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  53109. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  53110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  53113. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  53114. return PBRSpecularGlossinessMaterial;
  53115. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53116. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  53117. /***/ }),
  53118. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  53119. /*!********************************************************!*\
  53120. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  53121. \********************************************************/
  53122. /*! exports provided: _DDSTextureLoader */
  53123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53124. "use strict";
  53125. __webpack_require__.r(__webpack_exports__);
  53126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  53127. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  53128. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53129. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  53130. /**
  53131. * Implementation of the DDS Texture Loader.
  53132. * @hidden
  53133. */
  53134. var _DDSTextureLoader = /** @class */ (function () {
  53135. function _DDSTextureLoader() {
  53136. /**
  53137. * Defines wether the loader supports cascade loading the different faces.
  53138. */
  53139. this.supportCascades = true;
  53140. }
  53141. /**
  53142. * This returns if the loader support the current file information.
  53143. * @param extension defines the file extension of the file being loaded
  53144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53145. * @param fallback defines the fallback internal texture if any
  53146. * @param isBase64 defines whether the texture is encoded as a base64
  53147. * @param isBuffer defines whether the texture data are stored as a buffer
  53148. * @returns true if the loader can load the specified file
  53149. */
  53150. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53151. return extension.indexOf(".dds") === 0;
  53152. };
  53153. /**
  53154. * Transform the url before loading if required.
  53155. * @param rootUrl the url of the texture
  53156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53157. * @returns the transformed texture
  53158. */
  53159. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53160. return rootUrl;
  53161. };
  53162. /**
  53163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53164. * @param rootUrl the url of the texture
  53165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53166. * @returns the fallback texture
  53167. */
  53168. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53169. return null;
  53170. };
  53171. /**
  53172. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53173. * @param data contains the texture data
  53174. * @param texture defines the BabylonJS internal texture
  53175. * @param createPolynomials will be true if polynomials have been requested
  53176. * @param onLoad defines the callback to trigger once the texture is ready
  53177. * @param onError defines the callback to trigger in case of error
  53178. */
  53179. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53180. var engine = texture.getEngine();
  53181. var info;
  53182. var loadMipmap = false;
  53183. if (Array.isArray(imgs)) {
  53184. for (var index = 0; index < imgs.length; index++) {
  53185. var data_1 = imgs[index];
  53186. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53187. texture.width = info.width;
  53188. texture.height = info.height;
  53189. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53190. engine._unpackFlipY(info.isCompressed);
  53191. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53192. if (!info.isFourCC && info.mipmapCount === 1) {
  53193. engine.generateMipMapsForCubemap(texture);
  53194. }
  53195. }
  53196. }
  53197. else {
  53198. var data = imgs;
  53199. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53200. texture.width = info.width;
  53201. texture.height = info.height;
  53202. if (createPolynomials) {
  53203. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53204. }
  53205. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53206. engine._unpackFlipY(info.isCompressed);
  53207. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53208. if (!info.isFourCC && info.mipmapCount === 1) {
  53209. engine.generateMipMapsForCubemap(texture);
  53210. }
  53211. }
  53212. engine._setCubeMapTextureParams(loadMipmap);
  53213. texture.isReady = true;
  53214. if (onLoad) {
  53215. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53216. }
  53217. };
  53218. /**
  53219. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53220. * @param data contains the texture data
  53221. * @param texture defines the BabylonJS internal texture
  53222. * @param callback defines the method to call once ready to upload
  53223. */
  53224. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53225. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53226. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53227. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53228. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53229. });
  53230. };
  53231. return _DDSTextureLoader;
  53232. }());
  53233. // Register the loader.
  53234. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53235. /***/ }),
  53236. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53237. /*!********************************************************!*\
  53238. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53239. \********************************************************/
  53240. /*! exports provided: _ENVTextureLoader */
  53241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53242. "use strict";
  53243. __webpack_require__.r(__webpack_exports__);
  53244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53245. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53246. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53247. /**
  53248. * Implementation of the ENV Texture Loader.
  53249. * @hidden
  53250. */
  53251. var _ENVTextureLoader = /** @class */ (function () {
  53252. function _ENVTextureLoader() {
  53253. /**
  53254. * Defines wether the loader supports cascade loading the different faces.
  53255. */
  53256. this.supportCascades = false;
  53257. }
  53258. /**
  53259. * This returns if the loader support the current file information.
  53260. * @param extension defines the file extension of the file being loaded
  53261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53262. * @param fallback defines the fallback internal texture if any
  53263. * @param isBase64 defines whether the texture is encoded as a base64
  53264. * @param isBuffer defines whether the texture data are stored as a buffer
  53265. * @returns true if the loader can load the specified file
  53266. */
  53267. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53268. return extension.indexOf(".env") === 0;
  53269. };
  53270. /**
  53271. * Transform the url before loading if required.
  53272. * @param rootUrl the url of the texture
  53273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53274. * @returns the transformed texture
  53275. */
  53276. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53277. return rootUrl;
  53278. };
  53279. /**
  53280. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53281. * @param rootUrl the url of the texture
  53282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53283. * @returns the fallback texture
  53284. */
  53285. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53286. return null;
  53287. };
  53288. /**
  53289. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53290. * @param data contains the texture data
  53291. * @param texture defines the BabylonJS internal texture
  53292. * @param createPolynomials will be true if polynomials have been requested
  53293. * @param onLoad defines the callback to trigger once the texture is ready
  53294. * @param onError defines the callback to trigger in case of error
  53295. */
  53296. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53297. if (Array.isArray(data)) {
  53298. return;
  53299. }
  53300. data = data;
  53301. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53302. if (info) {
  53303. texture.width = info.width;
  53304. texture.height = info.width;
  53305. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53306. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53307. texture.isReady = true;
  53308. if (onLoad) {
  53309. onLoad();
  53310. }
  53311. });
  53312. }
  53313. else if (onError) {
  53314. onError("Can not parse the environment file", null);
  53315. }
  53316. };
  53317. /**
  53318. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53319. * @param data contains the texture data
  53320. * @param texture defines the BabylonJS internal texture
  53321. * @param callback defines the method to call once ready to upload
  53322. */
  53323. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53324. throw ".env not supported in 2d.";
  53325. };
  53326. return _ENVTextureLoader;
  53327. }());
  53328. // Register the loader.
  53329. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53330. /***/ }),
  53331. /***/ "./Materials/Textures/Loaders/index.ts":
  53332. /*!*********************************************!*\
  53333. !*** ./Materials/Textures/Loaders/index.ts ***!
  53334. \*********************************************/
  53335. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53337. "use strict";
  53338. __webpack_require__.r(__webpack_exports__);
  53339. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53341. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53343. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53345. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53347. /***/ }),
  53348. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53349. /*!********************************************************!*\
  53350. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53351. \********************************************************/
  53352. /*! exports provided: _KTXTextureLoader */
  53353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53354. "use strict";
  53355. __webpack_require__.r(__webpack_exports__);
  53356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53357. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53358. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53359. /**
  53360. * Implementation of the KTX Texture Loader.
  53361. * @hidden
  53362. */
  53363. var _KTXTextureLoader = /** @class */ (function () {
  53364. function _KTXTextureLoader() {
  53365. /**
  53366. * Defines wether the loader supports cascade loading the different faces.
  53367. */
  53368. this.supportCascades = false;
  53369. }
  53370. /**
  53371. * This returns if the loader support the current file information.
  53372. * @param extension defines the file extension of the file being loaded
  53373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53374. * @param fallback defines the fallback internal texture if any
  53375. * @param isBase64 defines whether the texture is encoded as a base64
  53376. * @param isBuffer defines whether the texture data are stored as a buffer
  53377. * @returns true if the loader can load the specified file
  53378. */
  53379. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53380. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53381. return true;
  53382. }
  53383. return false;
  53384. };
  53385. /**
  53386. * Transform the url before loading if required.
  53387. * @param rootUrl the url of the texture
  53388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53389. * @returns the transformed texture
  53390. */
  53391. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53392. var lastDot = rootUrl.lastIndexOf('.');
  53393. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53394. // Already transformed
  53395. return rootUrl;
  53396. }
  53397. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53398. };
  53399. /**
  53400. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53401. * @param rootUrl the url of the texture
  53402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53403. * @returns the fallback texture
  53404. */
  53405. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53406. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53407. var exp = new RegExp("" + textureFormatInUse + "$");
  53408. return rootUrl.replace(exp, "");
  53409. };
  53410. /**
  53411. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53412. * @param data contains the texture data
  53413. * @param texture defines the BabylonJS internal texture
  53414. * @param createPolynomials will be true if polynomials have been requested
  53415. * @param onLoad defines the callback to trigger once the texture is ready
  53416. * @param onError defines the callback to trigger in case of error
  53417. */
  53418. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53419. if (Array.isArray(data)) {
  53420. return;
  53421. }
  53422. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53423. texture._invertVScale = !texture.invertY;
  53424. var engine = texture.getEngine();
  53425. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53426. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53427. engine._unpackFlipY(true);
  53428. ktx.uploadLevels(texture, texture.generateMipMaps);
  53429. texture.width = ktx.pixelWidth;
  53430. texture.height = ktx.pixelHeight;
  53431. engine._setCubeMapTextureParams(loadMipmap);
  53432. texture.isReady = true;
  53433. };
  53434. /**
  53435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53436. * @param data contains the texture data
  53437. * @param texture defines the BabylonJS internal texture
  53438. * @param callback defines the method to call once ready to upload
  53439. */
  53440. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53441. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53442. texture._invertVScale = !texture.invertY;
  53443. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53444. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53445. ktx.uploadLevels(texture, texture.generateMipMaps);
  53446. }, ktx.isInvalid);
  53447. };
  53448. return _KTXTextureLoader;
  53449. }());
  53450. // Register the loader.
  53451. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53452. /***/ }),
  53453. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53454. /*!********************************************************!*\
  53455. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53456. \********************************************************/
  53457. /*! exports provided: _TGATextureLoader */
  53458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53459. "use strict";
  53460. __webpack_require__.r(__webpack_exports__);
  53461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53462. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53463. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53464. /**
  53465. * Implementation of the TGA Texture Loader.
  53466. * @hidden
  53467. */
  53468. var _TGATextureLoader = /** @class */ (function () {
  53469. function _TGATextureLoader() {
  53470. /**
  53471. * Defines wether the loader supports cascade loading the different faces.
  53472. */
  53473. this.supportCascades = false;
  53474. }
  53475. /**
  53476. * This returns if the loader support the current file information.
  53477. * @param extension defines the file extension of the file being loaded
  53478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53479. * @param fallback defines the fallback internal texture if any
  53480. * @param isBase64 defines whether the texture is encoded as a base64
  53481. * @param isBuffer defines whether the texture data are stored as a buffer
  53482. * @returns true if the loader can load the specified file
  53483. */
  53484. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53485. return extension.indexOf(".tga") === 0;
  53486. };
  53487. /**
  53488. * Transform the url before loading if required.
  53489. * @param rootUrl the url of the texture
  53490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53491. * @returns the transformed texture
  53492. */
  53493. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53494. return rootUrl;
  53495. };
  53496. /**
  53497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53498. * @param rootUrl the url of the texture
  53499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53500. * @returns the fallback texture
  53501. */
  53502. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53503. return null;
  53504. };
  53505. /**
  53506. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53507. * @param data contains the texture data
  53508. * @param texture defines the BabylonJS internal texture
  53509. * @param createPolynomials will be true if polynomials have been requested
  53510. * @param onLoad defines the callback to trigger once the texture is ready
  53511. * @param onError defines the callback to trigger in case of error
  53512. */
  53513. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53514. throw ".env not supported in Cube.";
  53515. };
  53516. /**
  53517. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53518. * @param data contains the texture data
  53519. * @param texture defines the BabylonJS internal texture
  53520. * @param callback defines the method to call once ready to upload
  53521. */
  53522. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  53523. var uintData = new Uint8Array(data);
  53524. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  53525. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  53526. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  53527. });
  53528. };
  53529. return _TGATextureLoader;
  53530. }());
  53531. // Register the loader.
  53532. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  53533. /***/ }),
  53534. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  53535. /*!*******************************************************************!*\
  53536. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  53537. \*******************************************************************/
  53538. /*! exports provided: CustomProceduralTexture */
  53539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53540. "use strict";
  53541. __webpack_require__.r(__webpack_exports__);
  53542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  53543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53544. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53545. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  53546. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  53547. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53548. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53549. /**
  53550. * 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.
  53551. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53552. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53553. */
  53554. var CustomProceduralTexture = /** @class */ (function (_super) {
  53555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  53556. /**
  53557. * Instantiates a new Custom Procedural Texture.
  53558. * 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.
  53559. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53560. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53561. * @param name Define the name of the texture
  53562. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53563. * @param size Define the size of the texture to create
  53564. * @param scene Define the scene the texture belongs to
  53565. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53566. * @param generateMipMaps Define if the texture should creates mip maps or not
  53567. */
  53568. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  53569. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  53570. _this._animate = true;
  53571. _this._time = 0;
  53572. _this._texturePath = texturePath;
  53573. //Try to load json
  53574. _this._loadJson(texturePath);
  53575. _this.refreshRate = 1;
  53576. return _this;
  53577. }
  53578. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53579. var _this = this;
  53580. var noConfigFile = function () {
  53581. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53582. try {
  53583. _this.setFragment(_this._texturePath);
  53584. }
  53585. catch (ex) {
  53586. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53587. }
  53588. };
  53589. var configFileUrl = jsonUrl + "/config.json";
  53590. var xhr = new XMLHttpRequest();
  53591. xhr.open("GET", configFileUrl, true);
  53592. xhr.addEventListener("load", function () {
  53593. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53594. try {
  53595. _this._config = JSON.parse(xhr.response);
  53596. _this.updateShaderUniforms();
  53597. _this.updateTextures();
  53598. _this.setFragment(_this._texturePath + "/custom");
  53599. _this._animate = _this._config.animate;
  53600. _this.refreshRate = _this._config.refreshrate;
  53601. }
  53602. catch (ex) {
  53603. noConfigFile();
  53604. }
  53605. }
  53606. else {
  53607. noConfigFile();
  53608. }
  53609. }, false);
  53610. xhr.addEventListener("error", function () {
  53611. noConfigFile();
  53612. }, false);
  53613. try {
  53614. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53615. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53616. }
  53617. xhr.send();
  53618. }
  53619. catch (ex) {
  53620. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53621. }
  53622. };
  53623. /**
  53624. * Is the texture ready to be used ? (rendered at least once)
  53625. * @returns true if ready, otherwise, false.
  53626. */
  53627. CustomProceduralTexture.prototype.isReady = function () {
  53628. if (!_super.prototype.isReady.call(this)) {
  53629. return false;
  53630. }
  53631. for (var name in this._textures) {
  53632. var texture = this._textures[name];
  53633. if (!texture.isReady()) {
  53634. return false;
  53635. }
  53636. }
  53637. return true;
  53638. };
  53639. /**
  53640. * Render the texture to its associated render target.
  53641. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53642. */
  53643. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53644. var scene = this.getScene();
  53645. if (this._animate && scene) {
  53646. this._time += scene.getAnimationRatio() * 0.03;
  53647. this.updateShaderUniforms();
  53648. }
  53649. _super.prototype.render.call(this, useCameraPostProcess);
  53650. };
  53651. /**
  53652. * Update the list of dependant textures samplers in the shader.
  53653. */
  53654. CustomProceduralTexture.prototype.updateTextures = function () {
  53655. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53656. 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()));
  53657. }
  53658. };
  53659. /**
  53660. * Update the uniform values of the procedural texture in the shader.
  53661. */
  53662. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53663. if (this._config) {
  53664. for (var j = 0; j < this._config.uniforms.length; j++) {
  53665. var uniform = this._config.uniforms[j];
  53666. switch (uniform.type) {
  53667. case "float":
  53668. this.setFloat(uniform.name, uniform.value);
  53669. break;
  53670. case "color3":
  53671. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53672. break;
  53673. case "color4":
  53674. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53675. break;
  53676. case "vector2":
  53677. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53678. break;
  53679. case "vector3":
  53680. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53681. break;
  53682. }
  53683. }
  53684. }
  53685. this.setFloat("time", this._time);
  53686. };
  53687. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53688. /**
  53689. * Define if the texture animates or not.
  53690. */
  53691. get: function () {
  53692. return this._animate;
  53693. },
  53694. set: function (value) {
  53695. this._animate = value;
  53696. },
  53697. enumerable: true,
  53698. configurable: true
  53699. });
  53700. return CustomProceduralTexture;
  53701. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53702. /***/ }),
  53703. /***/ "./Materials/Textures/Procedurals/index.ts":
  53704. /*!*************************************************!*\
  53705. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53706. \*************************************************/
  53707. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  53708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53709. "use strict";
  53710. __webpack_require__.r(__webpack_exports__);
  53711. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53713. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53715. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53717. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53719. /***/ }),
  53720. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53721. /*!******************************************************************!*\
  53722. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53723. \******************************************************************/
  53724. /*! exports provided: NoiseProceduralTexture */
  53725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53726. "use strict";
  53727. __webpack_require__.r(__webpack_exports__);
  53728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53729. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53730. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53731. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53732. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53733. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53734. /**
  53735. * Class used to generate noise procedural textures
  53736. */
  53737. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53739. /**
  53740. * Creates a new NoiseProceduralTexture
  53741. * @param name defines the name fo the texture
  53742. * @param size defines the size of the texture (default is 256)
  53743. * @param scene defines the hosting scene
  53744. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53745. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53746. */
  53747. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53748. if (size === void 0) { size = 256; }
  53749. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53750. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53751. _this._time = 0;
  53752. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53753. _this.brightness = 0.2;
  53754. /** Defines the number of octaves to process */
  53755. _this.octaves = 3;
  53756. /** Defines the level of persistence (0.8 by default) */
  53757. _this.persistence = 0.8;
  53758. /** Gets or sets animation speed factor (default is 1) */
  53759. _this.animationSpeedFactor = 1;
  53760. _this.autoClear = false;
  53761. _this._updateShaderUniforms();
  53762. return _this;
  53763. }
  53764. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53765. var scene = this.getScene();
  53766. if (!scene) {
  53767. return;
  53768. }
  53769. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53770. this.setFloat("brightness", this.brightness);
  53771. this.setFloat("persistence", this.persistence);
  53772. this.setFloat("timeScale", this._time);
  53773. };
  53774. NoiseProceduralTexture.prototype._getDefines = function () {
  53775. return "#define OCTAVES " + (this.octaves | 0);
  53776. };
  53777. /** Generate the current state of the procedural texture */
  53778. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53779. this._updateShaderUniforms();
  53780. _super.prototype.render.call(this, useCameraPostProcess);
  53781. };
  53782. /**
  53783. * Serializes this noise procedural texture
  53784. * @returns a serialized noise procedural texture object
  53785. */
  53786. NoiseProceduralTexture.prototype.serialize = function () {
  53787. var serializationObject = {};
  53788. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53789. serializationObject.brightness = this.brightness;
  53790. serializationObject.octaves = this.octaves;
  53791. serializationObject.persistence = this.persistence;
  53792. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53793. serializationObject.size = this.getSize().width;
  53794. serializationObject.generateMipMaps = this._generateMipMaps;
  53795. return serializationObject;
  53796. };
  53797. /**
  53798. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53799. * @param parsedTexture defines parsed texture data
  53800. * @param scene defines the current scene
  53801. * @param rootUrl defines the root URL containing noise procedural texture information
  53802. * @returns a parsed NoiseProceduralTexture
  53803. */
  53804. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53805. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53806. texture.brightness = parsedTexture.brightness;
  53807. texture.octaves = parsedTexture.octaves;
  53808. texture.persistence = parsedTexture.persistence;
  53809. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53810. return texture;
  53811. };
  53812. return NoiseProceduralTexture;
  53813. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53814. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53815. /***/ }),
  53816. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53817. /*!*************************************************************!*\
  53818. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53819. \*************************************************************/
  53820. /*! exports provided: ProceduralTexture */
  53821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53822. "use strict";
  53823. __webpack_require__.r(__webpack_exports__);
  53824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53825. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53826. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53827. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53828. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53829. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53830. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53831. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53832. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53833. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53834. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53835. /**
  53836. * 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.
  53837. * This is the base class of any Procedural texture and contains most of the shareable code.
  53838. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53839. */
  53840. var ProceduralTexture = /** @class */ (function (_super) {
  53841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53842. /**
  53843. * Instantiates a new procedural texture.
  53844. * 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.
  53845. * This is the base class of any Procedural texture and contains most of the shareable code.
  53846. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53847. * @param name Define the name of the texture
  53848. * @param size Define the size of the texture to create
  53849. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53850. * @param scene Define the scene the texture belongs to
  53851. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53852. * @param generateMipMaps Define if the texture should creates mip maps or not
  53853. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53854. */
  53855. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53856. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53857. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53858. if (isCube === void 0) { isCube = false; }
  53859. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53860. _this.isCube = isCube;
  53861. /**
  53862. * Define if the texture is enabled or not (disabled texture will not render)
  53863. */
  53864. _this.isEnabled = true;
  53865. /**
  53866. * Define if the texture must be cleared before rendering (default is true)
  53867. */
  53868. _this.autoClear = true;
  53869. /**
  53870. * Event raised when the texture is generated
  53871. */
  53872. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53873. /** @hidden */
  53874. _this._textures = {};
  53875. _this._currentRefreshId = -1;
  53876. _this._refreshRate = 1;
  53877. _this._vertexBuffers = {};
  53878. _this._uniforms = new Array();
  53879. _this._samplers = new Array();
  53880. _this._floats = {};
  53881. _this._ints = {};
  53882. _this._floatsArrays = {};
  53883. _this._colors3 = {};
  53884. _this._colors4 = {};
  53885. _this._vectors2 = {};
  53886. _this._vectors3 = {};
  53887. _this._matrices = {};
  53888. _this._fallbackTextureUsed = false;
  53889. _this._cachedDefines = "";
  53890. _this._contentUpdateId = -1;
  53891. scene = _this.getScene();
  53892. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  53893. if (!component) {
  53894. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  53895. scene._addComponent(component);
  53896. }
  53897. scene.proceduralTextures.push(_this);
  53898. _this._engine = scene.getEngine();
  53899. _this.name = name;
  53900. _this.isRenderTarget = true;
  53901. _this._size = size;
  53902. _this._generateMipMaps = generateMipMaps;
  53903. _this.setFragment(fragment);
  53904. _this._fallbackTexture = fallbackTexture;
  53905. if (isCube) {
  53906. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53907. _this.setFloat("face", 0);
  53908. }
  53909. else {
  53910. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53911. }
  53912. // VBO
  53913. var vertices = [];
  53914. vertices.push(1, 1);
  53915. vertices.push(-1, 1);
  53916. vertices.push(-1, -1);
  53917. vertices.push(1, -1);
  53918. _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);
  53919. _this._createIndexBuffer();
  53920. return _this;
  53921. }
  53922. /**
  53923. * The effect that is created when initializing the post process.
  53924. * @returns The created effect corrisponding the the postprocess.
  53925. */
  53926. ProceduralTexture.prototype.getEffect = function () {
  53927. return this._effect;
  53928. };
  53929. /**
  53930. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  53931. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  53932. */
  53933. ProceduralTexture.prototype.getContent = function () {
  53934. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  53935. return this._contentData;
  53936. }
  53937. this._contentData = this.readPixels(0, 0, this._contentData);
  53938. this._contentUpdateId = this._currentRefreshId;
  53939. return this._contentData;
  53940. };
  53941. ProceduralTexture.prototype._createIndexBuffer = function () {
  53942. var engine = this._engine;
  53943. // Indices
  53944. var indices = [];
  53945. indices.push(0);
  53946. indices.push(1);
  53947. indices.push(2);
  53948. indices.push(0);
  53949. indices.push(2);
  53950. indices.push(3);
  53951. this._indexBuffer = engine.createIndexBuffer(indices);
  53952. };
  53953. /** @hidden */
  53954. ProceduralTexture.prototype._rebuild = function () {
  53955. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53956. if (vb) {
  53957. vb._rebuild();
  53958. }
  53959. this._createIndexBuffer();
  53960. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  53961. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  53962. }
  53963. };
  53964. /**
  53965. * Resets the texture in order to recreate its associated resources.
  53966. * This can be called in case of context loss
  53967. */
  53968. ProceduralTexture.prototype.reset = function () {
  53969. if (this._effect === undefined) {
  53970. return;
  53971. }
  53972. var engine = this._engine;
  53973. engine._releaseEffect(this._effect);
  53974. };
  53975. ProceduralTexture.prototype._getDefines = function () {
  53976. return "";
  53977. };
  53978. /**
  53979. * Is the texture ready to be used ? (rendered at least once)
  53980. * @returns true if ready, otherwise, false.
  53981. */
  53982. ProceduralTexture.prototype.isReady = function () {
  53983. var _this = this;
  53984. var engine = this._engine;
  53985. var shaders;
  53986. if (!this._fragment) {
  53987. return false;
  53988. }
  53989. if (this._fallbackTextureUsed) {
  53990. return true;
  53991. }
  53992. var defines = this._getDefines();
  53993. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  53994. return true;
  53995. }
  53996. if (this._fragment.fragmentElement !== undefined) {
  53997. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  53998. }
  53999. else {
  54000. shaders = { vertex: "procedural", fragment: this._fragment };
  54001. }
  54002. this._cachedDefines = defines;
  54003. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  54004. _this.releaseInternalTexture();
  54005. if (_this._fallbackTexture) {
  54006. _this._texture = _this._fallbackTexture._texture;
  54007. if (_this._texture) {
  54008. _this._texture.incrementReferences();
  54009. }
  54010. }
  54011. _this._fallbackTextureUsed = true;
  54012. });
  54013. return this._effect.isReady();
  54014. };
  54015. /**
  54016. * Resets the refresh counter of the texture and start bak from scratch.
  54017. * Could be useful to regenerate the texture if it is setup to render only once.
  54018. */
  54019. ProceduralTexture.prototype.resetRefreshCounter = function () {
  54020. this._currentRefreshId = -1;
  54021. };
  54022. /**
  54023. * Set the fragment shader to use in order to render the texture.
  54024. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  54025. */
  54026. ProceduralTexture.prototype.setFragment = function (fragment) {
  54027. this._fragment = fragment;
  54028. };
  54029. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  54030. /**
  54031. * Define the refresh rate of the texture or the rendering frequency.
  54032. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  54033. */
  54034. get: function () {
  54035. return this._refreshRate;
  54036. },
  54037. set: function (value) {
  54038. this._refreshRate = value;
  54039. this.resetRefreshCounter();
  54040. },
  54041. enumerable: true,
  54042. configurable: true
  54043. });
  54044. /** @hidden */
  54045. ProceduralTexture.prototype._shouldRender = function () {
  54046. if (!this.isEnabled || !this.isReady() || !this._texture) {
  54047. if (this._texture) {
  54048. this._texture.isReady = false;
  54049. }
  54050. return false;
  54051. }
  54052. if (this._fallbackTextureUsed) {
  54053. return false;
  54054. }
  54055. if (this._currentRefreshId === -1) { // At least render once
  54056. this._currentRefreshId = 1;
  54057. return true;
  54058. }
  54059. if (this.refreshRate === this._currentRefreshId) {
  54060. this._currentRefreshId = 1;
  54061. return true;
  54062. }
  54063. this._currentRefreshId++;
  54064. return false;
  54065. };
  54066. /**
  54067. * Get the size the texture is rendering at.
  54068. * @returns the size (texture is always squared)
  54069. */
  54070. ProceduralTexture.prototype.getRenderSize = function () {
  54071. return this._size;
  54072. };
  54073. /**
  54074. * Resize the texture to new value.
  54075. * @param size Define the new size the texture should have
  54076. * @param generateMipMaps Define whether the new texture should create mip maps
  54077. */
  54078. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  54079. if (this._fallbackTextureUsed) {
  54080. return;
  54081. }
  54082. this.releaseInternalTexture();
  54083. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  54084. // Update properties
  54085. this._size = size;
  54086. this._generateMipMaps = generateMipMaps;
  54087. };
  54088. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  54089. if (this._uniforms.indexOf(uniformName) === -1) {
  54090. this._uniforms.push(uniformName);
  54091. }
  54092. };
  54093. /**
  54094. * Set a texture in the shader program used to render.
  54095. * @param name Define the name of the uniform samplers as defined in the shader
  54096. * @param texture Define the texture to bind to this sampler
  54097. * @return the texture itself allowing "fluent" like uniform updates
  54098. */
  54099. ProceduralTexture.prototype.setTexture = function (name, texture) {
  54100. if (this._samplers.indexOf(name) === -1) {
  54101. this._samplers.push(name);
  54102. }
  54103. this._textures[name] = texture;
  54104. return this;
  54105. };
  54106. /**
  54107. * Set a float in the shader.
  54108. * @param name Define the name of the uniform as defined in the shader
  54109. * @param value Define the value to give to the uniform
  54110. * @return the texture itself allowing "fluent" like uniform updates
  54111. */
  54112. ProceduralTexture.prototype.setFloat = function (name, value) {
  54113. this._checkUniform(name);
  54114. this._floats[name] = value;
  54115. return this;
  54116. };
  54117. /**
  54118. * Set a int in the shader.
  54119. * @param name Define the name of the uniform as defined in the shader
  54120. * @param value Define the value to give to the uniform
  54121. * @return the texture itself allowing "fluent" like uniform updates
  54122. */
  54123. ProceduralTexture.prototype.setInt = function (name, value) {
  54124. this._checkUniform(name);
  54125. this._ints[name] = value;
  54126. return this;
  54127. };
  54128. /**
  54129. * Set an array of floats in the shader.
  54130. * @param name Define the name of the uniform as defined in the shader
  54131. * @param value Define the value to give to the uniform
  54132. * @return the texture itself allowing "fluent" like uniform updates
  54133. */
  54134. ProceduralTexture.prototype.setFloats = function (name, value) {
  54135. this._checkUniform(name);
  54136. this._floatsArrays[name] = value;
  54137. return this;
  54138. };
  54139. /**
  54140. * Set a vec3 in the shader from a Color3.
  54141. * @param name Define the name of the uniform as defined in the shader
  54142. * @param value Define the value to give to the uniform
  54143. * @return the texture itself allowing "fluent" like uniform updates
  54144. */
  54145. ProceduralTexture.prototype.setColor3 = function (name, value) {
  54146. this._checkUniform(name);
  54147. this._colors3[name] = value;
  54148. return this;
  54149. };
  54150. /**
  54151. * Set a vec4 in the shader from a Color4.
  54152. * @param name Define the name of the uniform as defined in the shader
  54153. * @param value Define the value to give to the uniform
  54154. * @return the texture itself allowing "fluent" like uniform updates
  54155. */
  54156. ProceduralTexture.prototype.setColor4 = function (name, value) {
  54157. this._checkUniform(name);
  54158. this._colors4[name] = value;
  54159. return this;
  54160. };
  54161. /**
  54162. * Set a vec2 in the shader from a Vector2.
  54163. * @param name Define the name of the uniform as defined in the shader
  54164. * @param value Define the value to give to the uniform
  54165. * @return the texture itself allowing "fluent" like uniform updates
  54166. */
  54167. ProceduralTexture.prototype.setVector2 = function (name, value) {
  54168. this._checkUniform(name);
  54169. this._vectors2[name] = value;
  54170. return this;
  54171. };
  54172. /**
  54173. * Set a vec3 in the shader from a Vector3.
  54174. * @param name Define the name of the uniform as defined in the shader
  54175. * @param value Define the value to give to the uniform
  54176. * @return the texture itself allowing "fluent" like uniform updates
  54177. */
  54178. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54179. this._checkUniform(name);
  54180. this._vectors3[name] = value;
  54181. return this;
  54182. };
  54183. /**
  54184. * Set a mat4 in the shader from a MAtrix.
  54185. * @param name Define the name of the uniform as defined in the shader
  54186. * @param value Define the value to give to the uniform
  54187. * @return the texture itself allowing "fluent" like uniform updates
  54188. */
  54189. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54190. this._checkUniform(name);
  54191. this._matrices[name] = value;
  54192. return this;
  54193. };
  54194. /**
  54195. * Render the texture to its associated render target.
  54196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54197. */
  54198. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54199. var scene = this.getScene();
  54200. if (!scene) {
  54201. return;
  54202. }
  54203. var engine = this._engine;
  54204. // Render
  54205. engine.enableEffect(this._effect);
  54206. engine.setState(false);
  54207. // Texture
  54208. for (var name in this._textures) {
  54209. this._effect.setTexture(name, this._textures[name]);
  54210. }
  54211. // Float
  54212. for (name in this._ints) {
  54213. this._effect.setInt(name, this._ints[name]);
  54214. }
  54215. // Float
  54216. for (name in this._floats) {
  54217. this._effect.setFloat(name, this._floats[name]);
  54218. }
  54219. // Floats
  54220. for (name in this._floatsArrays) {
  54221. this._effect.setArray(name, this._floatsArrays[name]);
  54222. }
  54223. // Color3
  54224. for (name in this._colors3) {
  54225. this._effect.setColor3(name, this._colors3[name]);
  54226. }
  54227. // Color4
  54228. for (name in this._colors4) {
  54229. var color = this._colors4[name];
  54230. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54231. }
  54232. // Vector2
  54233. for (name in this._vectors2) {
  54234. this._effect.setVector2(name, this._vectors2[name]);
  54235. }
  54236. // Vector3
  54237. for (name in this._vectors3) {
  54238. this._effect.setVector3(name, this._vectors3[name]);
  54239. }
  54240. // Matrix
  54241. for (name in this._matrices) {
  54242. this._effect.setMatrix(name, this._matrices[name]);
  54243. }
  54244. if (!this._texture) {
  54245. return;
  54246. }
  54247. if (this.isCube) {
  54248. for (var face = 0; face < 6; face++) {
  54249. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54250. // VBOs
  54251. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54252. this._effect.setFloat("face", face);
  54253. // Clear
  54254. if (this.autoClear) {
  54255. engine.clear(scene.clearColor, true, false, false);
  54256. }
  54257. // Draw order
  54258. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54259. // Mipmaps
  54260. if (face === 5) {
  54261. engine.generateMipMapsForCubemap(this._texture);
  54262. }
  54263. }
  54264. }
  54265. else {
  54266. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54267. // VBOs
  54268. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54269. // Clear
  54270. if (this.autoClear) {
  54271. engine.clear(scene.clearColor, true, false, false);
  54272. }
  54273. // Draw order
  54274. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54275. }
  54276. // Unbind
  54277. engine.unBindFramebuffer(this._texture, this.isCube);
  54278. if (this.onGenerated) {
  54279. this.onGenerated();
  54280. }
  54281. this.onGeneratedObservable.notifyObservers(this);
  54282. };
  54283. /**
  54284. * Clone the texture.
  54285. * @returns the cloned texture
  54286. */
  54287. ProceduralTexture.prototype.clone = function () {
  54288. var textureSize = this.getSize();
  54289. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54290. // Base texture
  54291. newTexture.hasAlpha = this.hasAlpha;
  54292. newTexture.level = this.level;
  54293. // RenderTarget Texture
  54294. newTexture.coordinatesMode = this.coordinatesMode;
  54295. return newTexture;
  54296. };
  54297. /**
  54298. * Dispose the texture and release its asoociated resources.
  54299. */
  54300. ProceduralTexture.prototype.dispose = function () {
  54301. var scene = this.getScene();
  54302. if (!scene) {
  54303. return;
  54304. }
  54305. var index = scene.proceduralTextures.indexOf(this);
  54306. if (index >= 0) {
  54307. scene.proceduralTextures.splice(index, 1);
  54308. }
  54309. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54310. if (vertexBuffer) {
  54311. vertexBuffer.dispose();
  54312. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54313. }
  54314. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54315. this._indexBuffer = null;
  54316. }
  54317. _super.prototype.dispose.call(this);
  54318. };
  54319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54321. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54324. ], ProceduralTexture.prototype, "autoClear", void 0);
  54325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54327. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54330. ], ProceduralTexture.prototype, "_size", void 0);
  54331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54333. ], ProceduralTexture.prototype, "refreshRate", null);
  54334. return ProceduralTexture;
  54335. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54336. /***/ }),
  54337. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54338. /*!***************************************************************************!*\
  54339. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54340. \***************************************************************************/
  54341. /*! exports provided: ProceduralTextureSceneComponent */
  54342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54343. "use strict";
  54344. __webpack_require__.r(__webpack_exports__);
  54345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54346. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54347. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54348. /**
  54349. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54350. * in a given scene.
  54351. */
  54352. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54353. /**
  54354. * Creates a new instance of the component for the given scene
  54355. * @param scene Defines the scene to register the component in
  54356. */
  54357. function ProceduralTextureSceneComponent(scene) {
  54358. /**
  54359. * The component name helpfull to identify the component in the list of scene components.
  54360. */
  54361. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54362. this.scene = scene;
  54363. this.scene.proceduralTextures = new Array();
  54364. scene.layers = new Array();
  54365. }
  54366. /**
  54367. * Registers the component in a given scene
  54368. */
  54369. ProceduralTextureSceneComponent.prototype.register = function () {
  54370. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54371. };
  54372. /**
  54373. * Rebuilds the elements related to this component in case of
  54374. * context lost for instance.
  54375. */
  54376. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54377. // Nothing to do here.
  54378. };
  54379. /**
  54380. * Disposes the component and the associated ressources.
  54381. */
  54382. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54383. // Nothing to do here.
  54384. };
  54385. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54386. if (this.scene.proceduralTexturesEnabled) {
  54387. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54388. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54389. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54390. if (proceduralTexture._shouldRender()) {
  54391. proceduralTexture.render();
  54392. }
  54393. }
  54394. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54395. }
  54396. };
  54397. return ProceduralTextureSceneComponent;
  54398. }());
  54399. /***/ }),
  54400. /***/ "./Materials/Textures/baseTexture.ts":
  54401. /*!*******************************************!*\
  54402. !*** ./Materials/Textures/baseTexture.ts ***!
  54403. \*******************************************/
  54404. /*! exports provided: BaseTexture */
  54405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54406. "use strict";
  54407. __webpack_require__.r(__webpack_exports__);
  54408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54409. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54410. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54411. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54412. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54413. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54414. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54415. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54416. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54417. /**
  54418. * Base class of all the textures in babylon.
  54419. * It groups all the common properties the materials, post process, lights... might need
  54420. * in order to make a correct use of the texture.
  54421. */
  54422. var BaseTexture = /** @class */ (function () {
  54423. /**
  54424. * Instantiates a new BaseTexture.
  54425. * Base class of all the textures in babylon.
  54426. * It groups all the common properties the materials, post process, lights... might need
  54427. * in order to make a correct use of the texture.
  54428. * @param scene Define the scene the texture blongs to
  54429. */
  54430. function BaseTexture(scene) {
  54431. /**
  54432. * Gets or sets an object used to store user defined information.
  54433. */
  54434. this.metadata = null;
  54435. /**
  54436. * For internal use only. Please do not use.
  54437. */
  54438. this.reservedDataStore = null;
  54439. this._hasAlpha = false;
  54440. /**
  54441. * Defines if the alpha value should be determined via the rgb values.
  54442. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54443. */
  54444. this.getAlphaFromRGB = false;
  54445. /**
  54446. * Intensity or strength of the texture.
  54447. * It is commonly used by materials to fine tune the intensity of the texture
  54448. */
  54449. this.level = 1;
  54450. /**
  54451. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54452. * This is part of the texture as textures usually maps to one uv set.
  54453. */
  54454. this.coordinatesIndex = 0;
  54455. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54456. /**
  54457. * | Value | Type | Description |
  54458. * | ----- | ------------------ | ----------- |
  54459. * | 0 | CLAMP_ADDRESSMODE | |
  54460. * | 1 | WRAP_ADDRESSMODE | |
  54461. * | 2 | MIRROR_ADDRESSMODE | |
  54462. */
  54463. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54464. /**
  54465. * | Value | Type | Description |
  54466. * | ----- | ------------------ | ----------- |
  54467. * | 0 | CLAMP_ADDRESSMODE | |
  54468. * | 1 | WRAP_ADDRESSMODE | |
  54469. * | 2 | MIRROR_ADDRESSMODE | |
  54470. */
  54471. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54472. /**
  54473. * | Value | Type | Description |
  54474. * | ----- | ------------------ | ----------- |
  54475. * | 0 | CLAMP_ADDRESSMODE | |
  54476. * | 1 | WRAP_ADDRESSMODE | |
  54477. * | 2 | MIRROR_ADDRESSMODE | |
  54478. */
  54479. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54480. /**
  54481. * With compliant hardware and browser (supporting anisotropic filtering)
  54482. * this defines the level of anisotropic filtering in the texture.
  54483. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  54484. */
  54485. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  54486. /**
  54487. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  54488. * HDR texture are usually stored in linear space.
  54489. * This only impacts the PBR and Background materials
  54490. */
  54491. this.gammaSpace = true;
  54492. /**
  54493. * Is Z inverted in the texture (useful in a cube texture).
  54494. */
  54495. this.invertZ = false;
  54496. /**
  54497. * @hidden
  54498. */
  54499. this.lodLevelInAlpha = false;
  54500. /**
  54501. * Define if the texture is a render target.
  54502. */
  54503. this.isRenderTarget = false;
  54504. /**
  54505. * Define the list of animation attached to the texture.
  54506. */
  54507. this.animations = new Array();
  54508. /**
  54509. * An event triggered when the texture is disposed.
  54510. */
  54511. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54512. /**
  54513. * Define the current state of the loading sequence when in delayed load mode.
  54514. */
  54515. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  54516. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54517. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  54518. if (this._scene) {
  54519. this.uniqueId = this._scene.getUniqueId();
  54520. this._scene.addTexture(this);
  54521. }
  54522. this._uid = null;
  54523. }
  54524. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  54525. get: function () {
  54526. return this._hasAlpha;
  54527. },
  54528. /**
  54529. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  54530. */
  54531. set: function (value) {
  54532. if (this._hasAlpha === value) {
  54533. return;
  54534. }
  54535. this._hasAlpha = value;
  54536. if (this._scene) {
  54537. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  54538. }
  54539. },
  54540. enumerable: true,
  54541. configurable: true
  54542. });
  54543. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  54544. get: function () {
  54545. return this._coordinatesMode;
  54546. },
  54547. /**
  54548. * How a texture is mapped.
  54549. *
  54550. * | Value | Type | Description |
  54551. * | ----- | ----------------------------------- | ----------- |
  54552. * | 0 | EXPLICIT_MODE | |
  54553. * | 1 | SPHERICAL_MODE | |
  54554. * | 2 | PLANAR_MODE | |
  54555. * | 3 | CUBIC_MODE | |
  54556. * | 4 | PROJECTION_MODE | |
  54557. * | 5 | SKYBOX_MODE | |
  54558. * | 6 | INVCUBIC_MODE | |
  54559. * | 7 | EQUIRECTANGULAR_MODE | |
  54560. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  54561. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  54562. */
  54563. set: function (value) {
  54564. if (this._coordinatesMode === value) {
  54565. return;
  54566. }
  54567. this._coordinatesMode = value;
  54568. if (this._scene) {
  54569. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54570. }
  54571. },
  54572. enumerable: true,
  54573. configurable: true
  54574. });
  54575. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54576. /**
  54577. * Define if the texture is a cube texture or if false a 2d texture.
  54578. */
  54579. get: function () {
  54580. if (!this._texture) {
  54581. return false;
  54582. }
  54583. return this._texture.isCube;
  54584. },
  54585. set: function (value) {
  54586. if (!this._texture) {
  54587. return;
  54588. }
  54589. this._texture.isCube = value;
  54590. },
  54591. enumerable: true,
  54592. configurable: true
  54593. });
  54594. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54595. /**
  54596. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54597. */
  54598. get: function () {
  54599. if (!this._texture) {
  54600. return false;
  54601. }
  54602. return this._texture.is3D;
  54603. },
  54604. set: function (value) {
  54605. if (!this._texture) {
  54606. return;
  54607. }
  54608. this._texture.is3D = value;
  54609. },
  54610. enumerable: true,
  54611. configurable: true
  54612. });
  54613. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54614. /**
  54615. * Gets whether or not the texture contains RGBD data.
  54616. */
  54617. get: function () {
  54618. return this._texture != null && this._texture._isRGBD;
  54619. },
  54620. enumerable: true,
  54621. configurable: true
  54622. });
  54623. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54624. /**
  54625. * Are mip maps generated for this texture or not.
  54626. */
  54627. get: function () {
  54628. return false;
  54629. },
  54630. enumerable: true,
  54631. configurable: true
  54632. });
  54633. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54634. /**
  54635. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54636. */
  54637. get: function () {
  54638. if (this._texture) {
  54639. return this._texture._lodGenerationOffset;
  54640. }
  54641. return 0.0;
  54642. },
  54643. set: function (value) {
  54644. if (this._texture) {
  54645. this._texture._lodGenerationOffset = value;
  54646. }
  54647. },
  54648. enumerable: true,
  54649. configurable: true
  54650. });
  54651. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54652. /**
  54653. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54654. */
  54655. get: function () {
  54656. if (this._texture) {
  54657. return this._texture._lodGenerationScale;
  54658. }
  54659. return 0.0;
  54660. },
  54661. set: function (value) {
  54662. if (this._texture) {
  54663. this._texture._lodGenerationScale = value;
  54664. }
  54665. },
  54666. enumerable: true,
  54667. configurable: true
  54668. });
  54669. Object.defineProperty(BaseTexture.prototype, "uid", {
  54670. /**
  54671. * Define the unique id of the texture in the scene.
  54672. */
  54673. get: function () {
  54674. if (!this._uid) {
  54675. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54676. }
  54677. return this._uid;
  54678. },
  54679. enumerable: true,
  54680. configurable: true
  54681. });
  54682. /**
  54683. * Return a string representation of the texture.
  54684. * @returns the texture as a string
  54685. */
  54686. BaseTexture.prototype.toString = function () {
  54687. return this.name;
  54688. };
  54689. /**
  54690. * Get the class name of the texture.
  54691. * @returns "BaseTexture"
  54692. */
  54693. BaseTexture.prototype.getClassName = function () {
  54694. return "BaseTexture";
  54695. };
  54696. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54697. /**
  54698. * Callback triggered when the texture has been disposed.
  54699. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54700. */
  54701. set: function (callback) {
  54702. if (this._onDisposeObserver) {
  54703. this.onDisposeObservable.remove(this._onDisposeObserver);
  54704. }
  54705. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54706. },
  54707. enumerable: true,
  54708. configurable: true
  54709. });
  54710. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54711. /**
  54712. * Define if the texture is preventinga material to render or not.
  54713. * If not and the texture is not ready, the engine will use a default black texture instead.
  54714. */
  54715. get: function () {
  54716. return true;
  54717. },
  54718. enumerable: true,
  54719. configurable: true
  54720. });
  54721. /**
  54722. * Get the scene the texture belongs to.
  54723. * @returns the scene or null if undefined
  54724. */
  54725. BaseTexture.prototype.getScene = function () {
  54726. return this._scene;
  54727. };
  54728. /**
  54729. * Get the texture transform matrix used to offset tile the texture for istance.
  54730. * @returns the transformation matrix
  54731. */
  54732. BaseTexture.prototype.getTextureMatrix = function () {
  54733. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54734. };
  54735. /**
  54736. * Get the texture reflection matrix used to rotate/transform the reflection.
  54737. * @returns the reflection matrix
  54738. */
  54739. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54740. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54741. };
  54742. /**
  54743. * Get the underlying lower level texture from Babylon.
  54744. * @returns the insternal texture
  54745. */
  54746. BaseTexture.prototype.getInternalTexture = function () {
  54747. return this._texture;
  54748. };
  54749. /**
  54750. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54751. * @returns true if ready or not blocking
  54752. */
  54753. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54754. return !this.isBlocking || this.isReady();
  54755. };
  54756. /**
  54757. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54758. * @returns true if fully ready
  54759. */
  54760. BaseTexture.prototype.isReady = function () {
  54761. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54762. this.delayLoad();
  54763. return false;
  54764. }
  54765. if (this._texture) {
  54766. return this._texture.isReady;
  54767. }
  54768. return false;
  54769. };
  54770. /**
  54771. * Get the size of the texture.
  54772. * @returns the texture size.
  54773. */
  54774. BaseTexture.prototype.getSize = function () {
  54775. if (this._texture) {
  54776. if (this._texture.width) {
  54777. this._cachedSize.width = this._texture.width;
  54778. this._cachedSize.height = this._texture.height;
  54779. return this._cachedSize;
  54780. }
  54781. if (this._texture._size) {
  54782. this._cachedSize.width = this._texture._size;
  54783. this._cachedSize.height = this._texture._size;
  54784. return this._cachedSize;
  54785. }
  54786. }
  54787. return this._cachedSize;
  54788. };
  54789. /**
  54790. * Get the base size of the texture.
  54791. * It can be different from the size if the texture has been resized for POT for instance
  54792. * @returns the base size
  54793. */
  54794. BaseTexture.prototype.getBaseSize = function () {
  54795. if (!this.isReady() || !this._texture) {
  54796. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54797. }
  54798. if (this._texture._size) {
  54799. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54800. }
  54801. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54802. };
  54803. /**
  54804. * Update the sampling mode of the texture.
  54805. * Default is Trilinear mode.
  54806. *
  54807. * | Value | Type | Description |
  54808. * | ----- | ------------------ | ----------- |
  54809. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54810. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54811. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54812. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54813. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54814. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54815. * | 7 | NEAREST_LINEAR | |
  54816. * | 8 | NEAREST_NEAREST | |
  54817. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54818. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54819. * | 11 | LINEAR_LINEAR | |
  54820. * | 12 | LINEAR_NEAREST | |
  54821. *
  54822. * > _mag_: magnification filter (close to the viewer)
  54823. * > _min_: minification filter (far from the viewer)
  54824. * > _mip_: filter used between mip map levels
  54825. *@param samplingMode Define the new sampling mode of the texture
  54826. */
  54827. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54828. if (!this._texture) {
  54829. return;
  54830. }
  54831. var scene = this.getScene();
  54832. if (!scene) {
  54833. return;
  54834. }
  54835. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54836. };
  54837. /**
  54838. * Scales the texture if is `canRescale()`
  54839. * @param ratio the resize factor we want to use to rescale
  54840. */
  54841. BaseTexture.prototype.scale = function (ratio) {
  54842. };
  54843. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54844. /**
  54845. * Get if the texture can rescale.
  54846. */
  54847. get: function () {
  54848. return false;
  54849. },
  54850. enumerable: true,
  54851. configurable: true
  54852. });
  54853. /** @hidden */
  54854. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54855. if (!this._scene) {
  54856. return null;
  54857. }
  54858. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54859. for (var index = 0; index < texturesCache.length; index++) {
  54860. var texturesCacheEntry = texturesCache[index];
  54861. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54862. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54863. texturesCacheEntry.incrementReferences();
  54864. return texturesCacheEntry;
  54865. }
  54866. }
  54867. }
  54868. return null;
  54869. };
  54870. /** @hidden */
  54871. BaseTexture.prototype._rebuild = function () {
  54872. };
  54873. /**
  54874. * Triggers the load sequence in delayed load mode.
  54875. */
  54876. BaseTexture.prototype.delayLoad = function () {
  54877. };
  54878. /**
  54879. * Clones the texture.
  54880. * @returns the cloned texture
  54881. */
  54882. BaseTexture.prototype.clone = function () {
  54883. return null;
  54884. };
  54885. Object.defineProperty(BaseTexture.prototype, "textureType", {
  54886. /**
  54887. * Get the texture underlying type (INT, FLOAT...)
  54888. */
  54889. get: function () {
  54890. if (!this._texture) {
  54891. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54892. }
  54893. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54894. },
  54895. enumerable: true,
  54896. configurable: true
  54897. });
  54898. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  54899. /**
  54900. * Get the texture underlying format (RGB, RGBA...)
  54901. */
  54902. get: function () {
  54903. if (!this._texture) {
  54904. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54905. }
  54906. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54907. },
  54908. enumerable: true,
  54909. configurable: true
  54910. });
  54911. /**
  54912. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  54913. * This will returns an RGBA array buffer containing either in values (0-255) or
  54914. * float values (0-1) depending of the underlying buffer type.
  54915. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  54916. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  54917. * @param buffer defines a user defined buffer to fill with data (can be null)
  54918. * @returns The Array buffer containing the pixels data.
  54919. */
  54920. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  54921. if (faceIndex === void 0) { faceIndex = 0; }
  54922. if (level === void 0) { level = 0; }
  54923. if (buffer === void 0) { buffer = null; }
  54924. if (!this._texture) {
  54925. return null;
  54926. }
  54927. var size = this.getSize();
  54928. var width = size.width;
  54929. var height = size.height;
  54930. var scene = this.getScene();
  54931. if (!scene) {
  54932. return null;
  54933. }
  54934. var engine = scene.getEngine();
  54935. if (level != 0) {
  54936. width = width / Math.pow(2, level);
  54937. height = height / Math.pow(2, level);
  54938. width = Math.round(width);
  54939. height = Math.round(height);
  54940. }
  54941. if (this._texture.isCube) {
  54942. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  54943. }
  54944. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  54945. };
  54946. /**
  54947. * Release and destroy the underlying lower level texture aka internalTexture.
  54948. */
  54949. BaseTexture.prototype.releaseInternalTexture = function () {
  54950. if (this._texture) {
  54951. this._texture.dispose();
  54952. this._texture = null;
  54953. }
  54954. };
  54955. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  54956. /**
  54957. * Get the polynomial representation of the texture data.
  54958. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54959. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54960. */
  54961. get: function () {
  54962. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  54963. return null;
  54964. }
  54965. if (!this._texture._sphericalPolynomial) {
  54966. this._texture._sphericalPolynomial =
  54967. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  54968. }
  54969. return this._texture._sphericalPolynomial;
  54970. },
  54971. set: function (value) {
  54972. if (this._texture) {
  54973. this._texture._sphericalPolynomial = value;
  54974. }
  54975. },
  54976. enumerable: true,
  54977. configurable: true
  54978. });
  54979. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  54980. /** @hidden */
  54981. get: function () {
  54982. if (this._texture) {
  54983. return this._texture._lodTextureHigh;
  54984. }
  54985. return null;
  54986. },
  54987. enumerable: true,
  54988. configurable: true
  54989. });
  54990. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  54991. /** @hidden */
  54992. get: function () {
  54993. if (this._texture) {
  54994. return this._texture._lodTextureMid;
  54995. }
  54996. return null;
  54997. },
  54998. enumerable: true,
  54999. configurable: true
  55000. });
  55001. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  55002. /** @hidden */
  55003. get: function () {
  55004. if (this._texture) {
  55005. return this._texture._lodTextureLow;
  55006. }
  55007. return null;
  55008. },
  55009. enumerable: true,
  55010. configurable: true
  55011. });
  55012. /**
  55013. * Dispose the texture and release its associated resources.
  55014. */
  55015. BaseTexture.prototype.dispose = function () {
  55016. if (!this._scene) {
  55017. return;
  55018. }
  55019. // Animations
  55020. this._scene.stopAnimation(this);
  55021. // Remove from scene
  55022. this._scene._removePendingData(this);
  55023. var index = this._scene.textures.indexOf(this);
  55024. if (index >= 0) {
  55025. this._scene.textures.splice(index, 1);
  55026. }
  55027. this._scene.onTextureRemovedObservable.notifyObservers(this);
  55028. if (this._texture === undefined) {
  55029. return;
  55030. }
  55031. // Release
  55032. this.releaseInternalTexture();
  55033. // Callback
  55034. this.onDisposeObservable.notifyObservers(this);
  55035. this.onDisposeObservable.clear();
  55036. };
  55037. /**
  55038. * Serialize the texture into a JSON representation that can be parsed later on.
  55039. * @returns the JSON representation of the texture
  55040. */
  55041. BaseTexture.prototype.serialize = function () {
  55042. if (!this.name) {
  55043. return null;
  55044. }
  55045. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55046. // Animations
  55047. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  55048. return serializationObject;
  55049. };
  55050. /**
  55051. * Helper function to be called back once a list of texture contains only ready textures.
  55052. * @param textures Define the list of textures to wait for
  55053. * @param callback Define the callback triggered once the entire list will be ready
  55054. */
  55055. BaseTexture.WhenAllReady = function (textures, callback) {
  55056. var numRemaining = textures.length;
  55057. if (numRemaining === 0) {
  55058. callback();
  55059. return;
  55060. }
  55061. var _loop_1 = function () {
  55062. texture = textures[i];
  55063. if (texture.isReady()) {
  55064. if (--numRemaining === 0) {
  55065. callback();
  55066. }
  55067. }
  55068. else {
  55069. onLoadObservable = texture.onLoadObservable;
  55070. var onLoadCallback_1 = function () {
  55071. onLoadObservable.removeCallback(onLoadCallback_1);
  55072. if (--numRemaining === 0) {
  55073. callback();
  55074. }
  55075. };
  55076. onLoadObservable.add(onLoadCallback_1);
  55077. }
  55078. };
  55079. var texture, onLoadObservable;
  55080. for (var i = 0; i < textures.length; i++) {
  55081. _loop_1();
  55082. }
  55083. };
  55084. /**
  55085. * Default anisotropic filtering level for the application.
  55086. * It is set to 4 as a good tradeoff between perf and quality.
  55087. */
  55088. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  55089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55091. ], BaseTexture.prototype, "uniqueId", void 0);
  55092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55094. ], BaseTexture.prototype, "name", void 0);
  55095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55097. ], BaseTexture.prototype, "metadata", void 0);
  55098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  55100. ], BaseTexture.prototype, "_hasAlpha", void 0);
  55101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55103. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  55104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55106. ], BaseTexture.prototype, "level", void 0);
  55107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55109. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  55110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  55112. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  55113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55115. ], BaseTexture.prototype, "wrapU", void 0);
  55116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55118. ], BaseTexture.prototype, "wrapV", void 0);
  55119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55121. ], BaseTexture.prototype, "wrapR", void 0);
  55122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55124. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  55125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55127. ], BaseTexture.prototype, "isCube", null);
  55128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55130. ], BaseTexture.prototype, "is3D", null);
  55131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55133. ], BaseTexture.prototype, "gammaSpace", void 0);
  55134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55136. ], BaseTexture.prototype, "invertZ", void 0);
  55137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55139. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  55140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55142. ], BaseTexture.prototype, "lodGenerationOffset", null);
  55143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55145. ], BaseTexture.prototype, "lodGenerationScale", null);
  55146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55148. ], BaseTexture.prototype, "isRenderTarget", void 0);
  55149. return BaseTexture;
  55150. }());
  55151. /***/ }),
  55152. /***/ "./Materials/Textures/colorGradingTexture.ts":
  55153. /*!***************************************************!*\
  55154. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  55155. \***************************************************/
  55156. /*! exports provided: ColorGradingTexture */
  55157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55158. "use strict";
  55159. __webpack_require__.r(__webpack_exports__);
  55160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  55161. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55162. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55163. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55164. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55165. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55166. /**
  55167. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55168. * It can help converting any input color in a desired output one. This can then be used to create effects
  55169. * from sepia, black and white to sixties or futuristic rendering...
  55170. *
  55171. * The only supported format is currently 3dl.
  55172. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55173. */
  55174. var ColorGradingTexture = /** @class */ (function (_super) {
  55175. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55176. /**
  55177. * Instantiates a ColorGradingTexture from the following parameters.
  55178. *
  55179. * @param url The location of the color gradind data (currently only supporting 3dl)
  55180. * @param scene The scene the texture will be used in
  55181. */
  55182. function ColorGradingTexture(url, scene) {
  55183. var _this = _super.call(this, scene) || this;
  55184. if (!url) {
  55185. return _this;
  55186. }
  55187. _this._engine = scene.getEngine();
  55188. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55189. _this.name = url;
  55190. _this.url = url;
  55191. _this.hasAlpha = false;
  55192. _this.isCube = false;
  55193. _this.is3D = _this._engine.webGLVersion > 1;
  55194. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55195. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55196. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55197. _this.anisotropicFilteringLevel = 1;
  55198. _this._texture = _this._getFromCache(url, true);
  55199. if (!_this._texture) {
  55200. if (!scene.useDelayedTextureLoading) {
  55201. _this.loadTexture();
  55202. }
  55203. else {
  55204. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55205. }
  55206. }
  55207. return _this;
  55208. }
  55209. /**
  55210. * Returns the texture matrix used in most of the material.
  55211. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55212. */
  55213. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55214. return this._textureMatrix;
  55215. };
  55216. /**
  55217. * Occurs when the file being loaded is a .3dl LUT file.
  55218. */
  55219. ColorGradingTexture.prototype.load3dlTexture = function () {
  55220. var engine = this._engine;
  55221. var texture;
  55222. if (engine.webGLVersion === 1) {
  55223. 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);
  55224. }
  55225. else {
  55226. 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);
  55227. }
  55228. this._texture = texture;
  55229. var callback = function (text) {
  55230. if (typeof text !== "string") {
  55231. return;
  55232. }
  55233. var data = null;
  55234. var tempData = null;
  55235. var line;
  55236. var lines = text.split('\n');
  55237. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55238. var maxColor = 0;
  55239. for (var i = 0; i < lines.length; i++) {
  55240. line = lines[i];
  55241. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55242. continue;
  55243. }
  55244. if (line.indexOf('#') === 0) {
  55245. continue;
  55246. }
  55247. var words = line.split(" ");
  55248. if (size === 0) {
  55249. // Number of space + one
  55250. size = words.length;
  55251. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55252. tempData = new Float32Array(size * size * size * 4);
  55253. continue;
  55254. }
  55255. if (size != 0) {
  55256. var r = Math.max(parseInt(words[0]), 0);
  55257. var g = Math.max(parseInt(words[1]), 0);
  55258. var b = Math.max(parseInt(words[2]), 0);
  55259. maxColor = Math.max(r, maxColor);
  55260. maxColor = Math.max(g, maxColor);
  55261. maxColor = Math.max(b, maxColor);
  55262. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55263. if (tempData) {
  55264. tempData[pixelStorageIndex + 0] = r;
  55265. tempData[pixelStorageIndex + 1] = g;
  55266. tempData[pixelStorageIndex + 2] = b;
  55267. }
  55268. // Keep for reference in case of back compat problems.
  55269. // pixelIndexSlice++;
  55270. // if (pixelIndexSlice % size == 0) {
  55271. // pixelIndexH++;
  55272. // pixelIndexSlice = 0;
  55273. // if (pixelIndexH % size == 0) {
  55274. // pixelIndexW++;
  55275. // pixelIndexH = 0;
  55276. // }
  55277. // }
  55278. pixelIndexH++;
  55279. if (pixelIndexH % size == 0) {
  55280. pixelIndexSlice++;
  55281. pixelIndexH = 0;
  55282. if (pixelIndexSlice % size == 0) {
  55283. pixelIndexW++;
  55284. pixelIndexSlice = 0;
  55285. }
  55286. }
  55287. }
  55288. }
  55289. if (tempData && data) {
  55290. for (var i = 0; i < tempData.length; i++) {
  55291. if (i > 0 && (i + 1) % 4 === 0) {
  55292. data[i] = 255;
  55293. }
  55294. else {
  55295. var value = tempData[i];
  55296. data[i] = (value / maxColor * 255);
  55297. }
  55298. }
  55299. }
  55300. if (texture.is3D) {
  55301. texture.updateSize(size, size, size);
  55302. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55303. }
  55304. else {
  55305. texture.updateSize(size * size, size);
  55306. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55307. }
  55308. };
  55309. var scene = this.getScene();
  55310. if (scene) {
  55311. scene._loadFile(this.url, callback);
  55312. }
  55313. else {
  55314. this._engine._loadFile(this.url, callback);
  55315. }
  55316. return this._texture;
  55317. };
  55318. /**
  55319. * Starts the loading process of the texture.
  55320. */
  55321. ColorGradingTexture.prototype.loadTexture = function () {
  55322. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55323. this.load3dlTexture();
  55324. }
  55325. };
  55326. /**
  55327. * Clones the color gradind texture.
  55328. */
  55329. ColorGradingTexture.prototype.clone = function () {
  55330. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55331. // Base texture
  55332. newTexture.level = this.level;
  55333. return newTexture;
  55334. };
  55335. /**
  55336. * Called during delayed load for textures.
  55337. */
  55338. ColorGradingTexture.prototype.delayLoad = function () {
  55339. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55340. return;
  55341. }
  55342. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55343. this._texture = this._getFromCache(this.url, true);
  55344. if (!this._texture) {
  55345. this.loadTexture();
  55346. }
  55347. };
  55348. /**
  55349. * Parses a color grading texture serialized by Babylon.
  55350. * @param parsedTexture The texture information being parsedTexture
  55351. * @param scene The scene to load the texture in
  55352. * @param rootUrl The root url of the data assets to load
  55353. * @return A color gradind texture
  55354. */
  55355. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55356. var texture = null;
  55357. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55358. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55359. texture.name = parsedTexture.name;
  55360. texture.level = parsedTexture.level;
  55361. }
  55362. return texture;
  55363. };
  55364. /**
  55365. * Serializes the LUT texture to json format.
  55366. */
  55367. ColorGradingTexture.prototype.serialize = function () {
  55368. if (!this.name) {
  55369. return null;
  55370. }
  55371. var serializationObject = {};
  55372. serializationObject.name = this.name;
  55373. serializationObject.level = this.level;
  55374. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55375. return serializationObject;
  55376. };
  55377. /**
  55378. * Empty line regex stored for GC.
  55379. */
  55380. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55381. return ColorGradingTexture;
  55382. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55383. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55384. /***/ }),
  55385. /***/ "./Materials/Textures/cubeTexture.ts":
  55386. /*!*******************************************!*\
  55387. !*** ./Materials/Textures/cubeTexture.ts ***!
  55388. \*******************************************/
  55389. /*! exports provided: CubeTexture */
  55390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55391. "use strict";
  55392. __webpack_require__.r(__webpack_exports__);
  55393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55395. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55396. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55397. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55398. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55399. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55400. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55401. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55402. /**
  55403. * Class for creating a cube texture
  55404. */
  55405. var CubeTexture = /** @class */ (function (_super) {
  55406. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55407. /**
  55408. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55409. * as prefiltered data.
  55410. * @param rootUrl defines the url of the texture or the root name of the six images
  55411. * @param scene defines the scene the texture is attached to
  55412. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55413. * @param noMipmap defines if mipmaps should be created or not
  55414. * @param files defines the six files to load for the different faces
  55415. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55416. * @param onError defines a callback triggered in case of error during load
  55417. * @param format defines the internal format to use for the texture once loaded
  55418. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55419. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55420. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55421. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55422. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55423. * @return the cube texture
  55424. */
  55425. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55426. if (extensions === void 0) { extensions = null; }
  55427. if (noMipmap === void 0) { noMipmap = false; }
  55428. if (files === void 0) { files = null; }
  55429. if (onLoad === void 0) { onLoad = null; }
  55430. if (onError === void 0) { onError = null; }
  55431. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55432. if (prefiltered === void 0) { prefiltered = false; }
  55433. if (forcedExtension === void 0) { forcedExtension = null; }
  55434. if (createPolynomials === void 0) { createPolynomials = false; }
  55435. if (lodScale === void 0) { lodScale = 0.8; }
  55436. if (lodOffset === void 0) { lodOffset = 0; }
  55437. var _this = _super.call(this, scene) || this;
  55438. /**
  55439. * Gets or sets the center of the bounding box associated with the cube texture.
  55440. * It must define where the camera used to render the texture was set
  55441. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55442. */
  55443. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55444. _this._rotationY = 0;
  55445. /** @hidden */
  55446. _this._prefiltered = false;
  55447. _this.name = rootUrl;
  55448. _this.url = rootUrl;
  55449. _this._noMipmap = noMipmap;
  55450. _this.hasAlpha = false;
  55451. _this._format = format;
  55452. _this.isCube = true;
  55453. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55454. _this._createPolynomials = createPolynomials;
  55455. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55456. if (!rootUrl && !files) {
  55457. return _this;
  55458. }
  55459. var lastDot = rootUrl.lastIndexOf(".");
  55460. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55461. var isDDS = (extension === ".dds");
  55462. var isEnv = (extension === ".env");
  55463. if (isEnv) {
  55464. _this.gammaSpace = false;
  55465. _this._prefiltered = false;
  55466. }
  55467. else {
  55468. _this._prefiltered = prefiltered;
  55469. if (prefiltered) {
  55470. _this.gammaSpace = false;
  55471. }
  55472. }
  55473. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  55474. if (!files) {
  55475. if (!isEnv && !isDDS && !extensions) {
  55476. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  55477. }
  55478. files = [];
  55479. if (extensions) {
  55480. for (var index = 0; index < extensions.length; index++) {
  55481. files.push(rootUrl + extensions[index]);
  55482. }
  55483. }
  55484. }
  55485. _this._files = files;
  55486. if (!_this._texture) {
  55487. if (!scene.useDelayedTextureLoading) {
  55488. if (prefiltered) {
  55489. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  55490. }
  55491. else {
  55492. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  55493. }
  55494. }
  55495. else {
  55496. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55497. }
  55498. }
  55499. else if (onLoad) {
  55500. if (_this._texture.isReady) {
  55501. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  55502. }
  55503. else {
  55504. _this._texture.onLoadedObservable.add(onLoad);
  55505. }
  55506. }
  55507. return _this;
  55508. }
  55509. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  55510. /**
  55511. * Returns the bounding box size
  55512. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55513. */
  55514. get: function () {
  55515. return this._boundingBoxSize;
  55516. },
  55517. /**
  55518. * Gets or sets the size of the bounding box associated with the cube texture
  55519. * When defined, the cubemap will switch to local mode
  55520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55521. * @example https://www.babylonjs-playground.com/#RNASML
  55522. */
  55523. set: function (value) {
  55524. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55525. return;
  55526. }
  55527. this._boundingBoxSize = value;
  55528. var scene = this.getScene();
  55529. if (scene) {
  55530. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55531. }
  55532. },
  55533. enumerable: true,
  55534. configurable: true
  55535. });
  55536. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  55537. /**
  55538. * Gets texture matrix rotation angle around Y axis radians.
  55539. */
  55540. get: function () {
  55541. return this._rotationY;
  55542. },
  55543. /**
  55544. * Sets texture matrix rotation angle around Y axis in radians.
  55545. */
  55546. set: function (value) {
  55547. this._rotationY = value;
  55548. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  55549. },
  55550. enumerable: true,
  55551. configurable: true
  55552. });
  55553. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  55554. /**
  55555. * Are mip maps generated for this texture or not.
  55556. */
  55557. get: function () {
  55558. return this._noMipmap;
  55559. },
  55560. enumerable: true,
  55561. configurable: true
  55562. });
  55563. /**
  55564. * Creates a cube texture from an array of image urls
  55565. * @param files defines an array of image urls
  55566. * @param scene defines the hosting scene
  55567. * @param noMipmap specifies if mip maps are not used
  55568. * @returns a cube texture
  55569. */
  55570. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  55571. var rootUrlKey = "";
  55572. files.forEach(function (url) { return rootUrlKey += url; });
  55573. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55574. };
  55575. /**
  55576. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55577. * @param url defines the url of the prefiltered texture
  55578. * @param scene defines the scene the texture is attached to
  55579. * @param forcedExtension defines the extension of the file if different from the url
  55580. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55581. * @return the prefiltered texture
  55582. */
  55583. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55584. if (forcedExtension === void 0) { forcedExtension = null; }
  55585. if (createPolynomials === void 0) { createPolynomials = true; }
  55586. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55587. };
  55588. /**
  55589. * Get the current class name of the texture useful for serialization or dynamic coding.
  55590. * @returns "CubeTexture"
  55591. */
  55592. CubeTexture.prototype.getClassName = function () {
  55593. return "CubeTexture";
  55594. };
  55595. /**
  55596. * Update the url (and optional buffer) of this texture if url was null during construction.
  55597. * @param url the url of the texture
  55598. * @param forcedExtension defines the extension to use
  55599. * @param onLoad callback called when the texture is loaded (defaults to null)
  55600. */
  55601. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55602. if (this.url) {
  55603. this.releaseInternalTexture();
  55604. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55605. }
  55606. this.url = url;
  55607. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55608. this._prefiltered = false;
  55609. if (onLoad) {
  55610. this._delayedOnLoad = onLoad;
  55611. }
  55612. this.delayLoad(forcedExtension);
  55613. };
  55614. /**
  55615. * Delays loading of the cube texture
  55616. * @param forcedExtension defines the extension to use
  55617. */
  55618. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55619. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55620. return;
  55621. }
  55622. var scene = this.getScene();
  55623. if (!scene) {
  55624. return;
  55625. }
  55626. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  55627. this._texture = this._getFromCache(this.url, this._noMipmap);
  55628. if (!this._texture) {
  55629. if (this._prefiltered) {
  55630. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55631. }
  55632. else {
  55633. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55634. }
  55635. }
  55636. };
  55637. /**
  55638. * Returns the reflection texture matrix
  55639. * @returns the reflection texture matrix
  55640. */
  55641. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55642. return this._textureMatrix;
  55643. };
  55644. /**
  55645. * Sets the reflection texture matrix
  55646. * @param value Reflection texture matrix
  55647. */
  55648. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55649. var _this = this;
  55650. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55651. return;
  55652. }
  55653. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55654. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55655. }
  55656. this._textureMatrix = value;
  55657. };
  55658. /**
  55659. * Parses text to create a cube texture
  55660. * @param parsedTexture define the serialized text to read from
  55661. * @param scene defines the hosting scene
  55662. * @param rootUrl defines the root url of the cube texture
  55663. * @returns a cube texture
  55664. */
  55665. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55666. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55667. var prefiltered = false;
  55668. if (parsedTexture.prefiltered) {
  55669. prefiltered = parsedTexture.prefiltered;
  55670. }
  55671. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55672. }, parsedTexture, scene);
  55673. // Local Cubemaps
  55674. if (parsedTexture.boundingBoxPosition) {
  55675. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55676. }
  55677. if (parsedTexture.boundingBoxSize) {
  55678. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55679. }
  55680. // Animations
  55681. if (parsedTexture.animations) {
  55682. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55683. var parsedAnimation = parsedTexture.animations[animationIndex];
  55684. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  55685. if (internalClass) {
  55686. texture.animations.push(internalClass.Parse(parsedAnimation));
  55687. }
  55688. }
  55689. }
  55690. return texture;
  55691. };
  55692. /**
  55693. * Makes a clone, or deep copy, of the cube texture
  55694. * @returns a new cube texture
  55695. */
  55696. CubeTexture.prototype.clone = function () {
  55697. var _this = this;
  55698. var scene = this.getScene();
  55699. var uniqueId = 0;
  55700. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55701. if (!scene) {
  55702. return _this;
  55703. }
  55704. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55705. uniqueId = cubeTexture.uniqueId;
  55706. return cubeTexture;
  55707. }, this);
  55708. newCubeTexture.uniqueId = uniqueId;
  55709. return newCubeTexture;
  55710. };
  55711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55713. ], CubeTexture.prototype, "rotationY", null);
  55714. return CubeTexture;
  55715. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55716. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55717. /***/ }),
  55718. /***/ "./Materials/Textures/dynamicTexture.ts":
  55719. /*!**********************************************!*\
  55720. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55721. \**********************************************/
  55722. /*! exports provided: DynamicTexture */
  55723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55724. "use strict";
  55725. __webpack_require__.r(__webpack_exports__);
  55726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55728. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55729. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55730. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55731. /**
  55732. * A class extending Texture allowing drawing on a texture
  55733. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55734. */
  55735. var DynamicTexture = /** @class */ (function (_super) {
  55736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55737. /**
  55738. * Creates a DynamicTexture
  55739. * @param name defines the name of the texture
  55740. * @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
  55741. * @param scene defines the scene where you want the texture
  55742. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55743. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55744. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55745. */
  55746. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55747. if (scene === void 0) { scene = null; }
  55748. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55749. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55750. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55751. _this.name = name;
  55752. _this._engine = _this.getScene().getEngine();
  55753. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55754. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55755. _this._generateMipMaps = generateMipMaps;
  55756. if (options.getContext) {
  55757. _this._canvas = options;
  55758. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55759. }
  55760. else {
  55761. _this._canvas = document.createElement("canvas");
  55762. if (options.width || options.width === 0) {
  55763. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55764. }
  55765. else {
  55766. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55767. }
  55768. }
  55769. var textureSize = _this.getSize();
  55770. _this._canvas.width = textureSize.width;
  55771. _this._canvas.height = textureSize.height;
  55772. _this._context = _this._canvas.getContext("2d");
  55773. return _this;
  55774. }
  55775. /**
  55776. * Get the current class name of the texture useful for serialization or dynamic coding.
  55777. * @returns "DynamicTexture"
  55778. */
  55779. DynamicTexture.prototype.getClassName = function () {
  55780. return "DynamicTexture";
  55781. };
  55782. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55783. /**
  55784. * Gets the current state of canRescale
  55785. */
  55786. get: function () {
  55787. return true;
  55788. },
  55789. enumerable: true,
  55790. configurable: true
  55791. });
  55792. DynamicTexture.prototype._recreate = function (textureSize) {
  55793. this._canvas.width = textureSize.width;
  55794. this._canvas.height = textureSize.height;
  55795. this.releaseInternalTexture();
  55796. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55797. };
  55798. /**
  55799. * Scales the texture
  55800. * @param ratio the scale factor to apply to both width and height
  55801. */
  55802. DynamicTexture.prototype.scale = function (ratio) {
  55803. var textureSize = this.getSize();
  55804. textureSize.width *= ratio;
  55805. textureSize.height *= ratio;
  55806. this._recreate(textureSize);
  55807. };
  55808. /**
  55809. * Resizes the texture
  55810. * @param width the new width
  55811. * @param height the new height
  55812. */
  55813. DynamicTexture.prototype.scaleTo = function (width, height) {
  55814. var textureSize = this.getSize();
  55815. textureSize.width = width;
  55816. textureSize.height = height;
  55817. this._recreate(textureSize);
  55818. };
  55819. /**
  55820. * Gets the context of the canvas used by the texture
  55821. * @returns the canvas context of the dynamic texture
  55822. */
  55823. DynamicTexture.prototype.getContext = function () {
  55824. return this._context;
  55825. };
  55826. /**
  55827. * Clears the texture
  55828. */
  55829. DynamicTexture.prototype.clear = function () {
  55830. var size = this.getSize();
  55831. this._context.fillRect(0, 0, size.width, size.height);
  55832. };
  55833. /**
  55834. * Updates the texture
  55835. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55836. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55837. */
  55838. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55839. if (premulAlpha === void 0) { premulAlpha = false; }
  55840. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55841. };
  55842. /**
  55843. * Draws text onto the texture
  55844. * @param text defines the text to be drawn
  55845. * @param x defines the placement of the text from the left
  55846. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55847. * @param font defines the font to be used with font-style, font-size, font-name
  55848. * @param color defines the color used for the text
  55849. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55850. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55851. * @param update defines whether texture is immediately update (default is true)
  55852. */
  55853. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55854. if (update === void 0) { update = true; }
  55855. var size = this.getSize();
  55856. if (clearColor) {
  55857. this._context.fillStyle = clearColor;
  55858. this._context.fillRect(0, 0, size.width, size.height);
  55859. }
  55860. this._context.font = font;
  55861. if (x === null || x === undefined) {
  55862. var textSize = this._context.measureText(text);
  55863. x = (size.width - textSize.width) / 2;
  55864. }
  55865. if (y === null || y === undefined) {
  55866. var fontSize = parseInt((font.replace(/\D/g, '')));
  55867. y = (size.height / 2) + (fontSize / 3.65);
  55868. }
  55869. this._context.fillStyle = color;
  55870. this._context.fillText(text, x, y);
  55871. if (update) {
  55872. this.update(invertY);
  55873. }
  55874. };
  55875. /**
  55876. * Clones the texture
  55877. * @returns the clone of the texture.
  55878. */
  55879. DynamicTexture.prototype.clone = function () {
  55880. var scene = this.getScene();
  55881. if (!scene) {
  55882. return this;
  55883. }
  55884. var textureSize = this.getSize();
  55885. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  55886. // Base texture
  55887. newTexture.hasAlpha = this.hasAlpha;
  55888. newTexture.level = this.level;
  55889. // Dynamic Texture
  55890. newTexture.wrapU = this.wrapU;
  55891. newTexture.wrapV = this.wrapV;
  55892. return newTexture;
  55893. };
  55894. /**
  55895. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55896. * @returns a serialized dynamic texture object
  55897. */
  55898. DynamicTexture.prototype.serialize = function () {
  55899. var scene = this.getScene();
  55900. if (scene && !scene.isReady()) {
  55901. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  55902. }
  55903. var serializationObject = _super.prototype.serialize.call(this);
  55904. serializationObject.base64String = this._canvas.toDataURL();
  55905. serializationObject.invertY = this._invertY;
  55906. serializationObject.samplingMode = this.samplingMode;
  55907. return serializationObject;
  55908. };
  55909. /** @hidden */
  55910. DynamicTexture.prototype._rebuild = function () {
  55911. this.update();
  55912. };
  55913. return DynamicTexture;
  55914. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  55915. /***/ }),
  55916. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  55917. /*!**********************************************!*\
  55918. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  55919. \**********************************************/
  55920. /*! exports provided: HDRCubeTexture */
  55921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55922. "use strict";
  55923. __webpack_require__.r(__webpack_exports__);
  55924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  55925. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55926. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55927. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  55928. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55929. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55930. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55931. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  55932. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55933. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55934. /**
  55935. * This represents a texture coming from an HDR input.
  55936. *
  55937. * The only supported format is currently panorama picture stored in RGBE format.
  55938. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55939. */
  55940. var HDRCubeTexture = /** @class */ (function (_super) {
  55941. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  55942. /**
  55943. * Instantiates an HDRTexture from the following parameters.
  55944. *
  55945. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55946. * @param scene The scene the texture will be used in
  55947. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55948. * @param noMipmap Forces to not generate the mipmap if true
  55949. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55950. * @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)
  55951. * @param reserved Reserved flag for internal use.
  55952. */
  55953. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  55954. if (noMipmap === void 0) { noMipmap = false; }
  55955. if (generateHarmonics === void 0) { generateHarmonics = true; }
  55956. if (gammaSpace === void 0) { gammaSpace = false; }
  55957. if (reserved === void 0) { reserved = false; }
  55958. if (onLoad === void 0) { onLoad = null; }
  55959. if (onError === void 0) { onError = null; }
  55960. var _this = _super.call(this, scene) || this;
  55961. _this._generateHarmonics = true;
  55962. _this._onLoad = null;
  55963. _this._onError = null;
  55964. /**
  55965. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55966. */
  55967. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  55968. _this._isBlocking = true;
  55969. _this._rotationY = 0;
  55970. /**
  55971. * Gets or sets the center of the bounding box associated with the cube texture
  55972. * It must define where the camera used to render the texture was set
  55973. */
  55974. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  55975. if (!url) {
  55976. return _this;
  55977. }
  55978. _this.name = url;
  55979. _this.url = url;
  55980. _this.hasAlpha = false;
  55981. _this.isCube = true;
  55982. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55983. _this._onLoad = onLoad;
  55984. _this._onError = onError;
  55985. _this.gammaSpace = gammaSpace;
  55986. _this._noMipmap = noMipmap;
  55987. _this._size = size;
  55988. _this._texture = _this._getFromCache(url, _this._noMipmap);
  55989. if (!_this._texture) {
  55990. if (!scene.useDelayedTextureLoading) {
  55991. _this.loadTexture();
  55992. }
  55993. else {
  55994. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  55995. }
  55996. }
  55997. return _this;
  55998. }
  55999. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  56000. /**
  56001. * Gets wether or not the texture is blocking during loading.
  56002. */
  56003. get: function () {
  56004. return this._isBlocking;
  56005. },
  56006. /**
  56007. * Sets wether or not the texture is blocking during loading.
  56008. */
  56009. set: function (value) {
  56010. this._isBlocking = value;
  56011. },
  56012. enumerable: true,
  56013. configurable: true
  56014. });
  56015. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  56016. /**
  56017. * Gets texture matrix rotation angle around Y axis radians.
  56018. */
  56019. get: function () {
  56020. return this._rotationY;
  56021. },
  56022. /**
  56023. * Sets texture matrix rotation angle around Y axis in radians.
  56024. */
  56025. set: function (value) {
  56026. this._rotationY = value;
  56027. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  56028. },
  56029. enumerable: true,
  56030. configurable: true
  56031. });
  56032. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  56033. get: function () {
  56034. return this._boundingBoxSize;
  56035. },
  56036. /**
  56037. * Gets or sets the size of the bounding box associated with the cube texture
  56038. * When defined, the cubemap will switch to local mode
  56039. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56040. * @example https://www.babylonjs-playground.com/#RNASML
  56041. */
  56042. set: function (value) {
  56043. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56044. return;
  56045. }
  56046. this._boundingBoxSize = value;
  56047. var scene = this.getScene();
  56048. if (scene) {
  56049. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  56050. }
  56051. },
  56052. enumerable: true,
  56053. configurable: true
  56054. });
  56055. /**
  56056. * Get the current class name of the texture useful for serialization or dynamic coding.
  56057. * @returns "HDRCubeTexture"
  56058. */
  56059. HDRCubeTexture.prototype.getClassName = function () {
  56060. return "HDRCubeTexture";
  56061. };
  56062. /**
  56063. * Occurs when the file is raw .hdr file.
  56064. */
  56065. HDRCubeTexture.prototype.loadTexture = function () {
  56066. var _this = this;
  56067. var callback = function (buffer) {
  56068. _this.lodGenerationOffset = 0.0;
  56069. _this.lodGenerationScale = 0.8;
  56070. var scene = _this.getScene();
  56071. if (!scene) {
  56072. return null;
  56073. }
  56074. // Extract the raw linear data.
  56075. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  56076. // Generate harmonics if needed.
  56077. if (_this._generateHarmonics) {
  56078. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  56079. _this.sphericalPolynomial = sphericalPolynomial;
  56080. }
  56081. var results = [];
  56082. var byteArray = null;
  56083. // Push each faces.
  56084. for (var j = 0; j < 6; j++) {
  56085. // Create uintarray fallback.
  56086. if (!scene.getEngine().getCaps().textureFloat) {
  56087. // 3 channels of 1 bytes per pixel in bytes.
  56088. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  56089. byteArray = new Uint8Array(byteBuffer);
  56090. }
  56091. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  56092. // If special cases.
  56093. if (_this.gammaSpace || byteArray) {
  56094. for (var i = 0; i < _this._size * _this._size; i++) {
  56095. // Put in gamma space if requested.
  56096. if (_this.gammaSpace) {
  56097. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56098. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56099. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56100. }
  56101. // Convert to int texture for fallback.
  56102. if (byteArray) {
  56103. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  56104. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  56105. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  56106. // May use luminance instead if the result is not accurate.
  56107. var max = Math.max(Math.max(r, g), b);
  56108. if (max > 255) {
  56109. var scale = 255 / max;
  56110. r *= scale;
  56111. g *= scale;
  56112. b *= scale;
  56113. }
  56114. byteArray[(i * 3) + 0] = r;
  56115. byteArray[(i * 3) + 1] = g;
  56116. byteArray[(i * 3) + 2] = b;
  56117. }
  56118. }
  56119. }
  56120. if (byteArray) {
  56121. results.push(byteArray);
  56122. }
  56123. else {
  56124. results.push(dataFace);
  56125. }
  56126. }
  56127. return results;
  56128. };
  56129. var scene = this.getScene();
  56130. if (scene) {
  56131. 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);
  56132. }
  56133. };
  56134. HDRCubeTexture.prototype.clone = function () {
  56135. var scene = this.getScene();
  56136. if (!scene) {
  56137. return this;
  56138. }
  56139. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  56140. // Base texture
  56141. newTexture.level = this.level;
  56142. newTexture.wrapU = this.wrapU;
  56143. newTexture.wrapV = this.wrapV;
  56144. newTexture.coordinatesIndex = this.coordinatesIndex;
  56145. newTexture.coordinatesMode = this.coordinatesMode;
  56146. return newTexture;
  56147. };
  56148. // Methods
  56149. HDRCubeTexture.prototype.delayLoad = function () {
  56150. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  56151. return;
  56152. }
  56153. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  56154. this._texture = this._getFromCache(this.url, this._noMipmap);
  56155. if (!this._texture) {
  56156. this.loadTexture();
  56157. }
  56158. };
  56159. /**
  56160. * Get the texture reflection matrix used to rotate/transform the reflection.
  56161. * @returns the reflection matrix
  56162. */
  56163. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  56164. return this._textureMatrix;
  56165. };
  56166. /**
  56167. * Set the texture reflection matrix used to rotate/transform the reflection.
  56168. * @param value Define the reflection matrix to set
  56169. */
  56170. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56171. var _this = this;
  56172. this._textureMatrix = value;
  56173. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56174. return;
  56175. }
  56176. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56177. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56178. }
  56179. };
  56180. /**
  56181. * Parses a JSON representation of an HDR Texture in order to create the texture
  56182. * @param parsedTexture Define the JSON representation
  56183. * @param scene Define the scene the texture should be created in
  56184. * @param rootUrl Define the root url in case we need to load relative dependencies
  56185. * @returns the newly created texture after parsing
  56186. */
  56187. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56188. var texture = null;
  56189. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56190. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56191. texture.name = parsedTexture.name;
  56192. texture.hasAlpha = parsedTexture.hasAlpha;
  56193. texture.level = parsedTexture.level;
  56194. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56195. texture.isBlocking = parsedTexture.isBlocking;
  56196. }
  56197. if (texture) {
  56198. if (parsedTexture.boundingBoxPosition) {
  56199. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56200. }
  56201. if (parsedTexture.boundingBoxSize) {
  56202. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56203. }
  56204. if (parsedTexture.rotationY) {
  56205. texture.rotationY = parsedTexture.rotationY;
  56206. }
  56207. }
  56208. return texture;
  56209. };
  56210. HDRCubeTexture.prototype.serialize = function () {
  56211. if (!this.name) {
  56212. return null;
  56213. }
  56214. var serializationObject = {};
  56215. serializationObject.name = this.name;
  56216. serializationObject.hasAlpha = this.hasAlpha;
  56217. serializationObject.isCube = true;
  56218. serializationObject.level = this.level;
  56219. serializationObject.size = this._size;
  56220. serializationObject.coordinatesMode = this.coordinatesMode;
  56221. serializationObject.useInGammaSpace = this.gammaSpace;
  56222. serializationObject.generateHarmonics = this._generateHarmonics;
  56223. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56224. serializationObject.noMipmap = this._noMipmap;
  56225. serializationObject.isBlocking = this._isBlocking;
  56226. serializationObject.rotationY = this._rotationY;
  56227. return serializationObject;
  56228. };
  56229. HDRCubeTexture._facesMapping = [
  56230. "right",
  56231. "left",
  56232. "up",
  56233. "down",
  56234. "front",
  56235. "back"
  56236. ];
  56237. return HDRCubeTexture;
  56238. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56239. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56240. /***/ }),
  56241. /***/ "./Materials/Textures/index.ts":
  56242. /*!*************************************!*\
  56243. !*** ./Materials/Textures/index.ts ***!
  56244. \*************************************/
  56245. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56247. "use strict";
  56248. __webpack_require__.r(__webpack_exports__);
  56249. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56251. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56253. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56255. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56257. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56259. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56261. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56263. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56268. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56270. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56272. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56277. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56279. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56281. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56283. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56285. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56287. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56289. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56291. /***/ }),
  56292. /***/ "./Materials/Textures/internalTexture.ts":
  56293. /*!***********************************************!*\
  56294. !*** ./Materials/Textures/internalTexture.ts ***!
  56295. \***********************************************/
  56296. /*! exports provided: InternalTexture */
  56297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56298. "use strict";
  56299. __webpack_require__.r(__webpack_exports__);
  56300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56301. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56302. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56303. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56304. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  56305. /**
  56306. * Class used to store data associated with WebGL texture data for the engine
  56307. * This class should not be used directly
  56308. */
  56309. var InternalTexture = /** @class */ (function () {
  56310. /**
  56311. * Creates a new InternalTexture
  56312. * @param engine defines the engine to use
  56313. * @param dataSource defines the type of data that will be used
  56314. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56315. */
  56316. function InternalTexture(engine, dataSource, delayAllocation) {
  56317. if (delayAllocation === void 0) { delayAllocation = false; }
  56318. /**
  56319. * Observable called when the texture is loaded
  56320. */
  56321. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56322. /**
  56323. * Gets or set the previous tracker in the list
  56324. */
  56325. this.previous = null;
  56326. /**
  56327. * Gets or set the next tracker in the list
  56328. */
  56329. this.next = null;
  56330. // Private
  56331. /** @hidden */
  56332. this._invertVScale = false;
  56333. /** @hidden */
  56334. this._initialSlot = -1;
  56335. /** @hidden */
  56336. this._designatedSlot = -1;
  56337. /** @hidden */
  56338. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56339. /** @hidden */
  56340. this._comparisonFunction = 0;
  56341. /** @hidden */
  56342. this._sphericalPolynomial = null;
  56343. /** @hidden */
  56344. this._lodGenerationScale = 0;
  56345. /** @hidden */
  56346. this._lodGenerationOffset = 0;
  56347. /** @hidden */
  56348. this._isRGBD = false;
  56349. /** @hidden */
  56350. this._references = 1;
  56351. this._engine = engine;
  56352. this._dataSource = dataSource;
  56353. if (!delayAllocation) {
  56354. this._webGLTexture = engine._createTexture();
  56355. }
  56356. }
  56357. /**
  56358. * Gets the Engine the texture belongs to.
  56359. * @returns The babylon engine
  56360. */
  56361. InternalTexture.prototype.getEngine = function () {
  56362. return this._engine;
  56363. };
  56364. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56365. /**
  56366. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56367. */
  56368. get: function () {
  56369. return this._dataSource;
  56370. },
  56371. enumerable: true,
  56372. configurable: true
  56373. });
  56374. /**
  56375. * Increments the number of references (ie. the number of Texture that point to it)
  56376. */
  56377. InternalTexture.prototype.incrementReferences = function () {
  56378. this._references++;
  56379. };
  56380. /**
  56381. * Change the size of the texture (not the size of the content)
  56382. * @param width defines the new width
  56383. * @param height defines the new height
  56384. * @param depth defines the new depth (1 by default)
  56385. */
  56386. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56387. if (depth === void 0) { depth = 1; }
  56388. this.width = width;
  56389. this.height = height;
  56390. this.depth = depth;
  56391. this.baseWidth = width;
  56392. this.baseHeight = height;
  56393. this.baseDepth = depth;
  56394. this._size = width * height * depth;
  56395. };
  56396. /** @hidden */
  56397. InternalTexture.prototype._rebuild = function () {
  56398. var _this = this;
  56399. var proxy;
  56400. this.isReady = false;
  56401. this._cachedCoordinatesMode = null;
  56402. this._cachedWrapU = null;
  56403. this._cachedWrapV = null;
  56404. this._cachedAnisotropicFilteringLevel = null;
  56405. switch (this._dataSource) {
  56406. case InternalTexture.DATASOURCE_TEMP:
  56407. return;
  56408. case InternalTexture.DATASOURCE_URL:
  56409. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56410. proxy._swapAndDie(_this);
  56411. _this.isReady = true;
  56412. }, null, this._buffer, undefined, this.format);
  56413. return;
  56414. case InternalTexture.DATASOURCE_RAW:
  56415. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56416. proxy._swapAndDie(this);
  56417. this.isReady = true;
  56418. return;
  56419. case InternalTexture.DATASOURCE_RAW3D:
  56420. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56421. proxy._swapAndDie(this);
  56422. this.isReady = true;
  56423. return;
  56424. case InternalTexture.DATASOURCE_DYNAMIC:
  56425. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56426. proxy._swapAndDie(this);
  56427. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56428. // The engine will make sure to update content so no need to flag it as isReady = true
  56429. return;
  56430. case InternalTexture.DATASOURCE_RENDERTARGET:
  56431. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56432. options.generateDepthBuffer = this._generateDepthBuffer;
  56433. options.generateMipMaps = this.generateMipMaps;
  56434. options.generateStencilBuffer = this._generateStencilBuffer;
  56435. options.samplingMode = this.samplingMode;
  56436. options.type = this.type;
  56437. if (this.isCube) {
  56438. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56439. }
  56440. else {
  56441. var size = {
  56442. width: this.width,
  56443. height: this.height
  56444. };
  56445. proxy = this._engine.createRenderTargetTexture(size, options);
  56446. }
  56447. proxy._swapAndDie(this);
  56448. this.isReady = true;
  56449. return;
  56450. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56451. var depthTextureOptions = {
  56452. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56453. comparisonFunction: this._comparisonFunction,
  56454. generateStencil: this._generateStencilBuffer,
  56455. isCube: this.isCube
  56456. };
  56457. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56458. proxy._swapAndDie(this);
  56459. this.isReady = true;
  56460. return;
  56461. case InternalTexture.DATASOURCE_CUBE:
  56462. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  56463. proxy._swapAndDie(_this);
  56464. _this.isReady = true;
  56465. }, null, this.format, this._extension);
  56466. return;
  56467. case InternalTexture.DATASOURCE_CUBERAW:
  56468. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56469. proxy._swapAndDie(this);
  56470. this.isReady = true;
  56471. return;
  56472. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  56473. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56474. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  56475. proxy._swapAndDie(_this);
  56476. _this.isReady = true;
  56477. });
  56478. return;
  56479. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  56480. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  56481. if (proxy) {
  56482. proxy._swapAndDie(_this);
  56483. }
  56484. _this.isReady = true;
  56485. }, null, this.format, this._extension);
  56486. proxy._sphericalPolynomial = this._sphericalPolynomial;
  56487. return;
  56488. }
  56489. };
  56490. /** @hidden */
  56491. InternalTexture.prototype._swapAndDie = function (target) {
  56492. target._webGLTexture = this._webGLTexture;
  56493. if (this._framebuffer) {
  56494. target._framebuffer = this._framebuffer;
  56495. }
  56496. if (this._depthStencilBuffer) {
  56497. target._depthStencilBuffer = this._depthStencilBuffer;
  56498. }
  56499. if (this._lodTextureHigh) {
  56500. if (target._lodTextureHigh) {
  56501. target._lodTextureHigh.dispose();
  56502. }
  56503. target._lodTextureHigh = this._lodTextureHigh;
  56504. }
  56505. if (this._lodTextureMid) {
  56506. if (target._lodTextureMid) {
  56507. target._lodTextureMid.dispose();
  56508. }
  56509. target._lodTextureMid = this._lodTextureMid;
  56510. }
  56511. if (this._lodTextureLow) {
  56512. if (target._lodTextureLow) {
  56513. target._lodTextureLow.dispose();
  56514. }
  56515. target._lodTextureLow = this._lodTextureLow;
  56516. }
  56517. var cache = this._engine.getLoadedTexturesCache();
  56518. var index = cache.indexOf(this);
  56519. if (index !== -1) {
  56520. cache.splice(index, 1);
  56521. }
  56522. };
  56523. /**
  56524. * Dispose the current allocated resources
  56525. */
  56526. InternalTexture.prototype.dispose = function () {
  56527. if (!this._webGLTexture) {
  56528. return;
  56529. }
  56530. this._references--;
  56531. if (this._references === 0) {
  56532. this._engine._releaseTexture(this);
  56533. this._webGLTexture = null;
  56534. this.previous = null;
  56535. this.next = null;
  56536. }
  56537. };
  56538. /** hidden */
  56539. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56540. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  56541. };
  56542. /**
  56543. * The source of the texture data is unknown
  56544. */
  56545. InternalTexture.DATASOURCE_UNKNOWN = 0;
  56546. /**
  56547. * Texture data comes from an URL
  56548. */
  56549. InternalTexture.DATASOURCE_URL = 1;
  56550. /**
  56551. * Texture data is only used for temporary storage
  56552. */
  56553. InternalTexture.DATASOURCE_TEMP = 2;
  56554. /**
  56555. * Texture data comes from raw data (ArrayBuffer)
  56556. */
  56557. InternalTexture.DATASOURCE_RAW = 3;
  56558. /**
  56559. * Texture content is dynamic (video or dynamic texture)
  56560. */
  56561. InternalTexture.DATASOURCE_DYNAMIC = 4;
  56562. /**
  56563. * Texture content is generated by rendering to it
  56564. */
  56565. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  56566. /**
  56567. * Texture content is part of a multi render target process
  56568. */
  56569. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  56570. /**
  56571. * Texture data comes from a cube data file
  56572. */
  56573. InternalTexture.DATASOURCE_CUBE = 7;
  56574. /**
  56575. * Texture data comes from a raw cube data
  56576. */
  56577. InternalTexture.DATASOURCE_CUBERAW = 8;
  56578. /**
  56579. * Texture data come from a prefiltered cube data file
  56580. */
  56581. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56582. /**
  56583. * Texture content is raw 3D data
  56584. */
  56585. InternalTexture.DATASOURCE_RAW3D = 10;
  56586. /**
  56587. * Texture content is a depth texture
  56588. */
  56589. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56590. /**
  56591. * Texture data comes from a raw cube data encoded with RGBD
  56592. */
  56593. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56594. return InternalTexture;
  56595. }());
  56596. /***/ }),
  56597. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56598. /*!******************************************************!*\
  56599. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56600. \******************************************************/
  56601. /*! exports provided: DummyInternalTextureTracker */
  56602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56603. "use strict";
  56604. __webpack_require__.r(__webpack_exports__);
  56605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56606. /**
  56607. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56608. */
  56609. var DummyInternalTextureTracker = /** @class */ (function () {
  56610. function DummyInternalTextureTracker() {
  56611. /**
  56612. * Gets or set the previous tracker in the list
  56613. */
  56614. this.previous = null;
  56615. /**
  56616. * Gets or set the next tracker in the list
  56617. */
  56618. this.next = null;
  56619. }
  56620. return DummyInternalTextureTracker;
  56621. }());
  56622. /***/ }),
  56623. /***/ "./Materials/Textures/mirrorTexture.ts":
  56624. /*!*********************************************!*\
  56625. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56626. \*********************************************/
  56627. /*! exports provided: MirrorTexture */
  56628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56629. "use strict";
  56630. __webpack_require__.r(__webpack_exports__);
  56631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56633. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56634. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56635. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56636. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56637. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56638. /**
  56639. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56640. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56641. * You can then easily use it as a reflectionTexture on a flat surface.
  56642. * In case the surface is not a plane, please consider relying on reflection probes.
  56643. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56644. */
  56645. var MirrorTexture = /** @class */ (function (_super) {
  56646. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56647. /**
  56648. * Instantiates a Mirror Texture.
  56649. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56650. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56651. * You can then easily use it as a reflectionTexture on a flat surface.
  56652. * In case the surface is not a plane, please consider relying on reflection probes.
  56653. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56654. * @param name
  56655. * @param size
  56656. * @param scene
  56657. * @param generateMipMaps
  56658. * @param type
  56659. * @param samplingMode
  56660. * @param generateDepthBuffer
  56661. */
  56662. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56663. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56664. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56665. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56666. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56667. _this.scene = scene;
  56668. /**
  56669. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56670. * 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.
  56671. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56672. */
  56673. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56674. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56675. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56676. _this._adaptiveBlurKernel = 0;
  56677. _this._blurKernelX = 0;
  56678. _this._blurKernelY = 0;
  56679. _this._blurRatio = 1.0;
  56680. _this.ignoreCameraViewport = true;
  56681. _this._updateGammaSpace();
  56682. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56683. _this._updateGammaSpace;
  56684. });
  56685. _this.onBeforeRenderObservable.add(function () {
  56686. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56687. _this._savedViewMatrix = scene.getViewMatrix();
  56688. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56689. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56690. scene.clipPlane = _this.mirrorPlane;
  56691. scene.getEngine().cullBackFaces = false;
  56692. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56693. });
  56694. _this.onAfterRenderObservable.add(function () {
  56695. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56696. scene.getEngine().cullBackFaces = true;
  56697. scene._mirroredCameraPosition = null;
  56698. delete scene.clipPlane;
  56699. });
  56700. return _this;
  56701. }
  56702. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56703. get: function () {
  56704. return this._blurRatio;
  56705. },
  56706. /**
  56707. * Define the blur ratio used to blur the reflection if needed.
  56708. */
  56709. set: function (value) {
  56710. if (this._blurRatio === value) {
  56711. return;
  56712. }
  56713. this._blurRatio = value;
  56714. this._preparePostProcesses();
  56715. },
  56716. enumerable: true,
  56717. configurable: true
  56718. });
  56719. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56720. /**
  56721. * Define the adaptive blur kernel used to blur the reflection if needed.
  56722. * This will autocompute the closest best match for the `blurKernel`
  56723. */
  56724. set: function (value) {
  56725. this._adaptiveBlurKernel = value;
  56726. this._autoComputeBlurKernel();
  56727. },
  56728. enumerable: true,
  56729. configurable: true
  56730. });
  56731. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56732. /**
  56733. * Define the blur kernel used to blur the reflection if needed.
  56734. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56735. */
  56736. set: function (value) {
  56737. this.blurKernelX = value;
  56738. this.blurKernelY = value;
  56739. },
  56740. enumerable: true,
  56741. configurable: true
  56742. });
  56743. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56744. get: function () {
  56745. return this._blurKernelX;
  56746. },
  56747. /**
  56748. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56749. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56750. */
  56751. set: function (value) {
  56752. if (this._blurKernelX === value) {
  56753. return;
  56754. }
  56755. this._blurKernelX = value;
  56756. this._preparePostProcesses();
  56757. },
  56758. enumerable: true,
  56759. configurable: true
  56760. });
  56761. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56762. get: function () {
  56763. return this._blurKernelY;
  56764. },
  56765. /**
  56766. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56767. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56768. */
  56769. set: function (value) {
  56770. if (this._blurKernelY === value) {
  56771. return;
  56772. }
  56773. this._blurKernelY = value;
  56774. this._preparePostProcesses();
  56775. },
  56776. enumerable: true,
  56777. configurable: true
  56778. });
  56779. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56780. var engine = this.getScene().getEngine();
  56781. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56782. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56783. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56784. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56785. };
  56786. MirrorTexture.prototype._onRatioRescale = function () {
  56787. if (this._sizeRatio) {
  56788. this.resize(this._initialSizeParameter);
  56789. if (!this._adaptiveBlurKernel) {
  56790. this._preparePostProcesses();
  56791. }
  56792. }
  56793. if (this._adaptiveBlurKernel) {
  56794. this._autoComputeBlurKernel();
  56795. }
  56796. };
  56797. MirrorTexture.prototype._updateGammaSpace = function () {
  56798. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56799. };
  56800. MirrorTexture.prototype._preparePostProcesses = function () {
  56801. this.clearPostProcesses(true);
  56802. if (this._blurKernelX && this._blurKernelY) {
  56803. var engine = this.getScene().getEngine();
  56804. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56805. this._blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("horizontal blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1.0, 0), this._blurKernelX, this._blurRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, textureType);
  56806. this._blurX.autoClear = false;
  56807. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56808. this._blurX.inputTexture = this._texture;
  56809. }
  56810. else {
  56811. this._blurX.alwaysForcePOT = true;
  56812. }
  56813. this._blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("vertical blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1.0), this._blurKernelY, this._blurRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, textureType);
  56814. this._blurY.autoClear = false;
  56815. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56816. this.addPostProcess(this._blurX);
  56817. this.addPostProcess(this._blurY);
  56818. }
  56819. else {
  56820. if (this._blurY) {
  56821. this.removePostProcess(this._blurY);
  56822. this._blurY.dispose();
  56823. this._blurY = null;
  56824. }
  56825. if (this._blurX) {
  56826. this.removePostProcess(this._blurX);
  56827. this._blurX.dispose();
  56828. this._blurX = null;
  56829. }
  56830. }
  56831. };
  56832. /**
  56833. * Clone the mirror texture.
  56834. * @returns the cloned texture
  56835. */
  56836. MirrorTexture.prototype.clone = function () {
  56837. var scene = this.getScene();
  56838. if (!scene) {
  56839. return this;
  56840. }
  56841. var textureSize = this.getSize();
  56842. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56843. // Base texture
  56844. newTexture.hasAlpha = this.hasAlpha;
  56845. newTexture.level = this.level;
  56846. // Mirror Texture
  56847. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56848. if (this.renderList) {
  56849. newTexture.renderList = this.renderList.slice(0);
  56850. }
  56851. return newTexture;
  56852. };
  56853. /**
  56854. * Serialize the texture to a JSON representation you could use in Parse later on
  56855. * @returns the serialized JSON representation
  56856. */
  56857. MirrorTexture.prototype.serialize = function () {
  56858. if (!this.name) {
  56859. return null;
  56860. }
  56861. var serializationObject = _super.prototype.serialize.call(this);
  56862. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56863. return serializationObject;
  56864. };
  56865. /**
  56866. * Dispose the texture and release its associated resources.
  56867. */
  56868. MirrorTexture.prototype.dispose = function () {
  56869. _super.prototype.dispose.call(this);
  56870. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56871. };
  56872. return MirrorTexture;
  56873. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56874. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56875. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56876. };
  56877. /***/ }),
  56878. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56879. /*!*************************************************!*\
  56880. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56881. \*************************************************/
  56882. /*! exports provided: MultiRenderTarget */
  56883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56884. "use strict";
  56885. __webpack_require__.r(__webpack_exports__);
  56886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  56887. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56888. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56889. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56890. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56891. /**
  56892. * A multi render target, like a render target provides the ability to render to a texture.
  56893. * Unlike the render target, it can render to several draw buffers in one draw.
  56894. * This is specially interesting in deferred rendering or for any effects requiring more than
  56895. * just one color from a single pass.
  56896. */
  56897. var MultiRenderTarget = /** @class */ (function (_super) {
  56898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  56899. /**
  56900. * Instantiate a new multi render target texture.
  56901. * A multi render target, like a render target provides the ability to render to a texture.
  56902. * Unlike the render target, it can render to several draw buffers in one draw.
  56903. * This is specially interesting in deferred rendering or for any effects requiring more than
  56904. * just one color from a single pass.
  56905. * @param name Define the name of the texture
  56906. * @param size Define the size of the buffers to render to
  56907. * @param count Define the number of target we are rendering into
  56908. * @param scene Define the scene the texture belongs to
  56909. * @param options Define the options used to create the multi render target
  56910. */
  56911. function MultiRenderTarget(name, size, count, scene, options) {
  56912. var _this = this;
  56913. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  56914. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  56915. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  56916. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  56917. _this._engine = scene.getEngine();
  56918. if (!_this.isSupported) {
  56919. _this.dispose();
  56920. return;
  56921. }
  56922. var types = [];
  56923. var samplingModes = [];
  56924. for (var i = 0; i < count; i++) {
  56925. if (options && options.types && options.types[i] !== undefined) {
  56926. types.push(options.types[i]);
  56927. }
  56928. else {
  56929. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  56930. }
  56931. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  56932. samplingModes.push(options.samplingModes[i]);
  56933. }
  56934. else {
  56935. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  56936. }
  56937. }
  56938. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  56939. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  56940. _this._size = size;
  56941. _this._multiRenderTargetOptions = {
  56942. samplingModes: samplingModes,
  56943. generateMipMaps: generateMipMaps,
  56944. generateDepthBuffer: generateDepthBuffer,
  56945. generateStencilBuffer: generateStencilBuffer,
  56946. generateDepthTexture: generateDepthTexture,
  56947. types: types,
  56948. textureCount: count
  56949. };
  56950. _this._createInternalTextures();
  56951. _this._createTextures();
  56952. return _this;
  56953. }
  56954. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  56955. /**
  56956. * Get if draw buffers are currently supported by the used hardware and browser.
  56957. */
  56958. get: function () {
  56959. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  56960. },
  56961. enumerable: true,
  56962. configurable: true
  56963. });
  56964. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  56965. /**
  56966. * Get the list of textures generated by the multi render target.
  56967. */
  56968. get: function () {
  56969. return this._textures;
  56970. },
  56971. enumerable: true,
  56972. configurable: true
  56973. });
  56974. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  56975. /**
  56976. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  56977. */
  56978. get: function () {
  56979. return this._textures[this._textures.length - 1];
  56980. },
  56981. enumerable: true,
  56982. configurable: true
  56983. });
  56984. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  56985. /**
  56986. * Set the wrapping mode on U of all the textures we are rendering to.
  56987. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56988. */
  56989. set: function (wrap) {
  56990. if (this._textures) {
  56991. for (var i = 0; i < this._textures.length; i++) {
  56992. this._textures[i].wrapU = wrap;
  56993. }
  56994. }
  56995. },
  56996. enumerable: true,
  56997. configurable: true
  56998. });
  56999. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  57000. /**
  57001. * Set the wrapping mode on V of all the textures we are rendering to.
  57002. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57003. */
  57004. set: function (wrap) {
  57005. if (this._textures) {
  57006. for (var i = 0; i < this._textures.length; i++) {
  57007. this._textures[i].wrapV = wrap;
  57008. }
  57009. }
  57010. },
  57011. enumerable: true,
  57012. configurable: true
  57013. });
  57014. /** @hidden */
  57015. MultiRenderTarget.prototype._rebuild = function () {
  57016. this.releaseInternalTextures();
  57017. this._createInternalTextures();
  57018. for (var i = 0; i < this._internalTextures.length; i++) {
  57019. var texture = this._textures[i];
  57020. texture._texture = this._internalTextures[i];
  57021. }
  57022. // Keeps references to frame buffer and stencil/depth buffer
  57023. this._texture = this._internalTextures[0];
  57024. };
  57025. MultiRenderTarget.prototype._createInternalTextures = function () {
  57026. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  57027. };
  57028. MultiRenderTarget.prototype._createTextures = function () {
  57029. this._textures = [];
  57030. for (var i = 0; i < this._internalTextures.length; i++) {
  57031. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  57032. texture._texture = this._internalTextures[i];
  57033. this._textures.push(texture);
  57034. }
  57035. // Keeps references to frame buffer and stencil/depth buffer
  57036. this._texture = this._internalTextures[0];
  57037. };
  57038. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  57039. /**
  57040. * Define the number of samples used if MSAA is enabled.
  57041. */
  57042. get: function () {
  57043. return this._samples;
  57044. },
  57045. set: function (value) {
  57046. if (this._samples === value) {
  57047. return;
  57048. }
  57049. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  57050. },
  57051. enumerable: true,
  57052. configurable: true
  57053. });
  57054. /**
  57055. * Resize all the textures in the multi render target.
  57056. * Be carrefull as it will recreate all the data in the new texture.
  57057. * @param size Define the new size
  57058. */
  57059. MultiRenderTarget.prototype.resize = function (size) {
  57060. this.releaseInternalTextures();
  57061. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  57062. this._createInternalTextures();
  57063. };
  57064. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57065. var _this = this;
  57066. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  57067. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57068. });
  57069. };
  57070. /**
  57071. * Dispose the render targets and their associated resources
  57072. */
  57073. MultiRenderTarget.prototype.dispose = function () {
  57074. this.releaseInternalTextures();
  57075. _super.prototype.dispose.call(this);
  57076. };
  57077. /**
  57078. * Release all the underlying texture used as draw buffers.
  57079. */
  57080. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  57081. if (!this._internalTextures) {
  57082. return;
  57083. }
  57084. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  57085. if (this._internalTextures[i] !== undefined) {
  57086. this._internalTextures[i].dispose();
  57087. this._internalTextures.splice(i, 1);
  57088. }
  57089. }
  57090. };
  57091. return MultiRenderTarget;
  57092. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57093. /***/ }),
  57094. /***/ "./Materials/Textures/rawCubeTexture.ts":
  57095. /*!**********************************************!*\
  57096. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  57097. \**********************************************/
  57098. /*! exports provided: RawCubeTexture */
  57099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57100. "use strict";
  57101. __webpack_require__.r(__webpack_exports__);
  57102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  57103. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57104. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57105. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57106. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57107. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57108. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57109. /**
  57110. * Raw cube texture where the raw buffers are passed in
  57111. */
  57112. var RawCubeTexture = /** @class */ (function (_super) {
  57113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  57114. /**
  57115. * Creates a cube texture where the raw buffers are passed in.
  57116. * @param scene defines the scene the texture is attached to
  57117. * @param data defines the array of data to use to create each face
  57118. * @param size defines the size of the textures
  57119. * @param format defines the format of the data
  57120. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57121. * @param generateMipMaps defines if the engine should generate the mip levels
  57122. * @param invertY defines if data must be stored with Y axis inverted
  57123. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57124. * @param compression defines the compression used (null by default)
  57125. */
  57126. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  57127. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  57128. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57129. if (generateMipMaps === void 0) { generateMipMaps = false; }
  57130. if (invertY === void 0) { invertY = false; }
  57131. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57132. if (compression === void 0) { compression = null; }
  57133. var _this = _super.call(this, "", scene) || this;
  57134. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  57135. return _this;
  57136. }
  57137. /**
  57138. * Updates the raw cube texture.
  57139. * @param data defines the data to store
  57140. * @param format defines the data format
  57141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57142. * @param invertY defines if data must be stored with Y axis inverted
  57143. * @param compression defines the compression used (null by default)
  57144. * @param level defines which level of the texture to update
  57145. */
  57146. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  57147. if (compression === void 0) { compression = null; }
  57148. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  57149. };
  57150. /**
  57151. * Updates a raw cube texture with RGBD encoded data.
  57152. * @param data defines the array of data [mipmap][face] to use to create each face
  57153. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57154. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57155. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57156. * @returns a promsie that resolves when the operation is complete
  57157. */
  57158. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  57159. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  57160. if (lodScale === void 0) { lodScale = 0.8; }
  57161. if (lodOffset === void 0) { lodOffset = 0; }
  57162. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  57163. };
  57164. /**
  57165. * Clones the raw cube texture.
  57166. * @return a new cube texture
  57167. */
  57168. RawCubeTexture.prototype.clone = function () {
  57169. var _this = this;
  57170. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57171. var scene = _this.getScene();
  57172. var internalTexture = _this._texture;
  57173. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57174. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57175. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57176. }
  57177. return texture;
  57178. }, this);
  57179. };
  57180. /** @hidden */
  57181. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57182. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57183. internalTexture._bufferViewArrayArray = data;
  57184. internalTexture._lodGenerationScale = lodScale;
  57185. internalTexture._lodGenerationOffset = lodOffset;
  57186. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57187. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57188. internalTexture.isReady = true;
  57189. });
  57190. };
  57191. return RawCubeTexture;
  57192. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57193. /***/ }),
  57194. /***/ "./Materials/Textures/rawTexture.ts":
  57195. /*!******************************************!*\
  57196. !*** ./Materials/Textures/rawTexture.ts ***!
  57197. \******************************************/
  57198. /*! exports provided: RawTexture */
  57199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57200. "use strict";
  57201. __webpack_require__.r(__webpack_exports__);
  57202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57203. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57204. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57205. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57206. /**
  57207. * Raw texture can help creating a texture directly from an array of data.
  57208. * This can be super useful if you either get the data from an uncompressed source or
  57209. * if you wish to create your texture pixel by pixel.
  57210. */
  57211. var RawTexture = /** @class */ (function (_super) {
  57212. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57213. /**
  57214. * Instantiates a new RawTexture.
  57215. * Raw texture can help creating a texture directly from an array of data.
  57216. * This can be super useful if you either get the data from an uncompressed source or
  57217. * if you wish to create your texture pixel by pixel.
  57218. * @param data define the array of data to use to create the texture
  57219. * @param width define the width of the texture
  57220. * @param height define the height of the texture
  57221. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57222. * @param scene define the scene the texture belongs to
  57223. * @param generateMipMaps define whether mip maps should be generated or not
  57224. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57225. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57226. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57227. */
  57228. function RawTexture(data, width, height,
  57229. /**
  57230. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57231. */
  57232. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57233. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57234. if (invertY === void 0) { invertY = false; }
  57235. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57236. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57237. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57238. _this.format = format;
  57239. _this._engine = scene.getEngine();
  57240. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57241. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57242. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57243. return _this;
  57244. }
  57245. /**
  57246. * Updates the texture underlying data.
  57247. * @param data Define the new data of the texture
  57248. */
  57249. RawTexture.prototype.update = function (data) {
  57250. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57251. };
  57252. /**
  57253. * Creates a luminance texture from some data.
  57254. * @param data Define the texture data
  57255. * @param width Define the width of the texture
  57256. * @param height Define the height of the texture
  57257. * @param scene Define the scene the texture belongs to
  57258. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57259. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57260. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57261. * @returns the luminance texture
  57262. */
  57263. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57264. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57265. if (invertY === void 0) { invertY = false; }
  57266. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57267. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57268. };
  57269. /**
  57270. * Creates a luminance alpha texture from some data.
  57271. * @param data Define the texture data
  57272. * @param width Define the width of the texture
  57273. * @param height Define the height of the texture
  57274. * @param scene Define the scene the texture belongs to
  57275. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57276. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57277. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57278. * @returns the luminance alpha texture
  57279. */
  57280. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57281. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57282. if (invertY === void 0) { invertY = false; }
  57283. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57284. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57285. };
  57286. /**
  57287. * Creates an alpha texture from some data.
  57288. * @param data Define the texture data
  57289. * @param width Define the width of the texture
  57290. * @param height Define the height of the texture
  57291. * @param scene Define the scene the texture belongs to
  57292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57295. * @returns the alpha texture
  57296. */
  57297. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57298. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57299. if (invertY === void 0) { invertY = false; }
  57300. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57301. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57302. };
  57303. /**
  57304. * Creates a RGB texture from some data.
  57305. * @param data Define the texture data
  57306. * @param width Define the width of the texture
  57307. * @param height Define the height of the texture
  57308. * @param scene Define the scene the texture belongs to
  57309. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57312. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57313. * @returns the RGB alpha texture
  57314. */
  57315. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57316. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57317. if (invertY === void 0) { invertY = false; }
  57318. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57319. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57320. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57321. };
  57322. /**
  57323. * Creates a RGBA texture from some data.
  57324. * @param data Define the texture data
  57325. * @param width Define the width of the texture
  57326. * @param height Define the height of the texture
  57327. * @param scene Define the scene the texture belongs to
  57328. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57329. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57330. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57331. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57332. * @returns the RGBA texture
  57333. */
  57334. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57335. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57336. if (invertY === void 0) { invertY = false; }
  57337. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57338. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57339. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57340. };
  57341. /**
  57342. * Creates a R texture from some data.
  57343. * @param data Define the texture data
  57344. * @param width Define the width of the texture
  57345. * @param height Define the height of the texture
  57346. * @param scene Define the scene the texture belongs to
  57347. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57351. * @returns the R texture
  57352. */
  57353. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57354. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57355. if (invertY === void 0) { invertY = false; }
  57356. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57357. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57358. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57359. };
  57360. return RawTexture;
  57361. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57362. /***/ }),
  57363. /***/ "./Materials/Textures/rawTexture3D.ts":
  57364. /*!********************************************!*\
  57365. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57366. \********************************************/
  57367. /*! exports provided: RawTexture3D */
  57368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57369. "use strict";
  57370. __webpack_require__.r(__webpack_exports__);
  57371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57372. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57373. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57374. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57375. /**
  57376. * Class used to store 3D textures containing user data
  57377. */
  57378. var RawTexture3D = /** @class */ (function (_super) {
  57379. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57380. /**
  57381. * Create a new RawTexture3D
  57382. * @param data defines the data of the texture
  57383. * @param width defines the width of the texture
  57384. * @param height defines the height of the texture
  57385. * @param depth defines the depth of the texture
  57386. * @param format defines the texture format to use
  57387. * @param scene defines the hosting scene
  57388. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57389. * @param invertY defines if texture must be stored with Y axis inverted
  57390. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57391. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57392. */
  57393. function RawTexture3D(data, width, height, depth,
  57394. /** Gets or sets the texture format to use */
  57395. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57396. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57397. if (invertY === void 0) { invertY = false; }
  57398. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57399. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57400. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57401. _this.format = format;
  57402. _this._engine = scene.getEngine();
  57403. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57404. _this.is3D = true;
  57405. return _this;
  57406. }
  57407. /**
  57408. * Update the texture with new data
  57409. * @param data defines the data to store in the texture
  57410. */
  57411. RawTexture3D.prototype.update = function (data) {
  57412. if (!this._texture) {
  57413. return;
  57414. }
  57415. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57416. };
  57417. return RawTexture3D;
  57418. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57419. /***/ }),
  57420. /***/ "./Materials/Textures/refractionTexture.ts":
  57421. /*!*************************************************!*\
  57422. !*** ./Materials/Textures/refractionTexture.ts ***!
  57423. \*************************************************/
  57424. /*! exports provided: RefractionTexture */
  57425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57426. "use strict";
  57427. __webpack_require__.r(__webpack_exports__);
  57428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57429. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57431. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57432. /**
  57433. * Creates a refraction texture used by refraction channel of the standard material.
  57434. * It is like a mirror but to see through a material.
  57435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57436. */
  57437. var RefractionTexture = /** @class */ (function (_super) {
  57438. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57439. /**
  57440. * Creates a refraction texture used by refraction channel of the standard material.
  57441. * It is like a mirror but to see through a material.
  57442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57443. * @param name Define the texture name
  57444. * @param size Define the size of the underlying texture
  57445. * @param scene Define the scene the refraction belongs to
  57446. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57447. */
  57448. function RefractionTexture(name, size, scene, generateMipMaps) {
  57449. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57450. /**
  57451. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57452. * 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.
  57453. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57454. */
  57455. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57456. /**
  57457. * Define how deep under the surface we should see.
  57458. */
  57459. _this.depth = 2.0;
  57460. _this.onBeforeRenderObservable.add(function () {
  57461. scene.clipPlane = _this.refractionPlane;
  57462. });
  57463. _this.onAfterRenderObservable.add(function () {
  57464. delete scene.clipPlane;
  57465. });
  57466. return _this;
  57467. }
  57468. /**
  57469. * Clone the refraction texture.
  57470. * @returns the cloned texture
  57471. */
  57472. RefractionTexture.prototype.clone = function () {
  57473. var scene = this.getScene();
  57474. if (!scene) {
  57475. return this;
  57476. }
  57477. var textureSize = this.getSize();
  57478. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  57479. // Base texture
  57480. newTexture.hasAlpha = this.hasAlpha;
  57481. newTexture.level = this.level;
  57482. // Refraction Texture
  57483. newTexture.refractionPlane = this.refractionPlane.clone();
  57484. if (this.renderList) {
  57485. newTexture.renderList = this.renderList.slice(0);
  57486. }
  57487. newTexture.depth = this.depth;
  57488. return newTexture;
  57489. };
  57490. /**
  57491. * Serialize the texture to a JSON representation you could use in Parse later on
  57492. * @returns the serialized JSON representation
  57493. */
  57494. RefractionTexture.prototype.serialize = function () {
  57495. if (!this.name) {
  57496. return null;
  57497. }
  57498. var serializationObject = _super.prototype.serialize.call(this);
  57499. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  57500. serializationObject.depth = this.depth;
  57501. return serializationObject;
  57502. };
  57503. return RefractionTexture;
  57504. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57505. /***/ }),
  57506. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  57507. /*!***********************************************************!*\
  57508. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  57509. \***********************************************************/
  57510. /*! exports provided: RenderTargetCreationOptions */
  57511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57512. "use strict";
  57513. __webpack_require__.r(__webpack_exports__);
  57514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  57515. /**
  57516. * Define options used to create a render target texture
  57517. */
  57518. var RenderTargetCreationOptions = /** @class */ (function () {
  57519. function RenderTargetCreationOptions() {
  57520. }
  57521. return RenderTargetCreationOptions;
  57522. }());
  57523. /***/ }),
  57524. /***/ "./Materials/Textures/renderTargetTexture.ts":
  57525. /*!***************************************************!*\
  57526. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  57527. \***************************************************/
  57528. /*! exports provided: RenderTargetTexture */
  57529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57530. "use strict";
  57531. __webpack_require__.r(__webpack_exports__);
  57532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  57533. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57534. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57535. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57536. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57537. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57538. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  57539. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  57540. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57541. /**
  57542. * This Helps creating a texture that will be created from a camera in your scene.
  57543. * It is basically a dynamic texture that could be used to create special effects for instance.
  57544. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  57545. */
  57546. var RenderTargetTexture = /** @class */ (function (_super) {
  57547. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  57548. /**
  57549. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  57550. * or used a shadow, depth texture...
  57551. * @param name The friendly name of the texture
  57552. * @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)
  57553. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  57554. * @param generateMipMaps True if mip maps need to be generated after render.
  57555. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  57556. * @param type The type of the buffer in the RTT (int, half float, float...)
  57557. * @param isCube True if a cube texture needs to be created
  57558. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  57559. * @param generateDepthBuffer True to generate a depth buffer
  57560. * @param generateStencilBuffer True to generate a stencil buffer
  57561. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  57562. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  57563. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57564. */
  57565. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  57566. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  57567. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57568. if (isCube === void 0) { isCube = false; }
  57569. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57570. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57571. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  57572. if (isMulti === void 0) { isMulti = false; }
  57573. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  57574. if (delayAllocation === void 0) { delayAllocation = false; }
  57575. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57576. _this.isCube = isCube;
  57577. /**
  57578. * Define if particles should be rendered in your texture.
  57579. */
  57580. _this.renderParticles = true;
  57581. /**
  57582. * Define if sprites should be rendered in your texture.
  57583. */
  57584. _this.renderSprites = false;
  57585. /**
  57586. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57587. */
  57588. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57589. /**
  57590. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57591. */
  57592. _this.ignoreCameraViewport = false;
  57593. /**
  57594. * An event triggered when the texture is unbind.
  57595. */
  57596. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57597. /**
  57598. * An event triggered when the texture is unbind.
  57599. */
  57600. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57601. /**
  57602. * An event triggered before rendering the texture
  57603. */
  57604. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57605. /**
  57606. * An event triggered after rendering the texture
  57607. */
  57608. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57609. /**
  57610. * An event triggered after the texture clear
  57611. */
  57612. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57613. _this._currentRefreshId = -1;
  57614. _this._refreshRate = 1;
  57615. _this._samples = 1;
  57616. /**
  57617. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57618. * It must define where the camera used to render the texture is set
  57619. */
  57620. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57621. scene = _this.getScene();
  57622. if (!scene) {
  57623. return _this;
  57624. }
  57625. _this.renderList = new Array();
  57626. _this._engine = scene.getEngine();
  57627. _this.name = name;
  57628. _this.isRenderTarget = true;
  57629. _this._initialSizeParameter = size;
  57630. _this._processSizeParameter(size);
  57631. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57632. });
  57633. _this._generateMipMaps = generateMipMaps ? true : false;
  57634. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57635. // Rendering groups
  57636. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57637. _this._renderingManager._useSceneAutoClearSetup = true;
  57638. if (isMulti) {
  57639. return _this;
  57640. }
  57641. _this._renderTargetOptions = {
  57642. generateMipMaps: generateMipMaps,
  57643. type: type,
  57644. format: format,
  57645. samplingMode: samplingMode,
  57646. generateDepthBuffer: generateDepthBuffer,
  57647. generateStencilBuffer: generateStencilBuffer
  57648. };
  57649. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57650. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57651. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57652. }
  57653. if (!delayAllocation) {
  57654. if (isCube) {
  57655. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57656. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57657. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57658. }
  57659. else {
  57660. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57661. }
  57662. }
  57663. return _this;
  57664. }
  57665. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57666. /**
  57667. * Use this list to define the list of mesh you want to render.
  57668. */
  57669. get: function () {
  57670. return this._renderList;
  57671. },
  57672. set: function (value) {
  57673. this._renderList = value;
  57674. if (this._renderList) {
  57675. this._hookArray(this._renderList);
  57676. }
  57677. },
  57678. enumerable: true,
  57679. configurable: true
  57680. });
  57681. RenderTargetTexture.prototype._hookArray = function (array) {
  57682. var _this = this;
  57683. var oldPush = array.push;
  57684. array.push = function () {
  57685. var items = [];
  57686. for (var _i = 0; _i < arguments.length; _i++) {
  57687. items[_i] = arguments[_i];
  57688. }
  57689. var wasEmpty = array.length === 0;
  57690. var result = oldPush.apply(array, items);
  57691. if (wasEmpty) {
  57692. _this.getScene().meshes.forEach(function (mesh) {
  57693. mesh._markSubMeshesAsLightDirty();
  57694. });
  57695. }
  57696. return result;
  57697. };
  57698. var oldSplice = array.splice;
  57699. array.splice = function (index, deleteCount) {
  57700. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57701. if (array.length === 0) {
  57702. _this.getScene().meshes.forEach(function (mesh) {
  57703. mesh._markSubMeshesAsLightDirty();
  57704. });
  57705. }
  57706. return deleted;
  57707. };
  57708. };
  57709. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57710. /**
  57711. * Set a after unbind callback in the texture.
  57712. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57713. */
  57714. set: function (callback) {
  57715. if (this._onAfterUnbindObserver) {
  57716. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57717. }
  57718. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57719. },
  57720. enumerable: true,
  57721. configurable: true
  57722. });
  57723. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57724. /**
  57725. * Set a before render callback in the texture.
  57726. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57727. */
  57728. set: function (callback) {
  57729. if (this._onBeforeRenderObserver) {
  57730. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57731. }
  57732. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57733. },
  57734. enumerable: true,
  57735. configurable: true
  57736. });
  57737. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57738. /**
  57739. * Set a after render callback in the texture.
  57740. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57741. */
  57742. set: function (callback) {
  57743. if (this._onAfterRenderObserver) {
  57744. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57745. }
  57746. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57747. },
  57748. enumerable: true,
  57749. configurable: true
  57750. });
  57751. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57752. /**
  57753. * Set a clear callback in the texture.
  57754. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57755. */
  57756. set: function (callback) {
  57757. if (this._onClearObserver) {
  57758. this.onClearObservable.remove(this._onClearObserver);
  57759. }
  57760. this._onClearObserver = this.onClearObservable.add(callback);
  57761. },
  57762. enumerable: true,
  57763. configurable: true
  57764. });
  57765. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57766. /**
  57767. * Gets render target creation options that were used.
  57768. */
  57769. get: function () {
  57770. return this._renderTargetOptions;
  57771. },
  57772. enumerable: true,
  57773. configurable: true
  57774. });
  57775. RenderTargetTexture.prototype._onRatioRescale = function () {
  57776. if (this._sizeRatio) {
  57777. this.resize(this._initialSizeParameter);
  57778. }
  57779. };
  57780. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57781. get: function () {
  57782. return this._boundingBoxSize;
  57783. },
  57784. /**
  57785. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57786. * When defined, the cubemap will switch to local mode
  57787. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57788. * @example https://www.babylonjs-playground.com/#RNASML
  57789. */
  57790. set: function (value) {
  57791. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57792. return;
  57793. }
  57794. this._boundingBoxSize = value;
  57795. var scene = this.getScene();
  57796. if (scene) {
  57797. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57798. }
  57799. },
  57800. enumerable: true,
  57801. configurable: true
  57802. });
  57803. /**
  57804. * Creates a depth stencil texture.
  57805. * This is only available in WebGL 2 or with the depth texture extension available.
  57806. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57807. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57808. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57809. */
  57810. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57811. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57812. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57813. if (generateStencil === void 0) { generateStencil = false; }
  57814. if (!this.getScene()) {
  57815. return;
  57816. }
  57817. var engine = this.getScene().getEngine();
  57818. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57819. bilinearFiltering: bilinearFiltering,
  57820. comparisonFunction: comparisonFunction,
  57821. generateStencil: generateStencil,
  57822. isCube: this.isCube
  57823. });
  57824. engine.setFrameBufferDepthStencilTexture(this);
  57825. };
  57826. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57827. if (size.ratio) {
  57828. this._sizeRatio = size.ratio;
  57829. this._size = {
  57830. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57831. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57832. };
  57833. }
  57834. else {
  57835. this._size = size;
  57836. }
  57837. };
  57838. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57839. /**
  57840. * Define the number of samples to use in case of MSAA.
  57841. * It defaults to one meaning no MSAA has been enabled.
  57842. */
  57843. get: function () {
  57844. return this._samples;
  57845. },
  57846. set: function (value) {
  57847. if (this._samples === value) {
  57848. return;
  57849. }
  57850. var scene = this.getScene();
  57851. if (!scene) {
  57852. return;
  57853. }
  57854. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57855. },
  57856. enumerable: true,
  57857. configurable: true
  57858. });
  57859. /**
  57860. * Resets the refresh counter of the texture and start bak from scratch.
  57861. * Could be useful to regenerate the texture if it is setup to render only once.
  57862. */
  57863. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57864. this._currentRefreshId = -1;
  57865. };
  57866. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57867. /**
  57868. * Define the refresh rate of the texture or the rendering frequency.
  57869. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57870. */
  57871. get: function () {
  57872. return this._refreshRate;
  57873. },
  57874. set: function (value) {
  57875. this._refreshRate = value;
  57876. this.resetRefreshCounter();
  57877. },
  57878. enumerable: true,
  57879. configurable: true
  57880. });
  57881. /**
  57882. * Adds a post process to the render target rendering passes.
  57883. * @param postProcess define the post process to add
  57884. */
  57885. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  57886. if (!this._postProcessManager) {
  57887. var scene = this.getScene();
  57888. if (!scene) {
  57889. return;
  57890. }
  57891. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  57892. this._postProcesses = new Array();
  57893. }
  57894. this._postProcesses.push(postProcess);
  57895. this._postProcesses[0].autoClear = false;
  57896. };
  57897. /**
  57898. * Clear all the post processes attached to the render target
  57899. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  57900. */
  57901. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  57902. if (dispose === void 0) { dispose = false; }
  57903. if (!this._postProcesses) {
  57904. return;
  57905. }
  57906. if (dispose) {
  57907. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  57908. var postProcess = _a[_i];
  57909. postProcess.dispose();
  57910. }
  57911. }
  57912. this._postProcesses = [];
  57913. };
  57914. /**
  57915. * Remove one of the post process from the list of attached post processes to the texture
  57916. * @param postProcess define the post process to remove from the list
  57917. */
  57918. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  57919. if (!this._postProcesses) {
  57920. return;
  57921. }
  57922. var index = this._postProcesses.indexOf(postProcess);
  57923. if (index === -1) {
  57924. return;
  57925. }
  57926. this._postProcesses.splice(index, 1);
  57927. if (this._postProcesses.length > 0) {
  57928. this._postProcesses[0].autoClear = false;
  57929. }
  57930. };
  57931. /** @hidden */
  57932. RenderTargetTexture.prototype._shouldRender = function () {
  57933. if (this._currentRefreshId === -1) { // At least render once
  57934. this._currentRefreshId = 1;
  57935. return true;
  57936. }
  57937. if (this.refreshRate === this._currentRefreshId) {
  57938. this._currentRefreshId = 1;
  57939. return true;
  57940. }
  57941. this._currentRefreshId++;
  57942. return false;
  57943. };
  57944. /**
  57945. * Gets the actual render size of the texture.
  57946. * @returns the width of the render size
  57947. */
  57948. RenderTargetTexture.prototype.getRenderSize = function () {
  57949. return this.getRenderWidth();
  57950. };
  57951. /**
  57952. * Gets the actual render width of the texture.
  57953. * @returns the width of the render size
  57954. */
  57955. RenderTargetTexture.prototype.getRenderWidth = function () {
  57956. if (this._size.width) {
  57957. return this._size.width;
  57958. }
  57959. return this._size;
  57960. };
  57961. /**
  57962. * Gets the actual render height of the texture.
  57963. * @returns the height of the render size
  57964. */
  57965. RenderTargetTexture.prototype.getRenderHeight = function () {
  57966. if (this._size.width) {
  57967. return this._size.height;
  57968. }
  57969. return this._size;
  57970. };
  57971. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  57972. /**
  57973. * Get if the texture can be rescaled or not.
  57974. */
  57975. get: function () {
  57976. return true;
  57977. },
  57978. enumerable: true,
  57979. configurable: true
  57980. });
  57981. /**
  57982. * Resize the texture using a ratio.
  57983. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  57984. */
  57985. RenderTargetTexture.prototype.scale = function (ratio) {
  57986. var newSize = this.getRenderSize() * ratio;
  57987. this.resize(newSize);
  57988. };
  57989. /**
  57990. * Get the texture reflection matrix used to rotate/transform the reflection.
  57991. * @returns the reflection matrix
  57992. */
  57993. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  57994. if (this.isCube) {
  57995. return this._textureMatrix;
  57996. }
  57997. return _super.prototype.getReflectionTextureMatrix.call(this);
  57998. };
  57999. /**
  58000. * Resize the texture to a new desired size.
  58001. * Be carrefull as it will recreate all the data in the new texture.
  58002. * @param size Define the new size. It can be:
  58003. * - a number for squared texture,
  58004. * - an object containing { width: number, height: number }
  58005. * - or an object containing a ratio { ratio: number }
  58006. */
  58007. RenderTargetTexture.prototype.resize = function (size) {
  58008. this.releaseInternalTexture();
  58009. var scene = this.getScene();
  58010. if (!scene) {
  58011. return;
  58012. }
  58013. this._processSizeParameter(size);
  58014. if (this.isCube) {
  58015. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  58016. }
  58017. else {
  58018. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  58019. }
  58020. };
  58021. /**
  58022. * Renders all the objects from the render list into the texture.
  58023. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  58024. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  58025. */
  58026. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  58027. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  58028. if (dumpForDebug === void 0) { dumpForDebug = false; }
  58029. var scene = this.getScene();
  58030. if (!scene) {
  58031. return;
  58032. }
  58033. var engine = scene.getEngine();
  58034. if (this.useCameraPostProcesses !== undefined) {
  58035. useCameraPostProcess = this.useCameraPostProcesses;
  58036. }
  58037. if (this._waitingRenderList) {
  58038. this.renderList = [];
  58039. for (var index = 0; index < this._waitingRenderList.length; index++) {
  58040. var id = this._waitingRenderList[index];
  58041. var mesh_1 = scene.getMeshByID(id);
  58042. if (mesh_1) {
  58043. this.renderList.push(mesh_1);
  58044. }
  58045. }
  58046. delete this._waitingRenderList;
  58047. }
  58048. // Is predicate defined?
  58049. if (this.renderListPredicate) {
  58050. if (this.renderList) {
  58051. this.renderList.length = 0; // Clear previous renderList
  58052. }
  58053. else {
  58054. this.renderList = [];
  58055. }
  58056. var scene = this.getScene();
  58057. if (!scene) {
  58058. return;
  58059. }
  58060. var sceneMeshes = scene.meshes;
  58061. for (var index = 0; index < sceneMeshes.length; index++) {
  58062. var mesh = sceneMeshes[index];
  58063. if (this.renderListPredicate(mesh)) {
  58064. this.renderList.push(mesh);
  58065. }
  58066. }
  58067. }
  58068. this.onBeforeBindObservable.notifyObservers(this);
  58069. // Set custom projection.
  58070. // Needs to be before binding to prevent changing the aspect ratio.
  58071. var camera;
  58072. if (this.activeCamera) {
  58073. camera = this.activeCamera;
  58074. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58075. if (this.activeCamera !== scene.activeCamera) {
  58076. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  58077. }
  58078. }
  58079. else {
  58080. camera = scene.activeCamera;
  58081. if (camera) {
  58082. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58083. }
  58084. }
  58085. // Prepare renderingManager
  58086. this._renderingManager.reset();
  58087. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  58088. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  58089. var sceneRenderId = scene.getRenderId();
  58090. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  58091. var mesh = currentRenderList[meshIndex];
  58092. if (mesh) {
  58093. if (!mesh.isReady(this.refreshRate === 0)) {
  58094. this.resetRefreshCounter();
  58095. continue;
  58096. }
  58097. mesh._preActivateForIntermediateRendering(sceneRenderId);
  58098. var isMasked = void 0;
  58099. if (!this.renderList && camera) {
  58100. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  58101. }
  58102. else {
  58103. isMasked = false;
  58104. }
  58105. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  58106. mesh._activate(sceneRenderId);
  58107. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  58108. var subMesh = mesh.subMeshes[subIndex];
  58109. scene._activeIndices.addCount(subMesh.indexCount, false);
  58110. this._renderingManager.dispatch(subMesh, mesh);
  58111. }
  58112. }
  58113. }
  58114. }
  58115. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  58116. var particleSystem = scene.particleSystems[particleIndex];
  58117. var emitter = particleSystem.emitter;
  58118. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  58119. continue;
  58120. }
  58121. if (currentRenderList.indexOf(emitter) >= 0) {
  58122. this._renderingManager.dispatchParticles(particleSystem);
  58123. }
  58124. }
  58125. if (this.isCube) {
  58126. for (var face = 0; face < 6; face++) {
  58127. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  58128. scene.incrementRenderId();
  58129. scene.resetCachedMaterial();
  58130. }
  58131. }
  58132. else {
  58133. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  58134. }
  58135. this.onAfterUnbindObservable.notifyObservers(this);
  58136. if (scene.activeCamera) {
  58137. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  58138. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  58139. }
  58140. engine.setViewport(scene.activeCamera.viewport);
  58141. }
  58142. scene.resetCachedMaterial();
  58143. };
  58144. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  58145. var minimum = 128;
  58146. var x = renderDimension * scale;
  58147. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  58148. // Ensure we don't exceed the render dimension (while staying POT)
  58149. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  58150. };
  58151. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58152. var _this = this;
  58153. if (!this._texture) {
  58154. return;
  58155. }
  58156. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  58157. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58158. });
  58159. };
  58160. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  58161. var scene = this.getScene();
  58162. if (!scene) {
  58163. return;
  58164. }
  58165. var engine = scene.getEngine();
  58166. if (!this._texture) {
  58167. return;
  58168. }
  58169. // Bind
  58170. if (this._postProcessManager) {
  58171. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  58172. }
  58173. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58174. if (this._texture) {
  58175. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58176. }
  58177. }
  58178. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58179. // Clear
  58180. if (this.onClearObservable.hasObservers()) {
  58181. this.onClearObservable.notifyObservers(engine);
  58182. }
  58183. else {
  58184. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58185. }
  58186. if (!this._doNotChangeAspectRatio) {
  58187. scene.updateTransformMatrix(true);
  58188. }
  58189. // Before Camera Draw
  58190. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58191. var step = _a[_i];
  58192. step.action(this);
  58193. }
  58194. // Render
  58195. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58196. // After Camera Draw
  58197. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58198. var step = _c[_b];
  58199. step.action(this);
  58200. }
  58201. if (this._postProcessManager) {
  58202. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58203. }
  58204. else if (useCameraPostProcess) {
  58205. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58206. }
  58207. if (!this._doNotChangeAspectRatio) {
  58208. scene.updateTransformMatrix(true);
  58209. }
  58210. // Dump ?
  58211. if (dumpForDebug) {
  58212. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58213. }
  58214. // Unbind
  58215. if (!this.isCube || faceIndex === 5) {
  58216. if (this.isCube) {
  58217. if (faceIndex === 5) {
  58218. engine.generateMipMapsForCubemap(this._texture);
  58219. }
  58220. }
  58221. this.unbindFrameBuffer(engine, faceIndex);
  58222. }
  58223. else {
  58224. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58225. }
  58226. };
  58227. /**
  58228. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58229. * This allowed control for front to back rendering or reversly depending of the special needs.
  58230. *
  58231. * @param renderingGroupId The rendering group id corresponding to its index
  58232. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58233. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58234. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58235. */
  58236. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58237. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58238. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58239. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58240. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58241. };
  58242. /**
  58243. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58244. *
  58245. * @param renderingGroupId The rendering group id corresponding to its index
  58246. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58247. */
  58248. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58249. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58250. this._renderingManager._useSceneAutoClearSetup = false;
  58251. };
  58252. /**
  58253. * Clones the texture.
  58254. * @returns the cloned texture
  58255. */
  58256. RenderTargetTexture.prototype.clone = function () {
  58257. var textureSize = this.getSize();
  58258. 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);
  58259. // Base texture
  58260. newTexture.hasAlpha = this.hasAlpha;
  58261. newTexture.level = this.level;
  58262. // RenderTarget Texture
  58263. newTexture.coordinatesMode = this.coordinatesMode;
  58264. if (this.renderList) {
  58265. newTexture.renderList = this.renderList.slice(0);
  58266. }
  58267. return newTexture;
  58268. };
  58269. /**
  58270. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58271. * @returns The JSON representation of the texture
  58272. */
  58273. RenderTargetTexture.prototype.serialize = function () {
  58274. if (!this.name) {
  58275. return null;
  58276. }
  58277. var serializationObject = _super.prototype.serialize.call(this);
  58278. serializationObject.renderTargetSize = this.getRenderSize();
  58279. serializationObject.renderList = [];
  58280. if (this.renderList) {
  58281. for (var index = 0; index < this.renderList.length; index++) {
  58282. serializationObject.renderList.push(this.renderList[index].id);
  58283. }
  58284. }
  58285. return serializationObject;
  58286. };
  58287. /**
  58288. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58289. */
  58290. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58291. var objBuffer = this.getInternalTexture();
  58292. var scene = this.getScene();
  58293. if (objBuffer && scene) {
  58294. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58295. }
  58296. };
  58297. /**
  58298. * Dispose the texture and release its associated resources.
  58299. */
  58300. RenderTargetTexture.prototype.dispose = function () {
  58301. if (this._postProcessManager) {
  58302. this._postProcessManager.dispose();
  58303. this._postProcessManager = null;
  58304. }
  58305. this.clearPostProcesses(true);
  58306. if (this._resizeObserver) {
  58307. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58308. this._resizeObserver = null;
  58309. }
  58310. this.renderList = null;
  58311. // Remove from custom render targets
  58312. var scene = this.getScene();
  58313. if (!scene) {
  58314. return;
  58315. }
  58316. var index = scene.customRenderTargets.indexOf(this);
  58317. if (index >= 0) {
  58318. scene.customRenderTargets.splice(index, 1);
  58319. }
  58320. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58321. var camera = _a[_i];
  58322. index = camera.customRenderTargets.indexOf(this);
  58323. if (index >= 0) {
  58324. camera.customRenderTargets.splice(index, 1);
  58325. }
  58326. }
  58327. _super.prototype.dispose.call(this);
  58328. };
  58329. /** @hidden */
  58330. RenderTargetTexture.prototype._rebuild = function () {
  58331. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58332. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58333. }
  58334. if (this._postProcessManager) {
  58335. this._postProcessManager._rebuild();
  58336. }
  58337. };
  58338. /**
  58339. * Clear the info related to rendering groups preventing retention point in material dispose.
  58340. */
  58341. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58342. if (this._renderingManager) {
  58343. this._renderingManager.freeRenderingGroups();
  58344. }
  58345. };
  58346. /**
  58347. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58348. */
  58349. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58350. /**
  58351. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58352. */
  58353. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58354. /**
  58355. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58356. * the central point of your effect and can save a lot of performances.
  58357. */
  58358. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58359. return RenderTargetTexture;
  58360. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58361. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58362. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58363. };
  58364. /***/ }),
  58365. /***/ "./Materials/Textures/texture.ts":
  58366. /*!***************************************!*\
  58367. !*** ./Materials/Textures/texture.ts ***!
  58368. \***************************************/
  58369. /*! exports provided: Texture */
  58370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58371. "use strict";
  58372. __webpack_require__.r(__webpack_exports__);
  58373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58374. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58375. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58376. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58377. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58379. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58380. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58381. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58382. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58383. /**
  58384. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58385. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58386. */
  58387. var Texture = /** @class */ (function (_super) {
  58388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58389. /**
  58390. * Instantiates a new texture.
  58391. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58392. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58393. * @param url define the url of the picture to load as a texture
  58394. * @param scene define the scene the texture will belong to
  58395. * @param noMipmap define if the texture will require mip maps or not
  58396. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58397. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58398. * @param onLoad define a callback triggered when the texture has been loaded
  58399. * @param onError define a callback triggered when an error occurred during the loading session
  58400. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58401. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58402. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58403. */
  58404. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58405. if (noMipmap === void 0) { noMipmap = false; }
  58406. if (invertY === void 0) { invertY = true; }
  58407. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58408. if (onLoad === void 0) { onLoad = null; }
  58409. if (onError === void 0) { onError = null; }
  58410. if (buffer === void 0) { buffer = null; }
  58411. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58412. var _this = _super.call(this, scene) || this;
  58413. /**
  58414. * Define an offset on the texture to offset the u coordinates of the UVs
  58415. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58416. */
  58417. _this.uOffset = 0;
  58418. /**
  58419. * Define an offset on the texture to offset the v coordinates of the UVs
  58420. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58421. */
  58422. _this.vOffset = 0;
  58423. /**
  58424. * Define an offset on the texture to scale the u coordinates of the UVs
  58425. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58426. */
  58427. _this.uScale = 1.0;
  58428. /**
  58429. * Define an offset on the texture to scale the v coordinates of the UVs
  58430. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58431. */
  58432. _this.vScale = 1.0;
  58433. /**
  58434. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58435. * @see http://doc.babylonjs.com/how_to/more_materials
  58436. */
  58437. _this.uAng = 0;
  58438. /**
  58439. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58440. * @see http://doc.babylonjs.com/how_to/more_materials
  58441. */
  58442. _this.vAng = 0;
  58443. /**
  58444. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58445. * @see http://doc.babylonjs.com/how_to/more_materials
  58446. */
  58447. _this.wAng = 0;
  58448. /**
  58449. * Defines the center of rotation (U)
  58450. */
  58451. _this.uRotationCenter = 0.5;
  58452. /**
  58453. * Defines the center of rotation (V)
  58454. */
  58455. _this.vRotationCenter = 0.5;
  58456. /**
  58457. * Defines the center of rotation (W)
  58458. */
  58459. _this.wRotationCenter = 0.5;
  58460. /** @hidden */
  58461. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  58462. /**
  58463. * Observable triggered once the texture has been loaded.
  58464. */
  58465. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58466. _this._isBlocking = true;
  58467. _this.name = url || "";
  58468. _this.url = url;
  58469. _this._noMipmap = noMipmap;
  58470. _this._invertY = invertY;
  58471. _this._initialSamplingMode = samplingMode;
  58472. _this._buffer = buffer;
  58473. _this._deleteBuffer = deleteBuffer;
  58474. if (format) {
  58475. _this._format = format;
  58476. }
  58477. scene = _this.getScene();
  58478. if (!scene) {
  58479. return _this;
  58480. }
  58481. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  58482. var load = function () {
  58483. if (_this._texture && _this._texture._invertVScale) {
  58484. _this.vScale = -1;
  58485. }
  58486. if (_this.onLoadObservable.hasObservers()) {
  58487. _this.onLoadObservable.notifyObservers(_this);
  58488. }
  58489. if (onLoad) {
  58490. onLoad();
  58491. }
  58492. if (!_this.isBlocking && scene) {
  58493. scene.resetCachedMaterial();
  58494. }
  58495. };
  58496. if (!_this.url) {
  58497. _this._delayedOnLoad = load;
  58498. _this._delayedOnError = onError;
  58499. return _this;
  58500. }
  58501. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  58502. if (!_this._texture) {
  58503. if (!scene.useDelayedTextureLoading) {
  58504. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  58505. if (deleteBuffer) {
  58506. delete _this._buffer;
  58507. }
  58508. }
  58509. else {
  58510. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58511. _this._delayedOnLoad = load;
  58512. _this._delayedOnError = onError;
  58513. }
  58514. }
  58515. else {
  58516. if (_this._texture.isReady) {
  58517. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  58518. }
  58519. else {
  58520. _this._texture.onLoadedObservable.add(load);
  58521. }
  58522. }
  58523. return _this;
  58524. }
  58525. Object.defineProperty(Texture.prototype, "noMipmap", {
  58526. /**
  58527. * Are mip maps generated for this texture or not.
  58528. */
  58529. get: function () {
  58530. return this._noMipmap;
  58531. },
  58532. enumerable: true,
  58533. configurable: true
  58534. });
  58535. Object.defineProperty(Texture.prototype, "isBlocking", {
  58536. get: function () {
  58537. return this._isBlocking;
  58538. },
  58539. /**
  58540. * Is the texture preventing material to render while loading.
  58541. * If false, a default texture will be used instead of the loading one during the preparation step.
  58542. */
  58543. set: function (value) {
  58544. this._isBlocking = value;
  58545. },
  58546. enumerable: true,
  58547. configurable: true
  58548. });
  58549. Object.defineProperty(Texture.prototype, "samplingMode", {
  58550. /**
  58551. * Get the current sampling mode associated with the texture.
  58552. */
  58553. get: function () {
  58554. if (!this._texture) {
  58555. return this._initialSamplingMode;
  58556. }
  58557. return this._texture.samplingMode;
  58558. },
  58559. enumerable: true,
  58560. configurable: true
  58561. });
  58562. Object.defineProperty(Texture.prototype, "invertY", {
  58563. /**
  58564. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  58565. */
  58566. get: function () {
  58567. return this._invertY;
  58568. },
  58569. enumerable: true,
  58570. configurable: true
  58571. });
  58572. /**
  58573. * Update the url (and optional buffer) of this texture if url was null during construction.
  58574. * @param url the url of the texture
  58575. * @param buffer the buffer of the texture (defaults to null)
  58576. * @param onLoad callback called when the texture is loaded (defaults to null)
  58577. */
  58578. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58579. if (buffer === void 0) { buffer = null; }
  58580. if (this.url) {
  58581. this.releaseInternalTexture();
  58582. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58583. }
  58584. this.url = url;
  58585. this._buffer = buffer;
  58586. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58587. if (onLoad) {
  58588. this._delayedOnLoad = onLoad;
  58589. }
  58590. this.delayLoad();
  58591. };
  58592. /**
  58593. * Finish the loading sequence of a texture flagged as delayed load.
  58594. * @hidden
  58595. */
  58596. Texture.prototype.delayLoad = function () {
  58597. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58598. return;
  58599. }
  58600. var scene = this.getScene();
  58601. if (!scene) {
  58602. return;
  58603. }
  58604. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58605. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58606. if (!this._texture) {
  58607. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58608. if (this._deleteBuffer) {
  58609. delete this._buffer;
  58610. }
  58611. }
  58612. else {
  58613. if (this._delayedOnLoad) {
  58614. if (this._texture.isReady) {
  58615. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58616. }
  58617. else {
  58618. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58619. }
  58620. }
  58621. }
  58622. this._delayedOnLoad = null;
  58623. this._delayedOnError = null;
  58624. };
  58625. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58626. x *= this.uScale;
  58627. y *= this.vScale;
  58628. x -= this.uRotationCenter * this.uScale;
  58629. y -= this.vRotationCenter * this.vScale;
  58630. z -= this.wRotationCenter;
  58631. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58632. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58633. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58634. t.z += this.wRotationCenter;
  58635. };
  58636. /**
  58637. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58638. * @returns the transform matrix of the texture.
  58639. */
  58640. Texture.prototype.getTextureMatrix = function () {
  58641. var _this = this;
  58642. if (this.uOffset === this._cachedUOffset &&
  58643. this.vOffset === this._cachedVOffset &&
  58644. this.uScale === this._cachedUScale &&
  58645. this.vScale === this._cachedVScale &&
  58646. this.uAng === this._cachedUAng &&
  58647. this.vAng === this._cachedVAng &&
  58648. this.wAng === this._cachedWAng) {
  58649. return this._cachedTextureMatrix;
  58650. }
  58651. this._cachedUOffset = this.uOffset;
  58652. this._cachedVOffset = this.vOffset;
  58653. this._cachedUScale = this.uScale;
  58654. this._cachedVScale = this.vScale;
  58655. this._cachedUAng = this.uAng;
  58656. this._cachedVAng = this.vAng;
  58657. this._cachedWAng = this.wAng;
  58658. if (!this._cachedTextureMatrix) {
  58659. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58660. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58661. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58662. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58663. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58664. }
  58665. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58666. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58667. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58668. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58669. this._t1.subtractInPlace(this._t0);
  58670. this._t2.subtractInPlace(this._t0);
  58671. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0.0, this._t2.x, this._t2.y, this._t2.z, 0.0, this._t0.x, this._t0.y, this._t0.z, 0.0, 0.0, 0.0, 0.0, 1.0, this._cachedTextureMatrix);
  58672. var scene = this.getScene();
  58673. if (!scene) {
  58674. return this._cachedTextureMatrix;
  58675. }
  58676. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58677. return mat.hasTexture(_this);
  58678. });
  58679. return this._cachedTextureMatrix;
  58680. };
  58681. /**
  58682. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58683. * @returns The reflection texture transform
  58684. */
  58685. Texture.prototype.getReflectionTextureMatrix = function () {
  58686. var _this = this;
  58687. var scene = this.getScene();
  58688. if (!scene) {
  58689. return this._cachedTextureMatrix;
  58690. }
  58691. if (this.uOffset === this._cachedUOffset &&
  58692. this.vOffset === this._cachedVOffset &&
  58693. this.uScale === this._cachedUScale &&
  58694. this.vScale === this._cachedVScale &&
  58695. this.coordinatesMode === this._cachedCoordinatesMode) {
  58696. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58697. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58698. return this._cachedTextureMatrix;
  58699. }
  58700. }
  58701. else {
  58702. return this._cachedTextureMatrix;
  58703. }
  58704. }
  58705. if (!this._cachedTextureMatrix) {
  58706. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58707. }
  58708. if (!this._projectionModeMatrix) {
  58709. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58710. }
  58711. this._cachedUOffset = this.uOffset;
  58712. this._cachedVOffset = this.vOffset;
  58713. this._cachedUScale = this.uScale;
  58714. this._cachedVScale = this.vScale;
  58715. this._cachedCoordinatesMode = this.coordinatesMode;
  58716. switch (this.coordinatesMode) {
  58717. case Texture.PLANAR_MODE:
  58718. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58719. this._cachedTextureMatrix[0] = this.uScale;
  58720. this._cachedTextureMatrix[5] = this.vScale;
  58721. this._cachedTextureMatrix[12] = this.uOffset;
  58722. this._cachedTextureMatrix[13] = this.vOffset;
  58723. break;
  58724. case Texture.PROJECTION_MODE:
  58725. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromValuesToRef(0.5, 0.0, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, this._projectionModeMatrix);
  58726. var projectionMatrix = scene.getProjectionMatrix();
  58727. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58728. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58729. break;
  58730. default:
  58731. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58732. break;
  58733. }
  58734. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58735. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58736. });
  58737. return this._cachedTextureMatrix;
  58738. };
  58739. /**
  58740. * Clones the texture.
  58741. * @returns the cloned texture
  58742. */
  58743. Texture.prototype.clone = function () {
  58744. var _this = this;
  58745. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58746. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58747. }, this);
  58748. };
  58749. /**
  58750. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58751. * @returns The JSON representation of the texture
  58752. */
  58753. Texture.prototype.serialize = function () {
  58754. var serializationObject = _super.prototype.serialize.call(this);
  58755. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58756. serializationObject.base64String = this._buffer;
  58757. serializationObject.name = serializationObject.name.replace("data:", "");
  58758. }
  58759. serializationObject.invertY = this._invertY;
  58760. serializationObject.samplingMode = this.samplingMode;
  58761. return serializationObject;
  58762. };
  58763. /**
  58764. * Get the current class name of the texture useful for serialization or dynamic coding.
  58765. * @returns "Texture"
  58766. */
  58767. Texture.prototype.getClassName = function () {
  58768. return "Texture";
  58769. };
  58770. /**
  58771. * Dispose the texture and release its associated resources.
  58772. */
  58773. Texture.prototype.dispose = function () {
  58774. _super.prototype.dispose.call(this);
  58775. this.onLoadObservable.clear();
  58776. this._delayedOnLoad = null;
  58777. this._delayedOnError = null;
  58778. };
  58779. /**
  58780. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58781. * @param parsedTexture Define the JSON representation of the texture
  58782. * @param scene Define the scene the parsed texture should be instantiated in
  58783. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58784. * @returns The parsed texture if successful
  58785. */
  58786. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58787. if (parsedTexture.customType) {
  58788. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58789. // Update Sampling Mode
  58790. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58791. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58792. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58793. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58794. }
  58795. }
  58796. return parsedCustomTexture;
  58797. }
  58798. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58799. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58800. }
  58801. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58802. return null;
  58803. }
  58804. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58805. var generateMipMaps = true;
  58806. if (parsedTexture.noMipmap) {
  58807. generateMipMaps = false;
  58808. }
  58809. if (parsedTexture.mirrorPlane) {
  58810. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58811. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58812. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58813. return mirrorTexture;
  58814. }
  58815. else if (parsedTexture.isRenderTarget) {
  58816. var renderTargetTexture = null;
  58817. if (parsedTexture.isCube) {
  58818. // Search for an existing reflection probe (which contains a cube render target texture)
  58819. if (scene.reflectionProbes) {
  58820. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58821. var probe = scene.reflectionProbes[index];
  58822. if (probe.name === parsedTexture.name) {
  58823. return probe.cubeTexture;
  58824. }
  58825. }
  58826. }
  58827. }
  58828. else {
  58829. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58830. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58831. }
  58832. return renderTargetTexture;
  58833. }
  58834. else {
  58835. var texture;
  58836. if (parsedTexture.base64String) {
  58837. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58838. }
  58839. else {
  58840. var url = rootUrl + parsedTexture.name;
  58841. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58842. url = parsedTexture.url;
  58843. }
  58844. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58845. }
  58846. return texture;
  58847. }
  58848. }, parsedTexture, scene);
  58849. // Update Sampling Mode
  58850. if (parsedTexture.samplingMode) {
  58851. var sampling = parsedTexture.samplingMode;
  58852. if (texture && texture.samplingMode !== sampling) {
  58853. texture.updateSamplingMode(sampling);
  58854. }
  58855. }
  58856. // Animations
  58857. if (texture && parsedTexture.animations) {
  58858. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58859. var parsedAnimation = parsedTexture.animations[animationIndex];
  58860. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58861. if (internalClass) {
  58862. texture.animations.push(internalClass.Parse(parsedAnimation));
  58863. }
  58864. }
  58865. }
  58866. return texture;
  58867. };
  58868. /**
  58869. * Creates a texture from its base 64 representation.
  58870. * @param data Define the base64 payload without the data: prefix
  58871. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58872. * @param scene Define the scene the texture should belong to
  58873. * @param noMipmap Forces the texture to not create mip map information if true
  58874. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58875. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58876. * @param onLoad define a callback triggered when the texture has been loaded
  58877. * @param onError define a callback triggered when an error occurred during the loading session
  58878. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58879. * @returns the created texture
  58880. */
  58881. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58882. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58883. if (onLoad === void 0) { onLoad = null; }
  58884. if (onError === void 0) { onError = null; }
  58885. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58886. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  58887. };
  58888. /**
  58889. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  58890. * @param data Define the base64 payload without the data: prefix
  58891. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58892. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58893. * @param scene Define the scene the texture should belong to
  58894. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58895. * @param noMipmap Forces the texture to not create mip map information if true
  58896. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58897. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58898. * @param onLoad define a callback triggered when the texture has been loaded
  58899. * @param onError define a callback triggered when an error occurred during the loading session
  58900. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58901. * @returns the created texture
  58902. */
  58903. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58904. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58905. if (noMipmap === void 0) { noMipmap = false; }
  58906. if (invertY === void 0) { invertY = true; }
  58907. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58908. if (onLoad === void 0) { onLoad = null; }
  58909. if (onError === void 0) { onError = null; }
  58910. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58911. if (name.substr(0, 5) !== "data:") {
  58912. name = "data:" + name;
  58913. }
  58914. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  58915. };
  58916. /** @hidden */
  58917. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  58918. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  58919. };
  58920. /** @hidden */
  58921. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58922. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  58923. };
  58924. /** @hidden */
  58925. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58926. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  58927. };
  58928. /** nearest is mag = nearest and min = nearest and mip = linear */
  58929. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  58930. /** nearest is mag = nearest and min = nearest and mip = linear */
  58931. Texture.NEAREST_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR; // nearest is mag = nearest and min = nearest and mip = linear
  58932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58933. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  58934. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58935. Texture.LINEAR_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST; // Bilinear is mag = linear and min = linear and mip = nearest
  58936. /** Trilinear is mag = linear and min = linear and mip = linear */
  58937. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  58938. /** Trilinear is mag = linear and min = linear and mip = linear */
  58939. Texture.LINEAR_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR; // Trilinear is mag = linear and min = linear and mip = linear
  58940. /** mag = nearest and min = nearest and mip = nearest */
  58941. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  58942. /** mag = nearest and min = linear and mip = nearest */
  58943. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  58944. /** mag = nearest and min = linear and mip = linear */
  58945. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  58946. /** mag = nearest and min = linear and mip = none */
  58947. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  58948. /** mag = nearest and min = nearest and mip = none */
  58949. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  58950. /** mag = linear and min = nearest and mip = nearest */
  58951. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  58952. /** mag = linear and min = nearest and mip = linear */
  58953. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  58954. /** mag = linear and min = linear and mip = none */
  58955. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  58956. /** mag = linear and min = nearest and mip = none */
  58957. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  58958. /** Explicit coordinates mode */
  58959. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  58960. /** Spherical coordinates mode */
  58961. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  58962. /** Planar coordinates mode */
  58963. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  58964. /** Cubic coordinates mode */
  58965. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  58966. /** Projection coordinates mode */
  58967. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  58968. /** Inverse Cubic coordinates mode */
  58969. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  58970. /** Inverse Cubic coordinates mode */
  58971. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  58972. /** Equirectangular coordinates mode */
  58973. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  58974. /** Equirectangular Fixed coordinates mode */
  58975. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  58976. /** Equirectangular Fixed Mirrored coordinates mode */
  58977. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  58978. /** Texture is not repeating outside of 0..1 UVs */
  58979. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58980. /** Texture is repeating outside of 0..1 UVs */
  58981. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58982. /** Texture is repeating and mirrored */
  58983. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  58984. /**
  58985. * 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
  58986. */
  58987. Texture.UseSerializedUrlIfAny = false;
  58988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58990. ], Texture.prototype, "url", void 0);
  58991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58993. ], Texture.prototype, "uOffset", void 0);
  58994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58996. ], Texture.prototype, "vOffset", void 0);
  58997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58999. ], Texture.prototype, "uScale", void 0);
  59000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59002. ], Texture.prototype, "vScale", void 0);
  59003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59005. ], Texture.prototype, "uAng", void 0);
  59006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59008. ], Texture.prototype, "vAng", void 0);
  59009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59011. ], Texture.prototype, "wAng", void 0);
  59012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59014. ], Texture.prototype, "uRotationCenter", void 0);
  59015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59017. ], Texture.prototype, "vRotationCenter", void 0);
  59018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59020. ], Texture.prototype, "wRotationCenter", void 0);
  59021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59023. ], Texture.prototype, "isBlocking", null);
  59024. return Texture;
  59025. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  59026. // References the dependencies.
  59027. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  59028. /***/ }),
  59029. /***/ "./Materials/Textures/videoTexture.ts":
  59030. /*!********************************************!*\
  59031. !*** ./Materials/Textures/videoTexture.ts ***!
  59032. \********************************************/
  59033. /*! exports provided: VideoTexture */
  59034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59035. "use strict";
  59036. __webpack_require__.r(__webpack_exports__);
  59037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  59038. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59039. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59040. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59041. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  59042. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59043. /**
  59044. * If you want to display a video in your scene, this is the special texture for that.
  59045. * This special texture works similar to other textures, with the exception of a few parameters.
  59046. * @see https://doc.babylonjs.com/how_to/video_texture
  59047. */
  59048. var VideoTexture = /** @class */ (function (_super) {
  59049. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  59050. /**
  59051. * Creates a video texture.
  59052. * If you want to display a video in your scene, this is the special texture for that.
  59053. * This special texture works similar to other textures, with the exception of a few parameters.
  59054. * @see https://doc.babylonjs.com/how_to/video_texture
  59055. * @param name optional name, will detect from video source, if not defined
  59056. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  59057. * @param scene is obviously the current scene.
  59058. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  59059. * @param invertY is false by default but can be used to invert video on Y axis
  59060. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  59061. * @param settings allows finer control over video usage
  59062. */
  59063. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  59064. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59065. if (invertY === void 0) { invertY = false; }
  59066. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59067. if (settings === void 0) { settings = {
  59068. autoPlay: true,
  59069. loop: true,
  59070. autoUpdateTexture: true,
  59071. }; }
  59072. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59073. _this._onUserActionRequestedObservable = null;
  59074. _this._stillImageCaptured = false;
  59075. _this._displayingPosterTexture = false;
  59076. _this._createInternalTexture = function () {
  59077. if (_this._texture != null) {
  59078. if (_this._displayingPosterTexture) {
  59079. _this._texture.dispose();
  59080. _this._displayingPosterTexture = false;
  59081. }
  59082. else {
  59083. return;
  59084. }
  59085. }
  59086. if (!_this._engine.needPOTTextures ||
  59087. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  59088. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59089. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59090. }
  59091. else {
  59092. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59093. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59094. _this._generateMipMaps = false;
  59095. }
  59096. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  59097. if (!_this.video.autoplay && !_this._settings.poster) {
  59098. var oldHandler_1 = _this.video.onplaying;
  59099. var error_1 = false;
  59100. _this.video.onplaying = function () {
  59101. _this.video.onplaying = oldHandler_1;
  59102. _this._texture.isReady = true;
  59103. _this._updateInternalTexture();
  59104. if (!error_1) {
  59105. _this.video.pause();
  59106. }
  59107. if (_this.onLoadObservable.hasObservers()) {
  59108. _this.onLoadObservable.notifyObservers(_this);
  59109. }
  59110. };
  59111. var playing = _this.video.play();
  59112. if (playing) {
  59113. playing.then(function () {
  59114. // Everything is good.
  59115. })
  59116. .catch(function () {
  59117. error_1 = true;
  59118. // On Chrome for instance, new policies might prevent playing without user interaction.
  59119. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  59120. _this._onUserActionRequestedObservable.notifyObservers(_this);
  59121. }
  59122. });
  59123. }
  59124. else {
  59125. _this.video.onplaying = oldHandler_1;
  59126. _this._texture.isReady = true;
  59127. _this._updateInternalTexture();
  59128. if (_this.onLoadObservable.hasObservers()) {
  59129. _this.onLoadObservable.notifyObservers(_this);
  59130. }
  59131. }
  59132. }
  59133. else {
  59134. _this._texture.isReady = true;
  59135. _this._updateInternalTexture();
  59136. if (_this.onLoadObservable.hasObservers()) {
  59137. _this.onLoadObservable.notifyObservers(_this);
  59138. }
  59139. }
  59140. };
  59141. _this.reset = function () {
  59142. if (_this._texture == null) {
  59143. return;
  59144. }
  59145. if (!_this._displayingPosterTexture) {
  59146. _this._texture.dispose();
  59147. _this._texture = null;
  59148. }
  59149. };
  59150. _this._updateInternalTexture = function () {
  59151. if (_this._texture == null || !_this._texture.isReady) {
  59152. return;
  59153. }
  59154. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  59155. return;
  59156. }
  59157. if (_this._displayingPosterTexture) {
  59158. return;
  59159. }
  59160. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  59161. };
  59162. _this._engine = _this.getScene().getEngine();
  59163. _this._generateMipMaps = generateMipMaps;
  59164. _this._initialSamplingMode = samplingMode;
  59165. _this.autoUpdateTexture = settings.autoUpdateTexture;
  59166. _this.name = name || _this._getName(src);
  59167. _this.video = _this._getVideo(src);
  59168. _this._settings = settings;
  59169. if (settings.poster) {
  59170. _this.video.poster = settings.poster;
  59171. }
  59172. if (settings.autoPlay !== undefined) {
  59173. _this.video.autoplay = settings.autoPlay;
  59174. }
  59175. if (settings.loop !== undefined) {
  59176. _this.video.loop = settings.loop;
  59177. }
  59178. _this.video.setAttribute("playsinline", "");
  59179. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59180. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59181. _this.video.addEventListener("emptied", _this.reset);
  59182. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59183. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59184. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59185. if (settings.poster &&
  59186. (!settings.autoPlay || !videoHasEnoughData)) {
  59187. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59188. _this._displayingPosterTexture = true;
  59189. }
  59190. else if (videoHasEnoughData) {
  59191. _this._createInternalTexture();
  59192. }
  59193. return _this;
  59194. }
  59195. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59196. /**
  59197. * Event triggerd when a dom action is required by the user to play the video.
  59198. * This happens due to recent changes in browser policies preventing video to auto start.
  59199. */
  59200. get: function () {
  59201. if (!this._onUserActionRequestedObservable) {
  59202. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59203. }
  59204. return this._onUserActionRequestedObservable;
  59205. },
  59206. enumerable: true,
  59207. configurable: true
  59208. });
  59209. VideoTexture.prototype._getName = function (src) {
  59210. if (src instanceof HTMLVideoElement) {
  59211. return src.currentSrc;
  59212. }
  59213. if (typeof src === "object") {
  59214. return src.toString();
  59215. }
  59216. return src;
  59217. };
  59218. VideoTexture.prototype._getVideo = function (src) {
  59219. if (src instanceof HTMLVideoElement) {
  59220. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59221. return src;
  59222. }
  59223. var video = document.createElement("video");
  59224. if (typeof src === "string") {
  59225. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59226. video.src = src;
  59227. }
  59228. else {
  59229. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59230. src.forEach(function (url) {
  59231. var source = document.createElement("source");
  59232. source.src = url;
  59233. video.appendChild(source);
  59234. });
  59235. }
  59236. return video;
  59237. };
  59238. /**
  59239. * @hidden Internal method to initiate `update`.
  59240. */
  59241. VideoTexture.prototype._rebuild = function () {
  59242. this.update();
  59243. };
  59244. /**
  59245. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59246. */
  59247. VideoTexture.prototype.update = function () {
  59248. if (!this.autoUpdateTexture) {
  59249. // Expecting user to call `updateTexture` manually
  59250. return;
  59251. }
  59252. this.updateTexture(true);
  59253. };
  59254. /**
  59255. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59256. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59257. */
  59258. VideoTexture.prototype.updateTexture = function (isVisible) {
  59259. if (!isVisible) {
  59260. return;
  59261. }
  59262. if (this.video.paused && this._stillImageCaptured) {
  59263. return;
  59264. }
  59265. this._stillImageCaptured = true;
  59266. this._updateInternalTexture();
  59267. };
  59268. /**
  59269. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59270. * @param url New url.
  59271. */
  59272. VideoTexture.prototype.updateURL = function (url) {
  59273. this.video.src = url;
  59274. };
  59275. /**
  59276. * Dispose the texture and release its associated resources.
  59277. */
  59278. VideoTexture.prototype.dispose = function () {
  59279. _super.prototype.dispose.call(this);
  59280. if (this._onUserActionRequestedObservable) {
  59281. this._onUserActionRequestedObservable.clear();
  59282. this._onUserActionRequestedObservable = null;
  59283. }
  59284. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59285. this.video.removeEventListener("paused", this._updateInternalTexture);
  59286. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59287. this.video.removeEventListener("emptied", this.reset);
  59288. this.video.pause();
  59289. };
  59290. /**
  59291. * Creates a video texture straight from your WebCam video feed.
  59292. * @param scene Define the scene the texture should be created in
  59293. * @param onReady Define a callback to triggered once the texture will be ready
  59294. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59295. */
  59296. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59297. var video = document.createElement("video");
  59298. video.setAttribute('autoplay', '');
  59299. video.setAttribute('muted', '');
  59300. video.setAttribute('playsinline', '');
  59301. var constraintsDeviceId;
  59302. if (constraints && constraints.deviceId) {
  59303. constraintsDeviceId = {
  59304. exact: constraints.deviceId,
  59305. };
  59306. }
  59307. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59308. if (navigator.mediaDevices) {
  59309. navigator.mediaDevices.getUserMedia({ video: constraints })
  59310. .then(function (stream) {
  59311. if (video.mozSrcObject !== undefined) {
  59312. // hack for Firefox < 19
  59313. video.mozSrcObject = stream;
  59314. }
  59315. else {
  59316. video.srcObject = stream;
  59317. }
  59318. var onPlaying = function () {
  59319. if (onReady) {
  59320. onReady(new VideoTexture("video", video, scene, true, true));
  59321. }
  59322. video.removeEventListener("playing", onPlaying);
  59323. };
  59324. video.addEventListener("playing", onPlaying);
  59325. video.play();
  59326. })
  59327. .catch(function (err) {
  59328. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59329. });
  59330. }
  59331. else {
  59332. navigator.getUserMedia =
  59333. navigator.getUserMedia ||
  59334. navigator.webkitGetUserMedia ||
  59335. navigator.mozGetUserMedia ||
  59336. navigator.msGetUserMedia;
  59337. if (navigator.getUserMedia) {
  59338. navigator.getUserMedia({
  59339. video: {
  59340. deviceId: constraintsDeviceId,
  59341. width: {
  59342. min: (constraints && constraints.minWidth) || 256,
  59343. max: (constraints && constraints.maxWidth) || 640,
  59344. },
  59345. height: {
  59346. min: (constraints && constraints.minHeight) || 256,
  59347. max: (constraints && constraints.maxHeight) || 480,
  59348. },
  59349. },
  59350. }, function (stream) {
  59351. if (video.mozSrcObject !== undefined) {
  59352. // hack for Firefox < 19
  59353. video.mozSrcObject = stream;
  59354. }
  59355. else {
  59356. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59357. }
  59358. video.play();
  59359. if (onReady) {
  59360. onReady(new VideoTexture("video", video, scene, true, true));
  59361. }
  59362. }, function (e) {
  59363. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59364. });
  59365. }
  59366. }
  59367. };
  59368. return VideoTexture;
  59369. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59370. /***/ }),
  59371. /***/ "./Materials/colorCurves.ts":
  59372. /*!**********************************!*\
  59373. !*** ./Materials/colorCurves.ts ***!
  59374. \**********************************/
  59375. /*! exports provided: ColorCurves */
  59376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59377. "use strict";
  59378. __webpack_require__.r(__webpack_exports__);
  59379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59380. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59381. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59382. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59383. /**
  59384. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59385. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59386. * 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;
  59387. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59388. */
  59389. var ColorCurves = /** @class */ (function () {
  59390. function ColorCurves() {
  59391. this._dirty = true;
  59392. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59393. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59394. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59395. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59396. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59397. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59398. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59399. this._globalHue = 30;
  59400. this._globalDensity = 0;
  59401. this._globalSaturation = 0;
  59402. this._globalExposure = 0;
  59403. this._highlightsHue = 30;
  59404. this._highlightsDensity = 0;
  59405. this._highlightsSaturation = 0;
  59406. this._highlightsExposure = 0;
  59407. this._midtonesHue = 30;
  59408. this._midtonesDensity = 0;
  59409. this._midtonesSaturation = 0;
  59410. this._midtonesExposure = 0;
  59411. this._shadowsHue = 30;
  59412. this._shadowsDensity = 0;
  59413. this._shadowsSaturation = 0;
  59414. this._shadowsExposure = 0;
  59415. }
  59416. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59417. /**
  59418. * Gets the global Hue value.
  59419. * 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).
  59420. */
  59421. get: function () {
  59422. return this._globalHue;
  59423. },
  59424. /**
  59425. * Sets the global Hue value.
  59426. * 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).
  59427. */
  59428. set: function (value) {
  59429. this._globalHue = value;
  59430. this._dirty = true;
  59431. },
  59432. enumerable: true,
  59433. configurable: true
  59434. });
  59435. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59436. /**
  59437. * Gets the global Density value.
  59438. * 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.
  59439. * Values less than zero provide a filter of opposite hue.
  59440. */
  59441. get: function () {
  59442. return this._globalDensity;
  59443. },
  59444. /**
  59445. * Sets the global Density value.
  59446. * 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.
  59447. * Values less than zero provide a filter of opposite hue.
  59448. */
  59449. set: function (value) {
  59450. this._globalDensity = value;
  59451. this._dirty = true;
  59452. },
  59453. enumerable: true,
  59454. configurable: true
  59455. });
  59456. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59457. /**
  59458. * Gets the global Saturation value.
  59459. * 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.
  59460. */
  59461. get: function () {
  59462. return this._globalSaturation;
  59463. },
  59464. /**
  59465. * Sets the global Saturation value.
  59466. * 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.
  59467. */
  59468. set: function (value) {
  59469. this._globalSaturation = value;
  59470. this._dirty = true;
  59471. },
  59472. enumerable: true,
  59473. configurable: true
  59474. });
  59475. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  59476. /**
  59477. * Gets the global Exposure value.
  59478. * 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.
  59479. */
  59480. get: function () {
  59481. return this._globalExposure;
  59482. },
  59483. /**
  59484. * Sets the global Exposure value.
  59485. * 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.
  59486. */
  59487. set: function (value) {
  59488. this._globalExposure = value;
  59489. this._dirty = true;
  59490. },
  59491. enumerable: true,
  59492. configurable: true
  59493. });
  59494. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  59495. /**
  59496. * Gets the highlights Hue value.
  59497. * 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).
  59498. */
  59499. get: function () {
  59500. return this._highlightsHue;
  59501. },
  59502. /**
  59503. * Sets the highlights Hue value.
  59504. * 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).
  59505. */
  59506. set: function (value) {
  59507. this._highlightsHue = value;
  59508. this._dirty = true;
  59509. },
  59510. enumerable: true,
  59511. configurable: true
  59512. });
  59513. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  59514. /**
  59515. * Gets the highlights Density value.
  59516. * 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.
  59517. * Values less than zero provide a filter of opposite hue.
  59518. */
  59519. get: function () {
  59520. return this._highlightsDensity;
  59521. },
  59522. /**
  59523. * Sets the highlights Density value.
  59524. * 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.
  59525. * Values less than zero provide a filter of opposite hue.
  59526. */
  59527. set: function (value) {
  59528. this._highlightsDensity = value;
  59529. this._dirty = true;
  59530. },
  59531. enumerable: true,
  59532. configurable: true
  59533. });
  59534. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  59535. /**
  59536. * Gets the highlights Saturation value.
  59537. * 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.
  59538. */
  59539. get: function () {
  59540. return this._highlightsSaturation;
  59541. },
  59542. /**
  59543. * Sets the highlights Saturation value.
  59544. * 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.
  59545. */
  59546. set: function (value) {
  59547. this._highlightsSaturation = value;
  59548. this._dirty = true;
  59549. },
  59550. enumerable: true,
  59551. configurable: true
  59552. });
  59553. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  59554. /**
  59555. * Gets the highlights Exposure value.
  59556. * 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.
  59557. */
  59558. get: function () {
  59559. return this._highlightsExposure;
  59560. },
  59561. /**
  59562. * Sets the highlights Exposure value.
  59563. * 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.
  59564. */
  59565. set: function (value) {
  59566. this._highlightsExposure = value;
  59567. this._dirty = true;
  59568. },
  59569. enumerable: true,
  59570. configurable: true
  59571. });
  59572. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  59573. /**
  59574. * Gets the midtones Hue value.
  59575. * 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).
  59576. */
  59577. get: function () {
  59578. return this._midtonesHue;
  59579. },
  59580. /**
  59581. * Sets the midtones Hue value.
  59582. * 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).
  59583. */
  59584. set: function (value) {
  59585. this._midtonesHue = value;
  59586. this._dirty = true;
  59587. },
  59588. enumerable: true,
  59589. configurable: true
  59590. });
  59591. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59592. /**
  59593. * Gets the midtones Density value.
  59594. * 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.
  59595. * Values less than zero provide a filter of opposite hue.
  59596. */
  59597. get: function () {
  59598. return this._midtonesDensity;
  59599. },
  59600. /**
  59601. * Sets the midtones Density value.
  59602. * 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.
  59603. * Values less than zero provide a filter of opposite hue.
  59604. */
  59605. set: function (value) {
  59606. this._midtonesDensity = value;
  59607. this._dirty = true;
  59608. },
  59609. enumerable: true,
  59610. configurable: true
  59611. });
  59612. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59613. /**
  59614. * Gets the midtones Saturation value.
  59615. * 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.
  59616. */
  59617. get: function () {
  59618. return this._midtonesSaturation;
  59619. },
  59620. /**
  59621. * Sets the midtones Saturation value.
  59622. * 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.
  59623. */
  59624. set: function (value) {
  59625. this._midtonesSaturation = value;
  59626. this._dirty = true;
  59627. },
  59628. enumerable: true,
  59629. configurable: true
  59630. });
  59631. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59632. /**
  59633. * Gets the midtones Exposure value.
  59634. * 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.
  59635. */
  59636. get: function () {
  59637. return this._midtonesExposure;
  59638. },
  59639. /**
  59640. * Sets the midtones Exposure value.
  59641. * 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.
  59642. */
  59643. set: function (value) {
  59644. this._midtonesExposure = value;
  59645. this._dirty = true;
  59646. },
  59647. enumerable: true,
  59648. configurable: true
  59649. });
  59650. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59651. /**
  59652. * Gets the shadows Hue value.
  59653. * 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).
  59654. */
  59655. get: function () {
  59656. return this._shadowsHue;
  59657. },
  59658. /**
  59659. * Sets the shadows Hue value.
  59660. * 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).
  59661. */
  59662. set: function (value) {
  59663. this._shadowsHue = value;
  59664. this._dirty = true;
  59665. },
  59666. enumerable: true,
  59667. configurable: true
  59668. });
  59669. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59670. /**
  59671. * Gets the shadows Density value.
  59672. * 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.
  59673. * Values less than zero provide a filter of opposite hue.
  59674. */
  59675. get: function () {
  59676. return this._shadowsDensity;
  59677. },
  59678. /**
  59679. * Sets the shadows Density value.
  59680. * 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.
  59681. * Values less than zero provide a filter of opposite hue.
  59682. */
  59683. set: function (value) {
  59684. this._shadowsDensity = value;
  59685. this._dirty = true;
  59686. },
  59687. enumerable: true,
  59688. configurable: true
  59689. });
  59690. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59691. /**
  59692. * Gets the shadows Saturation value.
  59693. * 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.
  59694. */
  59695. get: function () {
  59696. return this._shadowsSaturation;
  59697. },
  59698. /**
  59699. * Sets the shadows Saturation value.
  59700. * 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.
  59701. */
  59702. set: function (value) {
  59703. this._shadowsSaturation = value;
  59704. this._dirty = true;
  59705. },
  59706. enumerable: true,
  59707. configurable: true
  59708. });
  59709. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59710. /**
  59711. * Gets the shadows Exposure value.
  59712. * 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.
  59713. */
  59714. get: function () {
  59715. return this._shadowsExposure;
  59716. },
  59717. /**
  59718. * Sets the shadows Exposure value.
  59719. * 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.
  59720. */
  59721. set: function (value) {
  59722. this._shadowsExposure = value;
  59723. this._dirty = true;
  59724. },
  59725. enumerable: true,
  59726. configurable: true
  59727. });
  59728. /**
  59729. * Returns the class name
  59730. * @returns The class name
  59731. */
  59732. ColorCurves.prototype.getClassName = function () {
  59733. return "ColorCurves";
  59734. };
  59735. /**
  59736. * Binds the color curves to the shader.
  59737. * @param colorCurves The color curve to bind
  59738. * @param effect The effect to bind to
  59739. * @param positiveUniform The positive uniform shader parameter
  59740. * @param neutralUniform The neutral uniform shader parameter
  59741. * @param negativeUniform The negative uniform shader parameter
  59742. */
  59743. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59744. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59745. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59746. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59747. if (colorCurves._dirty) {
  59748. colorCurves._dirty = false;
  59749. // Fill in global info.
  59750. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59751. // Compute highlights info.
  59752. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59753. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59754. // Compute midtones info.
  59755. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59756. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59757. // Compute shadows info.
  59758. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59759. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59760. // Compute deltas (neutral is midtones).
  59761. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59762. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59763. }
  59764. if (effect) {
  59765. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59766. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59767. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59768. }
  59769. };
  59770. /**
  59771. * Prepare the list of uniforms associated with the ColorCurves effects.
  59772. * @param uniformsList The list of uniforms used in the effect
  59773. */
  59774. ColorCurves.PrepareUniforms = function (uniformsList) {
  59775. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59776. };
  59777. /**
  59778. * Returns color grading data based on a hue, density, saturation and exposure value.
  59779. * @param filterHue The hue of the color filter.
  59780. * @param filterDensity The density of the color filter.
  59781. * @param saturation The saturation.
  59782. * @param exposure The exposure.
  59783. * @param result The result data container.
  59784. */
  59785. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59786. if (hue == null) {
  59787. return;
  59788. }
  59789. hue = ColorCurves.clamp(hue, 0, 360);
  59790. density = ColorCurves.clamp(density, -100, 100);
  59791. saturation = ColorCurves.clamp(saturation, -100, 100);
  59792. exposure = ColorCurves.clamp(exposure, -100, 100);
  59793. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59794. // so that the maximum filter density is only 50% control. This provides fine control
  59795. // for small values and reasonable range.
  59796. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59797. density *= 0.5;
  59798. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59799. if (density < 0) {
  59800. density *= -1;
  59801. hue = (hue + 180) % 360;
  59802. }
  59803. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59804. result.scaleToRef(2, result);
  59805. result.a = 1 + 0.01 * saturation;
  59806. };
  59807. /**
  59808. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59809. * @param value The input slider value in range [-100,100].
  59810. * @returns Adjusted value.
  59811. */
  59812. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59813. value /= 100;
  59814. var x = Math.abs(value);
  59815. x = Math.pow(x, 2);
  59816. if (value < 0) {
  59817. x *= -1;
  59818. }
  59819. x *= 100;
  59820. return x;
  59821. };
  59822. /**
  59823. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59824. * @param hue The hue (H) input.
  59825. * @param saturation The saturation (S) input.
  59826. * @param brightness The brightness (B) input.
  59827. * @result An RGBA color represented as Vector4.
  59828. */
  59829. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59830. var h = ColorCurves.clamp(hue, 0, 360);
  59831. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59832. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59833. if (s === 0) {
  59834. result.r = v;
  59835. result.g = v;
  59836. result.b = v;
  59837. }
  59838. else {
  59839. // sector 0 to 5
  59840. h /= 60;
  59841. var i = Math.floor(h);
  59842. // fractional part of h
  59843. var f = h - i;
  59844. var p = v * (1 - s);
  59845. var q = v * (1 - s * f);
  59846. var t = v * (1 - s * (1 - f));
  59847. switch (i) {
  59848. case 0:
  59849. result.r = v;
  59850. result.g = t;
  59851. result.b = p;
  59852. break;
  59853. case 1:
  59854. result.r = q;
  59855. result.g = v;
  59856. result.b = p;
  59857. break;
  59858. case 2:
  59859. result.r = p;
  59860. result.g = v;
  59861. result.b = t;
  59862. break;
  59863. case 3:
  59864. result.r = p;
  59865. result.g = q;
  59866. result.b = v;
  59867. break;
  59868. case 4:
  59869. result.r = t;
  59870. result.g = p;
  59871. result.b = v;
  59872. break;
  59873. default: // case 5:
  59874. result.r = v;
  59875. result.g = p;
  59876. result.b = q;
  59877. break;
  59878. }
  59879. }
  59880. result.a = 1;
  59881. };
  59882. /**
  59883. * Returns a value clamped between min and max
  59884. * @param value The value to clamp
  59885. * @param min The minimum of value
  59886. * @param max The maximum of value
  59887. * @returns The clamped value.
  59888. */
  59889. ColorCurves.clamp = function (value, min, max) {
  59890. return Math.min(Math.max(value, min), max);
  59891. };
  59892. /**
  59893. * Clones the current color curve instance.
  59894. * @return The cloned curves
  59895. */
  59896. ColorCurves.prototype.clone = function () {
  59897. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  59898. };
  59899. /**
  59900. * Serializes the current color curve instance to a json representation.
  59901. * @return a JSON representation
  59902. */
  59903. ColorCurves.prototype.serialize = function () {
  59904. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59905. };
  59906. /**
  59907. * Parses the color curve from a json representation.
  59908. * @param source the JSON source to parse
  59909. * @return The parsed curves
  59910. */
  59911. ColorCurves.Parse = function (source) {
  59912. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  59913. };
  59914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59916. ], ColorCurves.prototype, "_globalHue", void 0);
  59917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59919. ], ColorCurves.prototype, "_globalDensity", void 0);
  59920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59922. ], ColorCurves.prototype, "_globalSaturation", void 0);
  59923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59925. ], ColorCurves.prototype, "_globalExposure", void 0);
  59926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59928. ], ColorCurves.prototype, "_highlightsHue", void 0);
  59929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59931. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  59932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59934. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  59935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59937. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  59938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59940. ], ColorCurves.prototype, "_midtonesHue", void 0);
  59941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59943. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  59944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59946. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  59947. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59949. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  59950. return ColorCurves;
  59951. }());
  59952. // References the dependencies.
  59953. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  59954. /***/ }),
  59955. /***/ "./Materials/effect.ts":
  59956. /*!*****************************!*\
  59957. !*** ./Materials/effect.ts ***!
  59958. \*****************************/
  59959. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  59960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59961. "use strict";
  59962. __webpack_require__.r(__webpack_exports__);
  59963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  59964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  59965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  59966. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  59967. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  59968. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  59969. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  59970. /**
  59971. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  59972. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  59973. */
  59974. var EffectFallbacks = /** @class */ (function () {
  59975. function EffectFallbacks() {
  59976. this._defines = {};
  59977. this._currentRank = 32;
  59978. this._maxRank = -1;
  59979. }
  59980. /**
  59981. * Removes the fallback from the bound mesh.
  59982. */
  59983. EffectFallbacks.prototype.unBindMesh = function () {
  59984. this._mesh = null;
  59985. };
  59986. /**
  59987. * Adds a fallback on the specified property.
  59988. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59989. * @param define The name of the define in the shader
  59990. */
  59991. EffectFallbacks.prototype.addFallback = function (rank, define) {
  59992. if (!this._defines[rank]) {
  59993. if (rank < this._currentRank) {
  59994. this._currentRank = rank;
  59995. }
  59996. if (rank > this._maxRank) {
  59997. this._maxRank = rank;
  59998. }
  59999. this._defines[rank] = new Array();
  60000. }
  60001. this._defines[rank].push(define);
  60002. };
  60003. /**
  60004. * Sets the mesh to use CPU skinning when needing to fallback.
  60005. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60006. * @param mesh The mesh to use the fallbacks.
  60007. */
  60008. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  60009. this._mesh = mesh;
  60010. if (rank < this._currentRank) {
  60011. this._currentRank = rank;
  60012. }
  60013. if (rank > this._maxRank) {
  60014. this._maxRank = rank;
  60015. }
  60016. };
  60017. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  60018. /**
  60019. * Checks to see if more fallbacks are still availible.
  60020. */
  60021. get: function () {
  60022. return this._currentRank <= this._maxRank;
  60023. },
  60024. enumerable: true,
  60025. configurable: true
  60026. });
  60027. /**
  60028. * Removes the defines that shoould be removed when falling back.
  60029. * @param currentDefines defines the current define statements for the shader.
  60030. * @param effect defines the current effect we try to compile
  60031. * @returns The resulting defines with defines of the current rank removed.
  60032. */
  60033. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  60034. // First we try to switch to CPU skinning
  60035. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  60036. this._mesh.computeBonesUsingShaders = false;
  60037. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  60038. effect._bonesComputationForcedToCPU = true;
  60039. var scene = this._mesh.getScene();
  60040. for (var index = 0; index < scene.meshes.length; index++) {
  60041. var otherMesh = scene.meshes[index];
  60042. if (!otherMesh.material) {
  60043. continue;
  60044. }
  60045. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  60046. continue;
  60047. }
  60048. if (otherMesh.material.getEffect() === effect) {
  60049. otherMesh.computeBonesUsingShaders = false;
  60050. }
  60051. else if (otherMesh.subMeshes) {
  60052. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  60053. var subMesh = _a[_i];
  60054. var subMeshEffect = subMesh.effect;
  60055. if (subMeshEffect === effect) {
  60056. otherMesh.computeBonesUsingShaders = false;
  60057. break;
  60058. }
  60059. }
  60060. }
  60061. }
  60062. }
  60063. else {
  60064. var currentFallbacks = this._defines[this._currentRank];
  60065. if (currentFallbacks) {
  60066. for (var index = 0; index < currentFallbacks.length; index++) {
  60067. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  60068. }
  60069. }
  60070. this._currentRank++;
  60071. }
  60072. return currentDefines;
  60073. };
  60074. return EffectFallbacks;
  60075. }());
  60076. /**
  60077. * Options to be used when creating an effect.
  60078. */
  60079. var EffectCreationOptions = /** @class */ (function () {
  60080. function EffectCreationOptions() {
  60081. }
  60082. return EffectCreationOptions;
  60083. }());
  60084. /**
  60085. * Effect containing vertex and fragment shader that can be executed on an object.
  60086. */
  60087. var Effect = /** @class */ (function () {
  60088. /**
  60089. * Instantiates an effect.
  60090. * An effect can be used to create/manage/execute vertex and fragment shaders.
  60091. * @param baseName Name of the effect.
  60092. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  60093. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  60094. * @param samplers List of sampler variables that will be passed to the shader.
  60095. * @param engine Engine to be used to render the effect
  60096. * @param defines Define statements to be added to the shader.
  60097. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  60098. * @param onCompiled Callback that will be called when the shader is compiled.
  60099. * @param onError Callback that will be called if an error occurs during shader compilation.
  60100. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  60101. */
  60102. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  60103. if (samplers === void 0) { samplers = null; }
  60104. if (defines === void 0) { defines = null; }
  60105. if (fallbacks === void 0) { fallbacks = null; }
  60106. if (onCompiled === void 0) { onCompiled = null; }
  60107. if (onError === void 0) { onError = null; }
  60108. var _this = this;
  60109. /**
  60110. * Unique ID of the effect.
  60111. */
  60112. this.uniqueId = 0;
  60113. /**
  60114. * Observable that will be called when the shader is compiled.
  60115. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  60116. */
  60117. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60118. /**
  60119. * Observable that will be called if an error occurs during shader compilation.
  60120. */
  60121. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60122. /** @hidden */
  60123. this._bonesComputationForcedToCPU = false;
  60124. this._uniformBuffersNames = {};
  60125. this._isReady = false;
  60126. this._compilationError = "";
  60127. this.name = baseName;
  60128. if (attributesNamesOrOptions.attributes) {
  60129. var options = attributesNamesOrOptions;
  60130. this._engine = uniformsNamesOrEngine;
  60131. this._attributesNames = options.attributes;
  60132. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  60133. this._samplers = options.samplers.slice();
  60134. this.defines = options.defines;
  60135. this.onError = options.onError;
  60136. this.onCompiled = options.onCompiled;
  60137. this._fallbacks = options.fallbacks;
  60138. this._indexParameters = options.indexParameters;
  60139. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  60140. if (options.uniformBuffersNames) {
  60141. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  60142. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  60143. }
  60144. }
  60145. }
  60146. else {
  60147. this._engine = engine;
  60148. this.defines = defines;
  60149. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  60150. this._samplers = samplers ? samplers.slice() : [];
  60151. this._attributesNames = attributesNamesOrOptions;
  60152. this.onError = onError;
  60153. this.onCompiled = onCompiled;
  60154. this._indexParameters = indexParameters;
  60155. this._fallbacks = fallbacks;
  60156. }
  60157. this.uniqueId = Effect._uniqueIdSeed++;
  60158. var vertexSource;
  60159. var fragmentSource;
  60160. if (baseName.vertexElement) {
  60161. vertexSource = document.getElementById(baseName.vertexElement);
  60162. if (!vertexSource) {
  60163. vertexSource = baseName.vertexElement;
  60164. }
  60165. }
  60166. else {
  60167. vertexSource = baseName.vertex || baseName;
  60168. }
  60169. if (baseName.fragmentElement) {
  60170. fragmentSource = document.getElementById(baseName.fragmentElement);
  60171. if (!fragmentSource) {
  60172. fragmentSource = baseName.fragmentElement;
  60173. }
  60174. }
  60175. else {
  60176. fragmentSource = baseName.fragment || baseName;
  60177. }
  60178. this._loadVertexShader(vertexSource, function (vertexCode) {
  60179. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60180. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60181. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60182. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60183. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60184. if (baseName) {
  60185. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60186. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60187. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60188. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60189. }
  60190. else {
  60191. _this._vertexSourceCode = migratedVertexCode;
  60192. _this._fragmentSourceCode = migratedFragmentCode;
  60193. }
  60194. _this._prepareEffect();
  60195. });
  60196. });
  60197. });
  60198. });
  60199. });
  60200. });
  60201. }
  60202. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60203. /**
  60204. * Observable that will be called when effect is bound.
  60205. */
  60206. get: function () {
  60207. if (!this._onBindObservable) {
  60208. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60209. }
  60210. return this._onBindObservable;
  60211. },
  60212. enumerable: true,
  60213. configurable: true
  60214. });
  60215. Object.defineProperty(Effect.prototype, "key", {
  60216. /**
  60217. * Unique key for this effect
  60218. */
  60219. get: function () {
  60220. return this._key;
  60221. },
  60222. enumerable: true,
  60223. configurable: true
  60224. });
  60225. /**
  60226. * If the effect has been compiled and prepared.
  60227. * @returns if the effect is compiled and prepared.
  60228. */
  60229. Effect.prototype.isReady = function () {
  60230. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60231. return this._engine._isProgramCompiled(this._program);
  60232. }
  60233. return this._isReady;
  60234. };
  60235. /**
  60236. * The engine the effect was initialized with.
  60237. * @returns the engine.
  60238. */
  60239. Effect.prototype.getEngine = function () {
  60240. return this._engine;
  60241. };
  60242. /**
  60243. * The compiled webGL program for the effect
  60244. * @returns the webGL program.
  60245. */
  60246. Effect.prototype.getProgram = function () {
  60247. return this._program;
  60248. };
  60249. /**
  60250. * The set of names of attribute variables for the shader.
  60251. * @returns An array of attribute names.
  60252. */
  60253. Effect.prototype.getAttributesNames = function () {
  60254. return this._attributesNames;
  60255. };
  60256. /**
  60257. * Returns the attribute at the given index.
  60258. * @param index The index of the attribute.
  60259. * @returns The location of the attribute.
  60260. */
  60261. Effect.prototype.getAttributeLocation = function (index) {
  60262. return this._attributes[index];
  60263. };
  60264. /**
  60265. * Returns the attribute based on the name of the variable.
  60266. * @param name of the attribute to look up.
  60267. * @returns the attribute location.
  60268. */
  60269. Effect.prototype.getAttributeLocationByName = function (name) {
  60270. var index = this._attributesNames.indexOf(name);
  60271. return this._attributes[index];
  60272. };
  60273. /**
  60274. * The number of attributes.
  60275. * @returns the numnber of attributes.
  60276. */
  60277. Effect.prototype.getAttributesCount = function () {
  60278. return this._attributes.length;
  60279. };
  60280. /**
  60281. * Gets the index of a uniform variable.
  60282. * @param uniformName of the uniform to look up.
  60283. * @returns the index.
  60284. */
  60285. Effect.prototype.getUniformIndex = function (uniformName) {
  60286. return this._uniformsNames.indexOf(uniformName);
  60287. };
  60288. /**
  60289. * Returns the attribute based on the name of the variable.
  60290. * @param uniformName of the uniform to look up.
  60291. * @returns the location of the uniform.
  60292. */
  60293. Effect.prototype.getUniform = function (uniformName) {
  60294. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60295. };
  60296. /**
  60297. * Returns an array of sampler variable names
  60298. * @returns The array of sampler variable neames.
  60299. */
  60300. Effect.prototype.getSamplers = function () {
  60301. return this._samplers;
  60302. };
  60303. /**
  60304. * The error from the last compilation.
  60305. * @returns the error string.
  60306. */
  60307. Effect.prototype.getCompilationError = function () {
  60308. return this._compilationError;
  60309. };
  60310. /**
  60311. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60312. * @param func The callback to be used.
  60313. */
  60314. Effect.prototype.executeWhenCompiled = function (func) {
  60315. var _this = this;
  60316. if (this.isReady()) {
  60317. func(this);
  60318. return;
  60319. }
  60320. this.onCompileObservable.add(function (effect) {
  60321. func(effect);
  60322. });
  60323. if (!this._program || this._program.isParallelCompiled) {
  60324. setTimeout(function () {
  60325. _this._checkIsReady();
  60326. }, 16);
  60327. }
  60328. };
  60329. Effect.prototype._checkIsReady = function () {
  60330. var _this = this;
  60331. if (this.isReady()) {
  60332. return;
  60333. }
  60334. setTimeout(function () {
  60335. _this._checkIsReady();
  60336. }, 16);
  60337. };
  60338. /** @hidden */
  60339. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60340. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60341. // DOM element ?
  60342. if (vertex instanceof HTMLElement) {
  60343. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60344. callback(vertexCode);
  60345. return;
  60346. }
  60347. }
  60348. // Base64 encoded ?
  60349. if (vertex.substr(0, 7) === "base64:") {
  60350. var vertexBinary = window.atob(vertex.substr(7));
  60351. callback(vertexBinary);
  60352. return;
  60353. }
  60354. // Is in local store ?
  60355. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60356. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60357. return;
  60358. }
  60359. var vertexShaderUrl;
  60360. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60361. vertexShaderUrl = vertex;
  60362. }
  60363. else {
  60364. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60365. }
  60366. // Vertex shader
  60367. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60368. };
  60369. /** @hidden */
  60370. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60371. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60372. // DOM element ?
  60373. if (fragment instanceof HTMLElement) {
  60374. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60375. callback(fragmentCode);
  60376. return;
  60377. }
  60378. }
  60379. // Base64 encoded ?
  60380. if (fragment.substr(0, 7) === "base64:") {
  60381. var fragmentBinary = window.atob(fragment.substr(7));
  60382. callback(fragmentBinary);
  60383. return;
  60384. }
  60385. // Is in local store ?
  60386. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60387. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60388. return;
  60389. }
  60390. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60391. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60392. return;
  60393. }
  60394. var fragmentShaderUrl;
  60395. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60396. fragmentShaderUrl = fragment;
  60397. }
  60398. else {
  60399. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60400. }
  60401. // Fragment shader
  60402. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60403. };
  60404. /** @hidden */
  60405. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60406. // Rebuild shaders source code
  60407. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60408. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60409. vertexCode = prefix + vertexCode;
  60410. fragmentCode = prefix + fragmentCode;
  60411. // Number lines of shaders source code
  60412. var i = 2;
  60413. var regex = /\n/gm;
  60414. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60415. i = 2;
  60416. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60417. // Dump shaders name and formatted source code
  60418. if (this.name.vertexElement) {
  60419. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60420. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60421. }
  60422. else if (this.name.vertex) {
  60423. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60424. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60425. }
  60426. else {
  60427. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60428. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60429. }
  60430. };
  60431. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60432. var preparedSourceCode = this._processPrecision(sourceCode);
  60433. if (this._engine.webGLVersion == 1) {
  60434. callback(preparedSourceCode);
  60435. return;
  60436. }
  60437. // Already converted
  60438. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60439. callback(preparedSourceCode.replace("#version 300 es", ""));
  60440. return;
  60441. }
  60442. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60443. // Remove extensions
  60444. // #extension GL_OES_standard_derivatives : enable
  60445. // #extension GL_EXT_shader_texture_lod : enable
  60446. // #extension GL_EXT_frag_depth : enable
  60447. // #extension GL_EXT_draw_buffers : require
  60448. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60449. var result = preparedSourceCode.replace(regex, "");
  60450. // Migrate to GLSL v300
  60451. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60452. result = result.replace(/attribute[ \t]/g, "in ");
  60453. result = result.replace(/[ \t]attribute/g, " in");
  60454. result = result.replace(/texture2D\s*\(/g, "texture(");
  60455. if (isFragment) {
  60456. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60457. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  60458. result = result.replace(/textureCube\s*\(/g, "texture(");
  60459. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  60460. result = result.replace(/gl_FragColor/g, "glFragColor");
  60461. result = result.replace(/gl_FragData/g, "glFragData");
  60462. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  60463. }
  60464. callback(result);
  60465. };
  60466. Effect.prototype._processIncludes = function (sourceCode, callback) {
  60467. var _this = this;
  60468. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  60469. var match = regex.exec(sourceCode);
  60470. var returnValue = new String(sourceCode);
  60471. while (match != null) {
  60472. var includeFile = match[1];
  60473. // Uniform declaration
  60474. if (includeFile.indexOf("__decl__") !== -1) {
  60475. includeFile = includeFile.replace(/__decl__/, "");
  60476. if (this._engine.supportsUniformBuffers) {
  60477. includeFile = includeFile.replace(/Vertex/, "Ubo");
  60478. includeFile = includeFile.replace(/Fragment/, "Ubo");
  60479. }
  60480. includeFile = includeFile + "Declaration";
  60481. }
  60482. if (Effect.IncludesShadersStore[includeFile]) {
  60483. // Substitution
  60484. var includeContent = Effect.IncludesShadersStore[includeFile];
  60485. if (match[2]) {
  60486. var splits = match[3].split(",");
  60487. for (var index = 0; index < splits.length; index += 2) {
  60488. var source = new RegExp(splits[index], "g");
  60489. var dest = splits[index + 1];
  60490. includeContent = includeContent.replace(source, dest);
  60491. }
  60492. }
  60493. if (match[4]) {
  60494. var indexString = match[5];
  60495. if (indexString.indexOf("..") !== -1) {
  60496. var indexSplits = indexString.split("..");
  60497. var minIndex = parseInt(indexSplits[0]);
  60498. var maxIndex = parseInt(indexSplits[1]);
  60499. var sourceIncludeContent = includeContent.slice(0);
  60500. includeContent = "";
  60501. if (isNaN(maxIndex)) {
  60502. maxIndex = this._indexParameters[indexSplits[1]];
  60503. }
  60504. for (var i = minIndex; i < maxIndex; i++) {
  60505. if (!this._engine.supportsUniformBuffers) {
  60506. // Ubo replacement
  60507. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60508. return p1 + "{X}";
  60509. });
  60510. }
  60511. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  60512. }
  60513. }
  60514. else {
  60515. if (!this._engine.supportsUniformBuffers) {
  60516. // Ubo replacement
  60517. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60518. return p1 + "{X}";
  60519. });
  60520. }
  60521. includeContent = includeContent.replace(/\{X\}/g, indexString);
  60522. }
  60523. }
  60524. // Replace
  60525. returnValue = returnValue.replace(match[0], includeContent);
  60526. }
  60527. else {
  60528. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  60529. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  60530. Effect.IncludesShadersStore[includeFile] = fileContent;
  60531. _this._processIncludes(returnValue, callback);
  60532. });
  60533. return;
  60534. }
  60535. match = regex.exec(sourceCode);
  60536. }
  60537. callback(returnValue);
  60538. };
  60539. Effect.prototype._processPrecision = function (source) {
  60540. if (source.indexOf("precision highp float") === -1) {
  60541. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  60542. source = "precision mediump float;\n" + source;
  60543. }
  60544. else {
  60545. source = "precision highp float;\n" + source;
  60546. }
  60547. }
  60548. else {
  60549. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  60550. source = source.replace("precision highp float", "precision mediump float");
  60551. }
  60552. }
  60553. return source;
  60554. };
  60555. /**
  60556. * Recompiles the webGL program
  60557. * @param vertexSourceCode The source code for the vertex shader.
  60558. * @param fragmentSourceCode The source code for the fragment shader.
  60559. * @param onCompiled Callback called when completed.
  60560. * @param onError Callback called on error.
  60561. * @hidden
  60562. */
  60563. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  60564. var _this = this;
  60565. this._isReady = false;
  60566. this._vertexSourceCodeOverride = vertexSourceCode;
  60567. this._fragmentSourceCodeOverride = fragmentSourceCode;
  60568. this.onError = function (effect, error) {
  60569. if (onError) {
  60570. onError(error);
  60571. }
  60572. };
  60573. this.onCompiled = function () {
  60574. var scenes = _this.getEngine().scenes;
  60575. for (var i = 0; i < scenes.length; i++) {
  60576. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60577. }
  60578. if (onCompiled) {
  60579. onCompiled(_this._program);
  60580. }
  60581. };
  60582. this._fallbacks = null;
  60583. this._prepareEffect();
  60584. };
  60585. /**
  60586. * Gets the uniform locations of the the specified variable names
  60587. * @param names THe names of the variables to lookup.
  60588. * @returns Array of locations in the same order as variable names.
  60589. */
  60590. Effect.prototype.getSpecificUniformLocations = function (names) {
  60591. var engine = this._engine;
  60592. return engine.getUniforms(this._program, names);
  60593. };
  60594. /**
  60595. * Prepares the effect
  60596. * @hidden
  60597. */
  60598. Effect.prototype._prepareEffect = function () {
  60599. var _this = this;
  60600. var attributesNames = this._attributesNames;
  60601. var defines = this.defines;
  60602. var fallbacks = this._fallbacks;
  60603. this._valueCache = {};
  60604. var previousProgram = this._program;
  60605. try {
  60606. var engine_1 = this._engine;
  60607. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60608. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60609. }
  60610. else {
  60611. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60612. }
  60613. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60614. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60615. if (engine_1.supportsUniformBuffers) {
  60616. for (var name in _this._uniformBuffersNames) {
  60617. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60618. }
  60619. }
  60620. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60621. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60622. var index;
  60623. for (index = 0; index < _this._samplers.length; index++) {
  60624. var sampler = _this.getUniform(_this._samplers[index]);
  60625. if (sampler == null) {
  60626. _this._samplers.splice(index, 1);
  60627. index--;
  60628. }
  60629. }
  60630. engine_1.bindSamplers(_this);
  60631. _this._compilationError = "";
  60632. _this._isReady = true;
  60633. if (_this.onCompiled) {
  60634. _this.onCompiled(_this);
  60635. }
  60636. _this.onCompileObservable.notifyObservers(_this);
  60637. _this.onCompileObservable.clear();
  60638. // Unbind mesh reference in fallbacks
  60639. if (_this._fallbacks) {
  60640. _this._fallbacks.unBindMesh();
  60641. }
  60642. if (previousProgram) {
  60643. _this.getEngine()._deleteProgram(previousProgram);
  60644. }
  60645. });
  60646. if (this._program.isParallelCompiled) {
  60647. this._checkIsReady();
  60648. }
  60649. }
  60650. catch (e) {
  60651. this._compilationError = e.message;
  60652. // Let's go through fallbacks then
  60653. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60654. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60655. return " " + uniform;
  60656. }));
  60657. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60658. return " " + attribute;
  60659. }));
  60660. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60661. if (previousProgram) {
  60662. this._program = previousProgram;
  60663. this._isReady = true;
  60664. if (this.onError) {
  60665. this.onError(this, this._compilationError);
  60666. }
  60667. this.onErrorObservable.notifyObservers(this);
  60668. }
  60669. if (fallbacks && fallbacks.isMoreFallbacks) {
  60670. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60671. this.defines = fallbacks.reduce(this.defines, this);
  60672. this._prepareEffect();
  60673. }
  60674. else { // Sorry we did everything we can
  60675. if (this.onError) {
  60676. this.onError(this, this._compilationError);
  60677. }
  60678. this.onErrorObservable.notifyObservers(this);
  60679. this.onErrorObservable.clear();
  60680. // Unbind mesh reference in fallbacks
  60681. if (this._fallbacks) {
  60682. this._fallbacks.unBindMesh();
  60683. }
  60684. }
  60685. }
  60686. };
  60687. Object.defineProperty(Effect.prototype, "isSupported", {
  60688. /**
  60689. * Checks if the effect is supported. (Must be called after compilation)
  60690. */
  60691. get: function () {
  60692. return this._compilationError === "";
  60693. },
  60694. enumerable: true,
  60695. configurable: true
  60696. });
  60697. /**
  60698. * Binds a texture to the engine to be used as output of the shader.
  60699. * @param channel Name of the output variable.
  60700. * @param texture Texture to bind.
  60701. * @hidden
  60702. */
  60703. Effect.prototype._bindTexture = function (channel, texture) {
  60704. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60705. };
  60706. /**
  60707. * Sets a texture on the engine to be used in the shader.
  60708. * @param channel Name of the sampler variable.
  60709. * @param texture Texture to set.
  60710. */
  60711. Effect.prototype.setTexture = function (channel, texture) {
  60712. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60713. };
  60714. /**
  60715. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60716. * @param channel Name of the sampler variable.
  60717. * @param texture Texture to set.
  60718. */
  60719. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60720. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60721. };
  60722. /**
  60723. * Sets an array of textures on the engine to be used in the shader.
  60724. * @param channel Name of the variable.
  60725. * @param textures Textures to set.
  60726. */
  60727. Effect.prototype.setTextureArray = function (channel, textures) {
  60728. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60729. var initialPos = this._samplers.indexOf(channel);
  60730. for (var index = 1; index < textures.length; index++) {
  60731. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60732. }
  60733. }
  60734. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60735. };
  60736. /**
  60737. * 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)
  60738. * @param channel Name of the sampler variable.
  60739. * @param postProcess Post process to get the input texture from.
  60740. */
  60741. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60742. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60743. };
  60744. /**
  60745. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60746. * 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)
  60747. * @param channel Name of the sampler variable.
  60748. * @param postProcess Post process to get the output texture from.
  60749. */
  60750. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60751. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60752. };
  60753. /** @hidden */
  60754. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60755. var cache = this._valueCache[uniformName];
  60756. var flag = matrix.updateFlag;
  60757. if (cache !== undefined && cache === flag) {
  60758. return false;
  60759. }
  60760. this._valueCache[uniformName] = flag;
  60761. return true;
  60762. };
  60763. /** @hidden */
  60764. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60765. var cache = this._valueCache[uniformName];
  60766. if (!cache) {
  60767. cache = [x, y];
  60768. this._valueCache[uniformName] = cache;
  60769. return true;
  60770. }
  60771. var changed = false;
  60772. if (cache[0] !== x) {
  60773. cache[0] = x;
  60774. changed = true;
  60775. }
  60776. if (cache[1] !== y) {
  60777. cache[1] = y;
  60778. changed = true;
  60779. }
  60780. return changed;
  60781. };
  60782. /** @hidden */
  60783. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60784. var cache = this._valueCache[uniformName];
  60785. if (!cache) {
  60786. cache = [x, y, z];
  60787. this._valueCache[uniformName] = cache;
  60788. return true;
  60789. }
  60790. var changed = false;
  60791. if (cache[0] !== x) {
  60792. cache[0] = x;
  60793. changed = true;
  60794. }
  60795. if (cache[1] !== y) {
  60796. cache[1] = y;
  60797. changed = true;
  60798. }
  60799. if (cache[2] !== z) {
  60800. cache[2] = z;
  60801. changed = true;
  60802. }
  60803. return changed;
  60804. };
  60805. /** @hidden */
  60806. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60807. var cache = this._valueCache[uniformName];
  60808. if (!cache) {
  60809. cache = [x, y, z, w];
  60810. this._valueCache[uniformName] = cache;
  60811. return true;
  60812. }
  60813. var changed = false;
  60814. if (cache[0] !== x) {
  60815. cache[0] = x;
  60816. changed = true;
  60817. }
  60818. if (cache[1] !== y) {
  60819. cache[1] = y;
  60820. changed = true;
  60821. }
  60822. if (cache[2] !== z) {
  60823. cache[2] = z;
  60824. changed = true;
  60825. }
  60826. if (cache[3] !== w) {
  60827. cache[3] = w;
  60828. changed = true;
  60829. }
  60830. return changed;
  60831. };
  60832. /**
  60833. * Binds a buffer to a uniform.
  60834. * @param buffer Buffer to bind.
  60835. * @param name Name of the uniform variable to bind to.
  60836. */
  60837. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60838. var bufferName = this._uniformBuffersNames[name];
  60839. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60840. return;
  60841. }
  60842. Effect._baseCache[bufferName] = buffer;
  60843. this._engine.bindUniformBufferBase(buffer, bufferName);
  60844. };
  60845. /**
  60846. * Binds block to a uniform.
  60847. * @param blockName Name of the block to bind.
  60848. * @param index Index to bind.
  60849. */
  60850. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60851. this._engine.bindUniformBlock(this._program, blockName, index);
  60852. };
  60853. /**
  60854. * Sets an interger value on a uniform variable.
  60855. * @param uniformName Name of the variable.
  60856. * @param value Value to be set.
  60857. * @returns this effect.
  60858. */
  60859. Effect.prototype.setInt = function (uniformName, value) {
  60860. var cache = this._valueCache[uniformName];
  60861. if (cache !== undefined && cache === value) {
  60862. return this;
  60863. }
  60864. this._valueCache[uniformName] = value;
  60865. this._engine.setInt(this.getUniform(uniformName), value);
  60866. return this;
  60867. };
  60868. /**
  60869. * Sets an int array on a uniform variable.
  60870. * @param uniformName Name of the variable.
  60871. * @param array array to be set.
  60872. * @returns this effect.
  60873. */
  60874. Effect.prototype.setIntArray = function (uniformName, array) {
  60875. this._valueCache[uniformName] = null;
  60876. this._engine.setIntArray(this.getUniform(uniformName), array);
  60877. return this;
  60878. };
  60879. /**
  60880. * 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)
  60881. * @param uniformName Name of the variable.
  60882. * @param array array to be set.
  60883. * @returns this effect.
  60884. */
  60885. Effect.prototype.setIntArray2 = function (uniformName, array) {
  60886. this._valueCache[uniformName] = null;
  60887. this._engine.setIntArray2(this.getUniform(uniformName), array);
  60888. return this;
  60889. };
  60890. /**
  60891. * 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)
  60892. * @param uniformName Name of the variable.
  60893. * @param array array to be set.
  60894. * @returns this effect.
  60895. */
  60896. Effect.prototype.setIntArray3 = function (uniformName, array) {
  60897. this._valueCache[uniformName] = null;
  60898. this._engine.setIntArray3(this.getUniform(uniformName), array);
  60899. return this;
  60900. };
  60901. /**
  60902. * 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)
  60903. * @param uniformName Name of the variable.
  60904. * @param array array to be set.
  60905. * @returns this effect.
  60906. */
  60907. Effect.prototype.setIntArray4 = function (uniformName, array) {
  60908. this._valueCache[uniformName] = null;
  60909. this._engine.setIntArray4(this.getUniform(uniformName), array);
  60910. return this;
  60911. };
  60912. /**
  60913. * Sets an float array on a uniform variable.
  60914. * @param uniformName Name of the variable.
  60915. * @param array array to be set.
  60916. * @returns this effect.
  60917. */
  60918. Effect.prototype.setFloatArray = function (uniformName, array) {
  60919. this._valueCache[uniformName] = null;
  60920. this._engine.setFloatArray(this.getUniform(uniformName), array);
  60921. return this;
  60922. };
  60923. /**
  60924. * 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)
  60925. * @param uniformName Name of the variable.
  60926. * @param array array to be set.
  60927. * @returns this effect.
  60928. */
  60929. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  60930. this._valueCache[uniformName] = null;
  60931. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  60932. return this;
  60933. };
  60934. /**
  60935. * 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)
  60936. * @param uniformName Name of the variable.
  60937. * @param array array to be set.
  60938. * @returns this effect.
  60939. */
  60940. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  60941. this._valueCache[uniformName] = null;
  60942. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  60943. return this;
  60944. };
  60945. /**
  60946. * 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)
  60947. * @param uniformName Name of the variable.
  60948. * @param array array to be set.
  60949. * @returns this effect.
  60950. */
  60951. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  60952. this._valueCache[uniformName] = null;
  60953. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  60954. return this;
  60955. };
  60956. /**
  60957. * Sets an array on a uniform variable.
  60958. * @param uniformName Name of the variable.
  60959. * @param array array to be set.
  60960. * @returns this effect.
  60961. */
  60962. Effect.prototype.setArray = function (uniformName, array) {
  60963. this._valueCache[uniformName] = null;
  60964. this._engine.setArray(this.getUniform(uniformName), array);
  60965. return this;
  60966. };
  60967. /**
  60968. * 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)
  60969. * @param uniformName Name of the variable.
  60970. * @param array array to be set.
  60971. * @returns this effect.
  60972. */
  60973. Effect.prototype.setArray2 = function (uniformName, array) {
  60974. this._valueCache[uniformName] = null;
  60975. this._engine.setArray2(this.getUniform(uniformName), array);
  60976. return this;
  60977. };
  60978. /**
  60979. * 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)
  60980. * @param uniformName Name of the variable.
  60981. * @param array array to be set.
  60982. * @returns this effect.
  60983. */
  60984. Effect.prototype.setArray3 = function (uniformName, array) {
  60985. this._valueCache[uniformName] = null;
  60986. this._engine.setArray3(this.getUniform(uniformName), array);
  60987. return this;
  60988. };
  60989. /**
  60990. * 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)
  60991. * @param uniformName Name of the variable.
  60992. * @param array array to be set.
  60993. * @returns this effect.
  60994. */
  60995. Effect.prototype.setArray4 = function (uniformName, array) {
  60996. this._valueCache[uniformName] = null;
  60997. this._engine.setArray4(this.getUniform(uniformName), array);
  60998. return this;
  60999. };
  61000. /**
  61001. * Sets matrices on a uniform variable.
  61002. * @param uniformName Name of the variable.
  61003. * @param matrices matrices to be set.
  61004. * @returns this effect.
  61005. */
  61006. Effect.prototype.setMatrices = function (uniformName, matrices) {
  61007. if (!matrices) {
  61008. return this;
  61009. }
  61010. this._valueCache[uniformName] = null;
  61011. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  61012. return this;
  61013. };
  61014. /**
  61015. * Sets matrix on a uniform variable.
  61016. * @param uniformName Name of the variable.
  61017. * @param matrix matrix to be set.
  61018. * @returns this effect.
  61019. */
  61020. Effect.prototype.setMatrix = function (uniformName, matrix) {
  61021. if (this._cacheMatrix(uniformName, matrix)) {
  61022. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  61023. }
  61024. return this;
  61025. };
  61026. /**
  61027. * 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)
  61028. * @param uniformName Name of the variable.
  61029. * @param matrix matrix to be set.
  61030. * @returns this effect.
  61031. */
  61032. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  61033. this._valueCache[uniformName] = null;
  61034. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  61035. return this;
  61036. };
  61037. /**
  61038. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  61039. * @param uniformName Name of the variable.
  61040. * @param matrix matrix to be set.
  61041. * @returns this effect.
  61042. */
  61043. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  61044. this._valueCache[uniformName] = null;
  61045. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  61046. return this;
  61047. };
  61048. /**
  61049. * Sets a float on a uniform variable.
  61050. * @param uniformName Name of the variable.
  61051. * @param value value to be set.
  61052. * @returns this effect.
  61053. */
  61054. Effect.prototype.setFloat = function (uniformName, value) {
  61055. var cache = this._valueCache[uniformName];
  61056. if (cache !== undefined && cache === value) {
  61057. return this;
  61058. }
  61059. this._valueCache[uniformName] = value;
  61060. this._engine.setFloat(this.getUniform(uniformName), value);
  61061. return this;
  61062. };
  61063. /**
  61064. * Sets a boolean on a uniform variable.
  61065. * @param uniformName Name of the variable.
  61066. * @param bool value to be set.
  61067. * @returns this effect.
  61068. */
  61069. Effect.prototype.setBool = function (uniformName, bool) {
  61070. var cache = this._valueCache[uniformName];
  61071. if (cache !== undefined && cache === bool) {
  61072. return this;
  61073. }
  61074. this._valueCache[uniformName] = bool;
  61075. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  61076. return this;
  61077. };
  61078. /**
  61079. * Sets a Vector2 on a uniform variable.
  61080. * @param uniformName Name of the variable.
  61081. * @param vector2 vector2 to be set.
  61082. * @returns this effect.
  61083. */
  61084. Effect.prototype.setVector2 = function (uniformName, vector2) {
  61085. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  61086. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  61087. }
  61088. return this;
  61089. };
  61090. /**
  61091. * Sets a float2 on a uniform variable.
  61092. * @param uniformName Name of the variable.
  61093. * @param x First float in float2.
  61094. * @param y Second float in float2.
  61095. * @returns this effect.
  61096. */
  61097. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  61098. if (this._cacheFloat2(uniformName, x, y)) {
  61099. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  61100. }
  61101. return this;
  61102. };
  61103. /**
  61104. * Sets a Vector3 on a uniform variable.
  61105. * @param uniformName Name of the variable.
  61106. * @param vector3 Value to be set.
  61107. * @returns this effect.
  61108. */
  61109. Effect.prototype.setVector3 = function (uniformName, vector3) {
  61110. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  61111. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  61112. }
  61113. return this;
  61114. };
  61115. /**
  61116. * Sets a float3 on a uniform variable.
  61117. * @param uniformName Name of the variable.
  61118. * @param x First float in float3.
  61119. * @param y Second float in float3.
  61120. * @param z Third float in float3.
  61121. * @returns this effect.
  61122. */
  61123. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  61124. if (this._cacheFloat3(uniformName, x, y, z)) {
  61125. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  61126. }
  61127. return this;
  61128. };
  61129. /**
  61130. * Sets a Vector4 on a uniform variable.
  61131. * @param uniformName Name of the variable.
  61132. * @param vector4 Value to be set.
  61133. * @returns this effect.
  61134. */
  61135. Effect.prototype.setVector4 = function (uniformName, vector4) {
  61136. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  61137. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  61138. }
  61139. return this;
  61140. };
  61141. /**
  61142. * Sets a float4 on a uniform variable.
  61143. * @param uniformName Name of the variable.
  61144. * @param x First float in float4.
  61145. * @param y Second float in float4.
  61146. * @param z Third float in float4.
  61147. * @param w Fourth float in float4.
  61148. * @returns this effect.
  61149. */
  61150. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  61151. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  61152. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  61153. }
  61154. return this;
  61155. };
  61156. /**
  61157. * Sets a Color3 on a uniform variable.
  61158. * @param uniformName Name of the variable.
  61159. * @param color3 Value to be set.
  61160. * @returns this effect.
  61161. */
  61162. Effect.prototype.setColor3 = function (uniformName, color3) {
  61163. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  61164. this._engine.setColor3(this.getUniform(uniformName), color3);
  61165. }
  61166. return this;
  61167. };
  61168. /**
  61169. * Sets a Color4 on a uniform variable.
  61170. * @param uniformName Name of the variable.
  61171. * @param color3 Value to be set.
  61172. * @param alpha Alpha value to be set.
  61173. * @returns this effect.
  61174. */
  61175. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61176. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61177. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61178. }
  61179. return this;
  61180. };
  61181. /**
  61182. * Sets a Color4 on a uniform variable
  61183. * @param uniformName defines the name of the variable
  61184. * @param color4 defines the value to be set
  61185. * @returns this effect.
  61186. */
  61187. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61188. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61189. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61190. }
  61191. return this;
  61192. };
  61193. /**
  61194. * This function will add a new shader to the shader store
  61195. * @param name the name of the shader
  61196. * @param pixelShader optional pixel shader content
  61197. * @param vertexShader optional vertex shader content
  61198. */
  61199. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61200. if (pixelShader) {
  61201. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61202. }
  61203. if (vertexShader) {
  61204. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61205. }
  61206. };
  61207. /**
  61208. * Resets the cache of effects.
  61209. */
  61210. Effect.ResetCache = function () {
  61211. Effect._baseCache = {};
  61212. };
  61213. /**
  61214. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61215. */
  61216. Effect.ShadersRepository = "src/Shaders/";
  61217. Effect._uniqueIdSeed = 0;
  61218. Effect._baseCache = {};
  61219. /**
  61220. * Store of each shader (The can be looked up using effect.key)
  61221. */
  61222. Effect.ShadersStore = {};
  61223. /**
  61224. * Store of each included file for a shader (The can be looked up using effect.key)
  61225. */
  61226. Effect.IncludesShadersStore = {};
  61227. return Effect;
  61228. }());
  61229. /***/ }),
  61230. /***/ "./Materials/fresnelParameters.ts":
  61231. /*!****************************************!*\
  61232. !*** ./Materials/fresnelParameters.ts ***!
  61233. \****************************************/
  61234. /*! exports provided: FresnelParameters */
  61235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61236. "use strict";
  61237. __webpack_require__.r(__webpack_exports__);
  61238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61239. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61240. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61241. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61242. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61243. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61244. /**
  61245. * This represents all the required information to add a fresnel effect on a material:
  61246. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61247. */
  61248. var FresnelParameters = /** @class */ (function () {
  61249. function FresnelParameters() {
  61250. this._isEnabled = true;
  61251. /**
  61252. * Define the color used on edges (grazing angle)
  61253. */
  61254. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61255. /**
  61256. * Define the color used on center
  61257. */
  61258. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61259. /**
  61260. * Define bias applied to computed fresnel term
  61261. */
  61262. this.bias = 0;
  61263. /**
  61264. * Defined the power exponent applied to fresnel term
  61265. */
  61266. this.power = 1;
  61267. }
  61268. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61269. /**
  61270. * Define if the fresnel effect is enable or not.
  61271. */
  61272. get: function () {
  61273. return this._isEnabled;
  61274. },
  61275. set: function (value) {
  61276. if (this._isEnabled === value) {
  61277. return;
  61278. }
  61279. this._isEnabled = value;
  61280. _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);
  61281. },
  61282. enumerable: true,
  61283. configurable: true
  61284. });
  61285. /**
  61286. * Clones the current fresnel and its valuues
  61287. * @returns a clone fresnel configuration
  61288. */
  61289. FresnelParameters.prototype.clone = function () {
  61290. var newFresnelParameters = new FresnelParameters();
  61291. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61292. return newFresnelParameters;
  61293. };
  61294. /**
  61295. * Serializes the current fresnel parameters to a JSON representation.
  61296. * @return the JSON serialization
  61297. */
  61298. FresnelParameters.prototype.serialize = function () {
  61299. var serializationObject = {};
  61300. serializationObject.isEnabled = this.isEnabled;
  61301. serializationObject.leftColor = this.leftColor.asArray();
  61302. serializationObject.rightColor = this.rightColor.asArray();
  61303. serializationObject.bias = this.bias;
  61304. serializationObject.power = this.power;
  61305. return serializationObject;
  61306. };
  61307. /**
  61308. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61309. * @param parsedFresnelParameters Define the JSON representation
  61310. * @returns the parsed parameters
  61311. */
  61312. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61313. var fresnelParameters = new FresnelParameters();
  61314. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61315. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61316. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61317. fresnelParameters.bias = parsedFresnelParameters.bias;
  61318. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61319. return fresnelParameters;
  61320. };
  61321. return FresnelParameters;
  61322. }());
  61323. // References the dependencies.
  61324. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61325. /***/ }),
  61326. /***/ "./Materials/imageProcessingConfiguration.ts":
  61327. /*!***************************************************!*\
  61328. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61329. \***************************************************/
  61330. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61332. "use strict";
  61333. __webpack_require__.r(__webpack_exports__);
  61334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61337. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61338. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61339. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61340. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61341. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61342. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61343. /**
  61344. * @hidden
  61345. */
  61346. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61348. function ImageProcessingConfigurationDefines() {
  61349. var _this = _super.call(this) || this;
  61350. _this.IMAGEPROCESSING = false;
  61351. _this.VIGNETTE = false;
  61352. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61353. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61354. _this.TONEMAPPING = false;
  61355. _this.TONEMAPPING_ACES = false;
  61356. _this.CONTRAST = false;
  61357. _this.COLORCURVES = false;
  61358. _this.COLORGRADING = false;
  61359. _this.COLORGRADING3D = false;
  61360. _this.SAMPLER3DGREENDEPTH = false;
  61361. _this.SAMPLER3DBGRMAP = false;
  61362. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61363. _this.EXPOSURE = false;
  61364. _this.rebuild();
  61365. return _this;
  61366. }
  61367. return ImageProcessingConfigurationDefines;
  61368. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61369. /**
  61370. * This groups together the common properties used for image processing either in direct forward pass
  61371. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61372. * or not.
  61373. */
  61374. var ImageProcessingConfiguration = /** @class */ (function () {
  61375. function ImageProcessingConfiguration() {
  61376. /**
  61377. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61378. */
  61379. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61380. this._colorCurvesEnabled = false;
  61381. this._colorGradingEnabled = false;
  61382. this._colorGradingWithGreenDepth = true;
  61383. this._colorGradingBGR = true;
  61384. /** @hidden */
  61385. this._exposure = 1.0;
  61386. this._toneMappingEnabled = false;
  61387. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61388. this._contrast = 1.0;
  61389. /**
  61390. * Vignette stretch size.
  61391. */
  61392. this.vignetteStretch = 0;
  61393. /**
  61394. * Vignette centre X Offset.
  61395. */
  61396. this.vignetteCentreX = 0;
  61397. /**
  61398. * Vignette centre Y Offset.
  61399. */
  61400. this.vignetteCentreY = 0;
  61401. /**
  61402. * Vignette weight or intensity of the vignette effect.
  61403. */
  61404. this.vignetteWeight = 1.5;
  61405. /**
  61406. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61407. * if vignetteEnabled is set to true.
  61408. */
  61409. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61410. /**
  61411. * Camera field of view used by the Vignette effect.
  61412. */
  61413. this.vignetteCameraFov = 0.5;
  61414. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61415. this._vignetteEnabled = false;
  61416. this._applyByPostProcess = false;
  61417. this._isEnabled = true;
  61418. /**
  61419. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61420. */
  61421. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61422. }
  61423. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61424. /**
  61425. * Gets wether the color curves effect is enabled.
  61426. */
  61427. get: function () {
  61428. return this._colorCurvesEnabled;
  61429. },
  61430. /**
  61431. * Sets wether the color curves effect is enabled.
  61432. */
  61433. set: function (value) {
  61434. if (this._colorCurvesEnabled === value) {
  61435. return;
  61436. }
  61437. this._colorCurvesEnabled = value;
  61438. this._updateParameters();
  61439. },
  61440. enumerable: true,
  61441. configurable: true
  61442. });
  61443. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61444. /**
  61445. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61446. */
  61447. get: function () {
  61448. return this._colorGradingTexture;
  61449. },
  61450. /**
  61451. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61452. */
  61453. set: function (value) {
  61454. if (this._colorGradingTexture === value) {
  61455. return;
  61456. }
  61457. this._colorGradingTexture = value;
  61458. this._updateParameters();
  61459. },
  61460. enumerable: true,
  61461. configurable: true
  61462. });
  61463. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  61464. /**
  61465. * Gets wether the color grading effect is enabled.
  61466. */
  61467. get: function () {
  61468. return this._colorGradingEnabled;
  61469. },
  61470. /**
  61471. * Sets wether the color grading effect is enabled.
  61472. */
  61473. set: function (value) {
  61474. if (this._colorGradingEnabled === value) {
  61475. return;
  61476. }
  61477. this._colorGradingEnabled = value;
  61478. this._updateParameters();
  61479. },
  61480. enumerable: true,
  61481. configurable: true
  61482. });
  61483. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  61484. /**
  61485. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  61486. */
  61487. get: function () {
  61488. return this._colorGradingWithGreenDepth;
  61489. },
  61490. /**
  61491. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  61492. */
  61493. set: function (value) {
  61494. if (this._colorGradingWithGreenDepth === value) {
  61495. return;
  61496. }
  61497. this._colorGradingWithGreenDepth = value;
  61498. this._updateParameters();
  61499. },
  61500. enumerable: true,
  61501. configurable: true
  61502. });
  61503. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  61504. /**
  61505. * Gets wether the color grading texture contains BGR values.
  61506. */
  61507. get: function () {
  61508. return this._colorGradingBGR;
  61509. },
  61510. /**
  61511. * Sets wether the color grading texture contains BGR values.
  61512. */
  61513. set: function (value) {
  61514. if (this._colorGradingBGR === value) {
  61515. return;
  61516. }
  61517. this._colorGradingBGR = value;
  61518. this._updateParameters();
  61519. },
  61520. enumerable: true,
  61521. configurable: true
  61522. });
  61523. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  61524. /**
  61525. * Gets the Exposure used in the effect.
  61526. */
  61527. get: function () {
  61528. return this._exposure;
  61529. },
  61530. /**
  61531. * Sets the Exposure used in the effect.
  61532. */
  61533. set: function (value) {
  61534. if (this._exposure === value) {
  61535. return;
  61536. }
  61537. this._exposure = value;
  61538. this._updateParameters();
  61539. },
  61540. enumerable: true,
  61541. configurable: true
  61542. });
  61543. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  61544. /**
  61545. * Gets wether the tone mapping effect is enabled.
  61546. */
  61547. get: function () {
  61548. return this._toneMappingEnabled;
  61549. },
  61550. /**
  61551. * Sets wether the tone mapping effect is enabled.
  61552. */
  61553. set: function (value) {
  61554. if (this._toneMappingEnabled === value) {
  61555. return;
  61556. }
  61557. this._toneMappingEnabled = value;
  61558. this._updateParameters();
  61559. },
  61560. enumerable: true,
  61561. configurable: true
  61562. });
  61563. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  61564. /**
  61565. * Gets the type of tone mapping effect.
  61566. */
  61567. get: function () {
  61568. return this._toneMappingType;
  61569. },
  61570. /**
  61571. * Sets the type of tone mapping effect used in BabylonJS.
  61572. */
  61573. set: function (value) {
  61574. if (this._toneMappingType === value) {
  61575. return;
  61576. }
  61577. this._toneMappingType = value;
  61578. this._updateParameters();
  61579. },
  61580. enumerable: true,
  61581. configurable: true
  61582. });
  61583. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61584. /**
  61585. * Gets the contrast used in the effect.
  61586. */
  61587. get: function () {
  61588. return this._contrast;
  61589. },
  61590. /**
  61591. * Sets the contrast used in the effect.
  61592. */
  61593. set: function (value) {
  61594. if (this._contrast === value) {
  61595. return;
  61596. }
  61597. this._contrast = value;
  61598. this._updateParameters();
  61599. },
  61600. enumerable: true,
  61601. configurable: true
  61602. });
  61603. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61604. /**
  61605. * Gets the vignette blend mode allowing different kind of effect.
  61606. */
  61607. get: function () {
  61608. return this._vignetteBlendMode;
  61609. },
  61610. /**
  61611. * Sets the vignette blend mode allowing different kind of effect.
  61612. */
  61613. set: function (value) {
  61614. if (this._vignetteBlendMode === value) {
  61615. return;
  61616. }
  61617. this._vignetteBlendMode = value;
  61618. this._updateParameters();
  61619. },
  61620. enumerable: true,
  61621. configurable: true
  61622. });
  61623. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61624. /**
  61625. * Gets wether the vignette effect is enabled.
  61626. */
  61627. get: function () {
  61628. return this._vignetteEnabled;
  61629. },
  61630. /**
  61631. * Sets wether the vignette effect is enabled.
  61632. */
  61633. set: function (value) {
  61634. if (this._vignetteEnabled === value) {
  61635. return;
  61636. }
  61637. this._vignetteEnabled = value;
  61638. this._updateParameters();
  61639. },
  61640. enumerable: true,
  61641. configurable: true
  61642. });
  61643. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61644. /**
  61645. * Gets wether the image processing is applied through a post process or not.
  61646. */
  61647. get: function () {
  61648. return this._applyByPostProcess;
  61649. },
  61650. /**
  61651. * Sets wether the image processing is applied through a post process or not.
  61652. */
  61653. set: function (value) {
  61654. if (this._applyByPostProcess === value) {
  61655. return;
  61656. }
  61657. this._applyByPostProcess = value;
  61658. this._updateParameters();
  61659. },
  61660. enumerable: true,
  61661. configurable: true
  61662. });
  61663. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61664. /**
  61665. * Gets wether the image processing is enabled or not.
  61666. */
  61667. get: function () {
  61668. return this._isEnabled;
  61669. },
  61670. /**
  61671. * Sets wether the image processing is enabled or not.
  61672. */
  61673. set: function (value) {
  61674. if (this._isEnabled === value) {
  61675. return;
  61676. }
  61677. this._isEnabled = value;
  61678. this._updateParameters();
  61679. },
  61680. enumerable: true,
  61681. configurable: true
  61682. });
  61683. /**
  61684. * Method called each time the image processing information changes requires to recompile the effect.
  61685. */
  61686. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61687. this.onUpdateParameters.notifyObservers(this);
  61688. };
  61689. /**
  61690. * Gets the current class name.
  61691. * @return "ImageProcessingConfiguration"
  61692. */
  61693. ImageProcessingConfiguration.prototype.getClassName = function () {
  61694. return "ImageProcessingConfiguration";
  61695. };
  61696. /**
  61697. * Prepare the list of uniforms associated with the Image Processing effects.
  61698. * @param uniforms The list of uniforms used in the effect
  61699. * @param defines the list of defines currently in use
  61700. */
  61701. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61702. if (defines.EXPOSURE) {
  61703. uniforms.push("exposureLinear");
  61704. }
  61705. if (defines.CONTRAST) {
  61706. uniforms.push("contrast");
  61707. }
  61708. if (defines.COLORGRADING) {
  61709. uniforms.push("colorTransformSettings");
  61710. }
  61711. if (defines.VIGNETTE) {
  61712. uniforms.push("vInverseScreenSize");
  61713. uniforms.push("vignetteSettings1");
  61714. uniforms.push("vignetteSettings2");
  61715. }
  61716. if (defines.COLORCURVES) {
  61717. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61718. }
  61719. };
  61720. /**
  61721. * Prepare the list of samplers associated with the Image Processing effects.
  61722. * @param samplersList The list of uniforms used in the effect
  61723. * @param defines the list of defines currently in use
  61724. */
  61725. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61726. if (defines.COLORGRADING) {
  61727. samplersList.push("txColorTransform");
  61728. }
  61729. };
  61730. /**
  61731. * Prepare the list of defines associated to the shader.
  61732. * @param defines the list of defines to complete
  61733. * @param forPostProcess Define if we are currently in post process mode or not
  61734. */
  61735. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61736. if (forPostProcess === void 0) { forPostProcess = false; }
  61737. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61738. defines.VIGNETTE = false;
  61739. defines.TONEMAPPING = false;
  61740. defines.TONEMAPPING_ACES = false;
  61741. defines.CONTRAST = false;
  61742. defines.EXPOSURE = false;
  61743. defines.COLORCURVES = false;
  61744. defines.COLORGRADING = false;
  61745. defines.COLORGRADING3D = false;
  61746. defines.IMAGEPROCESSING = false;
  61747. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61748. return;
  61749. }
  61750. defines.VIGNETTE = this.vignetteEnabled;
  61751. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61752. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61753. defines.TONEMAPPING = this.toneMappingEnabled;
  61754. switch (this._toneMappingType) {
  61755. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61756. defines.TONEMAPPING_ACES = true;
  61757. break;
  61758. default:
  61759. defines.TONEMAPPING_ACES = false;
  61760. break;
  61761. }
  61762. defines.CONTRAST = (this.contrast !== 1.0);
  61763. defines.EXPOSURE = (this.exposure !== 1.0);
  61764. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61765. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61766. if (defines.COLORGRADING) {
  61767. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61768. }
  61769. else {
  61770. defines.COLORGRADING3D = false;
  61771. }
  61772. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61773. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61774. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61775. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61776. };
  61777. /**
  61778. * Returns true if all the image processing information are ready.
  61779. * @returns True if ready, otherwise, false
  61780. */
  61781. ImageProcessingConfiguration.prototype.isReady = function () {
  61782. // Color Grading texure can not be none blocking.
  61783. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61784. };
  61785. /**
  61786. * Binds the image processing to the shader.
  61787. * @param effect The effect to bind to
  61788. * @param aspectRatio Define the current aspect ratio of the effect
  61789. */
  61790. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61791. if (aspectRatio === void 0) { aspectRatio = 1; }
  61792. // Color Curves
  61793. if (this._colorCurvesEnabled && this.colorCurves) {
  61794. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61795. }
  61796. // Vignette
  61797. if (this._vignetteEnabled) {
  61798. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61799. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61800. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61801. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61802. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61803. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61804. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61805. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61806. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61807. var vignettePower = -2.0 * this.vignetteWeight;
  61808. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61809. }
  61810. // Exposure
  61811. effect.setFloat("exposureLinear", this.exposure);
  61812. // Contrast
  61813. effect.setFloat("contrast", this.contrast);
  61814. // Color transform settings
  61815. if (this.colorGradingTexture) {
  61816. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61817. var textureSize = this.colorGradingTexture.getSize().height;
  61818. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61819. 0.5 / textureSize, // textureOffset
  61820. textureSize, // textureSize
  61821. this.colorGradingTexture.level // weight
  61822. );
  61823. }
  61824. };
  61825. /**
  61826. * Clones the current image processing instance.
  61827. * @return The cloned image processing
  61828. */
  61829. ImageProcessingConfiguration.prototype.clone = function () {
  61830. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61831. };
  61832. /**
  61833. * Serializes the current image processing instance to a json representation.
  61834. * @return a JSON representation
  61835. */
  61836. ImageProcessingConfiguration.prototype.serialize = function () {
  61837. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61838. };
  61839. /**
  61840. * Parses the image processing from a json representation.
  61841. * @param source the JSON source to parse
  61842. * @return The parsed image processing
  61843. */
  61844. ImageProcessingConfiguration.Parse = function (source) {
  61845. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61846. };
  61847. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61848. /**
  61849. * Used to apply the vignette as a mix with the pixel color.
  61850. */
  61851. get: function () {
  61852. return this._VIGNETTEMODE_MULTIPLY;
  61853. },
  61854. enumerable: true,
  61855. configurable: true
  61856. });
  61857. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61858. /**
  61859. * Used to apply the vignette as a replacement of the pixel color.
  61860. */
  61861. get: function () {
  61862. return this._VIGNETTEMODE_OPAQUE;
  61863. },
  61864. enumerable: true,
  61865. configurable: true
  61866. });
  61867. /**
  61868. * Default tone mapping applied in BabylonJS.
  61869. */
  61870. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61871. /**
  61872. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61873. * to other engines rendering to increase portability.
  61874. */
  61875. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61876. // Static constants associated to the image processing.
  61877. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61878. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61881. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61884. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  61885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  61887. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  61888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61890. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  61891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61893. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  61894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61896. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  61897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61899. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  61900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61902. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  61903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61905. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  61906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61908. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  61909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61911. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  61912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61914. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  61915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61917. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  61918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61920. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  61921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  61923. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  61924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61926. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  61927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61929. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  61930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61932. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  61933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61935. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  61936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61938. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  61939. return ImageProcessingConfiguration;
  61940. }());
  61941. // References the dependencies.
  61942. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  61943. /***/ }),
  61944. /***/ "./Materials/index.ts":
  61945. /*!****************************!*\
  61946. !*** ./Materials/index.ts ***!
  61947. \****************************/
  61948. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  61949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61950. "use strict";
  61951. __webpack_require__.r(__webpack_exports__);
  61952. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  61953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  61954. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  61955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  61956. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  61957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  61958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  61959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  61960. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  61961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  61962. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  61963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  61964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  61965. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  61966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  61967. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  61968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  61969. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  61970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  61971. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  61972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  61973. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  61974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  61975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  61976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  61977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  61978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  61979. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  61980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  61981. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  61982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  61983. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  61984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  61985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  61986. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  61987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  61988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  61989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  61990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  61991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  61992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  61993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  61994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  61995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  61996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  61997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  61998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  61999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  62000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  62001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  62002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  62003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  62004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  62005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  62006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  62007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  62008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  62009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  62010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  62011. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  62013. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  62014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  62015. /***/ }),
  62016. /***/ "./Materials/material.ts":
  62017. /*!*******************************!*\
  62018. !*** ./Materials/material.ts ***!
  62019. \*******************************/
  62020. /*! exports provided: Material */
  62021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62022. "use strict";
  62023. __webpack_require__.r(__webpack_exports__);
  62024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  62025. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62026. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62027. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62028. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62030. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62031. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  62032. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62033. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62034. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62035. /**
  62036. * Base class for the main features of a material in Babylon.js
  62037. */
  62038. var Material = /** @class */ (function () {
  62039. /**
  62040. * Creates a material instance
  62041. * @param name defines the name of the material
  62042. * @param scene defines the scene to reference
  62043. * @param doNotAdd specifies if the material should be added to the scene
  62044. */
  62045. function Material(name, scene, doNotAdd) {
  62046. /**
  62047. * Gets or sets user defined metadata
  62048. */
  62049. this.metadata = null;
  62050. /**
  62051. * For internal use only. Please do not use.
  62052. */
  62053. this.reservedDataStore = null;
  62054. /**
  62055. * Specifies if the ready state should be checked on each call
  62056. */
  62057. this.checkReadyOnEveryCall = false;
  62058. /**
  62059. * Specifies if the ready state should be checked once
  62060. */
  62061. this.checkReadyOnlyOnce = false;
  62062. /**
  62063. * The state of the material
  62064. */
  62065. this.state = "";
  62066. /**
  62067. * The alpha value of the material
  62068. */
  62069. this._alpha = 1.0;
  62070. /**
  62071. * Specifies if back face culling is enabled
  62072. */
  62073. this._backFaceCulling = true;
  62074. /**
  62075. * Specifies if the material should be serialized
  62076. */
  62077. this.doNotSerialize = false;
  62078. /**
  62079. * @hidden
  62080. */
  62081. this._storeEffectOnSubMeshes = false;
  62082. /**
  62083. * An event triggered when the material is disposed
  62084. */
  62085. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62086. /**
  62087. * Stores the value of the alpha mode
  62088. */
  62089. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  62090. /**
  62091. * Stores the state of the need depth pre-pass value
  62092. */
  62093. this._needDepthPrePass = false;
  62094. /**
  62095. * Specifies if depth writing should be disabled
  62096. */
  62097. this.disableDepthWrite = false;
  62098. /**
  62099. * Specifies if depth writing should be forced
  62100. */
  62101. this.forceDepthWrite = false;
  62102. /**
  62103. * Specifies if there should be a separate pass for culling
  62104. */
  62105. this.separateCullingPass = false;
  62106. /**
  62107. * Stores the state specifing if fog should be enabled
  62108. */
  62109. this._fogEnabled = true;
  62110. /**
  62111. * Stores the size of points
  62112. */
  62113. this.pointSize = 1.0;
  62114. /**
  62115. * Stores the z offset value
  62116. */
  62117. this.zOffset = 0;
  62118. /**
  62119. * @hidden
  62120. * Specifies if the material was previously ready
  62121. */
  62122. this._wasPreviouslyReady = false;
  62123. /**
  62124. * Stores the fill mode state
  62125. */
  62126. this._fillMode = Material.TriangleFillMode;
  62127. /** @hidden */
  62128. this._indexInSceneMaterialArray = -1;
  62129. this.name = name;
  62130. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  62131. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  62132. this.uniqueId = this._scene.getUniqueId();
  62133. if (this._scene.useRightHandedSystem) {
  62134. this.sideOrientation = Material.ClockWiseSideOrientation;
  62135. }
  62136. else {
  62137. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  62138. }
  62139. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  62140. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  62141. if (!doNotAdd) {
  62142. this._scene.addMaterial(this);
  62143. }
  62144. if (this._scene.useMaterialMeshMap) {
  62145. this.meshMap = {};
  62146. }
  62147. }
  62148. Object.defineProperty(Material.prototype, "alpha", {
  62149. /**
  62150. * Gets the alpha value of the material
  62151. */
  62152. get: function () {
  62153. return this._alpha;
  62154. },
  62155. /**
  62156. * Sets the alpha value of the material
  62157. */
  62158. set: function (value) {
  62159. if (this._alpha === value) {
  62160. return;
  62161. }
  62162. this._alpha = value;
  62163. this.markAsDirty(Material.MiscDirtyFlag);
  62164. },
  62165. enumerable: true,
  62166. configurable: true
  62167. });
  62168. Object.defineProperty(Material.prototype, "backFaceCulling", {
  62169. /**
  62170. * Gets the back-face culling state
  62171. */
  62172. get: function () {
  62173. return this._backFaceCulling;
  62174. },
  62175. /**
  62176. * Sets the back-face culling state
  62177. */
  62178. set: function (value) {
  62179. if (this._backFaceCulling === value) {
  62180. return;
  62181. }
  62182. this._backFaceCulling = value;
  62183. this.markAsDirty(Material.TextureDirtyFlag);
  62184. },
  62185. enumerable: true,
  62186. configurable: true
  62187. });
  62188. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62189. /**
  62190. * Gets a boolean indicating that current material needs to register RTT
  62191. */
  62192. get: function () {
  62193. return false;
  62194. },
  62195. enumerable: true,
  62196. configurable: true
  62197. });
  62198. Object.defineProperty(Material.prototype, "onDispose", {
  62199. /**
  62200. * Called during a dispose event
  62201. */
  62202. set: function (callback) {
  62203. if (this._onDisposeObserver) {
  62204. this.onDisposeObservable.remove(this._onDisposeObserver);
  62205. }
  62206. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62207. },
  62208. enumerable: true,
  62209. configurable: true
  62210. });
  62211. Object.defineProperty(Material.prototype, "onBindObservable", {
  62212. /**
  62213. * An event triggered when the material is bound
  62214. */
  62215. get: function () {
  62216. if (!this._onBindObservable) {
  62217. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62218. }
  62219. return this._onBindObservable;
  62220. },
  62221. enumerable: true,
  62222. configurable: true
  62223. });
  62224. Object.defineProperty(Material.prototype, "onBind", {
  62225. /**
  62226. * Called during a bind event
  62227. */
  62228. set: function (callback) {
  62229. if (this._onBindObserver) {
  62230. this.onBindObservable.remove(this._onBindObserver);
  62231. }
  62232. this._onBindObserver = this.onBindObservable.add(callback);
  62233. },
  62234. enumerable: true,
  62235. configurable: true
  62236. });
  62237. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62238. /**
  62239. * An event triggered when the material is unbound
  62240. */
  62241. get: function () {
  62242. if (!this._onUnBindObservable) {
  62243. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62244. }
  62245. return this._onUnBindObservable;
  62246. },
  62247. enumerable: true,
  62248. configurable: true
  62249. });
  62250. Object.defineProperty(Material.prototype, "alphaMode", {
  62251. /**
  62252. * Gets the value of the alpha mode
  62253. */
  62254. get: function () {
  62255. return this._alphaMode;
  62256. },
  62257. /**
  62258. * Sets the value of the alpha mode.
  62259. *
  62260. * | Value | Type | Description |
  62261. * | --- | --- | --- |
  62262. * | 0 | ALPHA_DISABLE | |
  62263. * | 1 | ALPHA_ADD | |
  62264. * | 2 | ALPHA_COMBINE | |
  62265. * | 3 | ALPHA_SUBTRACT | |
  62266. * | 4 | ALPHA_MULTIPLY | |
  62267. * | 5 | ALPHA_MAXIMIZED | |
  62268. * | 6 | ALPHA_ONEONE | |
  62269. * | 7 | ALPHA_PREMULTIPLIED | |
  62270. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62271. * | 9 | ALPHA_INTERPOLATE | |
  62272. * | 10 | ALPHA_SCREENMODE | |
  62273. *
  62274. */
  62275. set: function (value) {
  62276. if (this._alphaMode === value) {
  62277. return;
  62278. }
  62279. this._alphaMode = value;
  62280. this.markAsDirty(Material.TextureDirtyFlag);
  62281. },
  62282. enumerable: true,
  62283. configurable: true
  62284. });
  62285. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62286. /**
  62287. * Gets the depth pre-pass value
  62288. */
  62289. get: function () {
  62290. return this._needDepthPrePass;
  62291. },
  62292. /**
  62293. * Sets the need depth pre-pass value
  62294. */
  62295. set: function (value) {
  62296. if (this._needDepthPrePass === value) {
  62297. return;
  62298. }
  62299. this._needDepthPrePass = value;
  62300. if (this._needDepthPrePass) {
  62301. this.checkReadyOnEveryCall = true;
  62302. }
  62303. },
  62304. enumerable: true,
  62305. configurable: true
  62306. });
  62307. Object.defineProperty(Material.prototype, "fogEnabled", {
  62308. /**
  62309. * Gets the value of the fog enabled state
  62310. */
  62311. get: function () {
  62312. return this._fogEnabled;
  62313. },
  62314. /**
  62315. * Sets the state for enabling fog
  62316. */
  62317. set: function (value) {
  62318. if (this._fogEnabled === value) {
  62319. return;
  62320. }
  62321. this._fogEnabled = value;
  62322. this.markAsDirty(Material.MiscDirtyFlag);
  62323. },
  62324. enumerable: true,
  62325. configurable: true
  62326. });
  62327. Object.defineProperty(Material.prototype, "wireframe", {
  62328. /**
  62329. * Gets a value specifying if wireframe mode is enabled
  62330. */
  62331. get: function () {
  62332. switch (this._fillMode) {
  62333. case Material.WireFrameFillMode:
  62334. case Material.LineListDrawMode:
  62335. case Material.LineLoopDrawMode:
  62336. case Material.LineStripDrawMode:
  62337. return true;
  62338. }
  62339. return this._scene.forceWireframe;
  62340. },
  62341. /**
  62342. * Sets the state of wireframe mode
  62343. */
  62344. set: function (value) {
  62345. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62346. },
  62347. enumerable: true,
  62348. configurable: true
  62349. });
  62350. Object.defineProperty(Material.prototype, "pointsCloud", {
  62351. /**
  62352. * Gets the value specifying if point clouds are enabled
  62353. */
  62354. get: function () {
  62355. switch (this._fillMode) {
  62356. case Material.PointFillMode:
  62357. case Material.PointListDrawMode:
  62358. return true;
  62359. }
  62360. return this._scene.forcePointsCloud;
  62361. },
  62362. /**
  62363. * Sets the state of point cloud mode
  62364. */
  62365. set: function (value) {
  62366. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62367. },
  62368. enumerable: true,
  62369. configurable: true
  62370. });
  62371. Object.defineProperty(Material.prototype, "fillMode", {
  62372. /**
  62373. * Gets the material fill mode
  62374. */
  62375. get: function () {
  62376. return this._fillMode;
  62377. },
  62378. /**
  62379. * Sets the material fill mode
  62380. */
  62381. set: function (value) {
  62382. if (this._fillMode === value) {
  62383. return;
  62384. }
  62385. this._fillMode = value;
  62386. this.markAsDirty(Material.MiscDirtyFlag);
  62387. },
  62388. enumerable: true,
  62389. configurable: true
  62390. });
  62391. /**
  62392. * Returns a string representation of the current material
  62393. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62394. * @returns a string with material information
  62395. */
  62396. Material.prototype.toString = function (fullDetails) {
  62397. var ret = "Name: " + this.name;
  62398. if (fullDetails) {
  62399. }
  62400. return ret;
  62401. };
  62402. /**
  62403. * Gets the class name of the material
  62404. * @returns a string with the class name of the material
  62405. */
  62406. Material.prototype.getClassName = function () {
  62407. return "Material";
  62408. };
  62409. Object.defineProperty(Material.prototype, "isFrozen", {
  62410. /**
  62411. * Specifies if updates for the material been locked
  62412. */
  62413. get: function () {
  62414. return this.checkReadyOnlyOnce;
  62415. },
  62416. enumerable: true,
  62417. configurable: true
  62418. });
  62419. /**
  62420. * Locks updates for the material
  62421. */
  62422. Material.prototype.freeze = function () {
  62423. this.checkReadyOnlyOnce = true;
  62424. };
  62425. /**
  62426. * Unlocks updates for the material
  62427. */
  62428. Material.prototype.unfreeze = function () {
  62429. this.checkReadyOnlyOnce = false;
  62430. };
  62431. /**
  62432. * Specifies if the material is ready to be used
  62433. * @param mesh defines the mesh to check
  62434. * @param useInstances specifies if instances should be used
  62435. * @returns a boolean indicating if the material is ready to be used
  62436. */
  62437. Material.prototype.isReady = function (mesh, useInstances) {
  62438. return true;
  62439. };
  62440. /**
  62441. * Specifies that the submesh is ready to be used
  62442. * @param mesh defines the mesh to check
  62443. * @param subMesh defines which submesh to check
  62444. * @param useInstances specifies that instances should be used
  62445. * @returns a boolean indicating that the submesh is ready or not
  62446. */
  62447. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62448. return false;
  62449. };
  62450. /**
  62451. * Returns the material effect
  62452. * @returns the effect associated with the material
  62453. */
  62454. Material.prototype.getEffect = function () {
  62455. return this._effect;
  62456. };
  62457. /**
  62458. * Returns the current scene
  62459. * @returns a Scene
  62460. */
  62461. Material.prototype.getScene = function () {
  62462. return this._scene;
  62463. };
  62464. /**
  62465. * Specifies if the material will require alpha blending
  62466. * @returns a boolean specifying if alpha blending is needed
  62467. */
  62468. Material.prototype.needAlphaBlending = function () {
  62469. return (this.alpha < 1.0);
  62470. };
  62471. /**
  62472. * Specifies if the mesh will require alpha blending
  62473. * @param mesh defines the mesh to check
  62474. * @returns a boolean specifying if alpha blending is needed for the mesh
  62475. */
  62476. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  62477. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  62478. };
  62479. /**
  62480. * Specifies if this material should be rendered in alpha test mode
  62481. * @returns a boolean specifying if an alpha test is needed.
  62482. */
  62483. Material.prototype.needAlphaTesting = function () {
  62484. return false;
  62485. };
  62486. /**
  62487. * Gets the texture used for the alpha test
  62488. * @returns the texture to use for alpha testing
  62489. */
  62490. Material.prototype.getAlphaTestTexture = function () {
  62491. return null;
  62492. };
  62493. /**
  62494. * Marks the material to indicate that it needs to be re-calculated
  62495. */
  62496. Material.prototype.markDirty = function () {
  62497. this._wasPreviouslyReady = false;
  62498. };
  62499. /** @hidden */
  62500. Material.prototype._preBind = function (effect, overrideOrientation) {
  62501. if (overrideOrientation === void 0) { overrideOrientation = null; }
  62502. var engine = this._scene.getEngine();
  62503. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  62504. var reverse = orientation === Material.ClockWiseSideOrientation;
  62505. engine.enableEffect(effect ? effect : this._effect);
  62506. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  62507. return reverse;
  62508. };
  62509. /**
  62510. * Binds the material to the mesh
  62511. * @param world defines the world transformation matrix
  62512. * @param mesh defines the mesh to bind the material to
  62513. */
  62514. Material.prototype.bind = function (world, mesh) {
  62515. };
  62516. /**
  62517. * Binds the submesh to the material
  62518. * @param world defines the world transformation matrix
  62519. * @param mesh defines the mesh containing the submesh
  62520. * @param subMesh defines the submesh to bind the material to
  62521. */
  62522. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  62523. };
  62524. /**
  62525. * Binds the world matrix to the material
  62526. * @param world defines the world transformation matrix
  62527. */
  62528. Material.prototype.bindOnlyWorldMatrix = function (world) {
  62529. };
  62530. /**
  62531. * Binds the scene's uniform buffer to the effect.
  62532. * @param effect defines the effect to bind to the scene uniform buffer
  62533. * @param sceneUbo defines the uniform buffer storing scene data
  62534. */
  62535. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  62536. sceneUbo.bindToEffect(effect, "Scene");
  62537. };
  62538. /**
  62539. * Binds the view matrix to the effect
  62540. * @param effect defines the effect to bind the view matrix to
  62541. */
  62542. Material.prototype.bindView = function (effect) {
  62543. if (!this._useUBO) {
  62544. effect.setMatrix("view", this.getScene().getViewMatrix());
  62545. }
  62546. else {
  62547. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62548. }
  62549. };
  62550. /**
  62551. * Binds the view projection matrix to the effect
  62552. * @param effect defines the effect to bind the view projection matrix to
  62553. */
  62554. Material.prototype.bindViewProjection = function (effect) {
  62555. if (!this._useUBO) {
  62556. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  62557. }
  62558. else {
  62559. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62560. }
  62561. };
  62562. /**
  62563. * Specifies if material alpha testing should be turned on for the mesh
  62564. * @param mesh defines the mesh to check
  62565. */
  62566. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  62567. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  62568. };
  62569. /**
  62570. * Processes to execute after binding the material to a mesh
  62571. * @param mesh defines the rendered mesh
  62572. */
  62573. Material.prototype._afterBind = function (mesh) {
  62574. this._scene._cachedMaterial = this;
  62575. if (mesh) {
  62576. this._scene._cachedVisibility = mesh.visibility;
  62577. }
  62578. else {
  62579. this._scene._cachedVisibility = 1;
  62580. }
  62581. if (this._onBindObservable && mesh) {
  62582. this._onBindObservable.notifyObservers(mesh);
  62583. }
  62584. if (this.disableDepthWrite) {
  62585. var engine = this._scene.getEngine();
  62586. this._cachedDepthWriteState = engine.getDepthWrite();
  62587. engine.setDepthWrite(false);
  62588. }
  62589. };
  62590. /**
  62591. * Unbinds the material from the mesh
  62592. */
  62593. Material.prototype.unbind = function () {
  62594. if (this._onUnBindObservable) {
  62595. this._onUnBindObservable.notifyObservers(this);
  62596. }
  62597. if (this.disableDepthWrite) {
  62598. var engine = this._scene.getEngine();
  62599. engine.setDepthWrite(this._cachedDepthWriteState);
  62600. }
  62601. };
  62602. /**
  62603. * Gets the active textures from the material
  62604. * @returns an array of textures
  62605. */
  62606. Material.prototype.getActiveTextures = function () {
  62607. return [];
  62608. };
  62609. /**
  62610. * Specifies if the material uses a texture
  62611. * @param texture defines the texture to check against the material
  62612. * @returns a boolean specifying if the material uses the texture
  62613. */
  62614. Material.prototype.hasTexture = function (texture) {
  62615. return false;
  62616. };
  62617. /**
  62618. * Makes a duplicate of the material, and gives it a new name
  62619. * @param name defines the new name for the duplicated material
  62620. * @returns the cloned material
  62621. */
  62622. Material.prototype.clone = function (name) {
  62623. return null;
  62624. };
  62625. /**
  62626. * Gets the meshes bound to the material
  62627. * @returns an array of meshes bound to the material
  62628. */
  62629. Material.prototype.getBindedMeshes = function () {
  62630. var _this = this;
  62631. if (this.meshMap) {
  62632. var result = new Array();
  62633. for (var meshId in this.meshMap) {
  62634. var mesh = this.meshMap[meshId];
  62635. if (mesh) {
  62636. result.push(mesh);
  62637. }
  62638. }
  62639. return result;
  62640. }
  62641. else {
  62642. var meshes = this._scene.meshes;
  62643. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62644. }
  62645. };
  62646. /**
  62647. * Force shader compilation
  62648. * @param mesh defines the mesh associated with this material
  62649. * @param onCompiled defines a function to execute once the material is compiled
  62650. * @param options defines the options to configure the compilation
  62651. */
  62652. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62653. var _this = this;
  62654. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62655. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62656. var scene = this.getScene();
  62657. var checkReady = function () {
  62658. if (!_this._scene || !_this._scene.getEngine()) {
  62659. return;
  62660. }
  62661. if (subMesh._materialDefines) {
  62662. subMesh._materialDefines._renderId = -1;
  62663. }
  62664. var clipPlaneState = scene.clipPlane;
  62665. if (localOptions.clipPlane) {
  62666. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62667. }
  62668. if (_this._storeEffectOnSubMeshes) {
  62669. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62670. if (onCompiled) {
  62671. onCompiled(_this);
  62672. }
  62673. }
  62674. else {
  62675. setTimeout(checkReady, 16);
  62676. }
  62677. }
  62678. else {
  62679. if (_this.isReady()) {
  62680. if (onCompiled) {
  62681. onCompiled(_this);
  62682. }
  62683. }
  62684. else {
  62685. setTimeout(checkReady, 16);
  62686. }
  62687. }
  62688. if (localOptions.clipPlane) {
  62689. scene.clipPlane = clipPlaneState;
  62690. }
  62691. };
  62692. checkReady();
  62693. };
  62694. /**
  62695. * Force shader compilation
  62696. * @param mesh defines the mesh that will use this material
  62697. * @param options defines additional options for compiling the shaders
  62698. * @returns a promise that resolves when the compilation completes
  62699. */
  62700. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62701. var _this = this;
  62702. return new Promise(function (resolve) {
  62703. _this.forceCompilation(mesh, function () {
  62704. resolve();
  62705. }, options);
  62706. });
  62707. };
  62708. /**
  62709. * Marks a define in the material to indicate that it needs to be re-computed
  62710. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62711. */
  62712. Material.prototype.markAsDirty = function (flag) {
  62713. if (this.getScene().blockMaterialDirtyMechanism) {
  62714. return;
  62715. }
  62716. Material._DirtyCallbackArray.length = 0;
  62717. if (flag & Material.TextureDirtyFlag) {
  62718. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62719. }
  62720. if (flag & Material.LightDirtyFlag) {
  62721. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62722. }
  62723. if (flag & Material.FresnelDirtyFlag) {
  62724. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62725. }
  62726. if (flag & Material.AttributesDirtyFlag) {
  62727. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62728. }
  62729. if (flag & Material.MiscDirtyFlag) {
  62730. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62731. }
  62732. if (Material._DirtyCallbackArray.length) {
  62733. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62734. }
  62735. this.getScene().resetCachedMaterial();
  62736. };
  62737. /**
  62738. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62739. * @param func defines a function which checks material defines against the submeshes
  62740. */
  62741. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62742. if (this.getScene().blockMaterialDirtyMechanism) {
  62743. return;
  62744. }
  62745. var meshes = this.getScene().meshes;
  62746. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62747. var mesh = meshes_1[_i];
  62748. if (!mesh.subMeshes) {
  62749. continue;
  62750. }
  62751. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62752. var subMesh = _b[_a];
  62753. if (subMesh.getMaterial() !== this) {
  62754. continue;
  62755. }
  62756. if (!subMesh._materialDefines) {
  62757. continue;
  62758. }
  62759. func(subMesh._materialDefines);
  62760. }
  62761. }
  62762. };
  62763. /**
  62764. * Indicates that image processing needs to be re-calculated for all submeshes
  62765. */
  62766. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62767. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62768. };
  62769. /**
  62770. * Indicates that textures need to be re-calculated for all submeshes
  62771. */
  62772. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62773. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62774. };
  62775. /**
  62776. * Indicates that fresnel needs to be re-calculated for all submeshes
  62777. */
  62778. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62779. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62780. };
  62781. /**
  62782. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62783. */
  62784. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62785. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62786. };
  62787. /**
  62788. * Indicates that lights need to be re-calculated for all submeshes
  62789. */
  62790. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62791. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62792. };
  62793. /**
  62794. * Indicates that attributes need to be re-calculated for all submeshes
  62795. */
  62796. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62797. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62798. };
  62799. /**
  62800. * Indicates that misc needs to be re-calculated for all submeshes
  62801. */
  62802. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62803. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62804. };
  62805. /**
  62806. * Indicates that textures and misc need to be re-calculated for all submeshes
  62807. */
  62808. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62809. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62810. };
  62811. /**
  62812. * Disposes the material
  62813. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62814. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62815. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62816. */
  62817. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62818. var scene = this.getScene();
  62819. // Animations
  62820. scene.stopAnimation(this);
  62821. scene.freeProcessedMaterials();
  62822. // Remove from scene
  62823. scene.removeMaterial(this);
  62824. if (notBoundToMesh !== true) {
  62825. // Remove from meshes
  62826. if (this.meshMap) {
  62827. for (var meshId in this.meshMap) {
  62828. var mesh = this.meshMap[meshId];
  62829. if (mesh) {
  62830. mesh.material = null; // will set the entry in the map to undefined
  62831. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62832. }
  62833. }
  62834. }
  62835. else {
  62836. var meshes = scene.meshes;
  62837. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62838. var mesh = meshes_2[_i];
  62839. if (mesh.material === this) {
  62840. mesh.material = null;
  62841. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62842. }
  62843. }
  62844. }
  62845. }
  62846. this._uniformBuffer.dispose();
  62847. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62848. if (forceDisposeEffect && this._effect) {
  62849. if (!this._storeEffectOnSubMeshes) {
  62850. scene.getEngine()._releaseEffect(this._effect);
  62851. }
  62852. this._effect = null;
  62853. }
  62854. // Callback
  62855. this.onDisposeObservable.notifyObservers(this);
  62856. this.onDisposeObservable.clear();
  62857. if (this._onBindObservable) {
  62858. this._onBindObservable.clear();
  62859. }
  62860. if (this._onUnBindObservable) {
  62861. this._onUnBindObservable.clear();
  62862. }
  62863. };
  62864. /** @hidden */
  62865. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62866. if (mesh.geometry) {
  62867. var geometry = (mesh.geometry);
  62868. var scene = this.getScene();
  62869. if (this._storeEffectOnSubMeshes) {
  62870. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62871. var subMesh = _a[_i];
  62872. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62873. if (forceDisposeEffect && subMesh._materialEffect) {
  62874. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62875. }
  62876. }
  62877. }
  62878. else {
  62879. geometry._releaseVertexArrayObject(this._effect);
  62880. }
  62881. }
  62882. };
  62883. /**
  62884. * Serializes this material
  62885. * @returns the serialized material object
  62886. */
  62887. Material.prototype.serialize = function () {
  62888. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62889. };
  62890. /**
  62891. * Creates a material from parsed material data
  62892. * @param parsedMaterial defines parsed material data
  62893. * @param scene defines the hosting scene
  62894. * @param rootUrl defines the root URL to use to load textures
  62895. * @returns a new material
  62896. */
  62897. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  62898. if (!parsedMaterial.customType) {
  62899. parsedMaterial.customType = "BABYLON.StandardMaterial";
  62900. }
  62901. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  62902. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  62903. if (!BABYLON.LegacyPBRMaterial) {
  62904. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
  62905. return;
  62906. }
  62907. }
  62908. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  62909. return materialType.Parse(parsedMaterial, scene, rootUrl);
  62910. };
  62911. /**
  62912. * Returns the triangle fill mode
  62913. */
  62914. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  62915. /**
  62916. * Returns the wireframe mode
  62917. */
  62918. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  62919. /**
  62920. * Returns the point fill mode
  62921. */
  62922. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  62923. /**
  62924. * Returns the point list draw mode
  62925. */
  62926. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  62927. /**
  62928. * Returns the line list draw mode
  62929. */
  62930. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  62931. /**
  62932. * Returns the line loop draw mode
  62933. */
  62934. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  62935. /**
  62936. * Returns the line strip draw mode
  62937. */
  62938. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  62939. /**
  62940. * Returns the triangle strip draw mode
  62941. */
  62942. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  62943. /**
  62944. * Returns the triangle fan draw mode
  62945. */
  62946. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  62947. /**
  62948. * Stores the clock-wise side orientation
  62949. */
  62950. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  62951. /**
  62952. * Stores the counter clock-wise side orientation
  62953. */
  62954. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  62955. /**
  62956. * The dirty texture flag value
  62957. */
  62958. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  62959. /**
  62960. * The dirty light flag value
  62961. */
  62962. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  62963. /**
  62964. * The dirty fresnel flag value
  62965. */
  62966. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  62967. /**
  62968. * The dirty attribute flag value
  62969. */
  62970. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  62971. /**
  62972. * The dirty misc flag value
  62973. */
  62974. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  62975. /**
  62976. * The all dirty flag value
  62977. */
  62978. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  62979. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  62980. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  62981. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  62982. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  62983. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  62984. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  62985. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  62986. Material._FresnelDirtyCallBack(defines);
  62987. Material._MiscDirtyCallBack(defines);
  62988. };
  62989. Material._TextureAndMiscDirtyCallBack = function (defines) {
  62990. Material._TextureDirtyCallBack(defines);
  62991. Material._MiscDirtyCallBack(defines);
  62992. };
  62993. Material._DirtyCallbackArray = [];
  62994. Material._RunDirtyCallBacks = function (defines) {
  62995. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  62996. var cb = _a[_i];
  62997. cb(defines);
  62998. }
  62999. };
  63000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63002. ], Material.prototype, "id", void 0);
  63003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63005. ], Material.prototype, "uniqueId", void 0);
  63006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63008. ], Material.prototype, "name", void 0);
  63009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63011. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  63012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63014. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  63015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63017. ], Material.prototype, "state", void 0);
  63018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  63020. ], Material.prototype, "_alpha", void 0);
  63021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  63023. ], Material.prototype, "_backFaceCulling", void 0);
  63024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63026. ], Material.prototype, "sideOrientation", void 0);
  63027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  63029. ], Material.prototype, "_alphaMode", void 0);
  63030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63032. ], Material.prototype, "_needDepthPrePass", void 0);
  63033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63035. ], Material.prototype, "disableDepthWrite", void 0);
  63036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63038. ], Material.prototype, "forceDepthWrite", void 0);
  63039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63041. ], Material.prototype, "separateCullingPass", void 0);
  63042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  63044. ], Material.prototype, "_fogEnabled", void 0);
  63045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63047. ], Material.prototype, "pointSize", void 0);
  63048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63050. ], Material.prototype, "zOffset", void 0);
  63051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63053. ], Material.prototype, "wireframe", null);
  63054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63056. ], Material.prototype, "pointsCloud", null);
  63057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63059. ], Material.prototype, "fillMode", null);
  63060. return Material;
  63061. }());
  63062. /***/ }),
  63063. /***/ "./Materials/materialDefines.ts":
  63064. /*!**************************************!*\
  63065. !*** ./Materials/materialDefines.ts ***!
  63066. \**************************************/
  63067. /*! exports provided: MaterialDefines */
  63068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63069. "use strict";
  63070. __webpack_require__.r(__webpack_exports__);
  63071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  63072. /**
  63073. * Manages the defines for the Material
  63074. */
  63075. var MaterialDefines = /** @class */ (function () {
  63076. function MaterialDefines() {
  63077. this._isDirty = true;
  63078. /** @hidden */
  63079. this._areLightsDirty = true;
  63080. /** @hidden */
  63081. this._areAttributesDirty = true;
  63082. /** @hidden */
  63083. this._areTexturesDirty = true;
  63084. /** @hidden */
  63085. this._areFresnelDirty = true;
  63086. /** @hidden */
  63087. this._areMiscDirty = true;
  63088. /** @hidden */
  63089. this._areImageProcessingDirty = true;
  63090. /** @hidden */
  63091. this._normals = false;
  63092. /** @hidden */
  63093. this._uvs = false;
  63094. /** @hidden */
  63095. this._needNormals = false;
  63096. /** @hidden */
  63097. this._needUVs = false;
  63098. }
  63099. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  63100. /**
  63101. * Specifies if the material needs to be re-calculated
  63102. */
  63103. get: function () {
  63104. return this._isDirty;
  63105. },
  63106. enumerable: true,
  63107. configurable: true
  63108. });
  63109. /**
  63110. * Marks the material to indicate that it has been re-calculated
  63111. */
  63112. MaterialDefines.prototype.markAsProcessed = function () {
  63113. this._isDirty = false;
  63114. this._areAttributesDirty = false;
  63115. this._areTexturesDirty = false;
  63116. this._areFresnelDirty = false;
  63117. this._areLightsDirty = false;
  63118. this._areMiscDirty = false;
  63119. this._areImageProcessingDirty = false;
  63120. };
  63121. /**
  63122. * Marks the material to indicate that it needs to be re-calculated
  63123. */
  63124. MaterialDefines.prototype.markAsUnprocessed = function () {
  63125. this._isDirty = true;
  63126. };
  63127. /**
  63128. * Marks the material to indicate all of its defines need to be re-calculated
  63129. */
  63130. MaterialDefines.prototype.markAllAsDirty = function () {
  63131. this._areTexturesDirty = true;
  63132. this._areAttributesDirty = true;
  63133. this._areLightsDirty = true;
  63134. this._areFresnelDirty = true;
  63135. this._areMiscDirty = true;
  63136. this._areImageProcessingDirty = true;
  63137. this._isDirty = true;
  63138. };
  63139. /**
  63140. * Marks the material to indicate that image processing needs to be re-calculated
  63141. */
  63142. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  63143. this._areImageProcessingDirty = true;
  63144. this._isDirty = true;
  63145. };
  63146. /**
  63147. * Marks the material to indicate the lights need to be re-calculated
  63148. */
  63149. MaterialDefines.prototype.markAsLightDirty = function () {
  63150. this._areLightsDirty = true;
  63151. this._isDirty = true;
  63152. };
  63153. /**
  63154. * Marks the attribute state as changed
  63155. */
  63156. MaterialDefines.prototype.markAsAttributesDirty = function () {
  63157. this._areAttributesDirty = true;
  63158. this._isDirty = true;
  63159. };
  63160. /**
  63161. * Marks the texture state as changed
  63162. */
  63163. MaterialDefines.prototype.markAsTexturesDirty = function () {
  63164. this._areTexturesDirty = true;
  63165. this._isDirty = true;
  63166. };
  63167. /**
  63168. * Marks the fresnel state as changed
  63169. */
  63170. MaterialDefines.prototype.markAsFresnelDirty = function () {
  63171. this._areFresnelDirty = true;
  63172. this._isDirty = true;
  63173. };
  63174. /**
  63175. * Marks the misc state as changed
  63176. */
  63177. MaterialDefines.prototype.markAsMiscDirty = function () {
  63178. this._areMiscDirty = true;
  63179. this._isDirty = true;
  63180. };
  63181. /**
  63182. * Rebuilds the material defines
  63183. */
  63184. MaterialDefines.prototype.rebuild = function () {
  63185. if (this._keys) {
  63186. delete this._keys;
  63187. }
  63188. this._keys = [];
  63189. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63190. var key = _a[_i];
  63191. if (key[0] === "_") {
  63192. continue;
  63193. }
  63194. this._keys.push(key);
  63195. }
  63196. };
  63197. /**
  63198. * Specifies if two material defines are equal
  63199. * @param other - A material define instance to compare to
  63200. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63201. */
  63202. MaterialDefines.prototype.isEqual = function (other) {
  63203. if (this._keys.length !== other._keys.length) {
  63204. return false;
  63205. }
  63206. for (var index = 0; index < this._keys.length; index++) {
  63207. var prop = this._keys[index];
  63208. if (this[prop] !== other[prop]) {
  63209. return false;
  63210. }
  63211. }
  63212. return true;
  63213. };
  63214. /**
  63215. * Clones this instance's defines to another instance
  63216. * @param other - material defines to clone values to
  63217. */
  63218. MaterialDefines.prototype.cloneTo = function (other) {
  63219. if (this._keys.length !== other._keys.length) {
  63220. other._keys = this._keys.slice(0);
  63221. }
  63222. for (var index = 0; index < this._keys.length; index++) {
  63223. var prop = this._keys[index];
  63224. other[prop] = this[prop];
  63225. }
  63226. };
  63227. /**
  63228. * Resets the material define values
  63229. */
  63230. MaterialDefines.prototype.reset = function () {
  63231. for (var index = 0; index < this._keys.length; index++) {
  63232. var prop = this._keys[index];
  63233. var type = typeof this[prop];
  63234. switch (type) {
  63235. case "number":
  63236. this[prop] = 0;
  63237. break;
  63238. case "string":
  63239. this[prop] = "";
  63240. break;
  63241. default:
  63242. this[prop] = false;
  63243. break;
  63244. }
  63245. }
  63246. };
  63247. /**
  63248. * Converts the material define values to a string
  63249. * @returns - String of material define information
  63250. */
  63251. MaterialDefines.prototype.toString = function () {
  63252. var result = "";
  63253. for (var index = 0; index < this._keys.length; index++) {
  63254. var prop = this._keys[index];
  63255. var value = this[prop];
  63256. var type = typeof value;
  63257. switch (type) {
  63258. case "number":
  63259. case "string":
  63260. result += "#define " + prop + " " + value + "\n";
  63261. break;
  63262. default:
  63263. if (value) {
  63264. result += "#define " + prop + "\n";
  63265. }
  63266. break;
  63267. }
  63268. }
  63269. return result;
  63270. };
  63271. return MaterialDefines;
  63272. }());
  63273. /***/ }),
  63274. /***/ "./Materials/materialFlags.ts":
  63275. /*!************************************!*\
  63276. !*** ./Materials/materialFlags.ts ***!
  63277. \************************************/
  63278. /*! exports provided: MaterialFlags */
  63279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63280. "use strict";
  63281. __webpack_require__.r(__webpack_exports__);
  63282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63283. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63284. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63285. /**
  63286. * This groups all the flags used to control the materials channel.
  63287. */
  63288. var MaterialFlags = /** @class */ (function () {
  63289. function MaterialFlags() {
  63290. }
  63291. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63292. /**
  63293. * Are diffuse textures enabled in the application.
  63294. */
  63295. get: function () {
  63296. return this._DiffuseTextureEnabled;
  63297. },
  63298. set: function (value) {
  63299. if (this._DiffuseTextureEnabled === value) {
  63300. return;
  63301. }
  63302. this._DiffuseTextureEnabled = value;
  63303. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63304. },
  63305. enumerable: true,
  63306. configurable: true
  63307. });
  63308. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63309. /**
  63310. * Are ambient textures enabled in the application.
  63311. */
  63312. get: function () {
  63313. return this._AmbientTextureEnabled;
  63314. },
  63315. set: function (value) {
  63316. if (this._AmbientTextureEnabled === value) {
  63317. return;
  63318. }
  63319. this._AmbientTextureEnabled = value;
  63320. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63321. },
  63322. enumerable: true,
  63323. configurable: true
  63324. });
  63325. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63326. /**
  63327. * Are opacity textures enabled in the application.
  63328. */
  63329. get: function () {
  63330. return this._OpacityTextureEnabled;
  63331. },
  63332. set: function (value) {
  63333. if (this._OpacityTextureEnabled === value) {
  63334. return;
  63335. }
  63336. this._OpacityTextureEnabled = value;
  63337. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63338. },
  63339. enumerable: true,
  63340. configurable: true
  63341. });
  63342. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63343. /**
  63344. * Are reflection textures enabled in the application.
  63345. */
  63346. get: function () {
  63347. return this._ReflectionTextureEnabled;
  63348. },
  63349. set: function (value) {
  63350. if (this._ReflectionTextureEnabled === value) {
  63351. return;
  63352. }
  63353. this._ReflectionTextureEnabled = value;
  63354. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63355. },
  63356. enumerable: true,
  63357. configurable: true
  63358. });
  63359. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63360. /**
  63361. * Are emissive textures enabled in the application.
  63362. */
  63363. get: function () {
  63364. return this._EmissiveTextureEnabled;
  63365. },
  63366. set: function (value) {
  63367. if (this._EmissiveTextureEnabled === value) {
  63368. return;
  63369. }
  63370. this._EmissiveTextureEnabled = value;
  63371. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63372. },
  63373. enumerable: true,
  63374. configurable: true
  63375. });
  63376. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63377. /**
  63378. * Are specular textures enabled in the application.
  63379. */
  63380. get: function () {
  63381. return this._SpecularTextureEnabled;
  63382. },
  63383. set: function (value) {
  63384. if (this._SpecularTextureEnabled === value) {
  63385. return;
  63386. }
  63387. this._SpecularTextureEnabled = value;
  63388. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63389. },
  63390. enumerable: true,
  63391. configurable: true
  63392. });
  63393. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63394. /**
  63395. * Are bump textures enabled in the application.
  63396. */
  63397. get: function () {
  63398. return this._BumpTextureEnabled;
  63399. },
  63400. set: function (value) {
  63401. if (this._BumpTextureEnabled === value) {
  63402. return;
  63403. }
  63404. this._BumpTextureEnabled = value;
  63405. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63406. },
  63407. enumerable: true,
  63408. configurable: true
  63409. });
  63410. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63411. /**
  63412. * Are lightmap textures enabled in the application.
  63413. */
  63414. get: function () {
  63415. return this._LightmapTextureEnabled;
  63416. },
  63417. set: function (value) {
  63418. if (this._LightmapTextureEnabled === value) {
  63419. return;
  63420. }
  63421. this._LightmapTextureEnabled = value;
  63422. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63423. },
  63424. enumerable: true,
  63425. configurable: true
  63426. });
  63427. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63428. /**
  63429. * Are refraction textures enabled in the application.
  63430. */
  63431. get: function () {
  63432. return this._RefractionTextureEnabled;
  63433. },
  63434. set: function (value) {
  63435. if (this._RefractionTextureEnabled === value) {
  63436. return;
  63437. }
  63438. this._RefractionTextureEnabled = value;
  63439. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63440. },
  63441. enumerable: true,
  63442. configurable: true
  63443. });
  63444. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63445. /**
  63446. * Are color grading textures enabled in the application.
  63447. */
  63448. get: function () {
  63449. return this._ColorGradingTextureEnabled;
  63450. },
  63451. set: function (value) {
  63452. if (this._ColorGradingTextureEnabled === value) {
  63453. return;
  63454. }
  63455. this._ColorGradingTextureEnabled = value;
  63456. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63457. },
  63458. enumerable: true,
  63459. configurable: true
  63460. });
  63461. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  63462. /**
  63463. * Are fresnels enabled in the application.
  63464. */
  63465. get: function () {
  63466. return this._FresnelEnabled;
  63467. },
  63468. set: function (value) {
  63469. if (this._FresnelEnabled === value) {
  63470. return;
  63471. }
  63472. this._FresnelEnabled = value;
  63473. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  63474. },
  63475. enumerable: true,
  63476. configurable: true
  63477. });
  63478. // Flags used to enable or disable a type of texture for all Standard Materials
  63479. MaterialFlags._DiffuseTextureEnabled = true;
  63480. MaterialFlags._AmbientTextureEnabled = true;
  63481. MaterialFlags._OpacityTextureEnabled = true;
  63482. MaterialFlags._ReflectionTextureEnabled = true;
  63483. MaterialFlags._EmissiveTextureEnabled = true;
  63484. MaterialFlags._SpecularTextureEnabled = true;
  63485. MaterialFlags._BumpTextureEnabled = true;
  63486. MaterialFlags._LightmapTextureEnabled = true;
  63487. MaterialFlags._RefractionTextureEnabled = true;
  63488. MaterialFlags._ColorGradingTextureEnabled = true;
  63489. MaterialFlags._FresnelEnabled = true;
  63490. return MaterialFlags;
  63491. }());
  63492. /***/ }),
  63493. /***/ "./Materials/materialHelper.ts":
  63494. /*!*************************************!*\
  63495. !*** ./Materials/materialHelper.ts ***!
  63496. \*************************************/
  63497. /*! exports provided: MaterialHelper */
  63498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63499. "use strict";
  63500. __webpack_require__.r(__webpack_exports__);
  63501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  63502. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63503. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  63504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63505. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63506. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63507. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  63508. /**
  63509. * "Static Class" containing the most commonly used helper while dealing with material for
  63510. * rendering purpose.
  63511. *
  63512. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  63513. *
  63514. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  63515. */
  63516. var MaterialHelper = /** @class */ (function () {
  63517. function MaterialHelper() {
  63518. }
  63519. /**
  63520. * Bind the current view position to an effect.
  63521. * @param effect The effect to be bound
  63522. * @param scene The scene the eyes position is used from
  63523. */
  63524. MaterialHelper.BindEyePosition = function (effect, scene) {
  63525. if (scene._forcedViewPosition) {
  63526. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  63527. return;
  63528. }
  63529. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  63530. };
  63531. /**
  63532. * Helps preparing the defines values about the UVs in used in the effect.
  63533. * UVs are shared as much as we can accross channels in the shaders.
  63534. * @param texture The texture we are preparing the UVs for
  63535. * @param defines The defines to update
  63536. * @param key The channel key "diffuse", "specular"... used in the shader
  63537. */
  63538. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  63539. defines._needUVs = true;
  63540. defines[key] = true;
  63541. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  63542. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  63543. if (texture.coordinatesIndex === 0) {
  63544. defines["MAINUV1"] = true;
  63545. }
  63546. else {
  63547. defines["MAINUV2"] = true;
  63548. }
  63549. }
  63550. else {
  63551. defines[key + "DIRECTUV"] = 0;
  63552. }
  63553. };
  63554. /**
  63555. * Binds a texture matrix value to its corrsponding uniform
  63556. * @param texture The texture to bind the matrix for
  63557. * @param uniformBuffer The uniform buffer receivin the data
  63558. * @param key The channel key "diffuse", "specular"... used in the shader
  63559. */
  63560. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  63561. var matrix = texture.getTextureMatrix();
  63562. if (!matrix.isIdentityAs3x2()) {
  63563. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  63564. }
  63565. };
  63566. /**
  63567. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  63568. * @param mesh defines the current mesh
  63569. * @param scene defines the current scene
  63570. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  63571. * @param pointsCloud defines if point cloud rendering has to be turned on
  63572. * @param fogEnabled defines if fog has to be turned on
  63573. * @param alphaTest defines if alpha testing has to be turned on
  63574. * @param defines defines the current list of defines
  63575. */
  63576. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63577. if (defines._areMiscDirty) {
  63578. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63579. defines["POINTSIZE"] = pointsCloud;
  63580. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63581. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63582. defines["ALPHATEST"] = alphaTest;
  63583. }
  63584. };
  63585. /**
  63586. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63587. * @param scene defines the current scene
  63588. * @param engine defines the current engine
  63589. * @param defines specifies the list of active defines
  63590. * @param useInstances defines if instances have to be turned on
  63591. * @param useClipPlane defines if clip plane have to be turned on
  63592. */
  63593. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63594. if (useClipPlane === void 0) { useClipPlane = null; }
  63595. var changed = false;
  63596. var useClipPlane1 = false;
  63597. var useClipPlane2 = false;
  63598. var useClipPlane3 = false;
  63599. var useClipPlane4 = false;
  63600. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63601. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63602. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63603. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63604. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63605. defines["CLIPPLANE"] = useClipPlane1;
  63606. changed = true;
  63607. }
  63608. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63609. defines["CLIPPLANE2"] = useClipPlane2;
  63610. changed = true;
  63611. }
  63612. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63613. defines["CLIPPLANE3"] = useClipPlane3;
  63614. changed = true;
  63615. }
  63616. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63617. defines["CLIPPLANE4"] = useClipPlane4;
  63618. changed = true;
  63619. }
  63620. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63621. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63622. changed = true;
  63623. }
  63624. if (defines["INSTANCES"] !== useInstances) {
  63625. defines["INSTANCES"] = useInstances;
  63626. changed = true;
  63627. }
  63628. if (changed) {
  63629. defines.markAsUnprocessed();
  63630. }
  63631. };
  63632. /**
  63633. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63634. * @param mesh The mesh containing the geometry data we will draw
  63635. * @param defines The defines to update
  63636. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63637. * @param useBones Precise whether bones should be used or not (override mesh info)
  63638. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63639. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63640. * @returns false if defines are considered not dirty and have not been checked
  63641. */
  63642. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63643. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63644. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63645. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63646. return false;
  63647. }
  63648. defines._normals = defines._needNormals;
  63649. defines._uvs = defines._needUVs;
  63650. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63651. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63652. defines["TANGENT"] = true;
  63653. }
  63654. if (defines._needUVs) {
  63655. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63656. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63657. }
  63658. else {
  63659. defines["UV1"] = false;
  63660. defines["UV2"] = false;
  63661. }
  63662. if (useVertexColor) {
  63663. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63664. defines["VERTEXCOLOR"] = hasVertexColors;
  63665. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63666. }
  63667. if (useBones) {
  63668. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63669. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63670. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63671. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63672. defines["BONETEXTURE"] = true;
  63673. }
  63674. else {
  63675. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63676. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63677. }
  63678. }
  63679. else {
  63680. defines["NUM_BONE_INFLUENCERS"] = 0;
  63681. defines["BonesPerMesh"] = 0;
  63682. }
  63683. }
  63684. if (useMorphTargets) {
  63685. var manager = mesh.morphTargetManager;
  63686. if (manager) {
  63687. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63688. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63689. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63690. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63691. }
  63692. else {
  63693. defines["MORPHTARGETS_TANGENT"] = false;
  63694. defines["MORPHTARGETS_NORMAL"] = false;
  63695. defines["MORPHTARGETS"] = false;
  63696. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63697. }
  63698. }
  63699. return true;
  63700. };
  63701. /**
  63702. * Prepares the defines related to the light information passed in parameter
  63703. * @param scene The scene we are intending to draw
  63704. * @param mesh The mesh the effect is compiling for
  63705. * @param defines The defines to update
  63706. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63707. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63708. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63709. * @returns true if normals will be required for the rest of the effect
  63710. */
  63711. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63712. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63713. if (disableLighting === void 0) { disableLighting = false; }
  63714. if (!defines._areLightsDirty) {
  63715. return defines._needNormals;
  63716. }
  63717. var lightIndex = 0;
  63718. var needNormals = false;
  63719. var needRebuild = false;
  63720. var lightmapMode = false;
  63721. var shadowEnabled = false;
  63722. var specularEnabled = false;
  63723. if (scene.lightsEnabled && !disableLighting) {
  63724. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63725. var light = _a[_i];
  63726. needNormals = true;
  63727. if (defines["LIGHT" + lightIndex] === undefined) {
  63728. needRebuild = true;
  63729. }
  63730. defines["LIGHT" + lightIndex] = true;
  63731. defines["SPOTLIGHT" + lightIndex] = false;
  63732. defines["HEMILIGHT" + lightIndex] = false;
  63733. defines["POINTLIGHT" + lightIndex] = false;
  63734. defines["DIRLIGHT" + lightIndex] = false;
  63735. light.prepareLightSpecificDefines(defines, lightIndex);
  63736. // FallOff.
  63737. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63738. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63739. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63740. switch (light.falloffType) {
  63741. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63742. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63743. break;
  63744. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63745. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63746. break;
  63747. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63748. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63749. break;
  63750. }
  63751. // Specular
  63752. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63753. specularEnabled = true;
  63754. }
  63755. // Shadows
  63756. defines["SHADOW" + lightIndex] = false;
  63757. defines["SHADOWPCF" + lightIndex] = false;
  63758. defines["SHADOWPCSS" + lightIndex] = false;
  63759. defines["SHADOWPOISSON" + lightIndex] = false;
  63760. defines["SHADOWESM" + lightIndex] = false;
  63761. defines["SHADOWCUBE" + lightIndex] = false;
  63762. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63763. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63764. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63765. var shadowGenerator = light.getShadowGenerator();
  63766. if (shadowGenerator) {
  63767. var shadowMap = shadowGenerator.getShadowMap();
  63768. if (shadowMap) {
  63769. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63770. shadowEnabled = true;
  63771. shadowGenerator.prepareDefines(defines, lightIndex);
  63772. }
  63773. }
  63774. }
  63775. }
  63776. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63777. lightmapMode = true;
  63778. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63779. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63780. }
  63781. else {
  63782. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63783. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63784. }
  63785. lightIndex++;
  63786. if (lightIndex === maxSimultaneousLights) {
  63787. break;
  63788. }
  63789. }
  63790. }
  63791. defines["SPECULARTERM"] = specularEnabled;
  63792. defines["SHADOWS"] = shadowEnabled;
  63793. // Resetting all other lights if any
  63794. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63795. if (defines["LIGHT" + index] !== undefined) {
  63796. defines["LIGHT" + index] = false;
  63797. defines["HEMILIGHT" + index] = false;
  63798. defines["POINTLIGHT" + index] = false;
  63799. defines["DIRLIGHT" + index] = false;
  63800. defines["SPOTLIGHT" + index] = false;
  63801. defines["SHADOW" + index] = false;
  63802. defines["SHADOWPCF" + index] = false;
  63803. defines["SHADOWPCSS" + index] = false;
  63804. defines["SHADOWPOISSON" + index] = false;
  63805. defines["SHADOWESM" + index] = false;
  63806. defines["SHADOWCUBE" + index] = false;
  63807. defines["SHADOWLOWQUALITY" + index] = false;
  63808. defines["SHADOWMEDIUMQUALITY" + index] = false;
  63809. }
  63810. }
  63811. var caps = scene.getEngine().getCaps();
  63812. if (defines["SHADOWFLOAT"] === undefined) {
  63813. needRebuild = true;
  63814. }
  63815. defines["SHADOWFLOAT"] = shadowEnabled &&
  63816. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63817. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63818. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63819. if (needRebuild) {
  63820. defines.rebuild();
  63821. }
  63822. return needNormals;
  63823. };
  63824. /**
  63825. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63826. * that won t be acctive due to defines being turned off.
  63827. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63828. * @param samplersList The samplers list
  63829. * @param defines The defines helping in the list generation
  63830. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63831. */
  63832. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63833. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63834. var uniformsList;
  63835. var uniformBuffersList = null;
  63836. if (uniformsListOrOptions.uniformsNames) {
  63837. var options = uniformsListOrOptions;
  63838. uniformsList = options.uniformsNames;
  63839. uniformBuffersList = options.uniformBuffersNames;
  63840. samplersList = options.samplers;
  63841. defines = options.defines;
  63842. maxSimultaneousLights = options.maxSimultaneousLights;
  63843. }
  63844. else {
  63845. uniformsList = uniformsListOrOptions;
  63846. if (!samplersList) {
  63847. samplersList = [];
  63848. }
  63849. }
  63850. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63851. if (!defines["LIGHT" + lightIndex]) {
  63852. break;
  63853. }
  63854. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63855. if (uniformBuffersList) {
  63856. uniformBuffersList.push("Light" + lightIndex);
  63857. }
  63858. samplersList.push("shadowSampler" + lightIndex);
  63859. samplersList.push("depthSampler" + lightIndex);
  63860. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63861. samplersList.push("projectionLightSampler" + lightIndex);
  63862. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63863. }
  63864. }
  63865. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63866. uniformsList.push("morphTargetInfluences");
  63867. }
  63868. };
  63869. /**
  63870. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63871. * @param defines The defines to update while falling back
  63872. * @param fallbacks The authorized effect fallbacks
  63873. * @param maxSimultaneousLights The maximum number of lights allowed
  63874. * @param rank the current rank of the Effect
  63875. * @returns The newly affected rank
  63876. */
  63877. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63878. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63879. if (rank === void 0) { rank = 0; }
  63880. var lightFallbackRank = 0;
  63881. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63882. if (!defines["LIGHT" + lightIndex]) {
  63883. break;
  63884. }
  63885. if (lightIndex > 0) {
  63886. lightFallbackRank = rank + lightIndex;
  63887. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  63888. }
  63889. if (!defines["SHADOWS"]) {
  63890. if (defines["SHADOW" + lightIndex]) {
  63891. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  63892. }
  63893. if (defines["SHADOWPCF" + lightIndex]) {
  63894. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  63895. }
  63896. if (defines["SHADOWPCSS" + lightIndex]) {
  63897. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  63898. }
  63899. if (defines["SHADOWPOISSON" + lightIndex]) {
  63900. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  63901. }
  63902. if (defines["SHADOWESM" + lightIndex]) {
  63903. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  63904. }
  63905. }
  63906. }
  63907. return lightFallbackRank++;
  63908. };
  63909. /**
  63910. * Prepares the list of attributes required for morph targets according to the effect defines.
  63911. * @param attribs The current list of supported attribs
  63912. * @param mesh The mesh to prepare the morph targets attributes for
  63913. * @param defines The current Defines of the effect
  63914. */
  63915. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  63916. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  63917. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  63918. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  63919. var manager = mesh.morphTargetManager;
  63920. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  63921. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  63922. for (var index = 0; index < influencers; index++) {
  63923. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  63924. if (normal) {
  63925. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  63926. }
  63927. if (tangent) {
  63928. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  63929. }
  63930. if (attribs.length > maxAttributesCount) {
  63931. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  63932. }
  63933. }
  63934. }
  63935. };
  63936. /**
  63937. * Prepares the list of attributes required for bones according to the effect defines.
  63938. * @param attribs The current list of supported attribs
  63939. * @param mesh The mesh to prepare the bones attributes for
  63940. * @param defines The current Defines of the effect
  63941. * @param fallbacks The current efffect fallback strategy
  63942. */
  63943. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  63944. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  63945. fallbacks.addCPUSkinningFallback(0, mesh);
  63946. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  63947. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  63948. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  63949. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  63950. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  63951. }
  63952. }
  63953. };
  63954. /**
  63955. * Prepares the list of attributes required for instances according to the effect defines.
  63956. * @param attribs The current list of supported attribs
  63957. * @param defines The current Defines of the effect
  63958. */
  63959. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  63960. if (defines["INSTANCES"]) {
  63961. attribs.push("world0");
  63962. attribs.push("world1");
  63963. attribs.push("world2");
  63964. attribs.push("world3");
  63965. }
  63966. };
  63967. /**
  63968. * Binds the light shadow information to the effect for the given mesh.
  63969. * @param light The light containing the generator
  63970. * @param scene The scene the lights belongs to
  63971. * @param mesh The mesh we are binding the information to render
  63972. * @param lightIndex The light index in the effect used to render the mesh
  63973. * @param effect The effect we are binding the data to
  63974. */
  63975. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  63976. if (light.shadowEnabled && mesh.receiveShadows) {
  63977. var shadowGenerator = light.getShadowGenerator();
  63978. if (shadowGenerator) {
  63979. shadowGenerator.bindShadowLight(lightIndex, effect);
  63980. }
  63981. }
  63982. };
  63983. /**
  63984. * Binds the light information to the effect.
  63985. * @param light The light containing the generator
  63986. * @param effect The effect we are binding the data to
  63987. * @param lightIndex The light index in the effect used to render
  63988. */
  63989. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  63990. light.transferToEffect(effect, lightIndex + "");
  63991. };
  63992. /**
  63993. * Binds the lights information from the scene to the effect for the given mesh.
  63994. * @param scene The scene the lights belongs to
  63995. * @param mesh The mesh we are binding the information to render
  63996. * @param effect The effect we are binding the data to
  63997. * @param defines The generated defines for the effect
  63998. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  63999. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  64000. */
  64001. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  64002. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64003. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  64004. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  64005. for (var i = 0; i < len; i++) {
  64006. var light = mesh._lightSources[i];
  64007. var iAsString = i.toString();
  64008. var scaledIntensity = light.getScaledIntensity();
  64009. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  64010. MaterialHelper.BindLightProperties(light, effect, i);
  64011. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  64012. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  64013. if (defines["SPECULARTERM"]) {
  64014. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  64015. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  64016. }
  64017. // Shadows
  64018. if (scene.shadowsEnabled) {
  64019. this.BindLightShadow(light, mesh, iAsString, effect);
  64020. }
  64021. light._uniformBuffer.update();
  64022. }
  64023. };
  64024. /**
  64025. * Binds the fog information from the scene to the effect for the given mesh.
  64026. * @param scene The scene the lights belongs to
  64027. * @param mesh The mesh we are binding the information to render
  64028. * @param effect The effect we are binding the data to
  64029. * @param linearSpace Defines if the fog effect is applied in linear space
  64030. */
  64031. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  64032. if (linearSpace === void 0) { linearSpace = false; }
  64033. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  64034. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  64035. // Convert fog color to linear space if used in a linear space computed shader.
  64036. if (linearSpace) {
  64037. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  64038. effect.setColor3("vFogColor", this._tempFogColor);
  64039. }
  64040. else {
  64041. effect.setColor3("vFogColor", scene.fogColor);
  64042. }
  64043. }
  64044. };
  64045. /**
  64046. * Binds the bones information from the mesh to the effect.
  64047. * @param mesh The mesh we are binding the information to render
  64048. * @param effect The effect we are binding the data to
  64049. */
  64050. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  64051. if (!effect || !mesh) {
  64052. return;
  64053. }
  64054. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  64055. mesh.computeBonesUsingShaders = false;
  64056. }
  64057. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64058. var skeleton = mesh.skeleton;
  64059. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  64060. var boneTexture = skeleton.getTransformMatrixTexture();
  64061. effect.setTexture("boneSampler", boneTexture);
  64062. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  64063. }
  64064. else {
  64065. var matrices = skeleton.getTransformMatrices(mesh);
  64066. if (matrices) {
  64067. effect.setMatrices("mBones", matrices);
  64068. }
  64069. }
  64070. }
  64071. };
  64072. /**
  64073. * Binds the morph targets information from the mesh to the effect.
  64074. * @param abstractMesh The mesh we are binding the information to render
  64075. * @param effect The effect we are binding the data to
  64076. */
  64077. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  64078. var manager = abstractMesh.morphTargetManager;
  64079. if (!abstractMesh || !manager) {
  64080. return;
  64081. }
  64082. effect.setFloatArray("morphTargetInfluences", manager.influences);
  64083. };
  64084. /**
  64085. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  64086. * @param defines The generated defines used in the effect
  64087. * @param effect The effect we are binding the data to
  64088. * @param scene The scene we are willing to render with logarithmic scale for
  64089. */
  64090. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  64091. if (defines["LOGARITHMICDEPTH"]) {
  64092. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  64093. }
  64094. };
  64095. /**
  64096. * Binds the clip plane information from the scene to the effect.
  64097. * @param scene The scene the clip plane information are extracted from
  64098. * @param effect The effect we are binding the data to
  64099. */
  64100. MaterialHelper.BindClipPlane = function (effect, scene) {
  64101. if (scene.clipPlane) {
  64102. var clipPlane = scene.clipPlane;
  64103. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64104. }
  64105. if (scene.clipPlane2) {
  64106. var clipPlane = scene.clipPlane2;
  64107. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64108. }
  64109. if (scene.clipPlane3) {
  64110. var clipPlane = scene.clipPlane3;
  64111. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64112. }
  64113. if (scene.clipPlane4) {
  64114. var clipPlane = scene.clipPlane4;
  64115. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64116. }
  64117. };
  64118. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  64119. return MaterialHelper;
  64120. }());
  64121. /***/ }),
  64122. /***/ "./Materials/multiMaterial.ts":
  64123. /*!************************************!*\
  64124. !*** ./Materials/multiMaterial.ts ***!
  64125. \************************************/
  64126. /*! exports provided: MultiMaterial */
  64127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64128. "use strict";
  64129. __webpack_require__.r(__webpack_exports__);
  64130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  64131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64132. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64133. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  64134. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64135. /**
  64136. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64137. * separate meshes. This can be use to improve performances.
  64138. * @see http://doc.babylonjs.com/how_to/multi_materials
  64139. */
  64140. var MultiMaterial = /** @class */ (function (_super) {
  64141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  64142. /**
  64143. * Instantiates a new Multi Material
  64144. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64145. * separate meshes. This can be use to improve performances.
  64146. * @see http://doc.babylonjs.com/how_to/multi_materials
  64147. * @param name Define the name in the scene
  64148. * @param scene Define the scene the material belongs to
  64149. */
  64150. function MultiMaterial(name, scene) {
  64151. var _this = _super.call(this, name, scene, true) || this;
  64152. scene.multiMaterials.push(_this);
  64153. _this.subMaterials = new Array();
  64154. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  64155. return _this;
  64156. }
  64157. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  64158. /**
  64159. * Gets or Sets the list of Materials used within the multi material.
  64160. * They need to be ordered according to the submeshes order in the associated mesh
  64161. */
  64162. get: function () {
  64163. return this._subMaterials;
  64164. },
  64165. set: function (value) {
  64166. this._subMaterials = value;
  64167. this._hookArray(value);
  64168. },
  64169. enumerable: true,
  64170. configurable: true
  64171. });
  64172. /**
  64173. * Function used to align with Node.getChildren()
  64174. * @returns the list of Materials used within the multi material
  64175. */
  64176. MultiMaterial.prototype.getChildren = function () {
  64177. return this.subMaterials;
  64178. };
  64179. MultiMaterial.prototype._hookArray = function (array) {
  64180. var _this = this;
  64181. var oldPush = array.push;
  64182. array.push = function () {
  64183. var items = [];
  64184. for (var _i = 0; _i < arguments.length; _i++) {
  64185. items[_i] = arguments[_i];
  64186. }
  64187. var result = oldPush.apply(array, items);
  64188. _this._markAllSubMeshesAsTexturesDirty();
  64189. return result;
  64190. };
  64191. var oldSplice = array.splice;
  64192. array.splice = function (index, deleteCount) {
  64193. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64194. _this._markAllSubMeshesAsTexturesDirty();
  64195. return deleted;
  64196. };
  64197. };
  64198. /**
  64199. * Get one of the submaterial by its index in the submaterials array
  64200. * @param index The index to look the sub material at
  64201. * @returns The Material if the index has been defined
  64202. */
  64203. MultiMaterial.prototype.getSubMaterial = function (index) {
  64204. if (index < 0 || index >= this.subMaterials.length) {
  64205. return this.getScene().defaultMaterial;
  64206. }
  64207. return this.subMaterials[index];
  64208. };
  64209. /**
  64210. * Get the list of active textures for the whole sub materials list.
  64211. * @returns All the textures that will be used during the rendering
  64212. */
  64213. MultiMaterial.prototype.getActiveTextures = function () {
  64214. var _a;
  64215. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64216. if (subMaterial) {
  64217. return subMaterial.getActiveTextures();
  64218. }
  64219. else {
  64220. return [];
  64221. }
  64222. }));
  64223. };
  64224. /**
  64225. * Gets the current class name of the material e.g. "MultiMaterial"
  64226. * Mainly use in serialization.
  64227. * @returns the class name
  64228. */
  64229. MultiMaterial.prototype.getClassName = function () {
  64230. return "MultiMaterial";
  64231. };
  64232. /**
  64233. * Checks if the material is ready to render the requested sub mesh
  64234. * @param mesh Define the mesh the submesh belongs to
  64235. * @param subMesh Define the sub mesh to look readyness for
  64236. * @param useInstances Define whether or not the material is used with instances
  64237. * @returns true if ready, otherwise false
  64238. */
  64239. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64240. for (var index = 0; index < this.subMaterials.length; index++) {
  64241. var subMaterial = this.subMaterials[index];
  64242. if (subMaterial) {
  64243. if (subMaterial._storeEffectOnSubMeshes) {
  64244. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64245. return false;
  64246. }
  64247. continue;
  64248. }
  64249. if (!subMaterial.isReady(mesh)) {
  64250. return false;
  64251. }
  64252. }
  64253. }
  64254. return true;
  64255. };
  64256. /**
  64257. * Clones the current material and its related sub materials
  64258. * @param name Define the name of the newly cloned material
  64259. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64260. * @returns the cloned material
  64261. */
  64262. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64263. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64264. for (var index = 0; index < this.subMaterials.length; index++) {
  64265. var subMaterial = null;
  64266. var current = this.subMaterials[index];
  64267. if (cloneChildren && current) {
  64268. subMaterial = current.clone(name + "-" + current.name);
  64269. }
  64270. else {
  64271. subMaterial = this.subMaterials[index];
  64272. }
  64273. newMultiMaterial.subMaterials.push(subMaterial);
  64274. }
  64275. return newMultiMaterial;
  64276. };
  64277. /**
  64278. * Serializes the materials into a JSON representation.
  64279. * @returns the JSON representation
  64280. */
  64281. MultiMaterial.prototype.serialize = function () {
  64282. var serializationObject = {};
  64283. serializationObject.name = this.name;
  64284. serializationObject.id = this.id;
  64285. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64286. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64287. }
  64288. serializationObject.materials = [];
  64289. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64290. var subMat = this.subMaterials[matIndex];
  64291. if (subMat) {
  64292. serializationObject.materials.push(subMat.id);
  64293. }
  64294. else {
  64295. serializationObject.materials.push(null);
  64296. }
  64297. }
  64298. return serializationObject;
  64299. };
  64300. /**
  64301. * Dispose the material and release its associated resources
  64302. * @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)
  64303. * @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)
  64304. * @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)
  64305. */
  64306. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64307. var scene = this.getScene();
  64308. if (!scene) {
  64309. return;
  64310. }
  64311. if (forceDisposeChildren) {
  64312. for (var index = 0; index < this.subMaterials.length; index++) {
  64313. var subMaterial = this.subMaterials[index];
  64314. if (subMaterial) {
  64315. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64316. }
  64317. }
  64318. }
  64319. var index = scene.multiMaterials.indexOf(this);
  64320. if (index >= 0) {
  64321. scene.multiMaterials.splice(index, 1);
  64322. }
  64323. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64324. };
  64325. /**
  64326. * Creates a MultiMaterial from parsed MultiMaterial data.
  64327. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64328. * @param scene defines the hosting scene
  64329. * @returns a new MultiMaterial
  64330. */
  64331. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64332. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64333. multiMaterial.id = parsedMultiMaterial.id;
  64334. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64335. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64336. }
  64337. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64338. var subMatId = parsedMultiMaterial.materials[matIndex];
  64339. if (subMatId) {
  64340. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64341. }
  64342. else {
  64343. multiMaterial.subMaterials.push(null);
  64344. }
  64345. }
  64346. return multiMaterial;
  64347. };
  64348. return MultiMaterial;
  64349. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64350. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64351. /***/ }),
  64352. /***/ "./Materials/pushMaterial.ts":
  64353. /*!***********************************!*\
  64354. !*** ./Materials/pushMaterial.ts ***!
  64355. \***********************************/
  64356. /*! exports provided: PushMaterial */
  64357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64358. "use strict";
  64359. __webpack_require__.r(__webpack_exports__);
  64360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64362. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64363. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64364. /**
  64365. * Base class of materials working in push mode in babylon JS
  64366. * @hidden
  64367. */
  64368. var PushMaterial = /** @class */ (function (_super) {
  64369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64370. function PushMaterial(name, scene) {
  64371. var _this = _super.call(this, name, scene) || this;
  64372. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64373. /**
  64374. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64375. * This means that the material can keep using a previous shader while a new one is being compiled.
  64376. * This is mostly used when shader parallel compilation is supported (true by default)
  64377. */
  64378. _this.allowShaderHotSwapping = true;
  64379. _this._storeEffectOnSubMeshes = true;
  64380. return _this;
  64381. }
  64382. PushMaterial.prototype.getEffect = function () {
  64383. return this._activeEffect;
  64384. };
  64385. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64386. if (!mesh) {
  64387. return false;
  64388. }
  64389. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64390. return true;
  64391. }
  64392. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64393. };
  64394. /**
  64395. * Binds the given world matrix to the active effect
  64396. *
  64397. * @param world the matrix to bind
  64398. */
  64399. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64400. this._activeEffect.setMatrix("world", world);
  64401. };
  64402. /**
  64403. * Binds the given normal matrix to the active effect
  64404. *
  64405. * @param normalMatrix the matrix to bind
  64406. */
  64407. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64408. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64409. };
  64410. PushMaterial.prototype.bind = function (world, mesh) {
  64411. if (!mesh) {
  64412. return;
  64413. }
  64414. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64415. };
  64416. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64417. if (effect === void 0) { effect = null; }
  64418. _super.prototype._afterBind.call(this, mesh);
  64419. this.getScene()._cachedEffect = effect;
  64420. };
  64421. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  64422. if (visibility === void 0) { visibility = 1; }
  64423. return scene.isCachedMaterialInvalid(this, effect, visibility);
  64424. };
  64425. return PushMaterial;
  64426. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  64427. /***/ }),
  64428. /***/ "./Materials/shaderMaterial.ts":
  64429. /*!*************************************!*\
  64430. !*** ./Materials/shaderMaterial.ts ***!
  64431. \*************************************/
  64432. /*! exports provided: ShaderMaterial */
  64433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64434. "use strict";
  64435. __webpack_require__.r(__webpack_exports__);
  64436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  64437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64438. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64439. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64440. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64441. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64442. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64443. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64444. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64445. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64446. /**
  64447. * 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.
  64448. *
  64449. * This returned material effects how the mesh will look based on the code in the shaders.
  64450. *
  64451. * @see http://doc.babylonjs.com/how_to/shader_material
  64452. */
  64453. var ShaderMaterial = /** @class */ (function (_super) {
  64454. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  64455. /**
  64456. * Instantiate a new shader material.
  64457. * 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.
  64458. * This returned material effects how the mesh will look based on the code in the shaders.
  64459. * @see http://doc.babylonjs.com/how_to/shader_material
  64460. * @param name Define the name of the material in the scene
  64461. * @param scene Define the scene the material belongs to
  64462. * @param shaderPath Defines the route to the shader code in one of three ways:
  64463. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  64464. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  64465. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  64466. * @param options Define the options used to create the shader
  64467. */
  64468. function ShaderMaterial(name, scene, shaderPath, options) {
  64469. if (options === void 0) { options = {}; }
  64470. var _this = _super.call(this, name, scene) || this;
  64471. _this._textures = {};
  64472. _this._textureArrays = {};
  64473. _this._floats = {};
  64474. _this._ints = {};
  64475. _this._floatsArrays = {};
  64476. _this._colors3 = {};
  64477. _this._colors3Arrays = {};
  64478. _this._colors4 = {};
  64479. _this._vectors2 = {};
  64480. _this._vectors3 = {};
  64481. _this._vectors4 = {};
  64482. _this._matrices = {};
  64483. _this._matrices3x3 = {};
  64484. _this._matrices2x2 = {};
  64485. _this._vectors2Arrays = {};
  64486. _this._vectors3Arrays = {};
  64487. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  64488. _this._shaderPath = shaderPath;
  64489. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  64490. return _this;
  64491. }
  64492. /**
  64493. * Gets the current class name of the material e.g. "ShaderMaterial"
  64494. * Mainly use in serialization.
  64495. * @returns the class name
  64496. */
  64497. ShaderMaterial.prototype.getClassName = function () {
  64498. return "ShaderMaterial";
  64499. };
  64500. /**
  64501. * Specifies if the material will require alpha blending
  64502. * @returns a boolean specifying if alpha blending is needed
  64503. */
  64504. ShaderMaterial.prototype.needAlphaBlending = function () {
  64505. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  64506. };
  64507. /**
  64508. * Specifies if this material should be rendered in alpha test mode
  64509. * @returns a boolean specifying if an alpha test is needed.
  64510. */
  64511. ShaderMaterial.prototype.needAlphaTesting = function () {
  64512. return this._options.needAlphaTesting;
  64513. };
  64514. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  64515. if (this._options.uniforms.indexOf(uniformName) === -1) {
  64516. this._options.uniforms.push(uniformName);
  64517. }
  64518. };
  64519. /**
  64520. * Set a texture in the shader.
  64521. * @param name Define the name of the uniform samplers as defined in the shader
  64522. * @param texture Define the texture to bind to this sampler
  64523. * @return the material itself allowing "fluent" like uniform updates
  64524. */
  64525. ShaderMaterial.prototype.setTexture = function (name, texture) {
  64526. if (this._options.samplers.indexOf(name) === -1) {
  64527. this._options.samplers.push(name);
  64528. }
  64529. this._textures[name] = texture;
  64530. return this;
  64531. };
  64532. /**
  64533. * Set a texture array in the shader.
  64534. * @param name Define the name of the uniform sampler array as defined in the shader
  64535. * @param textures Define the list of textures to bind to this sampler
  64536. * @return the material itself allowing "fluent" like uniform updates
  64537. */
  64538. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  64539. if (this._options.samplers.indexOf(name) === -1) {
  64540. this._options.samplers.push(name);
  64541. }
  64542. this._checkUniform(name);
  64543. this._textureArrays[name] = textures;
  64544. return this;
  64545. };
  64546. /**
  64547. * Set a float in the shader.
  64548. * @param name Define the name of the uniform as defined in the shader
  64549. * @param value Define the value to give to the uniform
  64550. * @return the material itself allowing "fluent" like uniform updates
  64551. */
  64552. ShaderMaterial.prototype.setFloat = function (name, value) {
  64553. this._checkUniform(name);
  64554. this._floats[name] = value;
  64555. return this;
  64556. };
  64557. /**
  64558. * Set a int in the shader.
  64559. * @param name Define the name of the uniform as defined in the shader
  64560. * @param value Define the value to give to the uniform
  64561. * @return the material itself allowing "fluent" like uniform updates
  64562. */
  64563. ShaderMaterial.prototype.setInt = function (name, value) {
  64564. this._checkUniform(name);
  64565. this._ints[name] = value;
  64566. return this;
  64567. };
  64568. /**
  64569. * Set an array of floats in the shader.
  64570. * @param name Define the name of the uniform as defined in the shader
  64571. * @param value Define the value to give to the uniform
  64572. * @return the material itself allowing "fluent" like uniform updates
  64573. */
  64574. ShaderMaterial.prototype.setFloats = function (name, value) {
  64575. this._checkUniform(name);
  64576. this._floatsArrays[name] = value;
  64577. return this;
  64578. };
  64579. /**
  64580. * Set a vec3 in the shader from a Color3.
  64581. * @param name Define the name of the uniform as defined in the shader
  64582. * @param value Define the value to give to the uniform
  64583. * @return the material itself allowing "fluent" like uniform updates
  64584. */
  64585. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64586. this._checkUniform(name);
  64587. this._colors3[name] = value;
  64588. return this;
  64589. };
  64590. /**
  64591. * Set a vec3 array in the shader from a Color3 array.
  64592. * @param name Define the name of the uniform as defined in the shader
  64593. * @param value Define the value to give to the uniform
  64594. * @return the material itself allowing "fluent" like uniform updates
  64595. */
  64596. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64597. this._checkUniform(name);
  64598. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64599. color.toArray(arr, arr.length);
  64600. return arr;
  64601. }, []);
  64602. return this;
  64603. };
  64604. /**
  64605. * Set a vec4 in the shader from a Color4.
  64606. * @param name Define the name of the uniform as defined in the shader
  64607. * @param value Define the value to give to the uniform
  64608. * @return the material itself allowing "fluent" like uniform updates
  64609. */
  64610. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64611. this._checkUniform(name);
  64612. this._colors4[name] = value;
  64613. return this;
  64614. };
  64615. /**
  64616. * Set a vec2 in the shader from a Vector2.
  64617. * @param name Define the name of the uniform as defined in the shader
  64618. * @param value Define the value to give to the uniform
  64619. * @return the material itself allowing "fluent" like uniform updates
  64620. */
  64621. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64622. this._checkUniform(name);
  64623. this._vectors2[name] = value;
  64624. return this;
  64625. };
  64626. /**
  64627. * Set a vec3 in the shader from a Vector3.
  64628. * @param name Define the name of the uniform as defined in the shader
  64629. * @param value Define the value to give to the uniform
  64630. * @return the material itself allowing "fluent" like uniform updates
  64631. */
  64632. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64633. this._checkUniform(name);
  64634. this._vectors3[name] = value;
  64635. return this;
  64636. };
  64637. /**
  64638. * Set a vec4 in the shader from a Vector4.
  64639. * @param name Define the name of the uniform as defined in the shader
  64640. * @param value Define the value to give to the uniform
  64641. * @return the material itself allowing "fluent" like uniform updates
  64642. */
  64643. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64644. this._checkUniform(name);
  64645. this._vectors4[name] = value;
  64646. return this;
  64647. };
  64648. /**
  64649. * Set a mat4 in the shader from a Matrix.
  64650. * @param name Define the name of the uniform as defined in the shader
  64651. * @param value Define the value to give to the uniform
  64652. * @return the material itself allowing "fluent" like uniform updates
  64653. */
  64654. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64655. this._checkUniform(name);
  64656. this._matrices[name] = value;
  64657. return this;
  64658. };
  64659. /**
  64660. * Set a mat3 in the shader from a Float32Array.
  64661. * @param name Define the name of the uniform as defined in the shader
  64662. * @param value Define the value to give to the uniform
  64663. * @return the material itself allowing "fluent" like uniform updates
  64664. */
  64665. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64666. this._checkUniform(name);
  64667. this._matrices3x3[name] = value;
  64668. return this;
  64669. };
  64670. /**
  64671. * Set a mat2 in the shader from a Float32Array.
  64672. * @param name Define the name of the uniform as defined in the shader
  64673. * @param value Define the value to give to the uniform
  64674. * @return the material itself allowing "fluent" like uniform updates
  64675. */
  64676. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64677. this._checkUniform(name);
  64678. this._matrices2x2[name] = value;
  64679. return this;
  64680. };
  64681. /**
  64682. * Set a vec2 array in the shader from a number array.
  64683. * @param name Define the name of the uniform as defined in the shader
  64684. * @param value Define the value to give to the uniform
  64685. * @return the material itself allowing "fluent" like uniform updates
  64686. */
  64687. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64688. this._checkUniform(name);
  64689. this._vectors2Arrays[name] = value;
  64690. return this;
  64691. };
  64692. /**
  64693. * Set a vec3 array in the shader from a number array.
  64694. * @param name Define the name of the uniform as defined in the shader
  64695. * @param value Define the value to give to the uniform
  64696. * @return the material itself allowing "fluent" like uniform updates
  64697. */
  64698. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64699. this._checkUniform(name);
  64700. this._vectors3Arrays[name] = value;
  64701. return this;
  64702. };
  64703. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64704. if (!mesh) {
  64705. return true;
  64706. }
  64707. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64708. return false;
  64709. }
  64710. return false;
  64711. };
  64712. /**
  64713. * Checks if the material is ready to render the requested mesh
  64714. * @param mesh Define the mesh to render
  64715. * @param useInstances Define whether or not the material is used with instances
  64716. * @returns true if ready, otherwise false
  64717. */
  64718. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64719. var scene = this.getScene();
  64720. var engine = scene.getEngine();
  64721. if (!this.checkReadyOnEveryCall) {
  64722. if (this._renderId === scene.getRenderId()) {
  64723. if (this._checkCache(mesh, useInstances)) {
  64724. return true;
  64725. }
  64726. }
  64727. }
  64728. // Instances
  64729. var defines = [];
  64730. var attribs = [];
  64731. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64732. for (var index = 0; index < this._options.defines.length; index++) {
  64733. defines.push(this._options.defines[index]);
  64734. }
  64735. for (var index = 0; index < this._options.attributes.length; index++) {
  64736. attribs.push(this._options.attributes[index]);
  64737. }
  64738. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64739. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64740. defines.push("#define VERTEXCOLOR");
  64741. }
  64742. if (useInstances) {
  64743. defines.push("#define INSTANCES");
  64744. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64745. }
  64746. // Bones
  64747. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64748. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64749. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64750. if (mesh.numBoneInfluencers > 4) {
  64751. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64752. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64753. }
  64754. var skeleton = mesh.skeleton;
  64755. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64756. fallbacks.addCPUSkinningFallback(0, mesh);
  64757. if (skeleton.isUsingTextureForMatrices) {
  64758. defines.push("#define BONETEXTURE");
  64759. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64760. this._options.uniforms.push("boneTextureWidth");
  64761. }
  64762. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64763. this._options.samplers.push("boneSampler");
  64764. }
  64765. }
  64766. else {
  64767. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64768. if (this._options.uniforms.indexOf("mBones") === -1) {
  64769. this._options.uniforms.push("mBones");
  64770. }
  64771. }
  64772. }
  64773. else {
  64774. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64775. }
  64776. // Textures
  64777. for (var name in this._textures) {
  64778. if (!this._textures[name].isReady()) {
  64779. return false;
  64780. }
  64781. }
  64782. // Alpha test
  64783. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64784. defines.push("#define ALPHATEST");
  64785. }
  64786. var previousEffect = this._effect;
  64787. var join = defines.join("\n");
  64788. this._effect = engine.createEffect(this._shaderPath, {
  64789. attributes: attribs,
  64790. uniformsNames: this._options.uniforms,
  64791. uniformBuffersNames: this._options.uniformBuffers,
  64792. samplers: this._options.samplers,
  64793. defines: join,
  64794. fallbacks: fallbacks,
  64795. onCompiled: this.onCompiled,
  64796. onError: this.onError
  64797. }, engine);
  64798. if (!this._effect.isReady()) {
  64799. return false;
  64800. }
  64801. if (previousEffect !== this._effect) {
  64802. scene.resetCachedMaterial();
  64803. }
  64804. this._renderId = scene.getRenderId();
  64805. return true;
  64806. };
  64807. /**
  64808. * Binds the world matrix to the material
  64809. * @param world defines the world transformation matrix
  64810. */
  64811. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64812. var scene = this.getScene();
  64813. if (!this._effect) {
  64814. return;
  64815. }
  64816. if (this._options.uniforms.indexOf("world") !== -1) {
  64817. this._effect.setMatrix("world", world);
  64818. }
  64819. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64820. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64821. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64822. }
  64823. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64824. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64825. }
  64826. };
  64827. /**
  64828. * Binds the material to the mesh
  64829. * @param world defines the world transformation matrix
  64830. * @param mesh defines the mesh to bind the material to
  64831. */
  64832. ShaderMaterial.prototype.bind = function (world, mesh) {
  64833. // Std values
  64834. this.bindOnlyWorldMatrix(world);
  64835. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64836. if (this._options.uniforms.indexOf("view") !== -1) {
  64837. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64838. }
  64839. if (this._options.uniforms.indexOf("projection") !== -1) {
  64840. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64841. }
  64842. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64843. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64844. }
  64845. // Bones
  64846. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64847. var name;
  64848. // Texture
  64849. for (name in this._textures) {
  64850. this._effect.setTexture(name, this._textures[name]);
  64851. }
  64852. // Texture arrays
  64853. for (name in this._textureArrays) {
  64854. this._effect.setTextureArray(name, this._textureArrays[name]);
  64855. }
  64856. // Int
  64857. for (name in this._ints) {
  64858. this._effect.setInt(name, this._ints[name]);
  64859. }
  64860. // Float
  64861. for (name in this._floats) {
  64862. this._effect.setFloat(name, this._floats[name]);
  64863. }
  64864. // Floats
  64865. for (name in this._floatsArrays) {
  64866. this._effect.setArray(name, this._floatsArrays[name]);
  64867. }
  64868. // Color3
  64869. for (name in this._colors3) {
  64870. this._effect.setColor3(name, this._colors3[name]);
  64871. }
  64872. for (name in this._colors3Arrays) {
  64873. this._effect.setArray3(name, this._colors3Arrays[name]);
  64874. }
  64875. // Color4
  64876. for (name in this._colors4) {
  64877. var color = this._colors4[name];
  64878. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  64879. }
  64880. // Vector2
  64881. for (name in this._vectors2) {
  64882. this._effect.setVector2(name, this._vectors2[name]);
  64883. }
  64884. // Vector3
  64885. for (name in this._vectors3) {
  64886. this._effect.setVector3(name, this._vectors3[name]);
  64887. }
  64888. // Vector4
  64889. for (name in this._vectors4) {
  64890. this._effect.setVector4(name, this._vectors4[name]);
  64891. }
  64892. // Matrix
  64893. for (name in this._matrices) {
  64894. this._effect.setMatrix(name, this._matrices[name]);
  64895. }
  64896. // Matrix 3x3
  64897. for (name in this._matrices3x3) {
  64898. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  64899. }
  64900. // Matrix 2x2
  64901. for (name in this._matrices2x2) {
  64902. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  64903. }
  64904. // Vector2Array
  64905. for (name in this._vectors2Arrays) {
  64906. this._effect.setArray2(name, this._vectors2Arrays[name]);
  64907. }
  64908. // Vector3Array
  64909. for (name in this._vectors3Arrays) {
  64910. this._effect.setArray3(name, this._vectors3Arrays[name]);
  64911. }
  64912. }
  64913. this._afterBind(mesh);
  64914. };
  64915. /**
  64916. * Gets the active textures from the material
  64917. * @returns an array of textures
  64918. */
  64919. ShaderMaterial.prototype.getActiveTextures = function () {
  64920. var activeTextures = _super.prototype.getActiveTextures.call(this);
  64921. for (var name in this._textures) {
  64922. activeTextures.push(this._textures[name]);
  64923. }
  64924. for (var name in this._textureArrays) {
  64925. var array = this._textureArrays[name];
  64926. for (var index = 0; index < array.length; index++) {
  64927. activeTextures.push(array[index]);
  64928. }
  64929. }
  64930. return activeTextures;
  64931. };
  64932. /**
  64933. * Specifies if the material uses a texture
  64934. * @param texture defines the texture to check against the material
  64935. * @returns a boolean specifying if the material uses the texture
  64936. */
  64937. ShaderMaterial.prototype.hasTexture = function (texture) {
  64938. if (_super.prototype.hasTexture.call(this, texture)) {
  64939. return true;
  64940. }
  64941. for (var name in this._textures) {
  64942. if (this._textures[name] === texture) {
  64943. return true;
  64944. }
  64945. }
  64946. for (var name in this._textureArrays) {
  64947. var array = this._textureArrays[name];
  64948. for (var index = 0; index < array.length; index++) {
  64949. if (array[index] === texture) {
  64950. return true;
  64951. }
  64952. }
  64953. }
  64954. return false;
  64955. };
  64956. /**
  64957. * Makes a duplicate of the material, and gives it a new name
  64958. * @param name defines the new name for the duplicated material
  64959. * @returns the cloned material
  64960. */
  64961. ShaderMaterial.prototype.clone = function (name) {
  64962. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  64963. return newShaderMaterial;
  64964. };
  64965. /**
  64966. * Disposes the material
  64967. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64968. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64969. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64970. */
  64971. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64972. if (forceDisposeTextures) {
  64973. var name;
  64974. for (name in this._textures) {
  64975. this._textures[name].dispose();
  64976. }
  64977. for (name in this._textureArrays) {
  64978. var array = this._textureArrays[name];
  64979. for (var index = 0; index < array.length; index++) {
  64980. array[index].dispose();
  64981. }
  64982. }
  64983. }
  64984. this._textures = {};
  64985. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  64986. };
  64987. /**
  64988. * Serializes this material in a JSON representation
  64989. * @returns the serialized material object
  64990. */
  64991. ShaderMaterial.prototype.serialize = function () {
  64992. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64993. serializationObject.customType = "ShaderMaterial";
  64994. serializationObject.options = this._options;
  64995. serializationObject.shaderPath = this._shaderPath;
  64996. var name;
  64997. // Texture
  64998. serializationObject.textures = {};
  64999. for (name in this._textures) {
  65000. serializationObject.textures[name] = this._textures[name].serialize();
  65001. }
  65002. // Texture arrays
  65003. serializationObject.textureArrays = {};
  65004. for (name in this._textureArrays) {
  65005. serializationObject.textureArrays[name] = [];
  65006. var array = this._textureArrays[name];
  65007. for (var index = 0; index < array.length; index++) {
  65008. serializationObject.textureArrays[name].push(array[index].serialize());
  65009. }
  65010. }
  65011. // Float
  65012. serializationObject.floats = {};
  65013. for (name in this._floats) {
  65014. serializationObject.floats[name] = this._floats[name];
  65015. }
  65016. // Float s
  65017. serializationObject.FloatArrays = {};
  65018. for (name in this._floatsArrays) {
  65019. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  65020. }
  65021. // Color3
  65022. serializationObject.colors3 = {};
  65023. for (name in this._colors3) {
  65024. serializationObject.colors3[name] = this._colors3[name].asArray();
  65025. }
  65026. // Color3 array
  65027. serializationObject.colors3Arrays = {};
  65028. for (name in this._colors3Arrays) {
  65029. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  65030. }
  65031. // Color4
  65032. serializationObject.colors4 = {};
  65033. for (name in this._colors4) {
  65034. serializationObject.colors4[name] = this._colors4[name].asArray();
  65035. }
  65036. // Vector2
  65037. serializationObject.vectors2 = {};
  65038. for (name in this._vectors2) {
  65039. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  65040. }
  65041. // Vector3
  65042. serializationObject.vectors3 = {};
  65043. for (name in this._vectors3) {
  65044. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  65045. }
  65046. // Vector4
  65047. serializationObject.vectors4 = {};
  65048. for (name in this._vectors4) {
  65049. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  65050. }
  65051. // Matrix
  65052. serializationObject.matrices = {};
  65053. for (name in this._matrices) {
  65054. serializationObject.matrices[name] = this._matrices[name].asArray();
  65055. }
  65056. // Matrix 3x3
  65057. serializationObject.matrices3x3 = {};
  65058. for (name in this._matrices3x3) {
  65059. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  65060. }
  65061. // Matrix 2x2
  65062. serializationObject.matrices2x2 = {};
  65063. for (name in this._matrices2x2) {
  65064. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  65065. }
  65066. // Vector2Array
  65067. serializationObject.vectors2Arrays = {};
  65068. for (name in this._vectors2Arrays) {
  65069. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  65070. }
  65071. // Vector3Array
  65072. serializationObject.vectors3Arrays = {};
  65073. for (name in this._vectors3Arrays) {
  65074. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  65075. }
  65076. return serializationObject;
  65077. };
  65078. /**
  65079. * Creates a shader material from parsed shader material data
  65080. * @param source defines the JSON represnetation of the material
  65081. * @param scene defines the hosting scene
  65082. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65083. * @returns a new material
  65084. */
  65085. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  65086. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  65087. var name;
  65088. // Texture
  65089. for (name in source.textures) {
  65090. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  65091. }
  65092. // Texture arrays
  65093. for (name in source.textureArrays) {
  65094. var array = source.textureArrays[name];
  65095. var textureArray = new Array();
  65096. for (var index = 0; index < array.length; index++) {
  65097. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  65098. }
  65099. material.setTextureArray(name, textureArray);
  65100. }
  65101. // Float
  65102. for (name in source.floats) {
  65103. material.setFloat(name, source.floats[name]);
  65104. }
  65105. // Float s
  65106. for (name in source.floatsArrays) {
  65107. material.setFloats(name, source.floatsArrays[name]);
  65108. }
  65109. // Color3
  65110. for (name in source.colors3) {
  65111. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  65112. }
  65113. // Color3 arrays
  65114. for (name in source.colors3Arrays) {
  65115. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  65116. if (i % 3 === 0) {
  65117. arr.push([num]);
  65118. }
  65119. else {
  65120. arr[arr.length - 1].push(num);
  65121. }
  65122. return arr;
  65123. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  65124. material.setColor3Array(name, colors);
  65125. }
  65126. // Color4
  65127. for (name in source.colors4) {
  65128. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  65129. }
  65130. // Vector2
  65131. for (name in source.vectors2) {
  65132. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  65133. }
  65134. // Vector3
  65135. for (name in source.vectors3) {
  65136. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  65137. }
  65138. // Vector4
  65139. for (name in source.vectors4) {
  65140. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  65141. }
  65142. // Matrix
  65143. for (name in source.matrices) {
  65144. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  65145. }
  65146. // Matrix 3x3
  65147. for (name in source.matrices3x3) {
  65148. material.setMatrix3x3(name, source.matrices3x3[name]);
  65149. }
  65150. // Matrix 2x2
  65151. for (name in source.matrices2x2) {
  65152. material.setMatrix2x2(name, source.matrices2x2[name]);
  65153. }
  65154. // Vector2Array
  65155. for (name in source.vectors2Arrays) {
  65156. material.setArray2(name, source.vectors2Arrays[name]);
  65157. }
  65158. // Vector3Array
  65159. for (name in source.vectors3Arrays) {
  65160. material.setArray3(name, source.vectors3Arrays[name]);
  65161. }
  65162. return material;
  65163. };
  65164. return ShaderMaterial;
  65165. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  65166. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  65167. /***/ }),
  65168. /***/ "./Materials/standardMaterial.ts":
  65169. /*!***************************************!*\
  65170. !*** ./Materials/standardMaterial.ts ***!
  65171. \***************************************/
  65172. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  65173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65174. "use strict";
  65175. __webpack_require__.r(__webpack_exports__);
  65176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  65177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  65178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65179. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65180. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  65181. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65182. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65183. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65184. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65185. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65186. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65187. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65188. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65189. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65190. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65191. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65192. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65193. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65195. /** @hidden */
  65196. var StandardMaterialDefines = /** @class */ (function (_super) {
  65197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65198. function StandardMaterialDefines() {
  65199. var _this = _super.call(this) || this;
  65200. _this.MAINUV1 = false;
  65201. _this.MAINUV2 = false;
  65202. _this.DIFFUSE = false;
  65203. _this.DIFFUSEDIRECTUV = 0;
  65204. _this.AMBIENT = false;
  65205. _this.AMBIENTDIRECTUV = 0;
  65206. _this.OPACITY = false;
  65207. _this.OPACITYDIRECTUV = 0;
  65208. _this.OPACITYRGB = false;
  65209. _this.REFLECTION = false;
  65210. _this.EMISSIVE = false;
  65211. _this.EMISSIVEDIRECTUV = 0;
  65212. _this.SPECULAR = false;
  65213. _this.SPECULARDIRECTUV = 0;
  65214. _this.BUMP = false;
  65215. _this.BUMPDIRECTUV = 0;
  65216. _this.PARALLAX = false;
  65217. _this.PARALLAXOCCLUSION = false;
  65218. _this.SPECULAROVERALPHA = false;
  65219. _this.CLIPPLANE = false;
  65220. _this.CLIPPLANE2 = false;
  65221. _this.CLIPPLANE3 = false;
  65222. _this.CLIPPLANE4 = false;
  65223. _this.ALPHATEST = false;
  65224. _this.DEPTHPREPASS = false;
  65225. _this.ALPHAFROMDIFFUSE = false;
  65226. _this.POINTSIZE = false;
  65227. _this.FOG = false;
  65228. _this.SPECULARTERM = false;
  65229. _this.DIFFUSEFRESNEL = false;
  65230. _this.OPACITYFRESNEL = false;
  65231. _this.REFLECTIONFRESNEL = false;
  65232. _this.REFRACTIONFRESNEL = false;
  65233. _this.EMISSIVEFRESNEL = false;
  65234. _this.FRESNEL = false;
  65235. _this.NORMAL = false;
  65236. _this.UV1 = false;
  65237. _this.UV2 = false;
  65238. _this.VERTEXCOLOR = false;
  65239. _this.VERTEXALPHA = false;
  65240. _this.NUM_BONE_INFLUENCERS = 0;
  65241. _this.BonesPerMesh = 0;
  65242. _this.BONETEXTURE = false;
  65243. _this.INSTANCES = false;
  65244. _this.GLOSSINESS = false;
  65245. _this.ROUGHNESS = false;
  65246. _this.EMISSIVEASILLUMINATION = false;
  65247. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65248. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65249. _this.LIGHTMAP = false;
  65250. _this.LIGHTMAPDIRECTUV = 0;
  65251. _this.OBJECTSPACE_NORMALMAP = false;
  65252. _this.USELIGHTMAPASSHADOWMAP = false;
  65253. _this.REFLECTIONMAP_3D = false;
  65254. _this.REFLECTIONMAP_SPHERICAL = false;
  65255. _this.REFLECTIONMAP_PLANAR = false;
  65256. _this.REFLECTIONMAP_CUBIC = false;
  65257. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65258. _this.REFLECTIONMAP_PROJECTION = false;
  65259. _this.REFLECTIONMAP_SKYBOX = false;
  65260. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65261. _this.REFLECTIONMAP_EXPLICIT = false;
  65262. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65263. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65264. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65265. _this.INVERTCUBICMAP = false;
  65266. _this.LOGARITHMICDEPTH = false;
  65267. _this.REFRACTION = false;
  65268. _this.REFRACTIONMAP_3D = false;
  65269. _this.REFLECTIONOVERALPHA = false;
  65270. _this.TWOSIDEDLIGHTING = false;
  65271. _this.SHADOWFLOAT = false;
  65272. _this.MORPHTARGETS = false;
  65273. _this.MORPHTARGETS_NORMAL = false;
  65274. _this.MORPHTARGETS_TANGENT = false;
  65275. _this.NUM_MORPH_INFLUENCERS = 0;
  65276. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65277. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65278. _this.IMAGEPROCESSING = false;
  65279. _this.VIGNETTE = false;
  65280. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65281. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65282. _this.TONEMAPPING = false;
  65283. _this.TONEMAPPING_ACES = false;
  65284. _this.CONTRAST = false;
  65285. _this.COLORCURVES = false;
  65286. _this.COLORGRADING = false;
  65287. _this.COLORGRADING3D = false;
  65288. _this.SAMPLER3DGREENDEPTH = false;
  65289. _this.SAMPLER3DBGRMAP = false;
  65290. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65291. /**
  65292. * If the reflection texture on this material is in linear color space
  65293. * @hidden
  65294. */
  65295. _this.IS_REFLECTION_LINEAR = false;
  65296. /**
  65297. * If the refraction texture on this material is in linear color space
  65298. * @hidden
  65299. */
  65300. _this.IS_REFRACTION_LINEAR = false;
  65301. _this.EXPOSURE = false;
  65302. _this.rebuild();
  65303. return _this;
  65304. }
  65305. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65306. var modes = [
  65307. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65308. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65309. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65310. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65311. ];
  65312. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65313. var mode = modes_1[_i];
  65314. this[mode] = (mode === modeToEnable);
  65315. }
  65316. };
  65317. return StandardMaterialDefines;
  65318. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65319. /**
  65320. * This is the default material used in Babylon. It is the best trade off between quality
  65321. * and performances.
  65322. * @see http://doc.babylonjs.com/babylon101/materials
  65323. */
  65324. var StandardMaterial = /** @class */ (function (_super) {
  65325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65326. /**
  65327. * Instantiates a new standard material.
  65328. * This is the default material used in Babylon. It is the best trade off between quality
  65329. * and performances.
  65330. * @see http://doc.babylonjs.com/babylon101/materials
  65331. * @param name Define the name of the material in the scene
  65332. * @param scene Define the scene the material belong to
  65333. */
  65334. function StandardMaterial(name, scene) {
  65335. var _this = _super.call(this, name, scene) || this;
  65336. /**
  65337. * The color of the material lit by the environmental background lighting.
  65338. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65339. */
  65340. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65341. /**
  65342. * The basic color of the material as viewed under a light.
  65343. */
  65344. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65345. /**
  65346. * Define how the color and intensity of the highlight given by the light in the material.
  65347. */
  65348. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65349. /**
  65350. * Define the color of the material as if self lit.
  65351. * This will be mixed in the final result even in the absence of light.
  65352. */
  65353. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65354. /**
  65355. * Defines how sharp are the highlights in the material.
  65356. * The bigger the value the sharper giving a more glossy feeling to the result.
  65357. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65358. */
  65359. _this.specularPower = 64;
  65360. _this._useAlphaFromDiffuseTexture = false;
  65361. _this._useEmissiveAsIllumination = false;
  65362. _this._linkEmissiveWithDiffuse = false;
  65363. _this._useSpecularOverAlpha = false;
  65364. _this._useReflectionOverAlpha = false;
  65365. _this._disableLighting = false;
  65366. _this._useObjectSpaceNormalMap = false;
  65367. _this._useParallax = false;
  65368. _this._useParallaxOcclusion = false;
  65369. /**
  65370. * 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.
  65371. */
  65372. _this.parallaxScaleBias = 0.05;
  65373. _this._roughness = 0;
  65374. /**
  65375. * In case of refraction, define the value of the indice of refraction.
  65376. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65377. */
  65378. _this.indexOfRefraction = 0.98;
  65379. /**
  65380. * Invert the refraction texture alongside the y axis.
  65381. * It can be useful with procedural textures or probe for instance.
  65382. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65383. */
  65384. _this.invertRefractionY = true;
  65385. /**
  65386. * Defines the alpha limits in alpha test mode.
  65387. */
  65388. _this.alphaCutOff = 0.4;
  65389. _this._useLightmapAsShadowmap = false;
  65390. _this._useReflectionFresnelFromSpecular = false;
  65391. _this._useGlossinessFromSpecularMapAlpha = false;
  65392. _this._maxSimultaneousLights = 4;
  65393. _this._invertNormalMapX = false;
  65394. _this._invertNormalMapY = false;
  65395. _this._twoSidedLighting = false;
  65396. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65397. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65398. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65399. // Setup the default processing configuration to the scene.
  65400. _this._attachImageProcessingConfiguration(null);
  65401. _this.getRenderTargetTextures = function () {
  65402. _this._renderTargets.reset();
  65403. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65404. _this._renderTargets.push(_this._reflectionTexture);
  65405. }
  65406. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65407. _this._renderTargets.push(_this._refractionTexture);
  65408. }
  65409. return _this._renderTargets;
  65410. };
  65411. return _this;
  65412. }
  65413. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65414. /**
  65415. * Gets the image processing configuration used either in this material.
  65416. */
  65417. get: function () {
  65418. return this._imageProcessingConfiguration;
  65419. },
  65420. /**
  65421. * Sets the Default image processing configuration used either in the this material.
  65422. *
  65423. * If sets to null, the scene one is in use.
  65424. */
  65425. set: function (value) {
  65426. this._attachImageProcessingConfiguration(value);
  65427. // Ensure the effect will be rebuilt.
  65428. this._markAllSubMeshesAsTexturesDirty();
  65429. },
  65430. enumerable: true,
  65431. configurable: true
  65432. });
  65433. /**
  65434. * Attaches a new image processing configuration to the Standard Material.
  65435. * @param configuration
  65436. */
  65437. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  65438. var _this = this;
  65439. if (configuration === this._imageProcessingConfiguration) {
  65440. return;
  65441. }
  65442. // Detaches observer.
  65443. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65444. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65445. }
  65446. // Pick the scene configuration if needed.
  65447. if (!configuration) {
  65448. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  65449. }
  65450. else {
  65451. this._imageProcessingConfiguration = configuration;
  65452. }
  65453. // Attaches observer.
  65454. if (this._imageProcessingConfiguration) {
  65455. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  65456. _this._markAllSubMeshesAsImageProcessingDirty();
  65457. });
  65458. }
  65459. };
  65460. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  65461. /**
  65462. * Gets wether the color curves effect is enabled.
  65463. */
  65464. get: function () {
  65465. return this.imageProcessingConfiguration.colorCurvesEnabled;
  65466. },
  65467. /**
  65468. * Sets wether the color curves effect is enabled.
  65469. */
  65470. set: function (value) {
  65471. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  65472. },
  65473. enumerable: true,
  65474. configurable: true
  65475. });
  65476. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  65477. /**
  65478. * Gets wether the color grading effect is enabled.
  65479. */
  65480. get: function () {
  65481. return this.imageProcessingConfiguration.colorGradingEnabled;
  65482. },
  65483. /**
  65484. * Gets wether the color grading effect is enabled.
  65485. */
  65486. set: function (value) {
  65487. this.imageProcessingConfiguration.colorGradingEnabled = value;
  65488. },
  65489. enumerable: true,
  65490. configurable: true
  65491. });
  65492. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  65493. /**
  65494. * Gets wether tonemapping is enabled or not.
  65495. */
  65496. get: function () {
  65497. return this._imageProcessingConfiguration.toneMappingEnabled;
  65498. },
  65499. /**
  65500. * Sets wether tonemapping is enabled or not
  65501. */
  65502. set: function (value) {
  65503. this._imageProcessingConfiguration.toneMappingEnabled = value;
  65504. },
  65505. enumerable: true,
  65506. configurable: true
  65507. });
  65508. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  65509. /**
  65510. * The camera exposure used on this material.
  65511. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65512. * This corresponds to a photographic exposure.
  65513. */
  65514. get: function () {
  65515. return this._imageProcessingConfiguration.exposure;
  65516. },
  65517. /**
  65518. * The camera exposure used on this material.
  65519. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65520. * This corresponds to a photographic exposure.
  65521. */
  65522. set: function (value) {
  65523. this._imageProcessingConfiguration.exposure = value;
  65524. },
  65525. enumerable: true,
  65526. configurable: true
  65527. });
  65528. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  65529. /**
  65530. * Gets The camera contrast used on this material.
  65531. */
  65532. get: function () {
  65533. return this._imageProcessingConfiguration.contrast;
  65534. },
  65535. /**
  65536. * Sets The camera contrast used on this material.
  65537. */
  65538. set: function (value) {
  65539. this._imageProcessingConfiguration.contrast = value;
  65540. },
  65541. enumerable: true,
  65542. configurable: true
  65543. });
  65544. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  65545. /**
  65546. * Gets the Color Grading 2D Lookup Texture.
  65547. */
  65548. get: function () {
  65549. return this._imageProcessingConfiguration.colorGradingTexture;
  65550. },
  65551. /**
  65552. * Sets the Color Grading 2D Lookup Texture.
  65553. */
  65554. set: function (value) {
  65555. this._imageProcessingConfiguration.colorGradingTexture = value;
  65556. },
  65557. enumerable: true,
  65558. configurable: true
  65559. });
  65560. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  65561. /**
  65562. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65563. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65564. * 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;
  65565. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65566. */
  65567. get: function () {
  65568. return this._imageProcessingConfiguration.colorCurves;
  65569. },
  65570. /**
  65571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65573. * 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;
  65574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65575. */
  65576. set: function (value) {
  65577. this._imageProcessingConfiguration.colorCurves = value;
  65578. },
  65579. enumerable: true,
  65580. configurable: true
  65581. });
  65582. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  65583. /**
  65584. * Gets a boolean indicating that current material needs to register RTT
  65585. */
  65586. get: function () {
  65587. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65588. return true;
  65589. }
  65590. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65591. return true;
  65592. }
  65593. return false;
  65594. },
  65595. enumerable: true,
  65596. configurable: true
  65597. });
  65598. /**
  65599. * Gets the current class name of the material e.g. "StandardMaterial"
  65600. * Mainly use in serialization.
  65601. * @returns the class name
  65602. */
  65603. StandardMaterial.prototype.getClassName = function () {
  65604. return "StandardMaterial";
  65605. };
  65606. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65607. /**
  65608. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65609. * You can try switching to logarithmic depth.
  65610. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65611. */
  65612. get: function () {
  65613. return this._useLogarithmicDepth;
  65614. },
  65615. set: function (value) {
  65616. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65617. this._markAllSubMeshesAsMiscDirty();
  65618. },
  65619. enumerable: true,
  65620. configurable: true
  65621. });
  65622. /**
  65623. * Specifies if the material will require alpha blending
  65624. * @returns a boolean specifying if alpha blending is needed
  65625. */
  65626. StandardMaterial.prototype.needAlphaBlending = function () {
  65627. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65628. };
  65629. /**
  65630. * Specifies if this material should be rendered in alpha test mode
  65631. * @returns a boolean specifying if an alpha test is needed.
  65632. */
  65633. StandardMaterial.prototype.needAlphaTesting = function () {
  65634. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65635. };
  65636. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65637. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65638. };
  65639. /**
  65640. * Get the texture used for alpha test purpose.
  65641. * @returns the diffuse texture in case of the standard material.
  65642. */
  65643. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65644. return this._diffuseTexture;
  65645. };
  65646. /**
  65647. * Get if the submesh is ready to be used and all its information available.
  65648. * Child classes can use it to update shaders
  65649. * @param mesh defines the mesh to check
  65650. * @param subMesh defines which submesh to check
  65651. * @param useInstances specifies that instances should be used
  65652. * @returns a boolean indicating that the submesh is ready or not
  65653. */
  65654. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65655. if (useInstances === void 0) { useInstances = false; }
  65656. if (subMesh.effect && this.isFrozen) {
  65657. if (this._wasPreviouslyReady) {
  65658. return true;
  65659. }
  65660. }
  65661. if (!subMesh._materialDefines) {
  65662. subMesh._materialDefines = new StandardMaterialDefines();
  65663. }
  65664. var scene = this.getScene();
  65665. var defines = subMesh._materialDefines;
  65666. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65667. if (defines._renderId === scene.getRenderId()) {
  65668. return true;
  65669. }
  65670. }
  65671. var engine = scene.getEngine();
  65672. // Lights
  65673. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65674. // Textures
  65675. if (defines._areTexturesDirty) {
  65676. defines._needUVs = false;
  65677. defines.MAINUV1 = false;
  65678. defines.MAINUV2 = false;
  65679. if (scene.texturesEnabled) {
  65680. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65681. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65682. return false;
  65683. }
  65684. else {
  65685. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65686. }
  65687. }
  65688. else {
  65689. defines.DIFFUSE = false;
  65690. }
  65691. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65692. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65693. return false;
  65694. }
  65695. else {
  65696. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65697. }
  65698. }
  65699. else {
  65700. defines.AMBIENT = false;
  65701. }
  65702. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65703. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65704. return false;
  65705. }
  65706. else {
  65707. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65708. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65709. }
  65710. }
  65711. else {
  65712. defines.OPACITY = false;
  65713. }
  65714. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65715. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65716. return false;
  65717. }
  65718. else {
  65719. defines._needNormals = true;
  65720. defines.REFLECTION = true;
  65721. defines.ROUGHNESS = (this._roughness > 0);
  65722. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65723. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65724. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65725. switch (this._reflectionTexture.coordinatesMode) {
  65726. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65727. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65728. break;
  65729. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65730. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65731. break;
  65732. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65733. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65734. break;
  65735. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65736. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65737. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65738. break;
  65739. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65740. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65741. break;
  65742. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65743. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65744. break;
  65745. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65746. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65747. break;
  65748. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65749. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65750. break;
  65751. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65752. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65753. default:
  65754. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65755. break;
  65756. }
  65757. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65758. }
  65759. }
  65760. else {
  65761. defines.REFLECTION = false;
  65762. }
  65763. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65764. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65765. return false;
  65766. }
  65767. else {
  65768. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65769. }
  65770. }
  65771. else {
  65772. defines.EMISSIVE = false;
  65773. }
  65774. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65775. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65776. return false;
  65777. }
  65778. else {
  65779. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65780. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65781. }
  65782. }
  65783. else {
  65784. defines.LIGHTMAP = false;
  65785. }
  65786. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65787. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65788. return false;
  65789. }
  65790. else {
  65791. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65792. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65793. }
  65794. }
  65795. else {
  65796. defines.SPECULAR = false;
  65797. }
  65798. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65799. // Bump texure can not be not blocking.
  65800. if (!this._bumpTexture.isReady()) {
  65801. return false;
  65802. }
  65803. else {
  65804. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65805. defines.PARALLAX = this._useParallax;
  65806. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65807. }
  65808. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65809. }
  65810. else {
  65811. defines.BUMP = false;
  65812. }
  65813. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65814. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65815. return false;
  65816. }
  65817. else {
  65818. defines._needUVs = true;
  65819. defines.REFRACTION = true;
  65820. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65821. }
  65822. }
  65823. else {
  65824. defines.REFRACTION = false;
  65825. }
  65826. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65827. }
  65828. else {
  65829. defines.DIFFUSE = false;
  65830. defines.AMBIENT = false;
  65831. defines.OPACITY = false;
  65832. defines.REFLECTION = false;
  65833. defines.EMISSIVE = false;
  65834. defines.LIGHTMAP = false;
  65835. defines.BUMP = false;
  65836. defines.REFRACTION = false;
  65837. }
  65838. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65839. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65840. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65841. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65842. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  65843. }
  65844. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65845. if (!this._imageProcessingConfiguration.isReady()) {
  65846. return false;
  65847. }
  65848. this._imageProcessingConfiguration.prepareDefines(defines);
  65849. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65850. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65851. }
  65852. if (defines._areFresnelDirty) {
  65853. if (StandardMaterial.FresnelEnabled) {
  65854. // Fresnel
  65855. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65856. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65857. this._reflectionFresnelParameters) {
  65858. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65859. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65860. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65861. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65862. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65863. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65864. defines._needNormals = true;
  65865. defines.FRESNEL = true;
  65866. }
  65867. }
  65868. else {
  65869. defines.FRESNEL = false;
  65870. }
  65871. }
  65872. // Misc.
  65873. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65874. // Attribs
  65875. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65876. // Values that need to be evaluated on every frame
  65877. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65878. // Get correct effect
  65879. if (defines.isDirty) {
  65880. defines.markAsProcessed();
  65881. // Fallbacks
  65882. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  65883. if (defines.REFLECTION) {
  65884. fallbacks.addFallback(0, "REFLECTION");
  65885. }
  65886. if (defines.SPECULAR) {
  65887. fallbacks.addFallback(0, "SPECULAR");
  65888. }
  65889. if (defines.BUMP) {
  65890. fallbacks.addFallback(0, "BUMP");
  65891. }
  65892. if (defines.PARALLAX) {
  65893. fallbacks.addFallback(1, "PARALLAX");
  65894. }
  65895. if (defines.PARALLAXOCCLUSION) {
  65896. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  65897. }
  65898. if (defines.SPECULAROVERALPHA) {
  65899. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  65900. }
  65901. if (defines.FOG) {
  65902. fallbacks.addFallback(1, "FOG");
  65903. }
  65904. if (defines.POINTSIZE) {
  65905. fallbacks.addFallback(0, "POINTSIZE");
  65906. }
  65907. if (defines.LOGARITHMICDEPTH) {
  65908. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  65909. }
  65910. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  65911. if (defines.SPECULARTERM) {
  65912. fallbacks.addFallback(0, "SPECULARTERM");
  65913. }
  65914. if (defines.DIFFUSEFRESNEL) {
  65915. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  65916. }
  65917. if (defines.OPACITYFRESNEL) {
  65918. fallbacks.addFallback(2, "OPACITYFRESNEL");
  65919. }
  65920. if (defines.REFLECTIONFRESNEL) {
  65921. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  65922. }
  65923. if (defines.EMISSIVEFRESNEL) {
  65924. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  65925. }
  65926. if (defines.FRESNEL) {
  65927. fallbacks.addFallback(4, "FRESNEL");
  65928. }
  65929. //Attributes
  65930. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  65931. if (defines.NORMAL) {
  65932. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  65933. }
  65934. if (defines.UV1) {
  65935. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  65936. }
  65937. if (defines.UV2) {
  65938. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  65939. }
  65940. if (defines.VERTEXCOLOR) {
  65941. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  65942. }
  65943. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  65944. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65945. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  65946. var shaderName = "default";
  65947. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  65948. "vFogInfos", "vFogColor", "pointSize",
  65949. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  65950. "mBones",
  65951. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  65952. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  65953. "vReflectionPosition", "vReflectionSize",
  65954. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  65955. ];
  65956. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  65957. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  65958. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  65959. var uniformBuffers = ["Material", "Scene"];
  65960. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  65961. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  65962. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  65963. }
  65964. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  65965. uniformsNames: uniforms,
  65966. uniformBuffersNames: uniformBuffers,
  65967. samplers: samplers,
  65968. defines: defines,
  65969. maxSimultaneousLights: this._maxSimultaneousLights
  65970. });
  65971. if (this.customShaderNameResolve) {
  65972. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  65973. }
  65974. var join = defines.toString();
  65975. var previousEffect = subMesh.effect;
  65976. var effect = scene.getEngine().createEffect(shaderName, {
  65977. attributes: attribs,
  65978. uniformsNames: uniforms,
  65979. uniformBuffersNames: uniformBuffers,
  65980. samplers: samplers,
  65981. defines: join,
  65982. fallbacks: fallbacks,
  65983. onCompiled: this.onCompiled,
  65984. onError: this.onError,
  65985. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  65986. }, engine);
  65987. if (effect) {
  65988. // Use previous effect while new one is compiling
  65989. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  65990. effect = previousEffect;
  65991. defines.markAsUnprocessed();
  65992. }
  65993. else {
  65994. scene.resetCachedMaterial();
  65995. subMesh.setEffect(effect, defines);
  65996. this.buildUniformLayout();
  65997. }
  65998. }
  65999. }
  66000. if (!subMesh.effect || !subMesh.effect.isReady()) {
  66001. return false;
  66002. }
  66003. defines._renderId = scene.getRenderId();
  66004. this._wasPreviouslyReady = true;
  66005. return true;
  66006. };
  66007. /**
  66008. * Builds the material UBO layouts.
  66009. * Used internally during the effect preparation.
  66010. */
  66011. StandardMaterial.prototype.buildUniformLayout = function () {
  66012. // Order is important !
  66013. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  66014. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  66015. this._uniformBuffer.addUniform("opacityParts", 4);
  66016. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  66017. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  66018. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  66019. this._uniformBuffer.addUniform("refractionRightColor", 4);
  66020. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  66021. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  66022. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  66023. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  66024. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  66025. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  66026. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  66027. this._uniformBuffer.addUniform("vReflectionSize", 3);
  66028. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  66029. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  66030. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  66031. this._uniformBuffer.addUniform("vBumpInfos", 3);
  66032. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  66033. this._uniformBuffer.addUniform("ambientMatrix", 16);
  66034. this._uniformBuffer.addUniform("opacityMatrix", 16);
  66035. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  66036. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  66037. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  66038. this._uniformBuffer.addUniform("specularMatrix", 16);
  66039. this._uniformBuffer.addUniform("bumpMatrix", 16);
  66040. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  66041. this._uniformBuffer.addUniform("refractionMatrix", 16);
  66042. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  66043. this._uniformBuffer.addUniform("vSpecularColor", 4);
  66044. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  66045. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  66046. this._uniformBuffer.addUniform("pointSize", 1);
  66047. this._uniformBuffer.create();
  66048. };
  66049. /**
  66050. * Unbinds the material from the mesh
  66051. */
  66052. StandardMaterial.prototype.unbind = function () {
  66053. if (this._activeEffect) {
  66054. var needFlag = false;
  66055. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66056. this._activeEffect.setTexture("reflection2DSampler", null);
  66057. needFlag = true;
  66058. }
  66059. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66060. this._activeEffect.setTexture("refraction2DSampler", null);
  66061. needFlag = true;
  66062. }
  66063. if (needFlag) {
  66064. this._markAllSubMeshesAsTexturesDirty();
  66065. }
  66066. }
  66067. _super.prototype.unbind.call(this);
  66068. };
  66069. /**
  66070. * Binds the submesh to this material by preparing the effect and shader to draw
  66071. * @param world defines the world transformation matrix
  66072. * @param mesh defines the mesh containing the submesh
  66073. * @param subMesh defines the submesh to bind the material to
  66074. */
  66075. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66076. var scene = this.getScene();
  66077. var defines = subMesh._materialDefines;
  66078. if (!defines) {
  66079. return;
  66080. }
  66081. var effect = subMesh.effect;
  66082. if (!effect) {
  66083. return;
  66084. }
  66085. this._activeEffect = effect;
  66086. // Matrices
  66087. this.bindOnlyWorldMatrix(world);
  66088. // Normal Matrix
  66089. if (defines.OBJECTSPACE_NORMALMAP) {
  66090. world.toNormalMatrix(this._normalMatrix);
  66091. this.bindOnlyNormalMatrix(this._normalMatrix);
  66092. }
  66093. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  66094. // Bones
  66095. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  66096. if (mustRebind) {
  66097. this._uniformBuffer.bindToEffect(effect, "Material");
  66098. this.bindViewProjection(effect);
  66099. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  66100. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  66101. // Fresnel
  66102. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  66103. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  66104. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  66105. }
  66106. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  66107. this._uniformBuffer.updateColor4("opacityParts", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
  66108. }
  66109. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  66110. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  66111. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  66112. }
  66113. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  66114. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  66115. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  66116. }
  66117. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  66118. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  66119. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  66120. }
  66121. }
  66122. // Textures
  66123. if (scene.texturesEnabled) {
  66124. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66125. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  66126. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  66127. if (this._diffuseTexture.hasAlpha) {
  66128. effect.setFloat("alphaCutOff", this.alphaCutOff);
  66129. }
  66130. }
  66131. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66132. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  66133. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  66134. }
  66135. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66136. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  66137. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  66138. }
  66139. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66140. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  66141. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  66142. if (this._reflectionTexture.boundingBoxSize) {
  66143. var cubeTexture = this._reflectionTexture;
  66144. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  66145. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  66146. }
  66147. }
  66148. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66149. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  66150. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  66151. }
  66152. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66153. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  66154. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  66155. }
  66156. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66157. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  66158. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  66159. }
  66160. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66161. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  66162. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  66163. if (scene._mirroredCameraPosition) {
  66164. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  66165. }
  66166. else {
  66167. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  66168. }
  66169. }
  66170. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66171. var depth = 1.0;
  66172. if (!this._refractionTexture.isCube) {
  66173. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  66174. if (this._refractionTexture.depth) {
  66175. depth = this._refractionTexture.depth;
  66176. }
  66177. }
  66178. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  66179. }
  66180. }
  66181. // Point size
  66182. if (this.pointsCloud) {
  66183. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66184. }
  66185. if (defines.SPECULARTERM) {
  66186. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66187. }
  66188. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66189. // Diffuse
  66190. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66191. }
  66192. // Textures
  66193. if (scene.texturesEnabled) {
  66194. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66195. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66196. }
  66197. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66198. effect.setTexture("ambientSampler", this._ambientTexture);
  66199. }
  66200. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66201. effect.setTexture("opacitySampler", this._opacityTexture);
  66202. }
  66203. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66204. if (this._reflectionTexture.isCube) {
  66205. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66206. }
  66207. else {
  66208. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66209. }
  66210. }
  66211. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66212. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66213. }
  66214. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66215. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66216. }
  66217. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66218. effect.setTexture("specularSampler", this._specularTexture);
  66219. }
  66220. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66221. effect.setTexture("bumpSampler", this._bumpTexture);
  66222. }
  66223. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66224. var depth = 1.0;
  66225. if (this._refractionTexture.isCube) {
  66226. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66227. }
  66228. else {
  66229. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66230. }
  66231. }
  66232. }
  66233. // Clip plane
  66234. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66235. // Colors
  66236. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66237. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66238. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66239. }
  66240. if (mustRebind || !this.isFrozen) {
  66241. // Lights
  66242. if (scene.lightsEnabled && !this._disableLighting) {
  66243. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66244. }
  66245. // View
  66246. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66247. this.bindView(effect);
  66248. }
  66249. // Fog
  66250. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66251. // Morph targets
  66252. if (defines.NUM_MORPH_INFLUENCERS) {
  66253. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66254. }
  66255. // Log. depth
  66256. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66257. // image processing
  66258. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66259. this._imageProcessingConfiguration.bind(this._activeEffect);
  66260. }
  66261. }
  66262. this._uniformBuffer.update();
  66263. this._afterBind(mesh, this._activeEffect);
  66264. };
  66265. /**
  66266. * Get the list of animatables in the material.
  66267. * @returns the list of animatables object used in the material
  66268. */
  66269. StandardMaterial.prototype.getAnimatables = function () {
  66270. var results = [];
  66271. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66272. results.push(this._diffuseTexture);
  66273. }
  66274. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66275. results.push(this._ambientTexture);
  66276. }
  66277. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66278. results.push(this._opacityTexture);
  66279. }
  66280. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66281. results.push(this._reflectionTexture);
  66282. }
  66283. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66284. results.push(this._emissiveTexture);
  66285. }
  66286. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66287. results.push(this._specularTexture);
  66288. }
  66289. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66290. results.push(this._bumpTexture);
  66291. }
  66292. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66293. results.push(this._lightmapTexture);
  66294. }
  66295. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66296. results.push(this._refractionTexture);
  66297. }
  66298. return results;
  66299. };
  66300. /**
  66301. * Gets the active textures from the material
  66302. * @returns an array of textures
  66303. */
  66304. StandardMaterial.prototype.getActiveTextures = function () {
  66305. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66306. if (this._diffuseTexture) {
  66307. activeTextures.push(this._diffuseTexture);
  66308. }
  66309. if (this._ambientTexture) {
  66310. activeTextures.push(this._ambientTexture);
  66311. }
  66312. if (this._opacityTexture) {
  66313. activeTextures.push(this._opacityTexture);
  66314. }
  66315. if (this._reflectionTexture) {
  66316. activeTextures.push(this._reflectionTexture);
  66317. }
  66318. if (this._emissiveTexture) {
  66319. activeTextures.push(this._emissiveTexture);
  66320. }
  66321. if (this._specularTexture) {
  66322. activeTextures.push(this._specularTexture);
  66323. }
  66324. if (this._bumpTexture) {
  66325. activeTextures.push(this._bumpTexture);
  66326. }
  66327. if (this._lightmapTexture) {
  66328. activeTextures.push(this._lightmapTexture);
  66329. }
  66330. if (this._refractionTexture) {
  66331. activeTextures.push(this._refractionTexture);
  66332. }
  66333. return activeTextures;
  66334. };
  66335. /**
  66336. * Specifies if the material uses a texture
  66337. * @param texture defines the texture to check against the material
  66338. * @returns a boolean specifying if the material uses the texture
  66339. */
  66340. StandardMaterial.prototype.hasTexture = function (texture) {
  66341. if (_super.prototype.hasTexture.call(this, texture)) {
  66342. return true;
  66343. }
  66344. if (this._diffuseTexture === texture) {
  66345. return true;
  66346. }
  66347. if (this._ambientTexture === texture) {
  66348. return true;
  66349. }
  66350. if (this._opacityTexture === texture) {
  66351. return true;
  66352. }
  66353. if (this._reflectionTexture === texture) {
  66354. return true;
  66355. }
  66356. if (this._emissiveTexture === texture) {
  66357. return true;
  66358. }
  66359. if (this._specularTexture === texture) {
  66360. return true;
  66361. }
  66362. if (this._bumpTexture === texture) {
  66363. return true;
  66364. }
  66365. if (this._lightmapTexture === texture) {
  66366. return true;
  66367. }
  66368. if (this._refractionTexture === texture) {
  66369. return true;
  66370. }
  66371. return false;
  66372. };
  66373. /**
  66374. * Disposes the material
  66375. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66376. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66377. */
  66378. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66379. if (forceDisposeTextures) {
  66380. if (this._diffuseTexture) {
  66381. this._diffuseTexture.dispose();
  66382. }
  66383. if (this._ambientTexture) {
  66384. this._ambientTexture.dispose();
  66385. }
  66386. if (this._opacityTexture) {
  66387. this._opacityTexture.dispose();
  66388. }
  66389. if (this._reflectionTexture) {
  66390. this._reflectionTexture.dispose();
  66391. }
  66392. if (this._emissiveTexture) {
  66393. this._emissiveTexture.dispose();
  66394. }
  66395. if (this._specularTexture) {
  66396. this._specularTexture.dispose();
  66397. }
  66398. if (this._bumpTexture) {
  66399. this._bumpTexture.dispose();
  66400. }
  66401. if (this._lightmapTexture) {
  66402. this._lightmapTexture.dispose();
  66403. }
  66404. if (this._refractionTexture) {
  66405. this._refractionTexture.dispose();
  66406. }
  66407. }
  66408. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66409. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66410. }
  66411. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66412. };
  66413. /**
  66414. * Makes a duplicate of the material, and gives it a new name
  66415. * @param name defines the new name for the duplicated material
  66416. * @returns the cloned material
  66417. */
  66418. StandardMaterial.prototype.clone = function (name) {
  66419. var _this = this;
  66420. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66421. result.name = name;
  66422. result.id = name;
  66423. return result;
  66424. };
  66425. /**
  66426. * Serializes this material in a JSON representation
  66427. * @returns the serialized material object
  66428. */
  66429. StandardMaterial.prototype.serialize = function () {
  66430. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66431. };
  66432. /**
  66433. * Creates a standard material from parsed material data
  66434. * @param source defines the JSON representation of the material
  66435. * @param scene defines the hosting scene
  66436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66437. * @returns a new standard material
  66438. */
  66439. StandardMaterial.Parse = function (source, scene, rootUrl) {
  66440. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  66441. };
  66442. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  66443. // Flags used to enable or disable a type of texture for all Standard Materials
  66444. /**
  66445. * Are diffuse textures enabled in the application.
  66446. */
  66447. get: function () {
  66448. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  66449. },
  66450. set: function (value) {
  66451. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  66452. },
  66453. enumerable: true,
  66454. configurable: true
  66455. });
  66456. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  66457. /**
  66458. * Are ambient textures enabled in the application.
  66459. */
  66460. get: function () {
  66461. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  66462. },
  66463. set: function (value) {
  66464. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  66465. },
  66466. enumerable: true,
  66467. configurable: true
  66468. });
  66469. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  66470. /**
  66471. * Are opacity textures enabled in the application.
  66472. */
  66473. get: function () {
  66474. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  66475. },
  66476. set: function (value) {
  66477. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  66478. },
  66479. enumerable: true,
  66480. configurable: true
  66481. });
  66482. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  66483. /**
  66484. * Are reflection textures enabled in the application.
  66485. */
  66486. get: function () {
  66487. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  66488. },
  66489. set: function (value) {
  66490. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  66491. },
  66492. enumerable: true,
  66493. configurable: true
  66494. });
  66495. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  66496. /**
  66497. * Are emissive textures enabled in the application.
  66498. */
  66499. get: function () {
  66500. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  66501. },
  66502. set: function (value) {
  66503. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  66504. },
  66505. enumerable: true,
  66506. configurable: true
  66507. });
  66508. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  66509. /**
  66510. * Are specular textures enabled in the application.
  66511. */
  66512. get: function () {
  66513. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  66514. },
  66515. set: function (value) {
  66516. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  66517. },
  66518. enumerable: true,
  66519. configurable: true
  66520. });
  66521. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  66522. /**
  66523. * Are bump textures enabled in the application.
  66524. */
  66525. get: function () {
  66526. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  66527. },
  66528. set: function (value) {
  66529. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  66530. },
  66531. enumerable: true,
  66532. configurable: true
  66533. });
  66534. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  66535. /**
  66536. * Are lightmap textures enabled in the application.
  66537. */
  66538. get: function () {
  66539. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  66540. },
  66541. set: function (value) {
  66542. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  66543. },
  66544. enumerable: true,
  66545. configurable: true
  66546. });
  66547. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  66548. /**
  66549. * Are refraction textures enabled in the application.
  66550. */
  66551. get: function () {
  66552. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  66553. },
  66554. set: function (value) {
  66555. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  66556. },
  66557. enumerable: true,
  66558. configurable: true
  66559. });
  66560. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  66561. /**
  66562. * Are color grading textures enabled in the application.
  66563. */
  66564. get: function () {
  66565. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  66566. },
  66567. set: function (value) {
  66568. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  66569. },
  66570. enumerable: true,
  66571. configurable: true
  66572. });
  66573. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  66574. /**
  66575. * Are fresnels enabled in the application.
  66576. */
  66577. get: function () {
  66578. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  66579. },
  66580. set: function (value) {
  66581. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  66582. },
  66583. enumerable: true,
  66584. configurable: true
  66585. });
  66586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66588. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66591. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66594. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66597. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66600. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66603. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66606. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66609. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66612. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66615. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66618. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66621. ], StandardMaterial.prototype, "specularTexture", void 0);
  66622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66624. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66627. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66630. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66633. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66636. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66639. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66642. ], StandardMaterial.prototype, "ambientColor", void 0);
  66643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66645. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66648. ], StandardMaterial.prototype, "specularColor", void 0);
  66649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66651. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66654. ], StandardMaterial.prototype, "specularPower", void 0);
  66655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66657. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66660. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66663. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66666. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66669. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66672. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66675. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66678. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66681. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66684. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66687. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66690. ], StandardMaterial.prototype, "disableLighting", void 0);
  66691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66693. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66696. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66699. ], StandardMaterial.prototype, "_useParallax", void 0);
  66700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66702. ], StandardMaterial.prototype, "useParallax", void 0);
  66703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66705. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66708. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66711. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66714. ], StandardMaterial.prototype, "_roughness", void 0);
  66715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66717. ], StandardMaterial.prototype, "roughness", void 0);
  66718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66720. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66723. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66726. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66729. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66732. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66735. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66738. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66741. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66744. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66747. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66750. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66753. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66756. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66759. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66762. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66765. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66768. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66771. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66774. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66777. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66780. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66783. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66786. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66789. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66792. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66795. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66798. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66801. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66802. return StandardMaterial;
  66803. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66804. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66806. return new StandardMaterial("default material", scene);
  66807. };
  66808. /***/ }),
  66809. /***/ "./Materials/uniformBuffer.ts":
  66810. /*!************************************!*\
  66811. !*** ./Materials/uniformBuffer.ts ***!
  66812. \************************************/
  66813. /*! exports provided: UniformBuffer */
  66814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66815. "use strict";
  66816. __webpack_require__.r(__webpack_exports__);
  66817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66818. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66819. /**
  66820. * Uniform buffer objects.
  66821. *
  66822. * Handles blocks of uniform on the GPU.
  66823. *
  66824. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66825. *
  66826. * For more information, please refer to :
  66827. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66828. */
  66829. var UniformBuffer = /** @class */ (function () {
  66830. /**
  66831. * Instantiates a new Uniform buffer objects.
  66832. *
  66833. * Handles blocks of uniform on the GPU.
  66834. *
  66835. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66836. *
  66837. * For more information, please refer to :
  66838. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66839. * @param engine Define the engine the buffer is associated with
  66840. * @param data Define the data contained in the buffer
  66841. * @param dynamic Define if the buffer is updatable
  66842. */
  66843. function UniformBuffer(engine, data, dynamic) {
  66844. this._engine = engine;
  66845. this._noUBO = !engine.supportsUniformBuffers;
  66846. this._dynamic = dynamic;
  66847. this._data = data || [];
  66848. this._uniformLocations = {};
  66849. this._uniformSizes = {};
  66850. this._uniformLocationPointer = 0;
  66851. this._needSync = false;
  66852. if (this._noUBO) {
  66853. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66854. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66855. this.updateFloat = this._updateFloatForEffect;
  66856. this.updateFloat2 = this._updateFloat2ForEffect;
  66857. this.updateFloat3 = this._updateFloat3ForEffect;
  66858. this.updateFloat4 = this._updateFloat4ForEffect;
  66859. this.updateMatrix = this._updateMatrixForEffect;
  66860. this.updateVector3 = this._updateVector3ForEffect;
  66861. this.updateVector4 = this._updateVector4ForEffect;
  66862. this.updateColor3 = this._updateColor3ForEffect;
  66863. this.updateColor4 = this._updateColor4ForEffect;
  66864. }
  66865. else {
  66866. this._engine._uniformBuffers.push(this);
  66867. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66868. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66869. this.updateFloat = this._updateFloatForUniform;
  66870. this.updateFloat2 = this._updateFloat2ForUniform;
  66871. this.updateFloat3 = this._updateFloat3ForUniform;
  66872. this.updateFloat4 = this._updateFloat4ForUniform;
  66873. this.updateMatrix = this._updateMatrixForUniform;
  66874. this.updateVector3 = this._updateVector3ForUniform;
  66875. this.updateVector4 = this._updateVector4ForUniform;
  66876. this.updateColor3 = this._updateColor3ForUniform;
  66877. this.updateColor4 = this._updateColor4ForUniform;
  66878. }
  66879. }
  66880. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  66881. /**
  66882. * Indicates if the buffer is using the WebGL2 UBO implementation,
  66883. * or just falling back on setUniformXXX calls.
  66884. */
  66885. get: function () {
  66886. return !this._noUBO;
  66887. },
  66888. enumerable: true,
  66889. configurable: true
  66890. });
  66891. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  66892. /**
  66893. * Indicates if the WebGL underlying uniform buffer is in sync
  66894. * with the javascript cache data.
  66895. */
  66896. get: function () {
  66897. return !this._needSync;
  66898. },
  66899. enumerable: true,
  66900. configurable: true
  66901. });
  66902. /**
  66903. * Indicates if the WebGL underlying uniform buffer is dynamic.
  66904. * Also, a dynamic UniformBuffer will disable cache verification and always
  66905. * update the underlying WebGL uniform buffer to the GPU.
  66906. * @returns if Dynamic, otherwise false
  66907. */
  66908. UniformBuffer.prototype.isDynamic = function () {
  66909. return this._dynamic !== undefined;
  66910. };
  66911. /**
  66912. * The data cache on JS side.
  66913. * @returns the underlying data as a float array
  66914. */
  66915. UniformBuffer.prototype.getData = function () {
  66916. return this._bufferData;
  66917. };
  66918. /**
  66919. * The underlying WebGL Uniform buffer.
  66920. * @returns the webgl buffer
  66921. */
  66922. UniformBuffer.prototype.getBuffer = function () {
  66923. return this._buffer;
  66924. };
  66925. /**
  66926. * std140 layout specifies how to align data within an UBO structure.
  66927. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  66928. * for specs.
  66929. */
  66930. UniformBuffer.prototype._fillAlignment = function (size) {
  66931. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  66932. // and 4x4 matrices
  66933. // TODO : change if other types are used
  66934. var alignment;
  66935. if (size <= 2) {
  66936. alignment = size;
  66937. }
  66938. else {
  66939. alignment = 4;
  66940. }
  66941. if ((this._uniformLocationPointer % alignment) !== 0) {
  66942. var oldPointer = this._uniformLocationPointer;
  66943. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  66944. var diff = this._uniformLocationPointer - oldPointer;
  66945. for (var i = 0; i < diff; i++) {
  66946. this._data.push(0);
  66947. }
  66948. }
  66949. };
  66950. /**
  66951. * Adds an uniform in the buffer.
  66952. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  66953. * for the layout to be correct !
  66954. * @param name Name of the uniform, as used in the uniform block in the shader.
  66955. * @param size Data size, or data directly.
  66956. */
  66957. UniformBuffer.prototype.addUniform = function (name, size) {
  66958. if (this._noUBO) {
  66959. return;
  66960. }
  66961. if (this._uniformLocations[name] !== undefined) {
  66962. // Already existing uniform
  66963. return;
  66964. }
  66965. // This function must be called in the order of the shader layout !
  66966. // size can be the size of the uniform, or data directly
  66967. var data;
  66968. if (size instanceof Array) {
  66969. data = size;
  66970. size = data.length;
  66971. }
  66972. else {
  66973. size = size;
  66974. data = [];
  66975. // Fill with zeros
  66976. for (var i = 0; i < size; i++) {
  66977. data.push(0);
  66978. }
  66979. }
  66980. this._fillAlignment(size);
  66981. this._uniformSizes[name] = size;
  66982. this._uniformLocations[name] = this._uniformLocationPointer;
  66983. this._uniformLocationPointer += size;
  66984. for (var i = 0; i < size; i++) {
  66985. this._data.push(data[i]);
  66986. }
  66987. this._needSync = true;
  66988. };
  66989. /**
  66990. * Adds a Matrix 4x4 to the uniform buffer.
  66991. * @param name Name of the uniform, as used in the uniform block in the shader.
  66992. * @param mat A 4x4 matrix.
  66993. */
  66994. UniformBuffer.prototype.addMatrix = function (name, mat) {
  66995. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  66996. };
  66997. /**
  66998. * Adds a vec2 to the uniform buffer.
  66999. * @param name Name of the uniform, as used in the uniform block in the shader.
  67000. * @param x Define the x component value of the vec2
  67001. * @param y Define the y component value of the vec2
  67002. */
  67003. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  67004. var temp = [x, y];
  67005. this.addUniform(name, temp);
  67006. };
  67007. /**
  67008. * Adds a vec3 to the uniform buffer.
  67009. * @param name Name of the uniform, as used in the uniform block in the shader.
  67010. * @param x Define the x component value of the vec3
  67011. * @param y Define the y component value of the vec3
  67012. * @param z Define the z component value of the vec3
  67013. */
  67014. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  67015. var temp = [x, y, z];
  67016. this.addUniform(name, temp);
  67017. };
  67018. /**
  67019. * Adds a vec3 to the uniform buffer.
  67020. * @param name Name of the uniform, as used in the uniform block in the shader.
  67021. * @param color Define the vec3 from a Color
  67022. */
  67023. UniformBuffer.prototype.addColor3 = function (name, color) {
  67024. var temp = new Array();
  67025. color.toArray(temp);
  67026. this.addUniform(name, temp);
  67027. };
  67028. /**
  67029. * Adds a vec4 to the uniform buffer.
  67030. * @param name Name of the uniform, as used in the uniform block in the shader.
  67031. * @param color Define the rgb components from a Color
  67032. * @param alpha Define the a component of the vec4
  67033. */
  67034. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  67035. var temp = new Array();
  67036. color.toArray(temp);
  67037. temp.push(alpha);
  67038. this.addUniform(name, temp);
  67039. };
  67040. /**
  67041. * Adds a vec3 to the uniform buffer.
  67042. * @param name Name of the uniform, as used in the uniform block in the shader.
  67043. * @param vector Define the vec3 components from a Vector
  67044. */
  67045. UniformBuffer.prototype.addVector3 = function (name, vector) {
  67046. var temp = new Array();
  67047. vector.toArray(temp);
  67048. this.addUniform(name, temp);
  67049. };
  67050. /**
  67051. * Adds a Matrix 3x3 to the uniform buffer.
  67052. * @param name Name of the uniform, as used in the uniform block in the shader.
  67053. */
  67054. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  67055. this.addUniform(name, 12);
  67056. };
  67057. /**
  67058. * Adds a Matrix 2x2 to the uniform buffer.
  67059. * @param name Name of the uniform, as used in the uniform block in the shader.
  67060. */
  67061. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  67062. this.addUniform(name, 8);
  67063. };
  67064. /**
  67065. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  67066. */
  67067. UniformBuffer.prototype.create = function () {
  67068. if (this._noUBO) {
  67069. return;
  67070. }
  67071. if (this._buffer) {
  67072. return; // nothing to do
  67073. }
  67074. // See spec, alignment must be filled as a vec4
  67075. this._fillAlignment(4);
  67076. this._bufferData = new Float32Array(this._data);
  67077. this._rebuild();
  67078. this._needSync = true;
  67079. };
  67080. /** @hidden */
  67081. UniformBuffer.prototype._rebuild = function () {
  67082. if (this._noUBO) {
  67083. return;
  67084. }
  67085. if (this._dynamic) {
  67086. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  67087. }
  67088. else {
  67089. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  67090. }
  67091. };
  67092. /**
  67093. * Updates the WebGL Uniform Buffer on the GPU.
  67094. * If the `dynamic` flag is set to true, no cache comparison is done.
  67095. * Otherwise, the buffer will be updated only if the cache differs.
  67096. */
  67097. UniformBuffer.prototype.update = function () {
  67098. if (!this._buffer) {
  67099. this.create();
  67100. return;
  67101. }
  67102. if (!this._dynamic && !this._needSync) {
  67103. return;
  67104. }
  67105. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  67106. this._needSync = false;
  67107. };
  67108. /**
  67109. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  67110. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67111. * @param data Define the flattened data
  67112. * @param size Define the size of the data.
  67113. */
  67114. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  67115. var location = this._uniformLocations[uniformName];
  67116. if (location === undefined) {
  67117. if (this._buffer) {
  67118. // Cannot add an uniform if the buffer is already created
  67119. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  67120. return;
  67121. }
  67122. this.addUniform(uniformName, size);
  67123. location = this._uniformLocations[uniformName];
  67124. }
  67125. if (!this._buffer) {
  67126. this.create();
  67127. }
  67128. if (!this._dynamic) {
  67129. // Cache for static uniform buffers
  67130. var changed = false;
  67131. for (var i = 0; i < size; i++) {
  67132. if (this._bufferData[location + i] !== data[i]) {
  67133. changed = true;
  67134. this._bufferData[location + i] = data[i];
  67135. }
  67136. }
  67137. this._needSync = this._needSync || changed;
  67138. }
  67139. else {
  67140. // No cache for dynamic
  67141. for (var i = 0; i < size; i++) {
  67142. this._bufferData[location + i] = data[i];
  67143. }
  67144. }
  67145. };
  67146. // Update methods
  67147. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  67148. // To match std140, matrix must be realigned
  67149. for (var i = 0; i < 3; i++) {
  67150. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  67151. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  67152. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  67153. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67154. }
  67155. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  67156. };
  67157. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  67158. this._currentEffect.setMatrix3x3(name, matrix);
  67159. };
  67160. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  67161. this._currentEffect.setMatrix2x2(name, matrix);
  67162. };
  67163. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  67164. // To match std140, matrix must be realigned
  67165. for (var i = 0; i < 2; i++) {
  67166. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  67167. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  67168. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  67169. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67170. }
  67171. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  67172. };
  67173. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  67174. this._currentEffect.setFloat(name, x);
  67175. };
  67176. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  67177. UniformBuffer._tempBuffer[0] = x;
  67178. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  67179. };
  67180. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  67181. if (suffix === void 0) { suffix = ""; }
  67182. this._currentEffect.setFloat2(name + suffix, x, y);
  67183. };
  67184. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67185. UniformBuffer._tempBuffer[0] = x;
  67186. UniformBuffer._tempBuffer[1] = y;
  67187. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67188. };
  67189. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67190. if (suffix === void 0) { suffix = ""; }
  67191. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67192. };
  67193. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67194. UniformBuffer._tempBuffer[0] = x;
  67195. UniformBuffer._tempBuffer[1] = y;
  67196. UniformBuffer._tempBuffer[2] = z;
  67197. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67198. };
  67199. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67200. if (suffix === void 0) { suffix = ""; }
  67201. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67202. };
  67203. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67204. UniformBuffer._tempBuffer[0] = x;
  67205. UniformBuffer._tempBuffer[1] = y;
  67206. UniformBuffer._tempBuffer[2] = z;
  67207. UniformBuffer._tempBuffer[3] = w;
  67208. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67209. };
  67210. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67211. this._currentEffect.setMatrix(name, mat);
  67212. };
  67213. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67214. this.updateUniform(name, mat.toArray(), 16);
  67215. };
  67216. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67217. this._currentEffect.setVector3(name, vector);
  67218. };
  67219. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67220. vector.toArray(UniformBuffer._tempBuffer);
  67221. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67222. };
  67223. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67224. this._currentEffect.setVector4(name, vector);
  67225. };
  67226. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67227. vector.toArray(UniformBuffer._tempBuffer);
  67228. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67229. };
  67230. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67231. if (suffix === void 0) { suffix = ""; }
  67232. this._currentEffect.setColor3(name + suffix, color);
  67233. };
  67234. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67235. color.toArray(UniformBuffer._tempBuffer);
  67236. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67237. };
  67238. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67239. if (suffix === void 0) { suffix = ""; }
  67240. this._currentEffect.setColor4(name + suffix, color, alpha);
  67241. };
  67242. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67243. color.toArray(UniformBuffer._tempBuffer);
  67244. UniformBuffer._tempBuffer[3] = alpha;
  67245. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67246. };
  67247. /**
  67248. * Sets a sampler uniform on the effect.
  67249. * @param name Define the name of the sampler.
  67250. * @param texture Define the texture to set in the sampler
  67251. */
  67252. UniformBuffer.prototype.setTexture = function (name, texture) {
  67253. this._currentEffect.setTexture(name, texture);
  67254. };
  67255. /**
  67256. * Directly updates the value of the uniform in the cache AND on the GPU.
  67257. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67258. * @param data Define the flattened data
  67259. */
  67260. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67261. this.updateUniform(uniformName, data, data.length);
  67262. this.update();
  67263. };
  67264. /**
  67265. * Binds this uniform buffer to an effect.
  67266. * @param effect Define the effect to bind the buffer to
  67267. * @param name Name of the uniform block in the shader.
  67268. */
  67269. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67270. this._currentEffect = effect;
  67271. if (this._noUBO || !this._buffer) {
  67272. return;
  67273. }
  67274. effect.bindUniformBuffer(this._buffer, name);
  67275. };
  67276. /**
  67277. * Disposes the uniform buffer.
  67278. */
  67279. UniformBuffer.prototype.dispose = function () {
  67280. if (this._noUBO) {
  67281. return;
  67282. }
  67283. var uniformBuffers = this._engine._uniformBuffers;
  67284. var index = uniformBuffers.indexOf(this);
  67285. if (index !== -1) {
  67286. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67287. uniformBuffers.pop();
  67288. }
  67289. if (!this._buffer) {
  67290. return;
  67291. }
  67292. if (this._engine._releaseBuffer(this._buffer)) {
  67293. this._buffer = null;
  67294. }
  67295. };
  67296. // Pool for avoiding memory leaks
  67297. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67298. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67299. return UniformBuffer;
  67300. }());
  67301. /***/ }),
  67302. /***/ "./Maths/index.ts":
  67303. /*!************************!*\
  67304. !*** ./Maths/index.ts ***!
  67305. \************************/
  67306. /*! exports provided: Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics */
  67307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67308. "use strict";
  67309. __webpack_require__.r(__webpack_exports__);
  67310. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67312. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67339. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67342. /***/ }),
  67343. /***/ "./Maths/math.scalar.ts":
  67344. /*!******************************!*\
  67345. !*** ./Maths/math.scalar.ts ***!
  67346. \******************************/
  67347. /*! exports provided: Scalar */
  67348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67349. "use strict";
  67350. __webpack_require__.r(__webpack_exports__);
  67351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67352. /**
  67353. * Scalar computation library
  67354. */
  67355. var Scalar = /** @class */ (function () {
  67356. function Scalar() {
  67357. }
  67358. /**
  67359. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67360. * @param a number
  67361. * @param b number
  67362. * @param epsilon (default = 1.401298E-45)
  67363. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67364. */
  67365. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67366. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67367. var num = a - b;
  67368. return -epsilon <= num && num <= epsilon;
  67369. };
  67370. /**
  67371. * Returns a string : the upper case translation of the number i to hexadecimal.
  67372. * @param i number
  67373. * @returns the upper case translation of the number i to hexadecimal.
  67374. */
  67375. Scalar.ToHex = function (i) {
  67376. var str = i.toString(16);
  67377. if (i <= 15) {
  67378. return ("0" + str).toUpperCase();
  67379. }
  67380. return str.toUpperCase();
  67381. };
  67382. /**
  67383. * Returns -1 if value is negative and +1 is value is positive.
  67384. * @param value the value
  67385. * @returns the value itself if it's equal to zero.
  67386. */
  67387. Scalar.Sign = function (value) {
  67388. value = +value; // convert to a number
  67389. if (value === 0 || isNaN(value)) {
  67390. return value;
  67391. }
  67392. return value > 0 ? 1 : -1;
  67393. };
  67394. /**
  67395. * Returns the value itself if it's between min and max.
  67396. * Returns min if the value is lower than min.
  67397. * Returns max if the value is greater than max.
  67398. * @param value the value to clmap
  67399. * @param min the min value to clamp to (default: 0)
  67400. * @param max the max value to clamp to (default: 1)
  67401. * @returns the clamped value
  67402. */
  67403. Scalar.Clamp = function (value, min, max) {
  67404. if (min === void 0) { min = 0; }
  67405. if (max === void 0) { max = 1; }
  67406. return Math.min(max, Math.max(min, value));
  67407. };
  67408. /**
  67409. * the log2 of value.
  67410. * @param value the value to compute log2 of
  67411. * @returns the log2 of value.
  67412. */
  67413. Scalar.Log2 = function (value) {
  67414. return Math.log(value) * Math.LOG2E;
  67415. };
  67416. /**
  67417. * Loops the value, so that it is never larger than length and never smaller than 0.
  67418. *
  67419. * This is similar to the modulo operator but it works with floating point numbers.
  67420. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67421. * With t = 5 and length = 2.5, the result would be 0.0.
  67422. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67423. * @param value the value
  67424. * @param length the length
  67425. * @returns the looped value
  67426. */
  67427. Scalar.Repeat = function (value, length) {
  67428. return value - Math.floor(value / length) * length;
  67429. };
  67430. /**
  67431. * Normalize the value between 0.0 and 1.0 using min and max values
  67432. * @param value value to normalize
  67433. * @param min max to normalize between
  67434. * @param max min to normalize between
  67435. * @returns the normalized value
  67436. */
  67437. Scalar.Normalize = function (value, min, max) {
  67438. return (value - min) / (max - min);
  67439. };
  67440. /**
  67441. * Denormalize the value from 0.0 and 1.0 using min and max values
  67442. * @param normalized value to denormalize
  67443. * @param min max to denormalize between
  67444. * @param max min to denormalize between
  67445. * @returns the denormalized value
  67446. */
  67447. Scalar.Denormalize = function (normalized, min, max) {
  67448. return (normalized * (max - min) + min);
  67449. };
  67450. /**
  67451. * Calculates the shortest difference between two given angles given in degrees.
  67452. * @param current current angle in degrees
  67453. * @param target target angle in degrees
  67454. * @returns the delta
  67455. */
  67456. Scalar.DeltaAngle = function (current, target) {
  67457. var num = Scalar.Repeat(target - current, 360.0);
  67458. if (num > 180.0) {
  67459. num -= 360.0;
  67460. }
  67461. return num;
  67462. };
  67463. /**
  67464. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67465. * @param tx value
  67466. * @param length length
  67467. * @returns The returned value will move back and forth between 0 and length
  67468. */
  67469. Scalar.PingPong = function (tx, length) {
  67470. var t = Scalar.Repeat(tx, length * 2.0);
  67471. return length - Math.abs(t - length);
  67472. };
  67473. /**
  67474. * Interpolates between min and max with smoothing at the limits.
  67475. *
  67476. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67477. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67478. * @param from from
  67479. * @param to to
  67480. * @param tx value
  67481. * @returns the smooth stepped value
  67482. */
  67483. Scalar.SmoothStep = function (from, to, tx) {
  67484. var t = Scalar.Clamp(tx);
  67485. t = -2.0 * t * t * t + 3.0 * t * t;
  67486. return to * t + from * (1.0 - t);
  67487. };
  67488. /**
  67489. * Moves a value current towards target.
  67490. *
  67491. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67492. * Negative values of maxDelta pushes the value away from target.
  67493. * @param current current value
  67494. * @param target target value
  67495. * @param maxDelta max distance to move
  67496. * @returns resulting value
  67497. */
  67498. Scalar.MoveTowards = function (current, target, maxDelta) {
  67499. var result = 0;
  67500. if (Math.abs(target - current) <= maxDelta) {
  67501. result = target;
  67502. }
  67503. else {
  67504. result = current + Scalar.Sign(target - current) * maxDelta;
  67505. }
  67506. return result;
  67507. };
  67508. /**
  67509. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67510. *
  67511. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67512. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67513. * @param current current value
  67514. * @param target target value
  67515. * @param maxDelta max distance to move
  67516. * @returns resulting angle
  67517. */
  67518. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  67519. var num = Scalar.DeltaAngle(current, target);
  67520. var result = 0;
  67521. if (-maxDelta < num && num < maxDelta) {
  67522. result = target;
  67523. }
  67524. else {
  67525. target = current + num;
  67526. result = Scalar.MoveTowards(current, target, maxDelta);
  67527. }
  67528. return result;
  67529. };
  67530. /**
  67531. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67532. * @param start start value
  67533. * @param end target value
  67534. * @param amount amount to lerp between
  67535. * @returns the lerped value
  67536. */
  67537. Scalar.Lerp = function (start, end, amount) {
  67538. return start + ((end - start) * amount);
  67539. };
  67540. /**
  67541. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67542. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67543. * @param start start value
  67544. * @param end target value
  67545. * @param amount amount to lerp between
  67546. * @returns the lerped value
  67547. */
  67548. Scalar.LerpAngle = function (start, end, amount) {
  67549. var num = Scalar.Repeat(end - start, 360.0);
  67550. if (num > 180.0) {
  67551. num -= 360.0;
  67552. }
  67553. return start + num * Scalar.Clamp(amount);
  67554. };
  67555. /**
  67556. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67557. * @param a start value
  67558. * @param b target value
  67559. * @param value value between a and b
  67560. * @returns the inverseLerp value
  67561. */
  67562. Scalar.InverseLerp = function (a, b, value) {
  67563. var result = 0;
  67564. if (a != b) {
  67565. result = Scalar.Clamp((value - a) / (b - a));
  67566. }
  67567. else {
  67568. result = 0.0;
  67569. }
  67570. return result;
  67571. };
  67572. /**
  67573. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67574. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67575. * @param value1 spline value
  67576. * @param tangent1 spline value
  67577. * @param value2 spline value
  67578. * @param tangent2 spline value
  67579. * @param amount input value
  67580. * @returns hermite result
  67581. */
  67582. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  67583. var squared = amount * amount;
  67584. var cubed = amount * squared;
  67585. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67586. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67587. var part3 = (cubed - (2.0 * squared)) + amount;
  67588. var part4 = cubed - squared;
  67589. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67590. };
  67591. /**
  67592. * Returns a random float number between and min and max values
  67593. * @param min min value of random
  67594. * @param max max value of random
  67595. * @returns random value
  67596. */
  67597. Scalar.RandomRange = function (min, max) {
  67598. if (min === max) {
  67599. return min;
  67600. }
  67601. return ((Math.random() * (max - min)) + min);
  67602. };
  67603. /**
  67604. * This function returns percentage of a number in a given range.
  67605. *
  67606. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67607. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67608. * @param number to convert to percentage
  67609. * @param min min range
  67610. * @param max max range
  67611. * @returns the percentage
  67612. */
  67613. Scalar.RangeToPercent = function (number, min, max) {
  67614. return ((number - min) / (max - min));
  67615. };
  67616. /**
  67617. * This function returns number that corresponds to the percentage in a given range.
  67618. *
  67619. * PercentToRange(0.34,0,100) will return 34.
  67620. * @param percent to convert to number
  67621. * @param min min range
  67622. * @param max max range
  67623. * @returns the number
  67624. */
  67625. Scalar.PercentToRange = function (percent, min, max) {
  67626. return ((max - min) * percent + min);
  67627. };
  67628. /**
  67629. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67630. * @param angle The angle to normalize in radian.
  67631. * @return The converted angle.
  67632. */
  67633. Scalar.NormalizeRadians = function (angle) {
  67634. // More precise but slower version kept for reference.
  67635. // angle = angle % Tools.TwoPi;
  67636. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67637. //if (angle > Math.PI) {
  67638. // angle -= Tools.TwoPi;
  67639. //}
  67640. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67641. return angle;
  67642. };
  67643. /**
  67644. * Two pi constants convenient for computation.
  67645. */
  67646. Scalar.TwoPi = Math.PI * 2;
  67647. return Scalar;
  67648. }());
  67649. /***/ }),
  67650. /***/ "./Maths/math.ts":
  67651. /*!***********************!*\
  67652. !*** ./Maths/math.ts ***!
  67653. \***********************/
  67654. /*! exports provided: ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp */
  67655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67656. "use strict";
  67657. __webpack_require__.r(__webpack_exports__);
  67658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67684. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67685. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67686. /**
  67687. * Constant used to convert a value to gamma space
  67688. * @ignorenaming
  67689. */
  67690. var ToGammaSpace = 1 / 2.2;
  67691. /**
  67692. * Constant used to convert a value to linear space
  67693. * @ignorenaming
  67694. */
  67695. var ToLinearSpace = 2.2;
  67696. /**
  67697. * Constant used to define the minimal number value in Babylon.js
  67698. * @ignorenaming
  67699. */
  67700. var Epsilon = 0.001;
  67701. /**
  67702. * Class used to hold a RBG color
  67703. */
  67704. var Color3 = /** @class */ (function () {
  67705. /**
  67706. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67707. * @param r defines the red component (between 0 and 1, default is 0)
  67708. * @param g defines the green component (between 0 and 1, default is 0)
  67709. * @param b defines the blue component (between 0 and 1, default is 0)
  67710. */
  67711. function Color3(
  67712. /**
  67713. * Defines the red component (between 0 and 1, default is 0)
  67714. */
  67715. r,
  67716. /**
  67717. * Defines the green component (between 0 and 1, default is 0)
  67718. */
  67719. g,
  67720. /**
  67721. * Defines the blue component (between 0 and 1, default is 0)
  67722. */
  67723. b) {
  67724. if (r === void 0) { r = 0; }
  67725. if (g === void 0) { g = 0; }
  67726. if (b === void 0) { b = 0; }
  67727. this.r = r;
  67728. this.g = g;
  67729. this.b = b;
  67730. }
  67731. /**
  67732. * Creates a string with the Color3 current values
  67733. * @returns the string representation of the Color3 object
  67734. */
  67735. Color3.prototype.toString = function () {
  67736. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67737. };
  67738. /**
  67739. * Returns the string "Color3"
  67740. * @returns "Color3"
  67741. */
  67742. Color3.prototype.getClassName = function () {
  67743. return "Color3";
  67744. };
  67745. /**
  67746. * Compute the Color3 hash code
  67747. * @returns an unique number that can be used to hash Color3 objects
  67748. */
  67749. Color3.prototype.getHashCode = function () {
  67750. var hash = this.r || 0;
  67751. hash = (hash * 397) ^ (this.g || 0);
  67752. hash = (hash * 397) ^ (this.b || 0);
  67753. return hash;
  67754. };
  67755. // Operators
  67756. /**
  67757. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67758. * @param array defines the array where to store the r,g,b components
  67759. * @param index defines an optional index in the target array to define where to start storing values
  67760. * @returns the current Color3 object
  67761. */
  67762. Color3.prototype.toArray = function (array, index) {
  67763. if (index === void 0) { index = 0; }
  67764. array[index] = this.r;
  67765. array[index + 1] = this.g;
  67766. array[index + 2] = this.b;
  67767. return this;
  67768. };
  67769. /**
  67770. * Returns a new Color4 object from the current Color3 and the given alpha
  67771. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67772. * @returns a new Color4 object
  67773. */
  67774. Color3.prototype.toColor4 = function (alpha) {
  67775. if (alpha === void 0) { alpha = 1; }
  67776. return new Color4(this.r, this.g, this.b, alpha);
  67777. };
  67778. /**
  67779. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67780. * @returns the new array
  67781. */
  67782. Color3.prototype.asArray = function () {
  67783. var result = new Array();
  67784. this.toArray(result, 0);
  67785. return result;
  67786. };
  67787. /**
  67788. * Returns the luminance value
  67789. * @returns a float value
  67790. */
  67791. Color3.prototype.toLuminance = function () {
  67792. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67793. };
  67794. /**
  67795. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67796. * @param otherColor defines the second operand
  67797. * @returns the new Color3 object
  67798. */
  67799. Color3.prototype.multiply = function (otherColor) {
  67800. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67801. };
  67802. /**
  67803. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67804. * @param otherColor defines the second operand
  67805. * @param result defines the Color3 object where to store the result
  67806. * @returns the current Color3
  67807. */
  67808. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67809. result.r = this.r * otherColor.r;
  67810. result.g = this.g * otherColor.g;
  67811. result.b = this.b * otherColor.b;
  67812. return this;
  67813. };
  67814. /**
  67815. * Determines equality between Color3 objects
  67816. * @param otherColor defines the second operand
  67817. * @returns true if the rgb values are equal to the given ones
  67818. */
  67819. Color3.prototype.equals = function (otherColor) {
  67820. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67821. };
  67822. /**
  67823. * Determines equality between the current Color3 object and a set of r,b,g values
  67824. * @param r defines the red component to check
  67825. * @param g defines the green component to check
  67826. * @param b defines the blue component to check
  67827. * @returns true if the rgb values are equal to the given ones
  67828. */
  67829. Color3.prototype.equalsFloats = function (r, g, b) {
  67830. return this.r === r && this.g === g && this.b === b;
  67831. };
  67832. /**
  67833. * Multiplies in place each rgb value by scale
  67834. * @param scale defines the scaling factor
  67835. * @returns the updated Color3
  67836. */
  67837. Color3.prototype.scale = function (scale) {
  67838. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67839. };
  67840. /**
  67841. * Multiplies the rgb values by scale and stores the result into "result"
  67842. * @param scale defines the scaling factor
  67843. * @param result defines the Color3 object where to store the result
  67844. * @returns the unmodified current Color3
  67845. */
  67846. Color3.prototype.scaleToRef = function (scale, result) {
  67847. result.r = this.r * scale;
  67848. result.g = this.g * scale;
  67849. result.b = this.b * scale;
  67850. return this;
  67851. };
  67852. /**
  67853. * Scale the current Color3 values by a factor and add the result to a given Color3
  67854. * @param scale defines the scale factor
  67855. * @param result defines color to store the result into
  67856. * @returns the unmodified current Color3
  67857. */
  67858. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67859. result.r += this.r * scale;
  67860. result.g += this.g * scale;
  67861. result.b += this.b * scale;
  67862. return this;
  67863. };
  67864. /**
  67865. * Clamps the rgb values by the min and max values and stores the result into "result"
  67866. * @param min defines minimum clamping value (default is 0)
  67867. * @param max defines maximum clamping value (default is 1)
  67868. * @param result defines color to store the result into
  67869. * @returns the original Color3
  67870. */
  67871. Color3.prototype.clampToRef = function (min, max, result) {
  67872. if (min === void 0) { min = 0; }
  67873. if (max === void 0) { max = 1; }
  67874. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67875. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67876. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67877. return this;
  67878. };
  67879. /**
  67880. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  67881. * @param otherColor defines the second operand
  67882. * @returns the new Color3
  67883. */
  67884. Color3.prototype.add = function (otherColor) {
  67885. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  67886. };
  67887. /**
  67888. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  67889. * @param otherColor defines the second operand
  67890. * @param result defines Color3 object to store the result into
  67891. * @returns the unmodified current Color3
  67892. */
  67893. Color3.prototype.addToRef = function (otherColor, result) {
  67894. result.r = this.r + otherColor.r;
  67895. result.g = this.g + otherColor.g;
  67896. result.b = this.b + otherColor.b;
  67897. return this;
  67898. };
  67899. /**
  67900. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  67901. * @param otherColor defines the second operand
  67902. * @returns the new Color3
  67903. */
  67904. Color3.prototype.subtract = function (otherColor) {
  67905. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  67906. };
  67907. /**
  67908. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  67909. * @param otherColor defines the second operand
  67910. * @param result defines Color3 object to store the result into
  67911. * @returns the unmodified current Color3
  67912. */
  67913. Color3.prototype.subtractToRef = function (otherColor, result) {
  67914. result.r = this.r - otherColor.r;
  67915. result.g = this.g - otherColor.g;
  67916. result.b = this.b - otherColor.b;
  67917. return this;
  67918. };
  67919. /**
  67920. * Copy the current object
  67921. * @returns a new Color3 copied the current one
  67922. */
  67923. Color3.prototype.clone = function () {
  67924. return new Color3(this.r, this.g, this.b);
  67925. };
  67926. /**
  67927. * Copies the rgb values from the source in the current Color3
  67928. * @param source defines the source Color3 object
  67929. * @returns the updated Color3 object
  67930. */
  67931. Color3.prototype.copyFrom = function (source) {
  67932. this.r = source.r;
  67933. this.g = source.g;
  67934. this.b = source.b;
  67935. return this;
  67936. };
  67937. /**
  67938. * Updates the Color3 rgb values from the given floats
  67939. * @param r defines the red component to read from
  67940. * @param g defines the green component to read from
  67941. * @param b defines the blue component to read from
  67942. * @returns the current Color3 object
  67943. */
  67944. Color3.prototype.copyFromFloats = function (r, g, b) {
  67945. this.r = r;
  67946. this.g = g;
  67947. this.b = b;
  67948. return this;
  67949. };
  67950. /**
  67951. * Updates the Color3 rgb values from the given floats
  67952. * @param r defines the red component to read from
  67953. * @param g defines the green component to read from
  67954. * @param b defines the blue component to read from
  67955. * @returns the current Color3 object
  67956. */
  67957. Color3.prototype.set = function (r, g, b) {
  67958. return this.copyFromFloats(r, g, b);
  67959. };
  67960. /**
  67961. * Compute the Color3 hexadecimal code as a string
  67962. * @returns a string containing the hexadecimal representation of the Color3 object
  67963. */
  67964. Color3.prototype.toHexString = function () {
  67965. var intR = (this.r * 255) | 0;
  67966. var intG = (this.g * 255) | 0;
  67967. var intB = (this.b * 255) | 0;
  67968. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intB);
  67969. };
  67970. /**
  67971. * Computes a new Color3 converted from the current one to linear space
  67972. * @returns a new Color3 object
  67973. */
  67974. Color3.prototype.toLinearSpace = function () {
  67975. var convertedColor = new Color3();
  67976. this.toLinearSpaceToRef(convertedColor);
  67977. return convertedColor;
  67978. };
  67979. /**
  67980. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  67981. * @param convertedColor defines the Color3 object where to store the linear space version
  67982. * @returns the unmodified Color3
  67983. */
  67984. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  67985. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67986. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67987. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67988. return this;
  67989. };
  67990. /**
  67991. * Computes a new Color3 converted from the current one to gamma space
  67992. * @returns a new Color3 object
  67993. */
  67994. Color3.prototype.toGammaSpace = function () {
  67995. var convertedColor = new Color3();
  67996. this.toGammaSpaceToRef(convertedColor);
  67997. return convertedColor;
  67998. };
  67999. /**
  68000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68001. * @param convertedColor defines the Color3 object where to store the gamma space version
  68002. * @returns the unmodified Color3
  68003. */
  68004. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  68005. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68006. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68007. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68008. return this;
  68009. };
  68010. /**
  68011. * Creates a new Color3 from the string containing valid hexadecimal values
  68012. * @param hex defines a string containing valid hexadecimal values
  68013. * @returns a new Color3 object
  68014. */
  68015. Color3.FromHexString = function (hex) {
  68016. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  68017. return new Color3(0, 0, 0);
  68018. }
  68019. var r = parseInt(hex.substring(1, 3), 16);
  68020. var g = parseInt(hex.substring(3, 5), 16);
  68021. var b = parseInt(hex.substring(5, 7), 16);
  68022. return Color3.FromInts(r, g, b);
  68023. };
  68024. /**
  68025. * Creates a new Vector3 from the starting index of the given array
  68026. * @param array defines the source array
  68027. * @param offset defines an offset in the source array
  68028. * @returns a new Color3 object
  68029. */
  68030. Color3.FromArray = function (array, offset) {
  68031. if (offset === void 0) { offset = 0; }
  68032. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  68033. };
  68034. /**
  68035. * Creates a new Color3 from integer values (< 256)
  68036. * @param r defines the red component to read from (value between 0 and 255)
  68037. * @param g defines the green component to read from (value between 0 and 255)
  68038. * @param b defines the blue component to read from (value between 0 and 255)
  68039. * @returns a new Color3 object
  68040. */
  68041. Color3.FromInts = function (r, g, b) {
  68042. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  68043. };
  68044. /**
  68045. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68046. * @param start defines the start Color3 value
  68047. * @param end defines the end Color3 value
  68048. * @param amount defines the gradient value between start and end
  68049. * @returns a new Color3 object
  68050. */
  68051. Color3.Lerp = function (start, end, amount) {
  68052. var result = new Color3(0.0, 0.0, 0.0);
  68053. Color3.LerpToRef(start, end, amount, result);
  68054. return result;
  68055. };
  68056. /**
  68057. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68058. * @param left defines the start value
  68059. * @param right defines the end value
  68060. * @param amount defines the gradient factor
  68061. * @param result defines the Color3 object where to store the result
  68062. */
  68063. Color3.LerpToRef = function (left, right, amount, result) {
  68064. result.r = left.r + ((right.r - left.r) * amount);
  68065. result.g = left.g + ((right.g - left.g) * amount);
  68066. result.b = left.b + ((right.b - left.b) * amount);
  68067. };
  68068. /**
  68069. * Returns a Color3 value containing a red color
  68070. * @returns a new Color3 object
  68071. */
  68072. Color3.Red = function () { return new Color3(1, 0, 0); };
  68073. /**
  68074. * Returns a Color3 value containing a green color
  68075. * @returns a new Color3 object
  68076. */
  68077. Color3.Green = function () { return new Color3(0, 1, 0); };
  68078. /**
  68079. * Returns a Color3 value containing a blue color
  68080. * @returns a new Color3 object
  68081. */
  68082. Color3.Blue = function () { return new Color3(0, 0, 1); };
  68083. /**
  68084. * Returns a Color3 value containing a black color
  68085. * @returns a new Color3 object
  68086. */
  68087. Color3.Black = function () { return new Color3(0, 0, 0); };
  68088. Object.defineProperty(Color3, "BlackReadOnly", {
  68089. /**
  68090. * Gets a Color3 value containing a black color that must not be updated
  68091. */
  68092. get: function () {
  68093. return Color3._BlackReadOnly;
  68094. },
  68095. enumerable: true,
  68096. configurable: true
  68097. });
  68098. /**
  68099. * Returns a Color3 value containing a white color
  68100. * @returns a new Color3 object
  68101. */
  68102. Color3.White = function () { return new Color3(1, 1, 1); };
  68103. /**
  68104. * Returns a Color3 value containing a purple color
  68105. * @returns a new Color3 object
  68106. */
  68107. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  68108. /**
  68109. * Returns a Color3 value containing a magenta color
  68110. * @returns a new Color3 object
  68111. */
  68112. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  68113. /**
  68114. * Returns a Color3 value containing a yellow color
  68115. * @returns a new Color3 object
  68116. */
  68117. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  68118. /**
  68119. * Returns a Color3 value containing a gray color
  68120. * @returns a new Color3 object
  68121. */
  68122. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  68123. /**
  68124. * Returns a Color3 value containing a teal color
  68125. * @returns a new Color3 object
  68126. */
  68127. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  68128. /**
  68129. * Returns a Color3 value containing a random color
  68130. * @returns a new Color3 object
  68131. */
  68132. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  68133. // Statics
  68134. Color3._BlackReadOnly = Color3.Black();
  68135. return Color3;
  68136. }());
  68137. /**
  68138. * Class used to hold a RBGA color
  68139. */
  68140. var Color4 = /** @class */ (function () {
  68141. /**
  68142. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68143. * @param r defines the red component (between 0 and 1, default is 0)
  68144. * @param g defines the green component (between 0 and 1, default is 0)
  68145. * @param b defines the blue component (between 0 and 1, default is 0)
  68146. * @param a defines the alpha component (between 0 and 1, default is 1)
  68147. */
  68148. function Color4(
  68149. /**
  68150. * Defines the red component (between 0 and 1, default is 0)
  68151. */
  68152. r,
  68153. /**
  68154. * Defines the green component (between 0 and 1, default is 0)
  68155. */
  68156. g,
  68157. /**
  68158. * Defines the blue component (between 0 and 1, default is 0)
  68159. */
  68160. b,
  68161. /**
  68162. * Defines the alpha component (between 0 and 1, default is 1)
  68163. */
  68164. a) {
  68165. if (r === void 0) { r = 0; }
  68166. if (g === void 0) { g = 0; }
  68167. if (b === void 0) { b = 0; }
  68168. if (a === void 0) { a = 1; }
  68169. this.r = r;
  68170. this.g = g;
  68171. this.b = b;
  68172. this.a = a;
  68173. }
  68174. // Operators
  68175. /**
  68176. * Adds in place the given Color4 values to the current Color4 object
  68177. * @param right defines the second operand
  68178. * @returns the current updated Color4 object
  68179. */
  68180. Color4.prototype.addInPlace = function (right) {
  68181. this.r += right.r;
  68182. this.g += right.g;
  68183. this.b += right.b;
  68184. this.a += right.a;
  68185. return this;
  68186. };
  68187. /**
  68188. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68189. * @returns the new array
  68190. */
  68191. Color4.prototype.asArray = function () {
  68192. var result = new Array();
  68193. this.toArray(result, 0);
  68194. return result;
  68195. };
  68196. /**
  68197. * Stores from the starting index in the given array the Color4 successive values
  68198. * @param array defines the array where to store the r,g,b components
  68199. * @param index defines an optional index in the target array to define where to start storing values
  68200. * @returns the current Color4 object
  68201. */
  68202. Color4.prototype.toArray = function (array, index) {
  68203. if (index === void 0) { index = 0; }
  68204. array[index] = this.r;
  68205. array[index + 1] = this.g;
  68206. array[index + 2] = this.b;
  68207. array[index + 3] = this.a;
  68208. return this;
  68209. };
  68210. /**
  68211. * Determines equality between Color4 objects
  68212. * @param otherColor defines the second operand
  68213. * @returns true if the rgba values are equal to the given ones
  68214. */
  68215. Color4.prototype.equals = function (otherColor) {
  68216. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68217. };
  68218. /**
  68219. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68220. * @param right defines the second operand
  68221. * @returns a new Color4 object
  68222. */
  68223. Color4.prototype.add = function (right) {
  68224. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68225. };
  68226. /**
  68227. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68228. * @param right defines the second operand
  68229. * @returns a new Color4 object
  68230. */
  68231. Color4.prototype.subtract = function (right) {
  68232. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68233. };
  68234. /**
  68235. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68236. * @param right defines the second operand
  68237. * @param result defines the Color4 object where to store the result
  68238. * @returns the current Color4 object
  68239. */
  68240. Color4.prototype.subtractToRef = function (right, result) {
  68241. result.r = this.r - right.r;
  68242. result.g = this.g - right.g;
  68243. result.b = this.b - right.b;
  68244. result.a = this.a - right.a;
  68245. return this;
  68246. };
  68247. /**
  68248. * Creates a new Color4 with the current Color4 values multiplied by scale
  68249. * @param scale defines the scaling factor to apply
  68250. * @returns a new Color4 object
  68251. */
  68252. Color4.prototype.scale = function (scale) {
  68253. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68254. };
  68255. /**
  68256. * Multiplies the current Color4 values by scale and stores the result in "result"
  68257. * @param scale defines the scaling factor to apply
  68258. * @param result defines the Color4 object where to store the result
  68259. * @returns the current unmodified Color4
  68260. */
  68261. Color4.prototype.scaleToRef = function (scale, result) {
  68262. result.r = this.r * scale;
  68263. result.g = this.g * scale;
  68264. result.b = this.b * scale;
  68265. result.a = this.a * scale;
  68266. return this;
  68267. };
  68268. /**
  68269. * Scale the current Color4 values by a factor and add the result to a given Color4
  68270. * @param scale defines the scale factor
  68271. * @param result defines the Color4 object where to store the result
  68272. * @returns the unmodified current Color4
  68273. */
  68274. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68275. result.r += this.r * scale;
  68276. result.g += this.g * scale;
  68277. result.b += this.b * scale;
  68278. result.a += this.a * scale;
  68279. return this;
  68280. };
  68281. /**
  68282. * Clamps the rgb values by the min and max values and stores the result into "result"
  68283. * @param min defines minimum clamping value (default is 0)
  68284. * @param max defines maximum clamping value (default is 1)
  68285. * @param result defines color to store the result into.
  68286. * @returns the cuurent Color4
  68287. */
  68288. Color4.prototype.clampToRef = function (min, max, result) {
  68289. if (min === void 0) { min = 0; }
  68290. if (max === void 0) { max = 1; }
  68291. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68292. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68293. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68294. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68295. return this;
  68296. };
  68297. /**
  68298. * Multipy an Color4 value by another and return a new Color4 object
  68299. * @param color defines the Color4 value to multiply by
  68300. * @returns a new Color4 object
  68301. */
  68302. Color4.prototype.multiply = function (color) {
  68303. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68304. };
  68305. /**
  68306. * Multipy a Color4 value by another and push the result in a reference value
  68307. * @param color defines the Color4 value to multiply by
  68308. * @param result defines the Color4 to fill the result in
  68309. * @returns the result Color4
  68310. */
  68311. Color4.prototype.multiplyToRef = function (color, result) {
  68312. result.r = this.r * color.r;
  68313. result.g = this.g * color.g;
  68314. result.b = this.b * color.b;
  68315. result.a = this.a * color.a;
  68316. return result;
  68317. };
  68318. /**
  68319. * Creates a string with the Color4 current values
  68320. * @returns the string representation of the Color4 object
  68321. */
  68322. Color4.prototype.toString = function () {
  68323. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68324. };
  68325. /**
  68326. * Returns the string "Color4"
  68327. * @returns "Color4"
  68328. */
  68329. Color4.prototype.getClassName = function () {
  68330. return "Color4";
  68331. };
  68332. /**
  68333. * Compute the Color4 hash code
  68334. * @returns an unique number that can be used to hash Color4 objects
  68335. */
  68336. Color4.prototype.getHashCode = function () {
  68337. var hash = this.r || 0;
  68338. hash = (hash * 397) ^ (this.g || 0);
  68339. hash = (hash * 397) ^ (this.b || 0);
  68340. hash = (hash * 397) ^ (this.a || 0);
  68341. return hash;
  68342. };
  68343. /**
  68344. * Creates a new Color4 copied from the current one
  68345. * @returns a new Color4 object
  68346. */
  68347. Color4.prototype.clone = function () {
  68348. return new Color4(this.r, this.g, this.b, this.a);
  68349. };
  68350. /**
  68351. * Copies the given Color4 values into the current one
  68352. * @param source defines the source Color4 object
  68353. * @returns the current updated Color4 object
  68354. */
  68355. Color4.prototype.copyFrom = function (source) {
  68356. this.r = source.r;
  68357. this.g = source.g;
  68358. this.b = source.b;
  68359. this.a = source.a;
  68360. return this;
  68361. };
  68362. /**
  68363. * Copies the given float values into the current one
  68364. * @param r defines the red component to read from
  68365. * @param g defines the green component to read from
  68366. * @param b defines the blue component to read from
  68367. * @param a defines the alpha component to read from
  68368. * @returns the current updated Color4 object
  68369. */
  68370. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68371. this.r = r;
  68372. this.g = g;
  68373. this.b = b;
  68374. this.a = a;
  68375. return this;
  68376. };
  68377. /**
  68378. * Copies the given float values into the current one
  68379. * @param r defines the red component to read from
  68380. * @param g defines the green component to read from
  68381. * @param b defines the blue component to read from
  68382. * @param a defines the alpha component to read from
  68383. * @returns the current updated Color4 object
  68384. */
  68385. Color4.prototype.set = function (r, g, b, a) {
  68386. return this.copyFromFloats(r, g, b, a);
  68387. };
  68388. /**
  68389. * Compute the Color4 hexadecimal code as a string
  68390. * @returns a string containing the hexadecimal representation of the Color4 object
  68391. */
  68392. Color4.prototype.toHexString = function () {
  68393. var intR = (this.r * 255) | 0;
  68394. var intG = (this.g * 255) | 0;
  68395. var intB = (this.b * 255) | 0;
  68396. var intA = (this.a * 255) | 0;
  68397. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intB) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intA);
  68398. };
  68399. /**
  68400. * Computes a new Color4 converted from the current one to linear space
  68401. * @returns a new Color4 object
  68402. */
  68403. Color4.prototype.toLinearSpace = function () {
  68404. var convertedColor = new Color4();
  68405. this.toLinearSpaceToRef(convertedColor);
  68406. return convertedColor;
  68407. };
  68408. /**
  68409. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68410. * @param convertedColor defines the Color4 object where to store the linear space version
  68411. * @returns the unmodified Color4
  68412. */
  68413. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68414. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68415. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68416. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68417. convertedColor.a = this.a;
  68418. return this;
  68419. };
  68420. /**
  68421. * Computes a new Color4 converted from the current one to gamma space
  68422. * @returns a new Color4 object
  68423. */
  68424. Color4.prototype.toGammaSpace = function () {
  68425. var convertedColor = new Color4();
  68426. this.toGammaSpaceToRef(convertedColor);
  68427. return convertedColor;
  68428. };
  68429. /**
  68430. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68431. * @param convertedColor defines the Color4 object where to store the gamma space version
  68432. * @returns the unmodified Color4
  68433. */
  68434. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  68435. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68436. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68437. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68438. convertedColor.a = this.a;
  68439. return this;
  68440. };
  68441. // Statics
  68442. /**
  68443. * Creates a new Color4 from the string containing valid hexadecimal values
  68444. * @param hex defines a string containing valid hexadecimal values
  68445. * @returns a new Color4 object
  68446. */
  68447. Color4.FromHexString = function (hex) {
  68448. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  68449. return new Color4(0.0, 0.0, 0.0, 0.0);
  68450. }
  68451. var r = parseInt(hex.substring(1, 3), 16);
  68452. var g = parseInt(hex.substring(3, 5), 16);
  68453. var b = parseInt(hex.substring(5, 7), 16);
  68454. var a = parseInt(hex.substring(7, 9), 16);
  68455. return Color4.FromInts(r, g, b, a);
  68456. };
  68457. /**
  68458. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68459. * @param left defines the start value
  68460. * @param right defines the end value
  68461. * @param amount defines the gradient factor
  68462. * @returns a new Color4 object
  68463. */
  68464. Color4.Lerp = function (left, right, amount) {
  68465. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  68466. Color4.LerpToRef(left, right, amount, result);
  68467. return result;
  68468. };
  68469. /**
  68470. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68471. * @param left defines the start value
  68472. * @param right defines the end value
  68473. * @param amount defines the gradient factor
  68474. * @param result defines the Color4 object where to store data
  68475. */
  68476. Color4.LerpToRef = function (left, right, amount, result) {
  68477. result.r = left.r + (right.r - left.r) * amount;
  68478. result.g = left.g + (right.g - left.g) * amount;
  68479. result.b = left.b + (right.b - left.b) * amount;
  68480. result.a = left.a + (right.a - left.a) * amount;
  68481. };
  68482. /**
  68483. * Creates a new Color4 from a Color3 and an alpha value
  68484. * @param color3 defines the source Color3 to read from
  68485. * @param alpha defines the alpha component (1.0 by default)
  68486. * @returns a new Color4 object
  68487. */
  68488. Color4.FromColor3 = function (color3, alpha) {
  68489. if (alpha === void 0) { alpha = 1.0; }
  68490. return new Color4(color3.r, color3.g, color3.b, alpha);
  68491. };
  68492. /**
  68493. * Creates a new Color4 from the starting index element of the given array
  68494. * @param array defines the source array to read from
  68495. * @param offset defines the offset in the source array
  68496. * @returns a new Color4 object
  68497. */
  68498. Color4.FromArray = function (array, offset) {
  68499. if (offset === void 0) { offset = 0; }
  68500. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  68501. };
  68502. /**
  68503. * Creates a new Color3 from integer values (< 256)
  68504. * @param r defines the red component to read from (value between 0 and 255)
  68505. * @param g defines the green component to read from (value between 0 and 255)
  68506. * @param b defines the blue component to read from (value between 0 and 255)
  68507. * @param a defines the alpha component to read from (value between 0 and 255)
  68508. * @returns a new Color3 object
  68509. */
  68510. Color4.FromInts = function (r, g, b, a) {
  68511. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  68512. };
  68513. /**
  68514. * Check the content of a given array and convert it to an array containing RGBA data
  68515. * If the original array was already containing count * 4 values then it is returned directly
  68516. * @param colors defines the array to check
  68517. * @param count defines the number of RGBA data to expect
  68518. * @returns an array containing count * 4 values (RGBA)
  68519. */
  68520. Color4.CheckColors4 = function (colors, count) {
  68521. // Check if color3 was used
  68522. if (colors.length === count * 3) {
  68523. var colors4 = [];
  68524. for (var index = 0; index < colors.length; index += 3) {
  68525. var newIndex = (index / 3) * 4;
  68526. colors4[newIndex] = colors[index];
  68527. colors4[newIndex + 1] = colors[index + 1];
  68528. colors4[newIndex + 2] = colors[index + 2];
  68529. colors4[newIndex + 3] = 1.0;
  68530. }
  68531. return colors4;
  68532. }
  68533. return colors;
  68534. };
  68535. return Color4;
  68536. }());
  68537. /**
  68538. * Class representing a vector containing 2 coordinates
  68539. */
  68540. var Vector2 = /** @class */ (function () {
  68541. /**
  68542. * Creates a new Vector2 from the given x and y coordinates
  68543. * @param x defines the first coordinate
  68544. * @param y defines the second coordinate
  68545. */
  68546. function Vector2(
  68547. /** defines the first coordinate */
  68548. x,
  68549. /** defines the second coordinate */
  68550. y) {
  68551. if (x === void 0) { x = 0; }
  68552. if (y === void 0) { y = 0; }
  68553. this.x = x;
  68554. this.y = y;
  68555. }
  68556. /**
  68557. * Gets a string with the Vector2 coordinates
  68558. * @returns a string with the Vector2 coordinates
  68559. */
  68560. Vector2.prototype.toString = function () {
  68561. return "{X: " + this.x + " Y:" + this.y + "}";
  68562. };
  68563. /**
  68564. * Gets class name
  68565. * @returns the string "Vector2"
  68566. */
  68567. Vector2.prototype.getClassName = function () {
  68568. return "Vector2";
  68569. };
  68570. /**
  68571. * Gets current vector hash code
  68572. * @returns the Vector2 hash code as a number
  68573. */
  68574. Vector2.prototype.getHashCode = function () {
  68575. var hash = this.x || 0;
  68576. hash = (hash * 397) ^ (this.y || 0);
  68577. return hash;
  68578. };
  68579. // Operators
  68580. /**
  68581. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68582. * @param array defines the source array
  68583. * @param index defines the offset in source array
  68584. * @returns the current Vector2
  68585. */
  68586. Vector2.prototype.toArray = function (array, index) {
  68587. if (index === void 0) { index = 0; }
  68588. array[index] = this.x;
  68589. array[index + 1] = this.y;
  68590. return this;
  68591. };
  68592. /**
  68593. * Copy the current vector to an array
  68594. * @returns a new array with 2 elements: the Vector2 coordinates.
  68595. */
  68596. Vector2.prototype.asArray = function () {
  68597. var result = new Array();
  68598. this.toArray(result, 0);
  68599. return result;
  68600. };
  68601. /**
  68602. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68603. * @param source defines the source Vector2
  68604. * @returns the current updated Vector2
  68605. */
  68606. Vector2.prototype.copyFrom = function (source) {
  68607. this.x = source.x;
  68608. this.y = source.y;
  68609. return this;
  68610. };
  68611. /**
  68612. * Sets the Vector2 coordinates with the given floats
  68613. * @param x defines the first coordinate
  68614. * @param y defines the second coordinate
  68615. * @returns the current updated Vector2
  68616. */
  68617. Vector2.prototype.copyFromFloats = function (x, y) {
  68618. this.x = x;
  68619. this.y = y;
  68620. return this;
  68621. };
  68622. /**
  68623. * Sets the Vector2 coordinates with the given floats
  68624. * @param x defines the first coordinate
  68625. * @param y defines the second coordinate
  68626. * @returns the current updated Vector2
  68627. */
  68628. Vector2.prototype.set = function (x, y) {
  68629. return this.copyFromFloats(x, y);
  68630. };
  68631. /**
  68632. * Add another vector with the current one
  68633. * @param otherVector defines the other vector
  68634. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68635. */
  68636. Vector2.prototype.add = function (otherVector) {
  68637. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68638. };
  68639. /**
  68640. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68641. * @param otherVector defines the other vector
  68642. * @param result defines the target vector
  68643. * @returns the unmodified current Vector2
  68644. */
  68645. Vector2.prototype.addToRef = function (otherVector, result) {
  68646. result.x = this.x + otherVector.x;
  68647. result.y = this.y + otherVector.y;
  68648. return this;
  68649. };
  68650. /**
  68651. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68652. * @param otherVector defines the other vector
  68653. * @returns the current updated Vector2
  68654. */
  68655. Vector2.prototype.addInPlace = function (otherVector) {
  68656. this.x += otherVector.x;
  68657. this.y += otherVector.y;
  68658. return this;
  68659. };
  68660. /**
  68661. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68662. * @param otherVector defines the other vector
  68663. * @returns a new Vector2
  68664. */
  68665. Vector2.prototype.addVector3 = function (otherVector) {
  68666. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68667. };
  68668. /**
  68669. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68670. * @param otherVector defines the other vector
  68671. * @returns a new Vector2
  68672. */
  68673. Vector2.prototype.subtract = function (otherVector) {
  68674. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68675. };
  68676. /**
  68677. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68678. * @param otherVector defines the other vector
  68679. * @param result defines the target vector
  68680. * @returns the unmodified current Vector2
  68681. */
  68682. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68683. result.x = this.x - otherVector.x;
  68684. result.y = this.y - otherVector.y;
  68685. return this;
  68686. };
  68687. /**
  68688. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68689. * @param otherVector defines the other vector
  68690. * @returns the current updated Vector2
  68691. */
  68692. Vector2.prototype.subtractInPlace = function (otherVector) {
  68693. this.x -= otherVector.x;
  68694. this.y -= otherVector.y;
  68695. return this;
  68696. };
  68697. /**
  68698. * Multiplies in place the current Vector2 coordinates by the given ones
  68699. * @param otherVector defines the other vector
  68700. * @returns the current updated Vector2
  68701. */
  68702. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68703. this.x *= otherVector.x;
  68704. this.y *= otherVector.y;
  68705. return this;
  68706. };
  68707. /**
  68708. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68709. * @param otherVector defines the other vector
  68710. * @returns a new Vector2
  68711. */
  68712. Vector2.prototype.multiply = function (otherVector) {
  68713. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68714. };
  68715. /**
  68716. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68717. * @param otherVector defines the other vector
  68718. * @param result defines the target vector
  68719. * @returns the unmodified current Vector2
  68720. */
  68721. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68722. result.x = this.x * otherVector.x;
  68723. result.y = this.y * otherVector.y;
  68724. return this;
  68725. };
  68726. /**
  68727. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68728. * @param x defines the first coordinate
  68729. * @param y defines the second coordinate
  68730. * @returns a new Vector2
  68731. */
  68732. Vector2.prototype.multiplyByFloats = function (x, y) {
  68733. return new Vector2(this.x * x, this.y * y);
  68734. };
  68735. /**
  68736. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68737. * @param otherVector defines the other vector
  68738. * @returns a new Vector2
  68739. */
  68740. Vector2.prototype.divide = function (otherVector) {
  68741. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68742. };
  68743. /**
  68744. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68745. * @param otherVector defines the other vector
  68746. * @param result defines the target vector
  68747. * @returns the unmodified current Vector2
  68748. */
  68749. Vector2.prototype.divideToRef = function (otherVector, result) {
  68750. result.x = this.x / otherVector.x;
  68751. result.y = this.y / otherVector.y;
  68752. return this;
  68753. };
  68754. /**
  68755. * Divides the current Vector2 coordinates by the given ones
  68756. * @param otherVector defines the other vector
  68757. * @returns the current updated Vector2
  68758. */
  68759. Vector2.prototype.divideInPlace = function (otherVector) {
  68760. return this.divideToRef(otherVector, this);
  68761. };
  68762. /**
  68763. * Gets a new Vector2 with current Vector2 negated coordinates
  68764. * @returns a new Vector2
  68765. */
  68766. Vector2.prototype.negate = function () {
  68767. return new Vector2(-this.x, -this.y);
  68768. };
  68769. /**
  68770. * Multiply the Vector2 coordinates by scale
  68771. * @param scale defines the scaling factor
  68772. * @returns the current updated Vector2
  68773. */
  68774. Vector2.prototype.scaleInPlace = function (scale) {
  68775. this.x *= scale;
  68776. this.y *= scale;
  68777. return this;
  68778. };
  68779. /**
  68780. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68781. * @param scale defines the scaling factor
  68782. * @returns a new Vector2
  68783. */
  68784. Vector2.prototype.scale = function (scale) {
  68785. var result = new Vector2(0, 0);
  68786. this.scaleToRef(scale, result);
  68787. return result;
  68788. };
  68789. /**
  68790. * Scale the current Vector2 values by a factor to a given Vector2
  68791. * @param scale defines the scale factor
  68792. * @param result defines the Vector2 object where to store the result
  68793. * @returns the unmodified current Vector2
  68794. */
  68795. Vector2.prototype.scaleToRef = function (scale, result) {
  68796. result.x = this.x * scale;
  68797. result.y = this.y * scale;
  68798. return this;
  68799. };
  68800. /**
  68801. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68802. * @param scale defines the scale factor
  68803. * @param result defines the Vector2 object where to store the result
  68804. * @returns the unmodified current Vector2
  68805. */
  68806. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68807. result.x += this.x * scale;
  68808. result.y += this.y * scale;
  68809. return this;
  68810. };
  68811. /**
  68812. * Gets a boolean if two vectors are equals
  68813. * @param otherVector defines the other vector
  68814. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68815. */
  68816. Vector2.prototype.equals = function (otherVector) {
  68817. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68818. };
  68819. /**
  68820. * Gets a boolean if two vectors are equals (using an epsilon value)
  68821. * @param otherVector defines the other vector
  68822. * @param epsilon defines the minimal distance to consider equality
  68823. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68824. */
  68825. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68826. if (epsilon === void 0) { epsilon = Epsilon; }
  68827. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon);
  68828. };
  68829. /**
  68830. * Gets a new Vector2 from current Vector2 floored values
  68831. * @returns a new Vector2
  68832. */
  68833. Vector2.prototype.floor = function () {
  68834. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68835. };
  68836. /**
  68837. * Gets a new Vector2 from current Vector2 floored values
  68838. * @returns a new Vector2
  68839. */
  68840. Vector2.prototype.fract = function () {
  68841. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68842. };
  68843. // Properties
  68844. /**
  68845. * Gets the length of the vector
  68846. * @returns the vector length (float)
  68847. */
  68848. Vector2.prototype.length = function () {
  68849. return Math.sqrt(this.x * this.x + this.y * this.y);
  68850. };
  68851. /**
  68852. * Gets the vector squared length
  68853. * @returns the vector squared length (float)
  68854. */
  68855. Vector2.prototype.lengthSquared = function () {
  68856. return (this.x * this.x + this.y * this.y);
  68857. };
  68858. // Methods
  68859. /**
  68860. * Normalize the vector
  68861. * @returns the current updated Vector2
  68862. */
  68863. Vector2.prototype.normalize = function () {
  68864. var len = this.length();
  68865. if (len === 0) {
  68866. return this;
  68867. }
  68868. var num = 1.0 / len;
  68869. this.x *= num;
  68870. this.y *= num;
  68871. return this;
  68872. };
  68873. /**
  68874. * Gets a new Vector2 copied from the Vector2
  68875. * @returns a new Vector2
  68876. */
  68877. Vector2.prototype.clone = function () {
  68878. return new Vector2(this.x, this.y);
  68879. };
  68880. // Statics
  68881. /**
  68882. * Gets a new Vector2(0, 0)
  68883. * @returns a new Vector2
  68884. */
  68885. Vector2.Zero = function () {
  68886. return new Vector2(0, 0);
  68887. };
  68888. /**
  68889. * Gets a new Vector2(1, 1)
  68890. * @returns a new Vector2
  68891. */
  68892. Vector2.One = function () {
  68893. return new Vector2(1, 1);
  68894. };
  68895. /**
  68896. * Gets a new Vector2 set from the given index element of the given array
  68897. * @param array defines the data source
  68898. * @param offset defines the offset in the data source
  68899. * @returns a new Vector2
  68900. */
  68901. Vector2.FromArray = function (array, offset) {
  68902. if (offset === void 0) { offset = 0; }
  68903. return new Vector2(array[offset], array[offset + 1]);
  68904. };
  68905. /**
  68906. * Sets "result" from the given index element of the given array
  68907. * @param array defines the data source
  68908. * @param offset defines the offset in the data source
  68909. * @param result defines the target vector
  68910. */
  68911. Vector2.FromArrayToRef = function (array, offset, result) {
  68912. result.x = array[offset];
  68913. result.y = array[offset + 1];
  68914. };
  68915. /**
  68916. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68917. * @param value1 defines 1st point of control
  68918. * @param value2 defines 2nd point of control
  68919. * @param value3 defines 3rd point of control
  68920. * @param value4 defines 4th point of control
  68921. * @param amount defines the interpolation factor
  68922. * @returns a new Vector2
  68923. */
  68924. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  68925. var squared = amount * amount;
  68926. var cubed = amount * squared;
  68927. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  68928. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  68929. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  68930. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  68931. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  68932. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  68933. return new Vector2(x, y);
  68934. };
  68935. /**
  68936. * 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".
  68937. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68938. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68939. * @param value defines the value to clamp
  68940. * @param min defines the lower limit
  68941. * @param max defines the upper limit
  68942. * @returns a new Vector2
  68943. */
  68944. Vector2.Clamp = function (value, min, max) {
  68945. var x = value.x;
  68946. x = (x > max.x) ? max.x : x;
  68947. x = (x < min.x) ? min.x : x;
  68948. var y = value.y;
  68949. y = (y > max.y) ? max.y : y;
  68950. y = (y < min.y) ? min.y : y;
  68951. return new Vector2(x, y);
  68952. };
  68953. /**
  68954. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68955. * @param value1 defines the 1st control point
  68956. * @param tangent1 defines the outgoing tangent
  68957. * @param value2 defines the 2nd control point
  68958. * @param tangent2 defines the incoming tangent
  68959. * @param amount defines the interpolation factor
  68960. * @returns a new Vector2
  68961. */
  68962. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68963. var squared = amount * amount;
  68964. var cubed = amount * squared;
  68965. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68966. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68967. var part3 = (cubed - (2.0 * squared)) + amount;
  68968. var part4 = cubed - squared;
  68969. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  68970. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  68971. return new Vector2(x, y);
  68972. };
  68973. /**
  68974. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68975. * @param start defines the start vector
  68976. * @param end defines the end vector
  68977. * @param amount defines the interpolation factor
  68978. * @returns a new Vector2
  68979. */
  68980. Vector2.Lerp = function (start, end, amount) {
  68981. var x = start.x + ((end.x - start.x) * amount);
  68982. var y = start.y + ((end.y - start.y) * amount);
  68983. return new Vector2(x, y);
  68984. };
  68985. /**
  68986. * Gets the dot product of the vector "left" and the vector "right"
  68987. * @param left defines first vector
  68988. * @param right defines second vector
  68989. * @returns the dot product (float)
  68990. */
  68991. Vector2.Dot = function (left, right) {
  68992. return left.x * right.x + left.y * right.y;
  68993. };
  68994. /**
  68995. * Returns a new Vector2 equal to the normalized given vector
  68996. * @param vector defines the vector to normalize
  68997. * @returns a new Vector2
  68998. */
  68999. Vector2.Normalize = function (vector) {
  69000. var newVector = vector.clone();
  69001. newVector.normalize();
  69002. return newVector;
  69003. };
  69004. /**
  69005. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69006. * @param left defines 1st vector
  69007. * @param right defines 2nd vector
  69008. * @returns a new Vector2
  69009. */
  69010. Vector2.Minimize = function (left, right) {
  69011. var x = (left.x < right.x) ? left.x : right.x;
  69012. var y = (left.y < right.y) ? left.y : right.y;
  69013. return new Vector2(x, y);
  69014. };
  69015. /**
  69016. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69017. * @param left defines 1st vector
  69018. * @param right defines 2nd vector
  69019. * @returns a new Vector2
  69020. */
  69021. Vector2.Maximize = function (left, right) {
  69022. var x = (left.x > right.x) ? left.x : right.x;
  69023. var y = (left.y > right.y) ? left.y : right.y;
  69024. return new Vector2(x, y);
  69025. };
  69026. /**
  69027. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69028. * @param vector defines the vector to transform
  69029. * @param transformation defines the matrix to apply
  69030. * @returns a new Vector2
  69031. */
  69032. Vector2.Transform = function (vector, transformation) {
  69033. var r = Vector2.Zero();
  69034. Vector2.TransformToRef(vector, transformation, r);
  69035. return r;
  69036. };
  69037. /**
  69038. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69039. * @param vector defines the vector to transform
  69040. * @param transformation defines the matrix to apply
  69041. * @param result defines the target vector
  69042. */
  69043. Vector2.TransformToRef = function (vector, transformation, result) {
  69044. var m = transformation.m;
  69045. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  69046. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  69047. result.x = x;
  69048. result.y = y;
  69049. };
  69050. /**
  69051. * Determines if a given vector is included in a triangle
  69052. * @param p defines the vector to test
  69053. * @param p0 defines 1st triangle point
  69054. * @param p1 defines 2nd triangle point
  69055. * @param p2 defines 3rd triangle point
  69056. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69057. */
  69058. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  69059. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  69060. var sign = a < 0 ? -1 : 1;
  69061. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  69062. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  69063. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  69064. };
  69065. /**
  69066. * Gets the distance between the vectors "value1" and "value2"
  69067. * @param value1 defines first vector
  69068. * @param value2 defines second vector
  69069. * @returns the distance between vectors
  69070. */
  69071. Vector2.Distance = function (value1, value2) {
  69072. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  69073. };
  69074. /**
  69075. * Returns the squared distance between the vectors "value1" and "value2"
  69076. * @param value1 defines first vector
  69077. * @param value2 defines second vector
  69078. * @returns the squared distance between vectors
  69079. */
  69080. Vector2.DistanceSquared = function (value1, value2) {
  69081. var x = value1.x - value2.x;
  69082. var y = value1.y - value2.y;
  69083. return (x * x) + (y * y);
  69084. };
  69085. /**
  69086. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69087. * @param value1 defines first vector
  69088. * @param value2 defines second vector
  69089. * @returns a new Vector2
  69090. */
  69091. Vector2.Center = function (value1, value2) {
  69092. var center = value1.add(value2);
  69093. center.scaleInPlace(0.5);
  69094. return center;
  69095. };
  69096. /**
  69097. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69098. * @param p defines the middle point
  69099. * @param segA defines one point of the segment
  69100. * @param segB defines the other point of the segment
  69101. * @returns the shortest distance
  69102. */
  69103. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  69104. var l2 = Vector2.DistanceSquared(segA, segB);
  69105. if (l2 === 0.0) {
  69106. return Vector2.Distance(p, segA);
  69107. }
  69108. var v = segB.subtract(segA);
  69109. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  69110. var proj = segA.add(v.multiplyByFloats(t, t));
  69111. return Vector2.Distance(p, proj);
  69112. };
  69113. return Vector2;
  69114. }());
  69115. /**
  69116. * Classed used to store (x,y,z) vector representation
  69117. * A Vector3 is the main object used in 3D geometry
  69118. * It can represent etiher the coordinates of a point the space, either a direction
  69119. * Reminder: js uses a left handed forward facing system
  69120. */
  69121. var Vector3 = /** @class */ (function () {
  69122. /**
  69123. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69124. * @param x defines the first coordinates (on X axis)
  69125. * @param y defines the second coordinates (on Y axis)
  69126. * @param z defines the third coordinates (on Z axis)
  69127. */
  69128. function Vector3(
  69129. /**
  69130. * Defines the first coordinates (on X axis)
  69131. */
  69132. x,
  69133. /**
  69134. * Defines the second coordinates (on Y axis)
  69135. */
  69136. y,
  69137. /**
  69138. * Defines the third coordinates (on Z axis)
  69139. */
  69140. z) {
  69141. if (x === void 0) { x = 0; }
  69142. if (y === void 0) { y = 0; }
  69143. if (z === void 0) { z = 0; }
  69144. this.x = x;
  69145. this.y = y;
  69146. this.z = z;
  69147. }
  69148. /**
  69149. * Creates a string representation of the Vector3
  69150. * @returns a string with the Vector3 coordinates.
  69151. */
  69152. Vector3.prototype.toString = function () {
  69153. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  69154. };
  69155. /**
  69156. * Gets the class name
  69157. * @returns the string "Vector3"
  69158. */
  69159. Vector3.prototype.getClassName = function () {
  69160. return "Vector3";
  69161. };
  69162. /**
  69163. * Creates the Vector3 hash code
  69164. * @returns a number which tends to be unique between Vector3 instances
  69165. */
  69166. Vector3.prototype.getHashCode = function () {
  69167. var hash = this.x || 0;
  69168. hash = (hash * 397) ^ (this.y || 0);
  69169. hash = (hash * 397) ^ (this.z || 0);
  69170. return hash;
  69171. };
  69172. // Operators
  69173. /**
  69174. * Creates an array containing three elements : the coordinates of the Vector3
  69175. * @returns a new array of numbers
  69176. */
  69177. Vector3.prototype.asArray = function () {
  69178. var result = [];
  69179. this.toArray(result, 0);
  69180. return result;
  69181. };
  69182. /**
  69183. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69184. * @param array defines the destination array
  69185. * @param index defines the offset in the destination array
  69186. * @returns the current Vector3
  69187. */
  69188. Vector3.prototype.toArray = function (array, index) {
  69189. if (index === void 0) { index = 0; }
  69190. array[index] = this.x;
  69191. array[index + 1] = this.y;
  69192. array[index + 2] = this.z;
  69193. return this;
  69194. };
  69195. /**
  69196. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69197. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69198. */
  69199. Vector3.prototype.toQuaternion = function () {
  69200. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69201. };
  69202. /**
  69203. * Adds the given vector to the current Vector3
  69204. * @param otherVector defines the second operand
  69205. * @returns the current updated Vector3
  69206. */
  69207. Vector3.prototype.addInPlace = function (otherVector) {
  69208. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69209. };
  69210. /**
  69211. * Adds the given coordinates to the current Vector3
  69212. * @param x defines the x coordinate of the operand
  69213. * @param y defines the y coordinate of the operand
  69214. * @param z defines the z coordinate of the operand
  69215. * @returns the current updated Vector3
  69216. */
  69217. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69218. this.x += x;
  69219. this.y += y;
  69220. this.z += z;
  69221. return this;
  69222. };
  69223. /**
  69224. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69225. * @param otherVector defines the second operand
  69226. * @returns the resulting Vector3
  69227. */
  69228. Vector3.prototype.add = function (otherVector) {
  69229. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69230. };
  69231. /**
  69232. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69233. * @param otherVector defines the second operand
  69234. * @param result defines the Vector3 object where to store the result
  69235. * @returns the current Vector3
  69236. */
  69237. Vector3.prototype.addToRef = function (otherVector, result) {
  69238. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69239. };
  69240. /**
  69241. * Subtract the given vector from the current Vector3
  69242. * @param otherVector defines the second operand
  69243. * @returns the current updated Vector3
  69244. */
  69245. Vector3.prototype.subtractInPlace = function (otherVector) {
  69246. this.x -= otherVector.x;
  69247. this.y -= otherVector.y;
  69248. this.z -= otherVector.z;
  69249. return this;
  69250. };
  69251. /**
  69252. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69253. * @param otherVector defines the second operand
  69254. * @returns the resulting Vector3
  69255. */
  69256. Vector3.prototype.subtract = function (otherVector) {
  69257. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69258. };
  69259. /**
  69260. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69261. * @param otherVector defines the second operand
  69262. * @param result defines the Vector3 object where to store the result
  69263. * @returns the current Vector3
  69264. */
  69265. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69266. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69267. };
  69268. /**
  69269. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69270. * @param x defines the x coordinate of the operand
  69271. * @param y defines the y coordinate of the operand
  69272. * @param z defines the z coordinate of the operand
  69273. * @returns the resulting Vector3
  69274. */
  69275. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69276. return new Vector3(this.x - x, this.y - y, this.z - z);
  69277. };
  69278. /**
  69279. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69280. * @param x defines the x coordinate of the operand
  69281. * @param y defines the y coordinate of the operand
  69282. * @param z defines the z coordinate of the operand
  69283. * @param result defines the Vector3 object where to store the result
  69284. * @returns the current Vector3
  69285. */
  69286. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69287. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69288. };
  69289. /**
  69290. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69291. * @returns a new Vector3
  69292. */
  69293. Vector3.prototype.negate = function () {
  69294. return new Vector3(-this.x, -this.y, -this.z);
  69295. };
  69296. /**
  69297. * Multiplies the Vector3 coordinates by the float "scale"
  69298. * @param scale defines the multiplier factor
  69299. * @returns the current updated Vector3
  69300. */
  69301. Vector3.prototype.scaleInPlace = function (scale) {
  69302. this.x *= scale;
  69303. this.y *= scale;
  69304. this.z *= scale;
  69305. return this;
  69306. };
  69307. /**
  69308. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69309. * @param scale defines the multiplier factor
  69310. * @returns a new Vector3
  69311. */
  69312. Vector3.prototype.scale = function (scale) {
  69313. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69314. };
  69315. /**
  69316. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69317. * @param scale defines the multiplier factor
  69318. * @param result defines the Vector3 object where to store the result
  69319. * @returns the current Vector3
  69320. */
  69321. Vector3.prototype.scaleToRef = function (scale, result) {
  69322. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69323. };
  69324. /**
  69325. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69326. * @param scale defines the scale factor
  69327. * @param result defines the Vector3 object where to store the result
  69328. * @returns the unmodified current Vector3
  69329. */
  69330. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69331. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69332. };
  69333. /**
  69334. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69335. * @param otherVector defines the second operand
  69336. * @returns true if both vectors are equals
  69337. */
  69338. Vector3.prototype.equals = function (otherVector) {
  69339. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69340. };
  69341. /**
  69342. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69343. * @param otherVector defines the second operand
  69344. * @param epsilon defines the minimal distance to define values as equals
  69345. * @returns true if both vectors are distant less than epsilon
  69346. */
  69347. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69348. if (epsilon === void 0) { epsilon = Epsilon; }
  69349. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon);
  69350. };
  69351. /**
  69352. * Returns true if the current Vector3 coordinates equals the given floats
  69353. * @param x defines the x coordinate of the operand
  69354. * @param y defines the y coordinate of the operand
  69355. * @param z defines the z coordinate of the operand
  69356. * @returns true if both vectors are equals
  69357. */
  69358. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69359. return this.x === x && this.y === y && this.z === z;
  69360. };
  69361. /**
  69362. * Multiplies the current Vector3 coordinates by the given ones
  69363. * @param otherVector defines the second operand
  69364. * @returns the current updated Vector3
  69365. */
  69366. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69367. this.x *= otherVector.x;
  69368. this.y *= otherVector.y;
  69369. this.z *= otherVector.z;
  69370. return this;
  69371. };
  69372. /**
  69373. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69374. * @param otherVector defines the second operand
  69375. * @returns the new Vector3
  69376. */
  69377. Vector3.prototype.multiply = function (otherVector) {
  69378. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69379. };
  69380. /**
  69381. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69382. * @param otherVector defines the second operand
  69383. * @param result defines the Vector3 object where to store the result
  69384. * @returns the current Vector3
  69385. */
  69386. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69387. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69388. };
  69389. /**
  69390. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69391. * @param x defines the x coordinate of the operand
  69392. * @param y defines the y coordinate of the operand
  69393. * @param z defines the z coordinate of the operand
  69394. * @returns the new Vector3
  69395. */
  69396. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69397. return new Vector3(this.x * x, this.y * y, this.z * z);
  69398. };
  69399. /**
  69400. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69401. * @param otherVector defines the second operand
  69402. * @returns the new Vector3
  69403. */
  69404. Vector3.prototype.divide = function (otherVector) {
  69405. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69406. };
  69407. /**
  69408. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69409. * @param otherVector defines the second operand
  69410. * @param result defines the Vector3 object where to store the result
  69411. * @returns the current Vector3
  69412. */
  69413. Vector3.prototype.divideToRef = function (otherVector, result) {
  69414. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69415. };
  69416. /**
  69417. * Divides the current Vector3 coordinates by the given ones.
  69418. * @param otherVector defines the second operand
  69419. * @returns the current updated Vector3
  69420. */
  69421. Vector3.prototype.divideInPlace = function (otherVector) {
  69422. return this.divideToRef(otherVector, this);
  69423. };
  69424. /**
  69425. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69426. * @param other defines the second operand
  69427. * @returns the current updated Vector3
  69428. */
  69429. Vector3.prototype.minimizeInPlace = function (other) {
  69430. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  69431. };
  69432. /**
  69433. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69434. * @param other defines the second operand
  69435. * @returns the current updated Vector3
  69436. */
  69437. Vector3.prototype.maximizeInPlace = function (other) {
  69438. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  69439. };
  69440. /**
  69441. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69442. * @param x defines the x coordinate of the operand
  69443. * @param y defines the y coordinate of the operand
  69444. * @param z defines the z coordinate of the operand
  69445. * @returns the current updated Vector3
  69446. */
  69447. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  69448. if (x < this.x) {
  69449. this.x = x;
  69450. }
  69451. if (y < this.y) {
  69452. this.y = y;
  69453. }
  69454. if (z < this.z) {
  69455. this.z = z;
  69456. }
  69457. return this;
  69458. };
  69459. /**
  69460. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69461. * @param x defines the x coordinate of the operand
  69462. * @param y defines the y coordinate of the operand
  69463. * @param z defines the z coordinate of the operand
  69464. * @returns the current updated Vector3
  69465. */
  69466. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  69467. if (x > this.x) {
  69468. this.x = x;
  69469. }
  69470. if (y > this.y) {
  69471. this.y = y;
  69472. }
  69473. if (z > this.z) {
  69474. this.z = z;
  69475. }
  69476. return this;
  69477. };
  69478. /**
  69479. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69480. * Check if is non uniform within a certain amount of decimal places to account for this
  69481. * @param epsilon the amount the values can differ
  69482. * @returns if the the vector is non uniform to a certain number of decimal places
  69483. */
  69484. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  69485. var absX = Math.abs(this.x);
  69486. var absY = Math.abs(this.y);
  69487. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  69488. return true;
  69489. }
  69490. var absZ = Math.abs(this.z);
  69491. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  69492. return true;
  69493. }
  69494. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  69495. return true;
  69496. }
  69497. return false;
  69498. };
  69499. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  69500. /**
  69501. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69502. */
  69503. get: function () {
  69504. var absX = Math.abs(this.x);
  69505. var absY = Math.abs(this.y);
  69506. if (absX !== absY) {
  69507. return true;
  69508. }
  69509. var absZ = Math.abs(this.z);
  69510. if (absX !== absZ) {
  69511. return true;
  69512. }
  69513. if (absY !== absZ) {
  69514. return true;
  69515. }
  69516. return false;
  69517. },
  69518. enumerable: true,
  69519. configurable: true
  69520. });
  69521. /**
  69522. * Gets a new Vector3 from current Vector3 floored values
  69523. * @returns a new Vector3
  69524. */
  69525. Vector3.prototype.floor = function () {
  69526. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  69527. };
  69528. /**
  69529. * Gets a new Vector3 from current Vector3 floored values
  69530. * @returns a new Vector3
  69531. */
  69532. Vector3.prototype.fract = function () {
  69533. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  69534. };
  69535. // Properties
  69536. /**
  69537. * Gets the length of the Vector3
  69538. * @returns the length of the Vecto3
  69539. */
  69540. Vector3.prototype.length = function () {
  69541. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  69542. };
  69543. /**
  69544. * Gets the squared length of the Vector3
  69545. * @returns squared length of the Vector3
  69546. */
  69547. Vector3.prototype.lengthSquared = function () {
  69548. return (this.x * this.x + this.y * this.y + this.z * this.z);
  69549. };
  69550. /**
  69551. * Normalize the current Vector3.
  69552. * Please note that this is an in place operation.
  69553. * @returns the current updated Vector3
  69554. */
  69555. Vector3.prototype.normalize = function () {
  69556. return this.normalizeFromLength(this.length());
  69557. };
  69558. /**
  69559. * Reorders the x y z properties of the vector in place
  69560. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69561. * @returns the current updated vector
  69562. */
  69563. Vector3.prototype.reorderInPlace = function (order) {
  69564. var _this = this;
  69565. order = order.toLowerCase();
  69566. if (order === "xyz") {
  69567. return this;
  69568. }
  69569. MathTmp.Vector3[0].copyFrom(this);
  69570. ["x", "y", "z"].forEach(function (val, i) {
  69571. _this[val] = MathTmp.Vector3[0][order[i]];
  69572. });
  69573. return this;
  69574. };
  69575. /**
  69576. * Rotates the vector around 0,0,0 by a quaternion
  69577. * @param quaternion the rotation quaternion
  69578. * @param result vector to store the result
  69579. * @returns the resulting vector
  69580. */
  69581. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  69582. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  69583. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69584. return result;
  69585. };
  69586. /**
  69587. * Rotates a vector around a given point
  69588. * @param quaternion the rotation quaternion
  69589. * @param point the point to rotate around
  69590. * @param result vector to store the result
  69591. * @returns the resulting vector
  69592. */
  69593. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69594. this.subtractToRef(point, MathTmp.Vector3[0]);
  69595. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69596. point.addToRef(MathTmp.Vector3[0], result);
  69597. return result;
  69598. };
  69599. /**
  69600. * Normalize the current Vector3 with the given input length.
  69601. * Please note that this is an in place operation.
  69602. * @param len the length of the vector
  69603. * @returns the current updated Vector3
  69604. */
  69605. Vector3.prototype.normalizeFromLength = function (len) {
  69606. if (len === 0 || len === 1.0) {
  69607. return this;
  69608. }
  69609. return this.scaleInPlace(1.0 / len);
  69610. };
  69611. /**
  69612. * Normalize the current Vector3 to a new vector
  69613. * @returns the new Vector3
  69614. */
  69615. Vector3.prototype.normalizeToNew = function () {
  69616. var normalized = new Vector3(0, 0, 0);
  69617. this.normalizeToRef(normalized);
  69618. return normalized;
  69619. };
  69620. /**
  69621. * Normalize the current Vector3 to the reference
  69622. * @param reference define the Vector3 to update
  69623. * @returns the updated Vector3
  69624. */
  69625. Vector3.prototype.normalizeToRef = function (reference) {
  69626. var len = this.length();
  69627. if (len === 0 || len === 1.0) {
  69628. return reference.copyFromFloats(this.x, this.y, this.z);
  69629. }
  69630. return this.scaleToRef(1.0 / len, reference);
  69631. };
  69632. /**
  69633. * Creates a new Vector3 copied from the current Vector3
  69634. * @returns the new Vector3
  69635. */
  69636. Vector3.prototype.clone = function () {
  69637. return new Vector3(this.x, this.y, this.z);
  69638. };
  69639. /**
  69640. * Copies the given vector coordinates to the current Vector3 ones
  69641. * @param source defines the source Vector3
  69642. * @returns the current updated Vector3
  69643. */
  69644. Vector3.prototype.copyFrom = function (source) {
  69645. return this.copyFromFloats(source.x, source.y, source.z);
  69646. };
  69647. /**
  69648. * Copies the given floats to the current Vector3 coordinates
  69649. * @param x defines the x coordinate of the operand
  69650. * @param y defines the y coordinate of the operand
  69651. * @param z defines the z coordinate of the operand
  69652. * @returns the current updated Vector3
  69653. */
  69654. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69655. this.x = x;
  69656. this.y = y;
  69657. this.z = z;
  69658. return this;
  69659. };
  69660. /**
  69661. * Copies the given floats to the current Vector3 coordinates
  69662. * @param x defines the x coordinate of the operand
  69663. * @param y defines the y coordinate of the operand
  69664. * @param z defines the z coordinate of the operand
  69665. * @returns the current updated Vector3
  69666. */
  69667. Vector3.prototype.set = function (x, y, z) {
  69668. return this.copyFromFloats(x, y, z);
  69669. };
  69670. /**
  69671. * Copies the given float to the current Vector3 coordinates
  69672. * @param v defines the x, y and z coordinates of the operand
  69673. * @returns the current updated Vector3
  69674. */
  69675. Vector3.prototype.setAll = function (v) {
  69676. this.x = this.y = this.z = v;
  69677. return this;
  69678. };
  69679. // Statics
  69680. /**
  69681. * Get the clip factor between two vectors
  69682. * @param vector0 defines the first operand
  69683. * @param vector1 defines the second operand
  69684. * @param axis defines the axis to use
  69685. * @param size defines the size along the axis
  69686. * @returns the clip factor
  69687. */
  69688. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69689. var d0 = Vector3.Dot(vector0, axis) - size;
  69690. var d1 = Vector3.Dot(vector1, axis) - size;
  69691. var s = d0 / (d0 - d1);
  69692. return s;
  69693. };
  69694. /**
  69695. * Get angle between two vectors
  69696. * @param vector0 angle between vector0 and vector1
  69697. * @param vector1 angle between vector0 and vector1
  69698. * @param normal direction of the normal
  69699. * @return the angle between vector0 and vector1
  69700. */
  69701. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69702. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69703. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69704. var dot = Vector3.Dot(v0, v1);
  69705. var n = MathTmp.Vector3[3];
  69706. Vector3.CrossToRef(v0, v1, n);
  69707. if (Vector3.Dot(n, normal) > 0) {
  69708. return Math.acos(dot);
  69709. }
  69710. return -Math.acos(dot);
  69711. };
  69712. /**
  69713. * Returns a new Vector3 set from the index "offset" of the given array
  69714. * @param array defines the source array
  69715. * @param offset defines the offset in the source array
  69716. * @returns the new Vector3
  69717. */
  69718. Vector3.FromArray = function (array, offset) {
  69719. if (offset === void 0) { offset = 0; }
  69720. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69721. };
  69722. /**
  69723. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69724. * This function is deprecated. Use FromArray instead
  69725. * @param array defines the source array
  69726. * @param offset defines the offset in the source array
  69727. * @returns the new Vector3
  69728. */
  69729. Vector3.FromFloatArray = function (array, offset) {
  69730. return Vector3.FromArray(array, offset);
  69731. };
  69732. /**
  69733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69734. * @param array defines the source array
  69735. * @param offset defines the offset in the source array
  69736. * @param result defines the Vector3 where to store the result
  69737. */
  69738. Vector3.FromArrayToRef = function (array, offset, result) {
  69739. result.x = array[offset];
  69740. result.y = array[offset + 1];
  69741. result.z = array[offset + 2];
  69742. };
  69743. /**
  69744. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69745. * This function is deprecated. Use FromArrayToRef instead.
  69746. * @param array defines the source array
  69747. * @param offset defines the offset in the source array
  69748. * @param result defines the Vector3 where to store the result
  69749. */
  69750. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69751. return Vector3.FromArrayToRef(array, offset, result);
  69752. };
  69753. /**
  69754. * Sets the given vector "result" with the given floats.
  69755. * @param x defines the x coordinate of the source
  69756. * @param y defines the y coordinate of the source
  69757. * @param z defines the z coordinate of the source
  69758. * @param result defines the Vector3 where to store the result
  69759. */
  69760. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69761. result.copyFromFloats(x, y, z);
  69762. };
  69763. /**
  69764. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69765. * @returns a new empty Vector3
  69766. */
  69767. Vector3.Zero = function () {
  69768. return new Vector3(0.0, 0.0, 0.0);
  69769. };
  69770. /**
  69771. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69772. * @returns a new unit Vector3
  69773. */
  69774. Vector3.One = function () {
  69775. return new Vector3(1.0, 1.0, 1.0);
  69776. };
  69777. /**
  69778. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69779. * @returns a new up Vector3
  69780. */
  69781. Vector3.Up = function () {
  69782. return new Vector3(0.0, 1.0, 0.0);
  69783. };
  69784. Object.defineProperty(Vector3, "UpReadOnly", {
  69785. /**
  69786. * Gets a up Vector3 that must not be updated
  69787. */
  69788. get: function () {
  69789. return Vector3._UpReadOnly;
  69790. },
  69791. enumerable: true,
  69792. configurable: true
  69793. });
  69794. /**
  69795. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69796. * @returns a new down Vector3
  69797. */
  69798. Vector3.Down = function () {
  69799. return new Vector3(0.0, -1.0, 0.0);
  69800. };
  69801. /**
  69802. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69803. * @returns a new forward Vector3
  69804. */
  69805. Vector3.Forward = function () {
  69806. return new Vector3(0.0, 0.0, 1.0);
  69807. };
  69808. /**
  69809. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69810. * @returns a new forward Vector3
  69811. */
  69812. Vector3.Backward = function () {
  69813. return new Vector3(0.0, 0.0, -1.0);
  69814. };
  69815. /**
  69816. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69817. * @returns a new right Vector3
  69818. */
  69819. Vector3.Right = function () {
  69820. return new Vector3(1.0, 0.0, 0.0);
  69821. };
  69822. /**
  69823. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69824. * @returns a new left Vector3
  69825. */
  69826. Vector3.Left = function () {
  69827. return new Vector3(-1.0, 0.0, 0.0);
  69828. };
  69829. /**
  69830. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69831. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69832. * @param vector defines the Vector3 to transform
  69833. * @param transformation defines the transformation matrix
  69834. * @returns the transformed Vector3
  69835. */
  69836. Vector3.TransformCoordinates = function (vector, transformation) {
  69837. var result = Vector3.Zero();
  69838. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69839. return result;
  69840. };
  69841. /**
  69842. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69843. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69844. * @param vector defines the Vector3 to transform
  69845. * @param transformation defines the transformation matrix
  69846. * @param result defines the Vector3 where to store the result
  69847. */
  69848. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69849. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69850. };
  69851. /**
  69852. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69853. * This method computes tranformed coordinates only, not transformed direction vectors
  69854. * @param x define the x coordinate of the source vector
  69855. * @param y define the y coordinate of the source vector
  69856. * @param z define the z coordinate of the source vector
  69857. * @param transformation defines the transformation matrix
  69858. * @param result defines the Vector3 where to store the result
  69859. */
  69860. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69861. var m = transformation.m;
  69862. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69863. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69864. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69865. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69866. result.x = rx * rw;
  69867. result.y = ry * rw;
  69868. result.z = rz * rw;
  69869. };
  69870. /**
  69871. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69872. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69873. * @param vector defines the Vector3 to transform
  69874. * @param transformation defines the transformation matrix
  69875. * @returns the new Vector3
  69876. */
  69877. Vector3.TransformNormal = function (vector, transformation) {
  69878. var result = Vector3.Zero();
  69879. Vector3.TransformNormalToRef(vector, transformation, result);
  69880. return result;
  69881. };
  69882. /**
  69883. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69884. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69885. * @param vector defines the Vector3 to transform
  69886. * @param transformation defines the transformation matrix
  69887. * @param result defines the Vector3 where to store the result
  69888. */
  69889. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  69890. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69891. };
  69892. /**
  69893. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69894. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69895. * @param x define the x coordinate of the source vector
  69896. * @param y define the y coordinate of the source vector
  69897. * @param z define the z coordinate of the source vector
  69898. * @param transformation defines the transformation matrix
  69899. * @param result defines the Vector3 where to store the result
  69900. */
  69901. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  69902. var m = transformation.m;
  69903. result.x = x * m[0] + y * m[4] + z * m[8];
  69904. result.y = x * m[1] + y * m[5] + z * m[9];
  69905. result.z = x * m[2] + y * m[6] + z * m[10];
  69906. };
  69907. /**
  69908. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69909. * @param value1 defines the first control point
  69910. * @param value2 defines the second control point
  69911. * @param value3 defines the third control point
  69912. * @param value4 defines the fourth control point
  69913. * @param amount defines the amount on the spline to use
  69914. * @returns the new Vector3
  69915. */
  69916. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  69917. var squared = amount * amount;
  69918. var cubed = amount * squared;
  69919. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69920. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69921. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69922. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69923. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69924. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69925. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  69926. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  69927. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  69928. return new Vector3(x, y, z);
  69929. };
  69930. /**
  69931. * 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"
  69932. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69933. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69934. * @param value defines the current value
  69935. * @param min defines the lower range value
  69936. * @param max defines the upper range value
  69937. * @returns the new Vector3
  69938. */
  69939. Vector3.Clamp = function (value, min, max) {
  69940. var v = new Vector3();
  69941. Vector3.ClampToRef(value, min, max, v);
  69942. return v;
  69943. };
  69944. /**
  69945. * 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"
  69946. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69947. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69948. * @param value defines the current value
  69949. * @param min defines the lower range value
  69950. * @param max defines the upper range value
  69951. * @param result defines the Vector3 where to store the result
  69952. */
  69953. Vector3.ClampToRef = function (value, min, max, result) {
  69954. var x = value.x;
  69955. x = (x > max.x) ? max.x : x;
  69956. x = (x < min.x) ? min.x : x;
  69957. var y = value.y;
  69958. y = (y > max.y) ? max.y : y;
  69959. y = (y < min.y) ? min.y : y;
  69960. var z = value.z;
  69961. z = (z > max.z) ? max.z : z;
  69962. z = (z < min.z) ? min.z : z;
  69963. result.copyFromFloats(x, y, z);
  69964. };
  69965. /**
  69966. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69967. * @param value1 defines the first control point
  69968. * @param tangent1 defines the first tangent vector
  69969. * @param value2 defines the second control point
  69970. * @param tangent2 defines the second tangent vector
  69971. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69972. * @returns the new Vector3
  69973. */
  69974. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69975. var squared = amount * amount;
  69976. var cubed = amount * squared;
  69977. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69978. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69979. var part3 = (cubed - (2.0 * squared)) + amount;
  69980. var part4 = cubed - squared;
  69981. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69982. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69983. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  69984. return new Vector3(x, y, z);
  69985. };
  69986. /**
  69987. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69988. * @param start defines the start value
  69989. * @param end defines the end value
  69990. * @param amount max defines amount between both (between 0 and 1)
  69991. * @returns the new Vector3
  69992. */
  69993. Vector3.Lerp = function (start, end, amount) {
  69994. var result = new Vector3(0, 0, 0);
  69995. Vector3.LerpToRef(start, end, amount, result);
  69996. return result;
  69997. };
  69998. /**
  69999. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70000. * @param start defines the start value
  70001. * @param end defines the end value
  70002. * @param amount max defines amount between both (between 0 and 1)
  70003. * @param result defines the Vector3 where to store the result
  70004. */
  70005. Vector3.LerpToRef = function (start, end, amount, result) {
  70006. result.x = start.x + ((end.x - start.x) * amount);
  70007. result.y = start.y + ((end.y - start.y) * amount);
  70008. result.z = start.z + ((end.z - start.z) * amount);
  70009. };
  70010. /**
  70011. * Returns the dot product (float) between the vectors "left" and "right"
  70012. * @param left defines the left operand
  70013. * @param right defines the right operand
  70014. * @returns the dot product
  70015. */
  70016. Vector3.Dot = function (left, right) {
  70017. return (left.x * right.x + left.y * right.y + left.z * right.z);
  70018. };
  70019. /**
  70020. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70021. * The cross product is then orthogonal to both "left" and "right"
  70022. * @param left defines the left operand
  70023. * @param right defines the right operand
  70024. * @returns the cross product
  70025. */
  70026. Vector3.Cross = function (left, right) {
  70027. var result = Vector3.Zero();
  70028. Vector3.CrossToRef(left, right, result);
  70029. return result;
  70030. };
  70031. /**
  70032. * Sets the given vector "result" with the cross product of "left" and "right"
  70033. * The cross product is then orthogonal to both "left" and "right"
  70034. * @param left defines the left operand
  70035. * @param right defines the right operand
  70036. * @param result defines the Vector3 where to store the result
  70037. */
  70038. Vector3.CrossToRef = function (left, right, result) {
  70039. var x = left.y * right.z - left.z * right.y;
  70040. var y = left.z * right.x - left.x * right.z;
  70041. var z = left.x * right.y - left.y * right.x;
  70042. result.copyFromFloats(x, y, z);
  70043. };
  70044. /**
  70045. * Returns a new Vector3 as the normalization of the given vector
  70046. * @param vector defines the Vector3 to normalize
  70047. * @returns the new Vector3
  70048. */
  70049. Vector3.Normalize = function (vector) {
  70050. var result = Vector3.Zero();
  70051. Vector3.NormalizeToRef(vector, result);
  70052. return result;
  70053. };
  70054. /**
  70055. * Sets the given vector "result" with the normalization of the given first vector
  70056. * @param vector defines the Vector3 to normalize
  70057. * @param result defines the Vector3 where to store the result
  70058. */
  70059. Vector3.NormalizeToRef = function (vector, result) {
  70060. vector.normalizeToRef(result);
  70061. };
  70062. /**
  70063. * Project a Vector3 onto screen space
  70064. * @param vector defines the Vector3 to project
  70065. * @param world defines the world matrix to use
  70066. * @param transform defines the transform (view x projection) matrix to use
  70067. * @param viewport defines the screen viewport to use
  70068. * @returns the new Vector3
  70069. */
  70070. Vector3.Project = function (vector, world, transform, viewport) {
  70071. var cw = viewport.width;
  70072. var ch = viewport.height;
  70073. var cx = viewport.x;
  70074. var cy = viewport.y;
  70075. var viewportMatrix = MathTmp.Matrix[1];
  70076. 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);
  70077. var matrix = MathTmp.Matrix[0];
  70078. world.multiplyToRef(transform, matrix);
  70079. matrix.multiplyToRef(viewportMatrix, matrix);
  70080. return Vector3.TransformCoordinates(vector, matrix);
  70081. };
  70082. /** @hidden */
  70083. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  70084. Vector3.TransformCoordinatesToRef(source, matrix, result);
  70085. var m = matrix.m;
  70086. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  70087. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  70088. result.scaleInPlace(1.0 / num);
  70089. }
  70090. };
  70091. /**
  70092. * Unproject from screen space to object space
  70093. * @param source defines the screen space Vector3 to use
  70094. * @param viewportWidth defines the current width of the viewport
  70095. * @param viewportHeight defines the current height of the viewport
  70096. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70097. * @param transform defines the transform (view x projection) matrix to use
  70098. * @returns the new Vector3
  70099. */
  70100. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  70101. var matrix = MathTmp.Matrix[0];
  70102. world.multiplyToRef(transform, matrix);
  70103. matrix.invert();
  70104. source.x = source.x / viewportWidth * 2 - 1;
  70105. source.y = -(source.y / viewportHeight * 2 - 1);
  70106. var vector = new Vector3();
  70107. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  70108. return vector;
  70109. };
  70110. /**
  70111. * Unproject from screen space to object space
  70112. * @param source defines the screen space Vector3 to use
  70113. * @param viewportWidth defines the current width of the viewport
  70114. * @param viewportHeight defines the current height of the viewport
  70115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70116. * @param view defines the view matrix to use
  70117. * @param projection defines the projection matrix to use
  70118. * @returns the new Vector3
  70119. */
  70120. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  70121. var result = Vector3.Zero();
  70122. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  70123. return result;
  70124. };
  70125. /**
  70126. * Unproject from screen space to object space
  70127. * @param source defines the screen space Vector3 to use
  70128. * @param viewportWidth defines the current width of the viewport
  70129. * @param viewportHeight defines the current height of the viewport
  70130. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70131. * @param view defines the view matrix to use
  70132. * @param projection defines the projection matrix to use
  70133. * @param result defines the Vector3 where to store the result
  70134. */
  70135. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  70136. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  70137. };
  70138. /**
  70139. * Unproject from screen space to object space
  70140. * @param sourceX defines the screen space x coordinate to use
  70141. * @param sourceY defines the screen space y coordinate to use
  70142. * @param sourceZ defines the screen space z coordinate to use
  70143. * @param viewportWidth defines the current width of the viewport
  70144. * @param viewportHeight defines the current height of the viewport
  70145. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70146. * @param view defines the view matrix to use
  70147. * @param projection defines the projection matrix to use
  70148. * @param result defines the Vector3 where to store the result
  70149. */
  70150. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  70151. var matrix = MathTmp.Matrix[0];
  70152. world.multiplyToRef(view, matrix);
  70153. matrix.multiplyToRef(projection, matrix);
  70154. matrix.invert();
  70155. var screenSource = MathTmp.Vector3[0];
  70156. screenSource.x = sourceX / viewportWidth * 2 - 1;
  70157. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  70158. screenSource.z = 2 * sourceZ - 1.0;
  70159. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  70160. };
  70161. /**
  70162. * Gets the minimal coordinate values between two Vector3
  70163. * @param left defines the first operand
  70164. * @param right defines the second operand
  70165. * @returns the new Vector3
  70166. */
  70167. Vector3.Minimize = function (left, right) {
  70168. var min = left.clone();
  70169. min.minimizeInPlace(right);
  70170. return min;
  70171. };
  70172. /**
  70173. * Gets the maximal coordinate values between two Vector3
  70174. * @param left defines the first operand
  70175. * @param right defines the second operand
  70176. * @returns the new Vector3
  70177. */
  70178. Vector3.Maximize = function (left, right) {
  70179. var max = left.clone();
  70180. max.maximizeInPlace(right);
  70181. return max;
  70182. };
  70183. /**
  70184. * Returns the distance between the vectors "value1" and "value2"
  70185. * @param value1 defines the first operand
  70186. * @param value2 defines the second operand
  70187. * @returns the distance
  70188. */
  70189. Vector3.Distance = function (value1, value2) {
  70190. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70191. };
  70192. /**
  70193. * Returns the squared distance between the vectors "value1" and "value2"
  70194. * @param value1 defines the first operand
  70195. * @param value2 defines the second operand
  70196. * @returns the squared distance
  70197. */
  70198. Vector3.DistanceSquared = function (value1, value2) {
  70199. var x = value1.x - value2.x;
  70200. var y = value1.y - value2.y;
  70201. var z = value1.z - value2.z;
  70202. return (x * x) + (y * y) + (z * z);
  70203. };
  70204. /**
  70205. * Returns a new Vector3 located at the center between "value1" and "value2"
  70206. * @param value1 defines the first operand
  70207. * @param value2 defines the second operand
  70208. * @returns the new Vector3
  70209. */
  70210. Vector3.Center = function (value1, value2) {
  70211. var center = value1.add(value2);
  70212. center.scaleInPlace(0.5);
  70213. return center;
  70214. };
  70215. /**
  70216. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70217. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70218. * to something in order to rotate it from its local system to the given target system
  70219. * Note: axis1, axis2 and axis3 are normalized during this operation
  70220. * @param axis1 defines the first axis
  70221. * @param axis2 defines the second axis
  70222. * @param axis3 defines the third axis
  70223. * @returns a new Vector3
  70224. */
  70225. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70226. var rotation = Vector3.Zero();
  70227. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70228. return rotation;
  70229. };
  70230. /**
  70231. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70232. * @param axis1 defines the first axis
  70233. * @param axis2 defines the second axis
  70234. * @param axis3 defines the third axis
  70235. * @param ref defines the Vector3 where to store the result
  70236. */
  70237. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70238. var quat = MathTmp.Quaternion[0];
  70239. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70240. quat.toEulerAnglesToRef(ref);
  70241. };
  70242. Vector3._UpReadOnly = Vector3.Up();
  70243. return Vector3;
  70244. }());
  70245. /**
  70246. * Vector4 class created for EulerAngle class conversion to Quaternion
  70247. */
  70248. var Vector4 = /** @class */ (function () {
  70249. /**
  70250. * Creates a Vector4 object from the given floats.
  70251. * @param x x value of the vector
  70252. * @param y y value of the vector
  70253. * @param z z value of the vector
  70254. * @param w w value of the vector
  70255. */
  70256. function Vector4(
  70257. /** x value of the vector */
  70258. x,
  70259. /** y value of the vector */
  70260. y,
  70261. /** z value of the vector */
  70262. z,
  70263. /** w value of the vector */
  70264. w) {
  70265. this.x = x;
  70266. this.y = y;
  70267. this.z = z;
  70268. this.w = w;
  70269. }
  70270. /**
  70271. * Returns the string with the Vector4 coordinates.
  70272. * @returns a string containing all the vector values
  70273. */
  70274. Vector4.prototype.toString = function () {
  70275. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70276. };
  70277. /**
  70278. * Returns the string "Vector4".
  70279. * @returns "Vector4"
  70280. */
  70281. Vector4.prototype.getClassName = function () {
  70282. return "Vector4";
  70283. };
  70284. /**
  70285. * Returns the Vector4 hash code.
  70286. * @returns a unique hash code
  70287. */
  70288. Vector4.prototype.getHashCode = function () {
  70289. var hash = this.x || 0;
  70290. hash = (hash * 397) ^ (this.y || 0);
  70291. hash = (hash * 397) ^ (this.z || 0);
  70292. hash = (hash * 397) ^ (this.w || 0);
  70293. return hash;
  70294. };
  70295. // Operators
  70296. /**
  70297. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70298. * @returns the resulting array
  70299. */
  70300. Vector4.prototype.asArray = function () {
  70301. var result = new Array();
  70302. this.toArray(result, 0);
  70303. return result;
  70304. };
  70305. /**
  70306. * Populates the given array from the given index with the Vector4 coordinates.
  70307. * @param array array to populate
  70308. * @param index index of the array to start at (default: 0)
  70309. * @returns the Vector4.
  70310. */
  70311. Vector4.prototype.toArray = function (array, index) {
  70312. if (index === undefined) {
  70313. index = 0;
  70314. }
  70315. array[index] = this.x;
  70316. array[index + 1] = this.y;
  70317. array[index + 2] = this.z;
  70318. array[index + 3] = this.w;
  70319. return this;
  70320. };
  70321. /**
  70322. * Adds the given vector to the current Vector4.
  70323. * @param otherVector the vector to add
  70324. * @returns the updated Vector4.
  70325. */
  70326. Vector4.prototype.addInPlace = function (otherVector) {
  70327. this.x += otherVector.x;
  70328. this.y += otherVector.y;
  70329. this.z += otherVector.z;
  70330. this.w += otherVector.w;
  70331. return this;
  70332. };
  70333. /**
  70334. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70335. * @param otherVector the vector to add
  70336. * @returns the resulting vector
  70337. */
  70338. Vector4.prototype.add = function (otherVector) {
  70339. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70340. };
  70341. /**
  70342. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70343. * @param otherVector the vector to add
  70344. * @param result the vector to store the result
  70345. * @returns the current Vector4.
  70346. */
  70347. Vector4.prototype.addToRef = function (otherVector, result) {
  70348. result.x = this.x + otherVector.x;
  70349. result.y = this.y + otherVector.y;
  70350. result.z = this.z + otherVector.z;
  70351. result.w = this.w + otherVector.w;
  70352. return this;
  70353. };
  70354. /**
  70355. * Subtract in place the given vector from the current Vector4.
  70356. * @param otherVector the vector to subtract
  70357. * @returns the updated Vector4.
  70358. */
  70359. Vector4.prototype.subtractInPlace = function (otherVector) {
  70360. this.x -= otherVector.x;
  70361. this.y -= otherVector.y;
  70362. this.z -= otherVector.z;
  70363. this.w -= otherVector.w;
  70364. return this;
  70365. };
  70366. /**
  70367. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70368. * @param otherVector the vector to add
  70369. * @returns the new vector with the result
  70370. */
  70371. Vector4.prototype.subtract = function (otherVector) {
  70372. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70373. };
  70374. /**
  70375. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70376. * @param otherVector the vector to subtract
  70377. * @param result the vector to store the result
  70378. * @returns the current Vector4.
  70379. */
  70380. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70381. result.x = this.x - otherVector.x;
  70382. result.y = this.y - otherVector.y;
  70383. result.z = this.z - otherVector.z;
  70384. result.w = this.w - otherVector.w;
  70385. return this;
  70386. };
  70387. /**
  70388. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70389. */
  70390. /**
  70391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70392. * @param x value to subtract
  70393. * @param y value to subtract
  70394. * @param z value to subtract
  70395. * @param w value to subtract
  70396. * @returns new vector containing the result
  70397. */
  70398. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70399. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70400. };
  70401. /**
  70402. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70403. * @param x value to subtract
  70404. * @param y value to subtract
  70405. * @param z value to subtract
  70406. * @param w value to subtract
  70407. * @param result the vector to store the result in
  70408. * @returns the current Vector4.
  70409. */
  70410. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70411. result.x = this.x - x;
  70412. result.y = this.y - y;
  70413. result.z = this.z - z;
  70414. result.w = this.w - w;
  70415. return this;
  70416. };
  70417. /**
  70418. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70419. * @returns a new vector with the negated values
  70420. */
  70421. Vector4.prototype.negate = function () {
  70422. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  70423. };
  70424. /**
  70425. * Multiplies the current Vector4 coordinates by scale (float).
  70426. * @param scale the number to scale with
  70427. * @returns the updated Vector4.
  70428. */
  70429. Vector4.prototype.scaleInPlace = function (scale) {
  70430. this.x *= scale;
  70431. this.y *= scale;
  70432. this.z *= scale;
  70433. this.w *= scale;
  70434. return this;
  70435. };
  70436. /**
  70437. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70438. * @param scale the number to scale with
  70439. * @returns a new vector with the result
  70440. */
  70441. Vector4.prototype.scale = function (scale) {
  70442. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  70443. };
  70444. /**
  70445. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70446. * @param scale the number to scale with
  70447. * @param result a vector to store the result in
  70448. * @returns the current Vector4.
  70449. */
  70450. Vector4.prototype.scaleToRef = function (scale, result) {
  70451. result.x = this.x * scale;
  70452. result.y = this.y * scale;
  70453. result.z = this.z * scale;
  70454. result.w = this.w * scale;
  70455. return this;
  70456. };
  70457. /**
  70458. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70459. * @param scale defines the scale factor
  70460. * @param result defines the Vector4 object where to store the result
  70461. * @returns the unmodified current Vector4
  70462. */
  70463. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  70464. result.x += this.x * scale;
  70465. result.y += this.y * scale;
  70466. result.z += this.z * scale;
  70467. result.w += this.w * scale;
  70468. return this;
  70469. };
  70470. /**
  70471. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70472. * @param otherVector the vector to compare against
  70473. * @returns true if they are equal
  70474. */
  70475. Vector4.prototype.equals = function (otherVector) {
  70476. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  70477. };
  70478. /**
  70479. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70480. * @param otherVector vector to compare against
  70481. * @param epsilon (Default: very small number)
  70482. * @returns true if they are equal
  70483. */
  70484. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70485. if (epsilon === void 0) { epsilon = Epsilon; }
  70486. return otherVector
  70487. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  70488. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  70489. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  70490. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  70491. };
  70492. /**
  70493. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70494. * @param x x value to compare against
  70495. * @param y y value to compare against
  70496. * @param z z value to compare against
  70497. * @param w w value to compare against
  70498. * @returns true if equal
  70499. */
  70500. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  70501. return this.x === x && this.y === y && this.z === z && this.w === w;
  70502. };
  70503. /**
  70504. * Multiplies in place the current Vector4 by the given one.
  70505. * @param otherVector vector to multiple with
  70506. * @returns the updated Vector4.
  70507. */
  70508. Vector4.prototype.multiplyInPlace = function (otherVector) {
  70509. this.x *= otherVector.x;
  70510. this.y *= otherVector.y;
  70511. this.z *= otherVector.z;
  70512. this.w *= otherVector.w;
  70513. return this;
  70514. };
  70515. /**
  70516. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70517. * @param otherVector vector to multiple with
  70518. * @returns resulting new vector
  70519. */
  70520. Vector4.prototype.multiply = function (otherVector) {
  70521. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  70522. };
  70523. /**
  70524. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70525. * @param otherVector vector to multiple with
  70526. * @param result vector to store the result
  70527. * @returns the current Vector4.
  70528. */
  70529. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  70530. result.x = this.x * otherVector.x;
  70531. result.y = this.y * otherVector.y;
  70532. result.z = this.z * otherVector.z;
  70533. result.w = this.w * otherVector.w;
  70534. return this;
  70535. };
  70536. /**
  70537. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70538. * @param x x value multiply with
  70539. * @param y y value multiply with
  70540. * @param z z value multiply with
  70541. * @param w w value multiply with
  70542. * @returns resulting new vector
  70543. */
  70544. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  70545. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  70546. };
  70547. /**
  70548. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70549. * @param otherVector vector to devide with
  70550. * @returns resulting new vector
  70551. */
  70552. Vector4.prototype.divide = function (otherVector) {
  70553. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  70554. };
  70555. /**
  70556. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70557. * @param otherVector vector to devide with
  70558. * @param result vector to store the result
  70559. * @returns the current Vector4.
  70560. */
  70561. Vector4.prototype.divideToRef = function (otherVector, result) {
  70562. result.x = this.x / otherVector.x;
  70563. result.y = this.y / otherVector.y;
  70564. result.z = this.z / otherVector.z;
  70565. result.w = this.w / otherVector.w;
  70566. return this;
  70567. };
  70568. /**
  70569. * Divides the current Vector3 coordinates by the given ones.
  70570. * @param otherVector vector to devide with
  70571. * @returns the updated Vector3.
  70572. */
  70573. Vector4.prototype.divideInPlace = function (otherVector) {
  70574. return this.divideToRef(otherVector, this);
  70575. };
  70576. /**
  70577. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70578. * @param other defines the second operand
  70579. * @returns the current updated Vector4
  70580. */
  70581. Vector4.prototype.minimizeInPlace = function (other) {
  70582. if (other.x < this.x) {
  70583. this.x = other.x;
  70584. }
  70585. if (other.y < this.y) {
  70586. this.y = other.y;
  70587. }
  70588. if (other.z < this.z) {
  70589. this.z = other.z;
  70590. }
  70591. if (other.w < this.w) {
  70592. this.w = other.w;
  70593. }
  70594. return this;
  70595. };
  70596. /**
  70597. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70598. * @param other defines the second operand
  70599. * @returns the current updated Vector4
  70600. */
  70601. Vector4.prototype.maximizeInPlace = function (other) {
  70602. if (other.x > this.x) {
  70603. this.x = other.x;
  70604. }
  70605. if (other.y > this.y) {
  70606. this.y = other.y;
  70607. }
  70608. if (other.z > this.z) {
  70609. this.z = other.z;
  70610. }
  70611. if (other.w > this.w) {
  70612. this.w = other.w;
  70613. }
  70614. return this;
  70615. };
  70616. /**
  70617. * Gets a new Vector4 from current Vector4 floored values
  70618. * @returns a new Vector4
  70619. */
  70620. Vector4.prototype.floor = function () {
  70621. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70622. };
  70623. /**
  70624. * Gets a new Vector4 from current Vector3 floored values
  70625. * @returns a new Vector4
  70626. */
  70627. Vector4.prototype.fract = function () {
  70628. 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));
  70629. };
  70630. // Properties
  70631. /**
  70632. * Returns the Vector4 length (float).
  70633. * @returns the length
  70634. */
  70635. Vector4.prototype.length = function () {
  70636. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70637. };
  70638. /**
  70639. * Returns the Vector4 squared length (float).
  70640. * @returns the length squared
  70641. */
  70642. Vector4.prototype.lengthSquared = function () {
  70643. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70644. };
  70645. // Methods
  70646. /**
  70647. * Normalizes in place the Vector4.
  70648. * @returns the updated Vector4.
  70649. */
  70650. Vector4.prototype.normalize = function () {
  70651. var len = this.length();
  70652. if (len === 0) {
  70653. return this;
  70654. }
  70655. return this.scaleInPlace(1.0 / len);
  70656. };
  70657. /**
  70658. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70659. * @returns this converted to a new vector3
  70660. */
  70661. Vector4.prototype.toVector3 = function () {
  70662. return new Vector3(this.x, this.y, this.z);
  70663. };
  70664. /**
  70665. * Returns a new Vector4 copied from the current one.
  70666. * @returns the new cloned vector
  70667. */
  70668. Vector4.prototype.clone = function () {
  70669. return new Vector4(this.x, this.y, this.z, this.w);
  70670. };
  70671. /**
  70672. * Updates the current Vector4 with the given one coordinates.
  70673. * @param source the source vector to copy from
  70674. * @returns the updated Vector4.
  70675. */
  70676. Vector4.prototype.copyFrom = function (source) {
  70677. this.x = source.x;
  70678. this.y = source.y;
  70679. this.z = source.z;
  70680. this.w = source.w;
  70681. return this;
  70682. };
  70683. /**
  70684. * Updates the current Vector4 coordinates with the given floats.
  70685. * @param x float to copy from
  70686. * @param y float to copy from
  70687. * @param z float to copy from
  70688. * @param w float to copy from
  70689. * @returns the updated Vector4.
  70690. */
  70691. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70692. this.x = x;
  70693. this.y = y;
  70694. this.z = z;
  70695. this.w = w;
  70696. return this;
  70697. };
  70698. /**
  70699. * Updates the current Vector4 coordinates with the given floats.
  70700. * @param x float to set from
  70701. * @param y float to set from
  70702. * @param z float to set from
  70703. * @param w float to set from
  70704. * @returns the updated Vector4.
  70705. */
  70706. Vector4.prototype.set = function (x, y, z, w) {
  70707. return this.copyFromFloats(x, y, z, w);
  70708. };
  70709. /**
  70710. * Copies the given float to the current Vector3 coordinates
  70711. * @param v defines the x, y, z and w coordinates of the operand
  70712. * @returns the current updated Vector3
  70713. */
  70714. Vector4.prototype.setAll = function (v) {
  70715. this.x = this.y = this.z = this.w = v;
  70716. return this;
  70717. };
  70718. // Statics
  70719. /**
  70720. * Returns a new Vector4 set from the starting index of the given array.
  70721. * @param array the array to pull values from
  70722. * @param offset the offset into the array to start at
  70723. * @returns the new vector
  70724. */
  70725. Vector4.FromArray = function (array, offset) {
  70726. if (!offset) {
  70727. offset = 0;
  70728. }
  70729. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70730. };
  70731. /**
  70732. * Updates the given vector "result" from the starting index of the given array.
  70733. * @param array the array to pull values from
  70734. * @param offset the offset into the array to start at
  70735. * @param result the vector to store the result in
  70736. */
  70737. Vector4.FromArrayToRef = function (array, offset, result) {
  70738. result.x = array[offset];
  70739. result.y = array[offset + 1];
  70740. result.z = array[offset + 2];
  70741. result.w = array[offset + 3];
  70742. };
  70743. /**
  70744. * Updates the given vector "result" from the starting index of the given Float32Array.
  70745. * @param array the array to pull values from
  70746. * @param offset the offset into the array to start at
  70747. * @param result the vector to store the result in
  70748. */
  70749. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70750. Vector4.FromArrayToRef(array, offset, result);
  70751. };
  70752. /**
  70753. * Updates the given vector "result" coordinates from the given floats.
  70754. * @param x float to set from
  70755. * @param y float to set from
  70756. * @param z float to set from
  70757. * @param w float to set from
  70758. * @param result the vector to the floats in
  70759. */
  70760. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70761. result.x = x;
  70762. result.y = y;
  70763. result.z = z;
  70764. result.w = w;
  70765. };
  70766. /**
  70767. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70768. * @returns the new vector
  70769. */
  70770. Vector4.Zero = function () {
  70771. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70772. };
  70773. /**
  70774. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70775. * @returns the new vector
  70776. */
  70777. Vector4.One = function () {
  70778. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70779. };
  70780. /**
  70781. * Returns a new normalized Vector4 from the given one.
  70782. * @param vector the vector to normalize
  70783. * @returns the vector
  70784. */
  70785. Vector4.Normalize = function (vector) {
  70786. var result = Vector4.Zero();
  70787. Vector4.NormalizeToRef(vector, result);
  70788. return result;
  70789. };
  70790. /**
  70791. * Updates the given vector "result" from the normalization of the given one.
  70792. * @param vector the vector to normalize
  70793. * @param result the vector to store the result in
  70794. */
  70795. Vector4.NormalizeToRef = function (vector, result) {
  70796. result.copyFrom(vector);
  70797. result.normalize();
  70798. };
  70799. /**
  70800. * Returns a vector with the minimum values from the left and right vectors
  70801. * @param left left vector to minimize
  70802. * @param right right vector to minimize
  70803. * @returns a new vector with the minimum of the left and right vector values
  70804. */
  70805. Vector4.Minimize = function (left, right) {
  70806. var min = left.clone();
  70807. min.minimizeInPlace(right);
  70808. return min;
  70809. };
  70810. /**
  70811. * Returns a vector with the maximum values from the left and right vectors
  70812. * @param left left vector to maximize
  70813. * @param right right vector to maximize
  70814. * @returns a new vector with the maximum of the left and right vector values
  70815. */
  70816. Vector4.Maximize = function (left, right) {
  70817. var max = left.clone();
  70818. max.maximizeInPlace(right);
  70819. return max;
  70820. };
  70821. /**
  70822. * Returns the distance (float) between the vectors "value1" and "value2".
  70823. * @param value1 value to calulate the distance between
  70824. * @param value2 value to calulate the distance between
  70825. * @return the distance between the two vectors
  70826. */
  70827. Vector4.Distance = function (value1, value2) {
  70828. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70829. };
  70830. /**
  70831. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70832. * @param value1 value to calulate the distance between
  70833. * @param value2 value to calulate the distance between
  70834. * @return the distance between the two vectors squared
  70835. */
  70836. Vector4.DistanceSquared = function (value1, value2) {
  70837. var x = value1.x - value2.x;
  70838. var y = value1.y - value2.y;
  70839. var z = value1.z - value2.z;
  70840. var w = value1.w - value2.w;
  70841. return (x * x) + (y * y) + (z * z) + (w * w);
  70842. };
  70843. /**
  70844. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70845. * @param value1 value to calulate the center between
  70846. * @param value2 value to calulate the center between
  70847. * @return the center between the two vectors
  70848. */
  70849. Vector4.Center = function (value1, value2) {
  70850. var center = value1.add(value2);
  70851. center.scaleInPlace(0.5);
  70852. return center;
  70853. };
  70854. /**
  70855. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70856. * This methods computes transformed normalized direction vectors only.
  70857. * @param vector the vector to transform
  70858. * @param transformation the transformation matrix to apply
  70859. * @returns the new vector
  70860. */
  70861. Vector4.TransformNormal = function (vector, transformation) {
  70862. var result = Vector4.Zero();
  70863. Vector4.TransformNormalToRef(vector, transformation, result);
  70864. return result;
  70865. };
  70866. /**
  70867. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70868. * This methods computes transformed normalized direction vectors only.
  70869. * @param vector the vector to transform
  70870. * @param transformation the transformation matrix to apply
  70871. * @param result the vector to store the result in
  70872. */
  70873. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70874. var m = transformation.m;
  70875. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70876. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70877. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70878. result.x = x;
  70879. result.y = y;
  70880. result.z = z;
  70881. result.w = vector.w;
  70882. };
  70883. /**
  70884. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70885. * This methods computes transformed normalized direction vectors only.
  70886. * @param x value to transform
  70887. * @param y value to transform
  70888. * @param z value to transform
  70889. * @param w value to transform
  70890. * @param transformation the transformation matrix to apply
  70891. * @param result the vector to store the results in
  70892. */
  70893. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  70894. var m = transformation.m;
  70895. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  70896. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  70897. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  70898. result.w = w;
  70899. };
  70900. /**
  70901. * Creates a new Vector4 from a Vector3
  70902. * @param source defines the source data
  70903. * @param w defines the 4th component (default is 0)
  70904. * @returns a new Vector4
  70905. */
  70906. Vector4.FromVector3 = function (source, w) {
  70907. if (w === void 0) { w = 0; }
  70908. return new Vector4(source.x, source.y, source.z, w);
  70909. };
  70910. return Vector4;
  70911. }());
  70912. /**
  70913. * Size containing widht and height
  70914. */
  70915. var Size = /** @class */ (function () {
  70916. /**
  70917. * Creates a Size object from the given width and height (floats).
  70918. * @param width width of the new size
  70919. * @param height height of the new size
  70920. */
  70921. function Size(width, height) {
  70922. this.width = width;
  70923. this.height = height;
  70924. }
  70925. /**
  70926. * Returns a string with the Size width and height
  70927. * @returns a string with the Size width and height
  70928. */
  70929. Size.prototype.toString = function () {
  70930. return "{W: " + this.width + ", H: " + this.height + "}";
  70931. };
  70932. /**
  70933. * "Size"
  70934. * @returns the string "Size"
  70935. */
  70936. Size.prototype.getClassName = function () {
  70937. return "Size";
  70938. };
  70939. /**
  70940. * Returns the Size hash code.
  70941. * @returns a hash code for a unique width and height
  70942. */
  70943. Size.prototype.getHashCode = function () {
  70944. var hash = this.width || 0;
  70945. hash = (hash * 397) ^ (this.height || 0);
  70946. return hash;
  70947. };
  70948. /**
  70949. * Updates the current size from the given one.
  70950. * @param src the given size
  70951. */
  70952. Size.prototype.copyFrom = function (src) {
  70953. this.width = src.width;
  70954. this.height = src.height;
  70955. };
  70956. /**
  70957. * Updates in place the current Size from the given floats.
  70958. * @param width width of the new size
  70959. * @param height height of the new size
  70960. * @returns the updated Size.
  70961. */
  70962. Size.prototype.copyFromFloats = function (width, height) {
  70963. this.width = width;
  70964. this.height = height;
  70965. return this;
  70966. };
  70967. /**
  70968. * Updates in place the current Size from the given floats.
  70969. * @param width width to set
  70970. * @param height height to set
  70971. * @returns the updated Size.
  70972. */
  70973. Size.prototype.set = function (width, height) {
  70974. return this.copyFromFloats(width, height);
  70975. };
  70976. /**
  70977. * Multiplies the width and height by numbers
  70978. * @param w factor to multiple the width by
  70979. * @param h factor to multiple the height by
  70980. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  70981. */
  70982. Size.prototype.multiplyByFloats = function (w, h) {
  70983. return new Size(this.width * w, this.height * h);
  70984. };
  70985. /**
  70986. * Clones the size
  70987. * @returns a new Size copied from the given one.
  70988. */
  70989. Size.prototype.clone = function () {
  70990. return new Size(this.width, this.height);
  70991. };
  70992. /**
  70993. * True if the current Size and the given one width and height are strictly equal.
  70994. * @param other the other size to compare against
  70995. * @returns True if the current Size and the given one width and height are strictly equal.
  70996. */
  70997. Size.prototype.equals = function (other) {
  70998. if (!other) {
  70999. return false;
  71000. }
  71001. return (this.width === other.width) && (this.height === other.height);
  71002. };
  71003. Object.defineProperty(Size.prototype, "surface", {
  71004. /**
  71005. * The surface of the Size : width * height (float).
  71006. */
  71007. get: function () {
  71008. return this.width * this.height;
  71009. },
  71010. enumerable: true,
  71011. configurable: true
  71012. });
  71013. /**
  71014. * Create a new size of zero
  71015. * @returns a new Size set to (0.0, 0.0)
  71016. */
  71017. Size.Zero = function () {
  71018. return new Size(0.0, 0.0);
  71019. };
  71020. /**
  71021. * Sums the width and height of two sizes
  71022. * @param otherSize size to add to this size
  71023. * @returns a new Size set as the addition result of the current Size and the given one.
  71024. */
  71025. Size.prototype.add = function (otherSize) {
  71026. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  71027. return r;
  71028. };
  71029. /**
  71030. * Subtracts the width and height of two
  71031. * @param otherSize size to subtract to this size
  71032. * @returns a new Size set as the subtraction result of the given one from the current Size.
  71033. */
  71034. Size.prototype.subtract = function (otherSize) {
  71035. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  71036. return r;
  71037. };
  71038. /**
  71039. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  71040. * @param start starting size to lerp between
  71041. * @param end end size to lerp between
  71042. * @param amount amount to lerp between the start and end values
  71043. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  71044. */
  71045. Size.Lerp = function (start, end, amount) {
  71046. var w = start.width + ((end.width - start.width) * amount);
  71047. var h = start.height + ((end.height - start.height) * amount);
  71048. return new Size(w, h);
  71049. };
  71050. return Size;
  71051. }());
  71052. /**
  71053. * Class used to store quaternion data
  71054. * @see https://en.wikipedia.org/wiki/Quaternion
  71055. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71056. */
  71057. var Quaternion = /** @class */ (function () {
  71058. /**
  71059. * Creates a new Quaternion from the given floats
  71060. * @param x defines the first component (0 by default)
  71061. * @param y defines the second component (0 by default)
  71062. * @param z defines the third component (0 by default)
  71063. * @param w defines the fourth component (1.0 by default)
  71064. */
  71065. function Quaternion(
  71066. /** defines the first component (0 by default) */
  71067. x,
  71068. /** defines the second component (0 by default) */
  71069. y,
  71070. /** defines the third component (0 by default) */
  71071. z,
  71072. /** defines the fourth component (1.0 by default) */
  71073. w) {
  71074. if (x === void 0) { x = 0.0; }
  71075. if (y === void 0) { y = 0.0; }
  71076. if (z === void 0) { z = 0.0; }
  71077. if (w === void 0) { w = 1.0; }
  71078. this.x = x;
  71079. this.y = y;
  71080. this.z = z;
  71081. this.w = w;
  71082. }
  71083. /**
  71084. * Gets a string representation for the current quaternion
  71085. * @returns a string with the Quaternion coordinates
  71086. */
  71087. Quaternion.prototype.toString = function () {
  71088. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71089. };
  71090. /**
  71091. * Gets the class name of the quaternion
  71092. * @returns the string "Quaternion"
  71093. */
  71094. Quaternion.prototype.getClassName = function () {
  71095. return "Quaternion";
  71096. };
  71097. /**
  71098. * Gets a hash code for this quaternion
  71099. * @returns the quaternion hash code
  71100. */
  71101. Quaternion.prototype.getHashCode = function () {
  71102. var hash = this.x || 0;
  71103. hash = (hash * 397) ^ (this.y || 0);
  71104. hash = (hash * 397) ^ (this.z || 0);
  71105. hash = (hash * 397) ^ (this.w || 0);
  71106. return hash;
  71107. };
  71108. /**
  71109. * Copy the quaternion to an array
  71110. * @returns a new array populated with 4 elements from the quaternion coordinates
  71111. */
  71112. Quaternion.prototype.asArray = function () {
  71113. return [this.x, this.y, this.z, this.w];
  71114. };
  71115. /**
  71116. * Check if two quaternions are equals
  71117. * @param otherQuaternion defines the second operand
  71118. * @return true if the current quaternion and the given one coordinates are strictly equals
  71119. */
  71120. Quaternion.prototype.equals = function (otherQuaternion) {
  71121. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  71122. };
  71123. /**
  71124. * Clone the current quaternion
  71125. * @returns a new quaternion copied from the current one
  71126. */
  71127. Quaternion.prototype.clone = function () {
  71128. return new Quaternion(this.x, this.y, this.z, this.w);
  71129. };
  71130. /**
  71131. * Copy a quaternion to the current one
  71132. * @param other defines the other quaternion
  71133. * @returns the updated current quaternion
  71134. */
  71135. Quaternion.prototype.copyFrom = function (other) {
  71136. this.x = other.x;
  71137. this.y = other.y;
  71138. this.z = other.z;
  71139. this.w = other.w;
  71140. return this;
  71141. };
  71142. /**
  71143. * Updates the current quaternion with the given float coordinates
  71144. * @param x defines the x coordinate
  71145. * @param y defines the y coordinate
  71146. * @param z defines the z coordinate
  71147. * @param w defines the w coordinate
  71148. * @returns the updated current quaternion
  71149. */
  71150. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  71151. this.x = x;
  71152. this.y = y;
  71153. this.z = z;
  71154. this.w = w;
  71155. return this;
  71156. };
  71157. /**
  71158. * Updates the current quaternion from the given float coordinates
  71159. * @param x defines the x coordinate
  71160. * @param y defines the y coordinate
  71161. * @param z defines the z coordinate
  71162. * @param w defines the w coordinate
  71163. * @returns the updated current quaternion
  71164. */
  71165. Quaternion.prototype.set = function (x, y, z, w) {
  71166. return this.copyFromFloats(x, y, z, w);
  71167. };
  71168. /**
  71169. * Adds two quaternions
  71170. * @param other defines the second operand
  71171. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71172. */
  71173. Quaternion.prototype.add = function (other) {
  71174. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  71175. };
  71176. /**
  71177. * Add a quaternion to the current one
  71178. * @param other defines the quaternion to add
  71179. * @returns the current quaternion
  71180. */
  71181. Quaternion.prototype.addInPlace = function (other) {
  71182. this.x += other.x;
  71183. this.y += other.y;
  71184. this.z += other.z;
  71185. this.w += other.w;
  71186. return this;
  71187. };
  71188. /**
  71189. * Subtract two quaternions
  71190. * @param other defines the second operand
  71191. * @returns a new quaternion as the subtraction result of the given one from the current one
  71192. */
  71193. Quaternion.prototype.subtract = function (other) {
  71194. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71195. };
  71196. /**
  71197. * Multiplies the current quaternion by a scale factor
  71198. * @param value defines the scale factor
  71199. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71200. */
  71201. Quaternion.prototype.scale = function (value) {
  71202. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71203. };
  71204. /**
  71205. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71206. * @param scale defines the scale factor
  71207. * @param result defines the Quaternion object where to store the result
  71208. * @returns the unmodified current quaternion
  71209. */
  71210. Quaternion.prototype.scaleToRef = function (scale, result) {
  71211. result.x = this.x * scale;
  71212. result.y = this.y * scale;
  71213. result.z = this.z * scale;
  71214. result.w = this.w * scale;
  71215. return this;
  71216. };
  71217. /**
  71218. * Multiplies in place the current quaternion by a scale factor
  71219. * @param value defines the scale factor
  71220. * @returns the current modified quaternion
  71221. */
  71222. Quaternion.prototype.scaleInPlace = function (value) {
  71223. this.x *= value;
  71224. this.y *= value;
  71225. this.z *= value;
  71226. this.w *= value;
  71227. return this;
  71228. };
  71229. /**
  71230. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71231. * @param scale defines the scale factor
  71232. * @param result defines the Quaternion object where to store the result
  71233. * @returns the unmodified current quaternion
  71234. */
  71235. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71236. result.x += this.x * scale;
  71237. result.y += this.y * scale;
  71238. result.z += this.z * scale;
  71239. result.w += this.w * scale;
  71240. return this;
  71241. };
  71242. /**
  71243. * Multiplies two quaternions
  71244. * @param q1 defines the second operand
  71245. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71246. */
  71247. Quaternion.prototype.multiply = function (q1) {
  71248. var result = new Quaternion(0, 0, 0, 1.0);
  71249. this.multiplyToRef(q1, result);
  71250. return result;
  71251. };
  71252. /**
  71253. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71254. * @param q1 defines the second operand
  71255. * @param result defines the target quaternion
  71256. * @returns the current quaternion
  71257. */
  71258. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71259. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71260. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71261. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71262. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71263. result.copyFromFloats(x, y, z, w);
  71264. return this;
  71265. };
  71266. /**
  71267. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71268. * @param q1 defines the second operand
  71269. * @returns the currentupdated quaternion
  71270. */
  71271. Quaternion.prototype.multiplyInPlace = function (q1) {
  71272. this.multiplyToRef(q1, this);
  71273. return this;
  71274. };
  71275. /**
  71276. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71277. * @param ref defines the target quaternion
  71278. * @returns the current quaternion
  71279. */
  71280. Quaternion.prototype.conjugateToRef = function (ref) {
  71281. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71282. return this;
  71283. };
  71284. /**
  71285. * Conjugates in place (1-q) the current quaternion
  71286. * @returns the current updated quaternion
  71287. */
  71288. Quaternion.prototype.conjugateInPlace = function () {
  71289. this.x *= -1;
  71290. this.y *= -1;
  71291. this.z *= -1;
  71292. return this;
  71293. };
  71294. /**
  71295. * Conjugates in place (1-q) the current quaternion
  71296. * @returns a new quaternion
  71297. */
  71298. Quaternion.prototype.conjugate = function () {
  71299. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71300. return result;
  71301. };
  71302. /**
  71303. * Gets length of current quaternion
  71304. * @returns the quaternion length (float)
  71305. */
  71306. Quaternion.prototype.length = function () {
  71307. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71308. };
  71309. /**
  71310. * Normalize in place the current quaternion
  71311. * @returns the current updated quaternion
  71312. */
  71313. Quaternion.prototype.normalize = function () {
  71314. var length = 1.0 / this.length();
  71315. this.x *= length;
  71316. this.y *= length;
  71317. this.z *= length;
  71318. this.w *= length;
  71319. return this;
  71320. };
  71321. /**
  71322. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71323. * @param order is a reserved parameter and is ignore for now
  71324. * @returns a new Vector3 containing the Euler angles
  71325. */
  71326. Quaternion.prototype.toEulerAngles = function (order) {
  71327. if (order === void 0) { order = "YZX"; }
  71328. var result = Vector3.Zero();
  71329. this.toEulerAnglesToRef(result);
  71330. return result;
  71331. };
  71332. /**
  71333. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71334. * @param result defines the vector which will be filled with the Euler angles
  71335. * @param order is a reserved parameter and is ignore for now
  71336. * @returns the current unchanged quaternion
  71337. */
  71338. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71339. var qz = this.z;
  71340. var qx = this.x;
  71341. var qy = this.y;
  71342. var qw = this.w;
  71343. var sqw = qw * qw;
  71344. var sqz = qz * qz;
  71345. var sqx = qx * qx;
  71346. var sqy = qy * qy;
  71347. var zAxisY = qy * qz - qx * qw;
  71348. var limit = .4999999;
  71349. if (zAxisY < -limit) {
  71350. result.y = 2 * Math.atan2(qy, qw);
  71351. result.x = Math.PI / 2;
  71352. result.z = 0;
  71353. }
  71354. else if (zAxisY > limit) {
  71355. result.y = 2 * Math.atan2(qy, qw);
  71356. result.x = -Math.PI / 2;
  71357. result.z = 0;
  71358. }
  71359. else {
  71360. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71361. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71362. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71363. }
  71364. return this;
  71365. };
  71366. /**
  71367. * Updates the given rotation matrix with the current quaternion values
  71368. * @param result defines the target matrix
  71369. * @returns the current unchanged quaternion
  71370. */
  71371. Quaternion.prototype.toRotationMatrix = function (result) {
  71372. Matrix.FromQuaternionToRef(this, result);
  71373. return this;
  71374. };
  71375. /**
  71376. * Updates the current quaternion from the given rotation matrix values
  71377. * @param matrix defines the source matrix
  71378. * @returns the current updated quaternion
  71379. */
  71380. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71381. Quaternion.FromRotationMatrixToRef(matrix, this);
  71382. return this;
  71383. };
  71384. // Statics
  71385. /**
  71386. * Creates a new quaternion from a rotation matrix
  71387. * @param matrix defines the source matrix
  71388. * @returns a new quaternion created from the given rotation matrix values
  71389. */
  71390. Quaternion.FromRotationMatrix = function (matrix) {
  71391. var result = new Quaternion();
  71392. Quaternion.FromRotationMatrixToRef(matrix, result);
  71393. return result;
  71394. };
  71395. /**
  71396. * Updates the given quaternion with the given rotation matrix values
  71397. * @param matrix defines the source matrix
  71398. * @param result defines the target quaternion
  71399. */
  71400. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71401. var data = matrix.m;
  71402. var m11 = data[0], m12 = data[4], m13 = data[8];
  71403. var m21 = data[1], m22 = data[5], m23 = data[9];
  71404. var m31 = data[2], m32 = data[6], m33 = data[10];
  71405. var trace = m11 + m22 + m33;
  71406. var s;
  71407. if (trace > 0) {
  71408. s = 0.5 / Math.sqrt(trace + 1.0);
  71409. result.w = 0.25 / s;
  71410. result.x = (m32 - m23) * s;
  71411. result.y = (m13 - m31) * s;
  71412. result.z = (m21 - m12) * s;
  71413. }
  71414. else if (m11 > m22 && m11 > m33) {
  71415. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71416. result.w = (m32 - m23) / s;
  71417. result.x = 0.25 * s;
  71418. result.y = (m12 + m21) / s;
  71419. result.z = (m13 + m31) / s;
  71420. }
  71421. else if (m22 > m33) {
  71422. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  71423. result.w = (m13 - m31) / s;
  71424. result.x = (m12 + m21) / s;
  71425. result.y = 0.25 * s;
  71426. result.z = (m23 + m32) / s;
  71427. }
  71428. else {
  71429. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  71430. result.w = (m21 - m12) / s;
  71431. result.x = (m13 + m31) / s;
  71432. result.y = (m23 + m32) / s;
  71433. result.z = 0.25 * s;
  71434. }
  71435. };
  71436. /**
  71437. * Returns the dot product (float) between the quaternions "left" and "right"
  71438. * @param left defines the left operand
  71439. * @param right defines the right operand
  71440. * @returns the dot product
  71441. */
  71442. Quaternion.Dot = function (left, right) {
  71443. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  71444. };
  71445. /**
  71446. * Checks if the two quaternions are close to each other
  71447. * @param quat0 defines the first quaternion to check
  71448. * @param quat1 defines the second quaternion to check
  71449. * @returns true if the two quaternions are close to each other
  71450. */
  71451. Quaternion.AreClose = function (quat0, quat1) {
  71452. var dot = Quaternion.Dot(quat0, quat1);
  71453. return dot >= 0;
  71454. };
  71455. /**
  71456. * Creates an empty quaternion
  71457. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71458. */
  71459. Quaternion.Zero = function () {
  71460. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  71461. };
  71462. /**
  71463. * Inverse a given quaternion
  71464. * @param q defines the source quaternion
  71465. * @returns a new quaternion as the inverted current quaternion
  71466. */
  71467. Quaternion.Inverse = function (q) {
  71468. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  71469. };
  71470. /**
  71471. * Inverse a given quaternion
  71472. * @param q defines the source quaternion
  71473. * @param result the quaternion the result will be stored in
  71474. * @returns the result quaternion
  71475. */
  71476. Quaternion.InverseToRef = function (q, result) {
  71477. result.set(-q.x, -q.y, -q.z, q.w);
  71478. return result;
  71479. };
  71480. /**
  71481. * Creates an identity quaternion
  71482. * @returns the identity quaternion
  71483. */
  71484. Quaternion.Identity = function () {
  71485. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  71486. };
  71487. /**
  71488. * Gets a boolean indicating if the given quaternion is identity
  71489. * @param quaternion defines the quaternion to check
  71490. * @returns true if the quaternion is identity
  71491. */
  71492. Quaternion.IsIdentity = function (quaternion) {
  71493. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  71494. };
  71495. /**
  71496. * Creates a quaternion from a rotation around an axis
  71497. * @param axis defines the axis to use
  71498. * @param angle defines the angle to use
  71499. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71500. */
  71501. Quaternion.RotationAxis = function (axis, angle) {
  71502. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  71503. };
  71504. /**
  71505. * Creates a rotation around an axis and stores it into the given quaternion
  71506. * @param axis defines the axis to use
  71507. * @param angle defines the angle to use
  71508. * @param result defines the target quaternion
  71509. * @returns the target quaternion
  71510. */
  71511. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  71512. var sin = Math.sin(angle / 2);
  71513. axis.normalize();
  71514. result.w = Math.cos(angle / 2);
  71515. result.x = axis.x * sin;
  71516. result.y = axis.y * sin;
  71517. result.z = axis.z * sin;
  71518. return result;
  71519. };
  71520. /**
  71521. * Creates a new quaternion from data stored into an array
  71522. * @param array defines the data source
  71523. * @param offset defines the offset in the source array where the data starts
  71524. * @returns a new quaternion
  71525. */
  71526. Quaternion.FromArray = function (array, offset) {
  71527. if (!offset) {
  71528. offset = 0;
  71529. }
  71530. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71531. };
  71532. /**
  71533. * Create a quaternion from Euler rotation angles
  71534. * @param x Pitch
  71535. * @param y Yaw
  71536. * @param z Roll
  71537. * @returns the new Quaternion
  71538. */
  71539. Quaternion.FromEulerAngles = function (x, y, z) {
  71540. var q = new Quaternion();
  71541. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  71542. return q;
  71543. };
  71544. /**
  71545. * Updates a quaternion from Euler rotation angles
  71546. * @param x Pitch
  71547. * @param y Yaw
  71548. * @param z Roll
  71549. * @param result the quaternion to store the result
  71550. * @returns the updated quaternion
  71551. */
  71552. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  71553. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  71554. return result;
  71555. };
  71556. /**
  71557. * Create a quaternion from Euler rotation vector
  71558. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71559. * @returns the new Quaternion
  71560. */
  71561. Quaternion.FromEulerVector = function (vec) {
  71562. var q = new Quaternion();
  71563. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  71564. return q;
  71565. };
  71566. /**
  71567. * Updates a quaternion from Euler rotation vector
  71568. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71569. * @param result the quaternion to store the result
  71570. * @returns the updated quaternion
  71571. */
  71572. Quaternion.FromEulerVectorToRef = function (vec, result) {
  71573. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  71574. return result;
  71575. };
  71576. /**
  71577. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71578. * @param yaw defines the rotation around Y axis
  71579. * @param pitch defines the rotation around X axis
  71580. * @param roll defines the rotation around Z axis
  71581. * @returns the new quaternion
  71582. */
  71583. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71584. var q = new Quaternion();
  71585. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71586. return q;
  71587. };
  71588. /**
  71589. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71590. * @param yaw defines the rotation around Y axis
  71591. * @param pitch defines the rotation around X axis
  71592. * @param roll defines the rotation around Z axis
  71593. * @param result defines the target quaternion
  71594. */
  71595. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71596. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71597. var halfRoll = roll * 0.5;
  71598. var halfPitch = pitch * 0.5;
  71599. var halfYaw = yaw * 0.5;
  71600. var sinRoll = Math.sin(halfRoll);
  71601. var cosRoll = Math.cos(halfRoll);
  71602. var sinPitch = Math.sin(halfPitch);
  71603. var cosPitch = Math.cos(halfPitch);
  71604. var sinYaw = Math.sin(halfYaw);
  71605. var cosYaw = Math.cos(halfYaw);
  71606. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71607. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71608. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71609. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71610. };
  71611. /**
  71612. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71613. * @param alpha defines the rotation around first axis
  71614. * @param beta defines the rotation around second axis
  71615. * @param gamma defines the rotation around third axis
  71616. * @returns the new quaternion
  71617. */
  71618. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71619. var result = new Quaternion();
  71620. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71621. return result;
  71622. };
  71623. /**
  71624. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71625. * @param alpha defines the rotation around first axis
  71626. * @param beta defines the rotation around second axis
  71627. * @param gamma defines the rotation around third axis
  71628. * @param result defines the target quaternion
  71629. */
  71630. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71631. // Produces a quaternion from Euler angles in the z-x-z orientation
  71632. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71633. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71634. var halfBeta = beta * 0.5;
  71635. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71636. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71637. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71638. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71639. };
  71640. /**
  71641. * 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)
  71642. * @param axis1 defines the first axis
  71643. * @param axis2 defines the second axis
  71644. * @param axis3 defines the third axis
  71645. * @returns the new quaternion
  71646. */
  71647. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71648. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71649. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71650. return quat;
  71651. };
  71652. /**
  71653. * 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
  71654. * @param axis1 defines the first axis
  71655. * @param axis2 defines the second axis
  71656. * @param axis3 defines the third axis
  71657. * @param ref defines the target quaternion
  71658. */
  71659. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71660. var rotMat = MathTmp.Matrix[0];
  71661. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71662. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71663. };
  71664. /**
  71665. * Interpolates between two quaternions
  71666. * @param left defines first quaternion
  71667. * @param right defines second quaternion
  71668. * @param amount defines the gradient to use
  71669. * @returns the new interpolated quaternion
  71670. */
  71671. Quaternion.Slerp = function (left, right, amount) {
  71672. var result = Quaternion.Identity();
  71673. Quaternion.SlerpToRef(left, right, amount, result);
  71674. return result;
  71675. };
  71676. /**
  71677. * Interpolates between two quaternions and stores it into a target quaternion
  71678. * @param left defines first quaternion
  71679. * @param right defines second quaternion
  71680. * @param amount defines the gradient to use
  71681. * @param result defines the target quaternion
  71682. */
  71683. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71684. var num2;
  71685. var num3;
  71686. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71687. var flag = false;
  71688. if (num4 < 0) {
  71689. flag = true;
  71690. num4 = -num4;
  71691. }
  71692. if (num4 > 0.999999) {
  71693. num3 = 1 - amount;
  71694. num2 = flag ? -amount : amount;
  71695. }
  71696. else {
  71697. var num5 = Math.acos(num4);
  71698. var num6 = (1.0 / Math.sin(num5));
  71699. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71700. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71701. }
  71702. result.x = (num3 * left.x) + (num2 * right.x);
  71703. result.y = (num3 * left.y) + (num2 * right.y);
  71704. result.z = (num3 * left.z) + (num2 * right.z);
  71705. result.w = (num3 * left.w) + (num2 * right.w);
  71706. };
  71707. /**
  71708. * Interpolate between two quaternions using Hermite interpolation
  71709. * @param value1 defines first quaternion
  71710. * @param tangent1 defines the incoming tangent
  71711. * @param value2 defines second quaternion
  71712. * @param tangent2 defines the outgoing tangent
  71713. * @param amount defines the target quaternion
  71714. * @returns the new interpolated quaternion
  71715. */
  71716. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71717. var squared = amount * amount;
  71718. var cubed = amount * squared;
  71719. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71720. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71721. var part3 = (cubed - (2.0 * squared)) + amount;
  71722. var part4 = cubed - squared;
  71723. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71724. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71725. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71726. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71727. return new Quaternion(x, y, z, w);
  71728. };
  71729. return Quaternion;
  71730. }());
  71731. /**
  71732. * Class used to store matrix data (4x4)
  71733. */
  71734. var Matrix = /** @class */ (function () {
  71735. /**
  71736. * Creates an empty matrix (filled with zeros)
  71737. */
  71738. function Matrix() {
  71739. this._isIdentity = false;
  71740. this._isIdentityDirty = true;
  71741. this._isIdentity3x2 = true;
  71742. this._isIdentity3x2Dirty = true;
  71743. this._m = new Float32Array(16);
  71744. this._updateIdentityStatus(false);
  71745. }
  71746. Object.defineProperty(Matrix.prototype, "m", {
  71747. /**
  71748. * Gets the internal data of the matrix
  71749. */
  71750. get: function () { return this._m; },
  71751. enumerable: true,
  71752. configurable: true
  71753. });
  71754. /** @hidden */
  71755. Matrix.prototype._markAsUpdated = function () {
  71756. this.updateFlag = Matrix._updateFlagSeed++;
  71757. this._isIdentity = false;
  71758. this._isIdentity3x2 = false;
  71759. this._isIdentityDirty = true;
  71760. this._isIdentity3x2Dirty = true;
  71761. };
  71762. /** @hidden */
  71763. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71764. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71765. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71766. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71767. this.updateFlag = Matrix._updateFlagSeed++;
  71768. this._isIdentity = isIdentity;
  71769. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71770. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71771. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71772. };
  71773. // Properties
  71774. /**
  71775. * Check if the current matrix is identity
  71776. * @returns true is the matrix is the identity matrix
  71777. */
  71778. Matrix.prototype.isIdentity = function () {
  71779. if (this._isIdentityDirty) {
  71780. this._isIdentityDirty = false;
  71781. var m = this._m;
  71782. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71783. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71784. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71785. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71786. }
  71787. return this._isIdentity;
  71788. };
  71789. /**
  71790. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71791. * @returns true is the matrix is the identity matrix
  71792. */
  71793. Matrix.prototype.isIdentityAs3x2 = function () {
  71794. if (this._isIdentity3x2Dirty) {
  71795. this._isIdentity3x2Dirty = false;
  71796. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71797. this._isIdentity3x2 = false;
  71798. }
  71799. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71800. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71801. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71802. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71803. this._isIdentity3x2 = false;
  71804. }
  71805. else {
  71806. this._isIdentity3x2 = true;
  71807. }
  71808. }
  71809. return this._isIdentity3x2;
  71810. };
  71811. /**
  71812. * Gets the determinant of the matrix
  71813. * @returns the matrix determinant
  71814. */
  71815. Matrix.prototype.determinant = function () {
  71816. if (this._isIdentity === true) {
  71817. return 1;
  71818. }
  71819. var m = this._m;
  71820. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71821. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71822. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71823. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71824. // https://en.wikipedia.org/wiki/Laplace_expansion
  71825. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71826. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71827. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71828. // where
  71829. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71830. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71831. //
  71832. // Here we do that for the 1st row.
  71833. var det_22_33 = m22 * m33 - m32 * m23;
  71834. var det_21_33 = m21 * m33 - m31 * m23;
  71835. var det_21_32 = m21 * m32 - m31 * m22;
  71836. var det_20_33 = m20 * m33 - m30 * m23;
  71837. var det_20_32 = m20 * m32 - m22 * m30;
  71838. var det_20_31 = m20 * m31 - m30 * m21;
  71839. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71840. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71841. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71842. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71843. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71844. };
  71845. // Methods
  71846. /**
  71847. * Returns the matrix as a Float32Array
  71848. * @returns the matrix underlying array
  71849. */
  71850. Matrix.prototype.toArray = function () {
  71851. return this._m;
  71852. };
  71853. /**
  71854. * Returns the matrix as a Float32Array
  71855. * @returns the matrix underlying array.
  71856. */
  71857. Matrix.prototype.asArray = function () {
  71858. return this._m;
  71859. };
  71860. /**
  71861. * Inverts the current matrix in place
  71862. * @returns the current inverted matrix
  71863. */
  71864. Matrix.prototype.invert = function () {
  71865. this.invertToRef(this);
  71866. return this;
  71867. };
  71868. /**
  71869. * Sets all the matrix elements to zero
  71870. * @returns the current matrix
  71871. */
  71872. Matrix.prototype.reset = function () {
  71873. 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);
  71874. this._updateIdentityStatus(false);
  71875. return this;
  71876. };
  71877. /**
  71878. * Adds the current matrix with a second one
  71879. * @param other defines the matrix to add
  71880. * @returns a new matrix as the addition of the current matrix and the given one
  71881. */
  71882. Matrix.prototype.add = function (other) {
  71883. var result = new Matrix();
  71884. this.addToRef(other, result);
  71885. return result;
  71886. };
  71887. /**
  71888. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71889. * @param other defines the matrix to add
  71890. * @param result defines the target matrix
  71891. * @returns the current matrix
  71892. */
  71893. Matrix.prototype.addToRef = function (other, result) {
  71894. var m = this._m;
  71895. var resultM = result._m;
  71896. var otherM = other.m;
  71897. for (var index = 0; index < 16; index++) {
  71898. resultM[index] = m[index] + otherM[index];
  71899. }
  71900. result._markAsUpdated();
  71901. return this;
  71902. };
  71903. /**
  71904. * Adds in place the given matrix to the current matrix
  71905. * @param other defines the second operand
  71906. * @returns the current updated matrix
  71907. */
  71908. Matrix.prototype.addToSelf = function (other) {
  71909. var m = this._m;
  71910. var otherM = other.m;
  71911. for (var index = 0; index < 16; index++) {
  71912. m[index] += otherM[index];
  71913. }
  71914. this._markAsUpdated();
  71915. return this;
  71916. };
  71917. /**
  71918. * Sets the given matrix to the current inverted Matrix
  71919. * @param other defines the target matrix
  71920. * @returns the unmodified current matrix
  71921. */
  71922. Matrix.prototype.invertToRef = function (other) {
  71923. if (this._isIdentity === true) {
  71924. Matrix.IdentityToRef(other);
  71925. return this;
  71926. }
  71927. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  71928. var m = this._m;
  71929. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71930. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71931. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71932. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71933. var det_22_33 = m22 * m33 - m32 * m23;
  71934. var det_21_33 = m21 * m33 - m31 * m23;
  71935. var det_21_32 = m21 * m32 - m31 * m22;
  71936. var det_20_33 = m20 * m33 - m30 * m23;
  71937. var det_20_32 = m20 * m32 - m22 * m30;
  71938. var det_20_31 = m20 * m31 - m30 * m21;
  71939. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71940. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71941. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71942. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71943. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71944. if (det === 0) {
  71945. // not invertible
  71946. other.copyFrom(this);
  71947. return this;
  71948. }
  71949. var detInv = 1 / det;
  71950. var det_12_33 = m12 * m33 - m32 * m13;
  71951. var det_11_33 = m11 * m33 - m31 * m13;
  71952. var det_11_32 = m11 * m32 - m31 * m12;
  71953. var det_10_33 = m10 * m33 - m30 * m13;
  71954. var det_10_32 = m10 * m32 - m30 * m12;
  71955. var det_10_31 = m10 * m31 - m30 * m11;
  71956. var det_12_23 = m12 * m23 - m22 * m13;
  71957. var det_11_23 = m11 * m23 - m21 * m13;
  71958. var det_11_22 = m11 * m22 - m21 * m12;
  71959. var det_10_23 = m10 * m23 - m20 * m13;
  71960. var det_10_22 = m10 * m22 - m20 * m12;
  71961. var det_10_21 = m10 * m21 - m20 * m11;
  71962. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  71963. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  71964. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  71965. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  71966. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  71967. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  71968. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  71969. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  71970. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  71971. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  71972. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  71973. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  71974. 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);
  71975. return this;
  71976. };
  71977. /**
  71978. * add a value at the specified position in the current Matrix
  71979. * @param index the index of the value within the matrix. between 0 and 15.
  71980. * @param value the value to be added
  71981. * @returns the current updated matrix
  71982. */
  71983. Matrix.prototype.addAtIndex = function (index, value) {
  71984. this._m[index] += value;
  71985. this._markAsUpdated();
  71986. return this;
  71987. };
  71988. /**
  71989. * mutiply the specified position in the current Matrix by a value
  71990. * @param index the index of the value within the matrix. between 0 and 15.
  71991. * @param value the value to be added
  71992. * @returns the current updated matrix
  71993. */
  71994. Matrix.prototype.multiplyAtIndex = function (index, value) {
  71995. this._m[index] *= value;
  71996. this._markAsUpdated();
  71997. return this;
  71998. };
  71999. /**
  72000. * Inserts the translation vector (using 3 floats) in the current matrix
  72001. * @param x defines the 1st component of the translation
  72002. * @param y defines the 2nd component of the translation
  72003. * @param z defines the 3rd component of the translation
  72004. * @returns the current updated matrix
  72005. */
  72006. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  72007. this._m[12] = x;
  72008. this._m[13] = y;
  72009. this._m[14] = z;
  72010. this._markAsUpdated();
  72011. return this;
  72012. };
  72013. /**
  72014. * Inserts the translation vector in the current matrix
  72015. * @param vector3 defines the translation to insert
  72016. * @returns the current updated matrix
  72017. */
  72018. Matrix.prototype.setTranslation = function (vector3) {
  72019. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  72020. };
  72021. /**
  72022. * Gets the translation value of the current matrix
  72023. * @returns a new Vector3 as the extracted translation from the matrix
  72024. */
  72025. Matrix.prototype.getTranslation = function () {
  72026. return new Vector3(this._m[12], this._m[13], this._m[14]);
  72027. };
  72028. /**
  72029. * Fill a Vector3 with the extracted translation from the matrix
  72030. * @param result defines the Vector3 where to store the translation
  72031. * @returns the current matrix
  72032. */
  72033. Matrix.prototype.getTranslationToRef = function (result) {
  72034. result.x = this._m[12];
  72035. result.y = this._m[13];
  72036. result.z = this._m[14];
  72037. return this;
  72038. };
  72039. /**
  72040. * Remove rotation and scaling part from the matrix
  72041. * @returns the updated matrix
  72042. */
  72043. Matrix.prototype.removeRotationAndScaling = function () {
  72044. var m = this.m;
  72045. 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);
  72046. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  72047. return this;
  72048. };
  72049. /**
  72050. * Multiply two matrices
  72051. * @param other defines the second operand
  72052. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72053. */
  72054. Matrix.prototype.multiply = function (other) {
  72055. var result = new Matrix();
  72056. this.multiplyToRef(other, result);
  72057. return result;
  72058. };
  72059. /**
  72060. * Copy the current matrix from the given one
  72061. * @param other defines the source matrix
  72062. * @returns the current updated matrix
  72063. */
  72064. Matrix.prototype.copyFrom = function (other) {
  72065. other.copyToArray(this._m);
  72066. var o = other;
  72067. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  72068. return this;
  72069. };
  72070. /**
  72071. * Populates the given array from the starting index with the current matrix values
  72072. * @param array defines the target array
  72073. * @param offset defines the offset in the target array where to start storing values
  72074. * @returns the current matrix
  72075. */
  72076. Matrix.prototype.copyToArray = function (array, offset) {
  72077. if (offset === void 0) { offset = 0; }
  72078. for (var index = 0; index < 16; index++) {
  72079. array[offset + index] = this._m[index];
  72080. }
  72081. return this;
  72082. };
  72083. /**
  72084. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72085. * @param other defines the second operand
  72086. * @param result defines the matrix where to store the multiplication
  72087. * @returns the current matrix
  72088. */
  72089. Matrix.prototype.multiplyToRef = function (other, result) {
  72090. if (this._isIdentity) {
  72091. result.copyFrom(other);
  72092. return this;
  72093. }
  72094. if (other._isIdentity) {
  72095. result.copyFrom(this);
  72096. return this;
  72097. }
  72098. this.multiplyToArray(other, result._m, 0);
  72099. result._markAsUpdated();
  72100. return this;
  72101. };
  72102. /**
  72103. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72104. * @param other defines the second operand
  72105. * @param result defines the array where to store the multiplication
  72106. * @param offset defines the offset in the target array where to start storing values
  72107. * @returns the current matrix
  72108. */
  72109. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  72110. var m = this._m;
  72111. var otherM = other.m;
  72112. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  72113. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  72114. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  72115. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  72116. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  72117. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  72118. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  72119. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  72120. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  72121. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  72122. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  72123. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  72124. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  72125. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  72126. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  72127. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  72128. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  72129. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  72130. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  72131. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  72132. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  72133. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  72134. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  72135. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  72136. return this;
  72137. };
  72138. /**
  72139. * Check equality between this matrix and a second one
  72140. * @param value defines the second matrix to compare
  72141. * @returns true is the current matrix and the given one values are strictly equal
  72142. */
  72143. Matrix.prototype.equals = function (value) {
  72144. var other = value;
  72145. if (!other) {
  72146. return false;
  72147. }
  72148. if (this._isIdentity || other._isIdentity) {
  72149. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  72150. return this._isIdentity && other._isIdentity;
  72151. }
  72152. }
  72153. var m = this.m;
  72154. var om = other.m;
  72155. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  72156. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  72157. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  72158. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  72159. };
  72160. /**
  72161. * Clone the current matrix
  72162. * @returns a new matrix from the current matrix
  72163. */
  72164. Matrix.prototype.clone = function () {
  72165. var matrix = new Matrix();
  72166. matrix.copyFrom(this);
  72167. return matrix;
  72168. };
  72169. /**
  72170. * Returns the name of the current matrix class
  72171. * @returns the string "Matrix"
  72172. */
  72173. Matrix.prototype.getClassName = function () {
  72174. return "Matrix";
  72175. };
  72176. /**
  72177. * Gets the hash code of the current matrix
  72178. * @returns the hash code
  72179. */
  72180. Matrix.prototype.getHashCode = function () {
  72181. var hash = this._m[0] || 0;
  72182. for (var i = 1; i < 16; i++) {
  72183. hash = (hash * 397) ^ (this._m[i] || 0);
  72184. }
  72185. return hash;
  72186. };
  72187. /**
  72188. * Decomposes the current Matrix into a translation, rotation and scaling components
  72189. * @param scale defines the scale vector3 given as a reference to update
  72190. * @param rotation defines the rotation quaternion given as a reference to update
  72191. * @param translation defines the translation vector3 given as a reference to update
  72192. * @returns true if operation was successful
  72193. */
  72194. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72195. if (this._isIdentity) {
  72196. if (translation) {
  72197. translation.setAll(0);
  72198. }
  72199. if (scale) {
  72200. scale.setAll(1);
  72201. }
  72202. if (rotation) {
  72203. rotation.copyFromFloats(0, 0, 0, 1);
  72204. }
  72205. return true;
  72206. }
  72207. var m = this._m;
  72208. if (translation) {
  72209. translation.copyFromFloats(m[12], m[13], m[14]);
  72210. }
  72211. scale = scale || MathTmp.Vector3[0];
  72212. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72213. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72214. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72215. if (this.determinant() <= 0) {
  72216. scale.y *= -1;
  72217. }
  72218. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72219. if (rotation) {
  72220. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72221. }
  72222. return false;
  72223. }
  72224. if (rotation) {
  72225. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72226. 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]);
  72227. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72228. }
  72229. return true;
  72230. };
  72231. /**
  72232. * Gets specific row of the matrix
  72233. * @param index defines the number of the row to get
  72234. * @returns the index-th row of the current matrix as a new Vector4
  72235. */
  72236. Matrix.prototype.getRow = function (index) {
  72237. if (index < 0 || index > 3) {
  72238. return null;
  72239. }
  72240. var i = index * 4;
  72241. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72242. };
  72243. /**
  72244. * Sets the index-th row of the current matrix to the vector4 values
  72245. * @param index defines the number of the row to set
  72246. * @param row defines the target vector4
  72247. * @returns the updated current matrix
  72248. */
  72249. Matrix.prototype.setRow = function (index, row) {
  72250. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72251. };
  72252. /**
  72253. * Compute the transpose of the matrix
  72254. * @returns the new transposed matrix
  72255. */
  72256. Matrix.prototype.transpose = function () {
  72257. return Matrix.Transpose(this);
  72258. };
  72259. /**
  72260. * Compute the transpose of the matrix and store it in a given matrix
  72261. * @param result defines the target matrix
  72262. * @returns the current matrix
  72263. */
  72264. Matrix.prototype.transposeToRef = function (result) {
  72265. Matrix.TransposeToRef(this, result);
  72266. return this;
  72267. };
  72268. /**
  72269. * Sets the index-th row of the current matrix with the given 4 x float values
  72270. * @param index defines the row index
  72271. * @param x defines the x component to set
  72272. * @param y defines the y component to set
  72273. * @param z defines the z component to set
  72274. * @param w defines the w component to set
  72275. * @returns the updated current matrix
  72276. */
  72277. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72278. if (index < 0 || index > 3) {
  72279. return this;
  72280. }
  72281. var i = index * 4;
  72282. this._m[i + 0] = x;
  72283. this._m[i + 1] = y;
  72284. this._m[i + 2] = z;
  72285. this._m[i + 3] = w;
  72286. this._markAsUpdated();
  72287. return this;
  72288. };
  72289. /**
  72290. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72291. * @param scale defines the scale factor
  72292. * @returns a new matrix
  72293. */
  72294. Matrix.prototype.scale = function (scale) {
  72295. var result = new Matrix();
  72296. this.scaleToRef(scale, result);
  72297. return result;
  72298. };
  72299. /**
  72300. * Scale the current matrix values by a factor to a given result matrix
  72301. * @param scale defines the scale factor
  72302. * @param result defines the matrix to store the result
  72303. * @returns the current matrix
  72304. */
  72305. Matrix.prototype.scaleToRef = function (scale, result) {
  72306. for (var index = 0; index < 16; index++) {
  72307. result._m[index] = this._m[index] * scale;
  72308. }
  72309. result._markAsUpdated();
  72310. return this;
  72311. };
  72312. /**
  72313. * Scale the current matrix values by a factor and add the result to a given matrix
  72314. * @param scale defines the scale factor
  72315. * @param result defines the Matrix to store the result
  72316. * @returns the current matrix
  72317. */
  72318. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72319. for (var index = 0; index < 16; index++) {
  72320. result._m[index] += this._m[index] * scale;
  72321. }
  72322. result._markAsUpdated();
  72323. return this;
  72324. };
  72325. /**
  72326. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72327. * @param ref matrix to store the result
  72328. */
  72329. Matrix.prototype.toNormalMatrix = function (ref) {
  72330. var tmp = MathTmp.Matrix[0];
  72331. this.invertToRef(tmp);
  72332. tmp.transposeToRef(ref);
  72333. var m = ref._m;
  72334. 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);
  72335. };
  72336. /**
  72337. * Gets only rotation part of the current matrix
  72338. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72339. */
  72340. Matrix.prototype.getRotationMatrix = function () {
  72341. var result = new Matrix();
  72342. this.getRotationMatrixToRef(result);
  72343. return result;
  72344. };
  72345. /**
  72346. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72347. * @param result defines the target matrix to store data to
  72348. * @returns the current matrix
  72349. */
  72350. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72351. var scale = MathTmp.Vector3[0];
  72352. if (!this.decompose(scale)) {
  72353. Matrix.IdentityToRef(result);
  72354. return this;
  72355. }
  72356. var m = this._m;
  72357. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72358. 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);
  72359. return this;
  72360. };
  72361. /**
  72362. * Toggles model matrix from being right handed to left handed in place and vice versa
  72363. */
  72364. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72365. var m = this._m;
  72366. m[2] *= -1;
  72367. m[6] *= -1;
  72368. m[8] *= -1;
  72369. m[9] *= -1;
  72370. m[14] *= -1;
  72371. this._markAsUpdated();
  72372. };
  72373. /**
  72374. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72375. */
  72376. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72377. var m = this._m;
  72378. m[8] *= -1;
  72379. m[9] *= -1;
  72380. m[10] *= -1;
  72381. m[11] *= -1;
  72382. this._markAsUpdated();
  72383. };
  72384. // Statics
  72385. /**
  72386. * Creates a matrix from an array
  72387. * @param array defines the source array
  72388. * @param offset defines an offset in the source array
  72389. * @returns a new Matrix set from the starting index of the given array
  72390. */
  72391. Matrix.FromArray = function (array, offset) {
  72392. if (offset === void 0) { offset = 0; }
  72393. var result = new Matrix();
  72394. Matrix.FromArrayToRef(array, offset, result);
  72395. return result;
  72396. };
  72397. /**
  72398. * Copy the content of an array into a given matrix
  72399. * @param array defines the source array
  72400. * @param offset defines an offset in the source array
  72401. * @param result defines the target matrix
  72402. */
  72403. Matrix.FromArrayToRef = function (array, offset, result) {
  72404. for (var index = 0; index < 16; index++) {
  72405. result._m[index] = array[index + offset];
  72406. }
  72407. result._markAsUpdated();
  72408. };
  72409. /**
  72410. * Stores an array into a matrix after having multiplied each component by a given factor
  72411. * @param array defines the source array
  72412. * @param offset defines the offset in the source array
  72413. * @param scale defines the scaling factor
  72414. * @param result defines the target matrix
  72415. */
  72416. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72417. for (var index = 0; index < 16; index++) {
  72418. result._m[index] = array[index + offset] * scale;
  72419. }
  72420. result._markAsUpdated();
  72421. };
  72422. Object.defineProperty(Matrix, "IdentityReadOnly", {
  72423. /**
  72424. * Gets an identity matrix that must not be updated
  72425. */
  72426. get: function () {
  72427. return Matrix._identityReadOnly;
  72428. },
  72429. enumerable: true,
  72430. configurable: true
  72431. });
  72432. /**
  72433. * Stores a list of values (16) inside a given matrix
  72434. * @param initialM11 defines 1st value of 1st row
  72435. * @param initialM12 defines 2nd value of 1st row
  72436. * @param initialM13 defines 3rd value of 1st row
  72437. * @param initialM14 defines 4th value of 1st row
  72438. * @param initialM21 defines 1st value of 2nd row
  72439. * @param initialM22 defines 2nd value of 2nd row
  72440. * @param initialM23 defines 3rd value of 2nd row
  72441. * @param initialM24 defines 4th value of 2nd row
  72442. * @param initialM31 defines 1st value of 3rd row
  72443. * @param initialM32 defines 2nd value of 3rd row
  72444. * @param initialM33 defines 3rd value of 3rd row
  72445. * @param initialM34 defines 4th value of 3rd row
  72446. * @param initialM41 defines 1st value of 4th row
  72447. * @param initialM42 defines 2nd value of 4th row
  72448. * @param initialM43 defines 3rd value of 4th row
  72449. * @param initialM44 defines 4th value of 4th row
  72450. * @param result defines the target matrix
  72451. */
  72452. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  72453. var m = result._m;
  72454. m[0] = initialM11;
  72455. m[1] = initialM12;
  72456. m[2] = initialM13;
  72457. m[3] = initialM14;
  72458. m[4] = initialM21;
  72459. m[5] = initialM22;
  72460. m[6] = initialM23;
  72461. m[7] = initialM24;
  72462. m[8] = initialM31;
  72463. m[9] = initialM32;
  72464. m[10] = initialM33;
  72465. m[11] = initialM34;
  72466. m[12] = initialM41;
  72467. m[13] = initialM42;
  72468. m[14] = initialM43;
  72469. m[15] = initialM44;
  72470. result._markAsUpdated();
  72471. };
  72472. /**
  72473. * Creates new matrix from a list of values (16)
  72474. * @param initialM11 defines 1st value of 1st row
  72475. * @param initialM12 defines 2nd value of 1st row
  72476. * @param initialM13 defines 3rd value of 1st row
  72477. * @param initialM14 defines 4th value of 1st row
  72478. * @param initialM21 defines 1st value of 2nd row
  72479. * @param initialM22 defines 2nd value of 2nd row
  72480. * @param initialM23 defines 3rd value of 2nd row
  72481. * @param initialM24 defines 4th value of 2nd row
  72482. * @param initialM31 defines 1st value of 3rd row
  72483. * @param initialM32 defines 2nd value of 3rd row
  72484. * @param initialM33 defines 3rd value of 3rd row
  72485. * @param initialM34 defines 4th value of 3rd row
  72486. * @param initialM41 defines 1st value of 4th row
  72487. * @param initialM42 defines 2nd value of 4th row
  72488. * @param initialM43 defines 3rd value of 4th row
  72489. * @param initialM44 defines 4th value of 4th row
  72490. * @returns the new matrix
  72491. */
  72492. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  72493. var result = new Matrix();
  72494. var m = result._m;
  72495. m[0] = initialM11;
  72496. m[1] = initialM12;
  72497. m[2] = initialM13;
  72498. m[3] = initialM14;
  72499. m[4] = initialM21;
  72500. m[5] = initialM22;
  72501. m[6] = initialM23;
  72502. m[7] = initialM24;
  72503. m[8] = initialM31;
  72504. m[9] = initialM32;
  72505. m[10] = initialM33;
  72506. m[11] = initialM34;
  72507. m[12] = initialM41;
  72508. m[13] = initialM42;
  72509. m[14] = initialM43;
  72510. m[15] = initialM44;
  72511. result._markAsUpdated();
  72512. return result;
  72513. };
  72514. /**
  72515. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72516. * @param scale defines the scale vector3
  72517. * @param rotation defines the rotation quaternion
  72518. * @param translation defines the translation vector3
  72519. * @returns a new matrix
  72520. */
  72521. Matrix.Compose = function (scale, rotation, translation) {
  72522. var result = new Matrix();
  72523. Matrix.ComposeToRef(scale, rotation, translation, result);
  72524. return result;
  72525. };
  72526. /**
  72527. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72528. * @param scale defines the scale vector3
  72529. * @param rotation defines the rotation quaternion
  72530. * @param translation defines the translation vector3
  72531. * @param result defines the target matrix
  72532. */
  72533. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  72534. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  72535. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  72536. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  72537. result.setTranslation(translation);
  72538. };
  72539. /**
  72540. * Creates a new identity matrix
  72541. * @returns a new identity matrix
  72542. */
  72543. Matrix.Identity = function () {
  72544. 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);
  72545. identity._updateIdentityStatus(true);
  72546. return identity;
  72547. };
  72548. /**
  72549. * Creates a new identity matrix and stores the result in a given matrix
  72550. * @param result defines the target matrix
  72551. */
  72552. Matrix.IdentityToRef = function (result) {
  72553. 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);
  72554. result._updateIdentityStatus(true);
  72555. };
  72556. /**
  72557. * Creates a new zero matrix
  72558. * @returns a new zero matrix
  72559. */
  72560. Matrix.Zero = function () {
  72561. 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);
  72562. zero._updateIdentityStatus(false);
  72563. return zero;
  72564. };
  72565. /**
  72566. * Creates a new rotation matrix for "angle" radians around the X axis
  72567. * @param angle defines the angle (in radians) to use
  72568. * @return the new matrix
  72569. */
  72570. Matrix.RotationX = function (angle) {
  72571. var result = new Matrix();
  72572. Matrix.RotationXToRef(angle, result);
  72573. return result;
  72574. };
  72575. /**
  72576. * Creates a new matrix as the invert of a given matrix
  72577. * @param source defines the source matrix
  72578. * @returns the new matrix
  72579. */
  72580. Matrix.Invert = function (source) {
  72581. var result = new Matrix();
  72582. source.invertToRef(result);
  72583. return result;
  72584. };
  72585. /**
  72586. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72587. * @param angle defines the angle (in radians) to use
  72588. * @param result defines the target matrix
  72589. */
  72590. Matrix.RotationXToRef = function (angle, result) {
  72591. var s = Math.sin(angle);
  72592. var c = Math.cos(angle);
  72593. 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);
  72594. result._updateIdentityStatus(c === 1 && s === 0);
  72595. };
  72596. /**
  72597. * Creates a new rotation matrix for "angle" radians around the Y axis
  72598. * @param angle defines the angle (in radians) to use
  72599. * @return the new matrix
  72600. */
  72601. Matrix.RotationY = function (angle) {
  72602. var result = new Matrix();
  72603. Matrix.RotationYToRef(angle, result);
  72604. return result;
  72605. };
  72606. /**
  72607. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72608. * @param angle defines the angle (in radians) to use
  72609. * @param result defines the target matrix
  72610. */
  72611. Matrix.RotationYToRef = function (angle, result) {
  72612. var s = Math.sin(angle);
  72613. var c = Math.cos(angle);
  72614. 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);
  72615. result._updateIdentityStatus(c === 1 && s === 0);
  72616. };
  72617. /**
  72618. * Creates a new rotation matrix for "angle" radians around the Z axis
  72619. * @param angle defines the angle (in radians) to use
  72620. * @return the new matrix
  72621. */
  72622. Matrix.RotationZ = function (angle) {
  72623. var result = new Matrix();
  72624. Matrix.RotationZToRef(angle, result);
  72625. return result;
  72626. };
  72627. /**
  72628. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72629. * @param angle defines the angle (in radians) to use
  72630. * @param result defines the target matrix
  72631. */
  72632. Matrix.RotationZToRef = function (angle, result) {
  72633. var s = Math.sin(angle);
  72634. var c = Math.cos(angle);
  72635. 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);
  72636. result._updateIdentityStatus(c === 1 && s === 0);
  72637. };
  72638. /**
  72639. * Creates a new rotation matrix for "angle" radians around the given axis
  72640. * @param axis defines the axis to use
  72641. * @param angle defines the angle (in radians) to use
  72642. * @return the new matrix
  72643. */
  72644. Matrix.RotationAxis = function (axis, angle) {
  72645. var result = new Matrix();
  72646. Matrix.RotationAxisToRef(axis, angle, result);
  72647. return result;
  72648. };
  72649. /**
  72650. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72651. * @param axis defines the axis to use
  72652. * @param angle defines the angle (in radians) to use
  72653. * @param result defines the target matrix
  72654. */
  72655. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72656. var s = Math.sin(-angle);
  72657. var c = Math.cos(-angle);
  72658. var c1 = 1 - c;
  72659. axis.normalize();
  72660. var m = result._m;
  72661. m[0] = (axis.x * axis.x) * c1 + c;
  72662. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72663. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72664. m[3] = 0.0;
  72665. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72666. m[5] = (axis.y * axis.y) * c1 + c;
  72667. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72668. m[7] = 0.0;
  72669. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72670. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72671. m[10] = (axis.z * axis.z) * c1 + c;
  72672. m[11] = 0.0;
  72673. m[12] = 0.0;
  72674. m[13] = 0.0;
  72675. m[14] = 0.0;
  72676. m[15] = 1.0;
  72677. result._markAsUpdated();
  72678. };
  72679. /**
  72680. * Creates a rotation matrix
  72681. * @param yaw defines the yaw angle in radians (Y axis)
  72682. * @param pitch defines the pitch angle in radians (X axis)
  72683. * @param roll defines the roll angle in radians (X axis)
  72684. * @returns the new rotation matrix
  72685. */
  72686. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72687. var result = new Matrix();
  72688. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72689. return result;
  72690. };
  72691. /**
  72692. * Creates a rotation matrix and stores it in a given matrix
  72693. * @param yaw defines the yaw angle in radians (Y axis)
  72694. * @param pitch defines the pitch angle in radians (X axis)
  72695. * @param roll defines the roll angle in radians (X axis)
  72696. * @param result defines the target matrix
  72697. */
  72698. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72699. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72700. MathTmp.Quaternion[0].toRotationMatrix(result);
  72701. };
  72702. /**
  72703. * Creates a scaling matrix
  72704. * @param x defines the scale factor on X axis
  72705. * @param y defines the scale factor on Y axis
  72706. * @param z defines the scale factor on Z axis
  72707. * @returns the new matrix
  72708. */
  72709. Matrix.Scaling = function (x, y, z) {
  72710. var result = new Matrix();
  72711. Matrix.ScalingToRef(x, y, z, result);
  72712. return result;
  72713. };
  72714. /**
  72715. * Creates a scaling matrix and stores it in a given matrix
  72716. * @param x defines the scale factor on X axis
  72717. * @param y defines the scale factor on Y axis
  72718. * @param z defines the scale factor on Z axis
  72719. * @param result defines the target matrix
  72720. */
  72721. Matrix.ScalingToRef = function (x, y, z, result) {
  72722. 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);
  72723. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72724. };
  72725. /**
  72726. * Creates a translation matrix
  72727. * @param x defines the translation on X axis
  72728. * @param y defines the translation on Y axis
  72729. * @param z defines the translationon Z axis
  72730. * @returns the new matrix
  72731. */
  72732. Matrix.Translation = function (x, y, z) {
  72733. var result = new Matrix();
  72734. Matrix.TranslationToRef(x, y, z, result);
  72735. return result;
  72736. };
  72737. /**
  72738. * Creates a translation matrix and stores it in a given matrix
  72739. * @param x defines the translation on X axis
  72740. * @param y defines the translation on Y axis
  72741. * @param z defines the translationon Z axis
  72742. * @param result defines the target matrix
  72743. */
  72744. Matrix.TranslationToRef = function (x, y, z, result) {
  72745. 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);
  72746. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72747. };
  72748. /**
  72749. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72750. * @param startValue defines the start value
  72751. * @param endValue defines the end value
  72752. * @param gradient defines the gradient factor
  72753. * @returns the new matrix
  72754. */
  72755. Matrix.Lerp = function (startValue, endValue, gradient) {
  72756. var result = new Matrix();
  72757. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72758. return result;
  72759. };
  72760. /**
  72761. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72762. * @param startValue defines the start value
  72763. * @param endValue defines the end value
  72764. * @param gradient defines the gradient factor
  72765. * @param result defines the Matrix object where to store data
  72766. */
  72767. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72768. var resultM = result._m;
  72769. var startM = startValue.m;
  72770. var endM = endValue.m;
  72771. for (var index = 0; index < 16; index++) {
  72772. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72773. }
  72774. result._markAsUpdated();
  72775. };
  72776. /**
  72777. * Builds a new matrix whose values are computed by:
  72778. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72779. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72780. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72781. * @param startValue defines the first matrix
  72782. * @param endValue defines the second matrix
  72783. * @param gradient defines the gradient between the two matrices
  72784. * @returns the new matrix
  72785. */
  72786. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72787. var result = new Matrix();
  72788. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72789. return result;
  72790. };
  72791. /**
  72792. * Update a matrix to values which are computed by:
  72793. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72794. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72795. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72796. * @param startValue defines the first matrix
  72797. * @param endValue defines the second matrix
  72798. * @param gradient defines the gradient between the two matrices
  72799. * @param result defines the target matrix
  72800. */
  72801. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72802. var startScale = MathTmp.Vector3[0];
  72803. var startRotation = MathTmp.Quaternion[0];
  72804. var startTranslation = MathTmp.Vector3[1];
  72805. startValue.decompose(startScale, startRotation, startTranslation);
  72806. var endScale = MathTmp.Vector3[2];
  72807. var endRotation = MathTmp.Quaternion[1];
  72808. var endTranslation = MathTmp.Vector3[3];
  72809. endValue.decompose(endScale, endRotation, endTranslation);
  72810. var resultScale = MathTmp.Vector3[4];
  72811. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72812. var resultRotation = MathTmp.Quaternion[2];
  72813. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72814. var resultTranslation = MathTmp.Vector3[5];
  72815. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72816. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72817. };
  72818. /**
  72819. * 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"
  72820. * This function works in left handed mode
  72821. * @param eye defines the final position of the entity
  72822. * @param target defines where the entity should look at
  72823. * @param up defines the up vector for the entity
  72824. * @returns the new matrix
  72825. */
  72826. Matrix.LookAtLH = function (eye, target, up) {
  72827. var result = new Matrix();
  72828. Matrix.LookAtLHToRef(eye, target, up, result);
  72829. return result;
  72830. };
  72831. /**
  72832. * 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".
  72833. * This function works in left handed mode
  72834. * @param eye defines the final position of the entity
  72835. * @param target defines where the entity should look at
  72836. * @param up defines the up vector for the entity
  72837. * @param result defines the target matrix
  72838. */
  72839. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72840. var xAxis = MathTmp.Vector3[0];
  72841. var yAxis = MathTmp.Vector3[1];
  72842. var zAxis = MathTmp.Vector3[2];
  72843. // Z axis
  72844. target.subtractToRef(eye, zAxis);
  72845. zAxis.normalize();
  72846. // X axis
  72847. Vector3.CrossToRef(up, zAxis, xAxis);
  72848. var xSquareLength = xAxis.lengthSquared();
  72849. if (xSquareLength === 0) {
  72850. xAxis.x = 1.0;
  72851. }
  72852. else {
  72853. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72854. }
  72855. // Y axis
  72856. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72857. yAxis.normalize();
  72858. // Eye angles
  72859. var ex = -Vector3.Dot(xAxis, eye);
  72860. var ey = -Vector3.Dot(yAxis, eye);
  72861. var ez = -Vector3.Dot(zAxis, eye);
  72862. 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);
  72863. };
  72864. /**
  72865. * 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"
  72866. * This function works in right handed mode
  72867. * @param eye defines the final position of the entity
  72868. * @param target defines where the entity should look at
  72869. * @param up defines the up vector for the entity
  72870. * @returns the new matrix
  72871. */
  72872. Matrix.LookAtRH = function (eye, target, up) {
  72873. var result = new Matrix();
  72874. Matrix.LookAtRHToRef(eye, target, up, result);
  72875. return result;
  72876. };
  72877. /**
  72878. * 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".
  72879. * This function works in right handed mode
  72880. * @param eye defines the final position of the entity
  72881. * @param target defines where the entity should look at
  72882. * @param up defines the up vector for the entity
  72883. * @param result defines the target matrix
  72884. */
  72885. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  72886. var xAxis = MathTmp.Vector3[0];
  72887. var yAxis = MathTmp.Vector3[1];
  72888. var zAxis = MathTmp.Vector3[2];
  72889. // Z axis
  72890. eye.subtractToRef(target, zAxis);
  72891. zAxis.normalize();
  72892. // X axis
  72893. Vector3.CrossToRef(up, zAxis, xAxis);
  72894. var xSquareLength = xAxis.lengthSquared();
  72895. if (xSquareLength === 0) {
  72896. xAxis.x = 1.0;
  72897. }
  72898. else {
  72899. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72900. }
  72901. // Y axis
  72902. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72903. yAxis.normalize();
  72904. // Eye angles
  72905. var ex = -Vector3.Dot(xAxis, eye);
  72906. var ey = -Vector3.Dot(yAxis, eye);
  72907. var ez = -Vector3.Dot(zAxis, eye);
  72908. 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);
  72909. };
  72910. /**
  72911. * Create a left-handed orthographic projection matrix
  72912. * @param width defines the viewport width
  72913. * @param height defines the viewport height
  72914. * @param znear defines the near clip plane
  72915. * @param zfar defines the far clip plane
  72916. * @returns a new matrix as a left-handed orthographic projection matrix
  72917. */
  72918. Matrix.OrthoLH = function (width, height, znear, zfar) {
  72919. var matrix = new Matrix();
  72920. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  72921. return matrix;
  72922. };
  72923. /**
  72924. * Store a left-handed orthographic projection to a given matrix
  72925. * @param width defines the viewport width
  72926. * @param height defines the viewport height
  72927. * @param znear defines the near clip plane
  72928. * @param zfar defines the far clip plane
  72929. * @param result defines the target matrix
  72930. */
  72931. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  72932. var n = znear;
  72933. var f = zfar;
  72934. var a = 2.0 / width;
  72935. var b = 2.0 / height;
  72936. var c = 2.0 / (f - n);
  72937. var d = -(f + n) / (f - n);
  72938. 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);
  72939. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  72940. };
  72941. /**
  72942. * Create a left-handed orthographic projection matrix
  72943. * @param left defines the viewport left coordinate
  72944. * @param right defines the viewport right coordinate
  72945. * @param bottom defines the viewport bottom coordinate
  72946. * @param top defines the viewport top coordinate
  72947. * @param znear defines the near clip plane
  72948. * @param zfar defines the far clip plane
  72949. * @returns a new matrix as a left-handed orthographic projection matrix
  72950. */
  72951. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  72952. var matrix = new Matrix();
  72953. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  72954. return matrix;
  72955. };
  72956. /**
  72957. * Stores a left-handed orthographic projection into a given matrix
  72958. * @param left defines the viewport left coordinate
  72959. * @param right defines the viewport right coordinate
  72960. * @param bottom defines the viewport bottom coordinate
  72961. * @param top defines the viewport top coordinate
  72962. * @param znear defines the near clip plane
  72963. * @param zfar defines the far clip plane
  72964. * @param result defines the target matrix
  72965. */
  72966. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72967. var n = znear;
  72968. var f = zfar;
  72969. var a = 2.0 / (right - left);
  72970. var b = 2.0 / (top - bottom);
  72971. var c = 2.0 / (f - n);
  72972. var d = -(f + n) / (f - n);
  72973. var i0 = (left + right) / (left - right);
  72974. var i1 = (top + bottom) / (bottom - top);
  72975. 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);
  72976. result._markAsUpdated();
  72977. };
  72978. /**
  72979. * Creates a right-handed orthographic projection matrix
  72980. * @param left defines the viewport left coordinate
  72981. * @param right defines the viewport right coordinate
  72982. * @param bottom defines the viewport bottom coordinate
  72983. * @param top defines the viewport top coordinate
  72984. * @param znear defines the near clip plane
  72985. * @param zfar defines the far clip plane
  72986. * @returns a new matrix as a right-handed orthographic projection matrix
  72987. */
  72988. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  72989. var matrix = new Matrix();
  72990. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  72991. return matrix;
  72992. };
  72993. /**
  72994. * Stores a right-handed orthographic projection into a given matrix
  72995. * @param left defines the viewport left coordinate
  72996. * @param right defines the viewport right coordinate
  72997. * @param bottom defines the viewport bottom coordinate
  72998. * @param top defines the viewport top coordinate
  72999. * @param znear defines the near clip plane
  73000. * @param zfar defines the far clip plane
  73001. * @param result defines the target matrix
  73002. */
  73003. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73004. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  73005. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  73006. };
  73007. /**
  73008. * Creates a left-handed perspective projection matrix
  73009. * @param width defines the viewport width
  73010. * @param height defines the viewport height
  73011. * @param znear defines the near clip plane
  73012. * @param zfar defines the far clip plane
  73013. * @returns a new matrix as a left-handed perspective projection matrix
  73014. */
  73015. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  73016. var matrix = new Matrix();
  73017. var n = znear;
  73018. var f = zfar;
  73019. var a = 2.0 * n / width;
  73020. var b = 2.0 * n / height;
  73021. var c = (f + n) / (f - n);
  73022. var d = -2.0 * f * n / (f - n);
  73023. 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);
  73024. matrix._updateIdentityStatus(false);
  73025. return matrix;
  73026. };
  73027. /**
  73028. * Creates a left-handed perspective projection matrix
  73029. * @param fov defines the horizontal field of view
  73030. * @param aspect defines the aspect ratio
  73031. * @param znear defines the near clip plane
  73032. * @param zfar defines the far clip plane
  73033. * @returns a new matrix as a left-handed perspective projection matrix
  73034. */
  73035. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  73036. var matrix = new Matrix();
  73037. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  73038. return matrix;
  73039. };
  73040. /**
  73041. * Stores a left-handed perspective projection into a given matrix
  73042. * @param fov defines the horizontal field of view
  73043. * @param aspect defines the aspect ratio
  73044. * @param znear defines the near clip plane
  73045. * @param zfar defines the far clip plane
  73046. * @param result defines the target matrix
  73047. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73048. */
  73049. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73050. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73051. var n = znear;
  73052. var f = zfar;
  73053. var t = 1.0 / (Math.tan(fov * 0.5));
  73054. var a = isVerticalFovFixed ? (t / aspect) : t;
  73055. var b = isVerticalFovFixed ? t : (t * aspect);
  73056. var c = (f + n) / (f - n);
  73057. var d = -2.0 * f * n / (f - n);
  73058. 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);
  73059. result._updateIdentityStatus(false);
  73060. };
  73061. /**
  73062. * Creates a right-handed perspective projection matrix
  73063. * @param fov defines the horizontal field of view
  73064. * @param aspect defines the aspect ratio
  73065. * @param znear defines the near clip plane
  73066. * @param zfar defines the far clip plane
  73067. * @returns a new matrix as a right-handed perspective projection matrix
  73068. */
  73069. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  73070. var matrix = new Matrix();
  73071. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  73072. return matrix;
  73073. };
  73074. /**
  73075. * Stores a right-handed perspective projection into a given matrix
  73076. * @param fov defines the horizontal field of view
  73077. * @param aspect defines the aspect ratio
  73078. * @param znear defines the near clip plane
  73079. * @param zfar defines the far clip plane
  73080. * @param result defines the target matrix
  73081. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73082. */
  73083. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73084. //alternatively this could be expressed as:
  73085. // m = PerspectiveFovLHToRef
  73086. // m[10] *= -1.0;
  73087. // m[11] *= -1.0;
  73088. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73089. var n = znear;
  73090. var f = zfar;
  73091. var t = 1.0 / (Math.tan(fov * 0.5));
  73092. var a = isVerticalFovFixed ? (t / aspect) : t;
  73093. var b = isVerticalFovFixed ? t : (t * aspect);
  73094. var c = -(f + n) / (f - n);
  73095. var d = -2 * f * n / (f - n);
  73096. 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);
  73097. result._updateIdentityStatus(false);
  73098. };
  73099. /**
  73100. * Stores a perspective projection for WebVR info a given matrix
  73101. * @param fov defines the field of view
  73102. * @param znear defines the near clip plane
  73103. * @param zfar defines the far clip plane
  73104. * @param result defines the target matrix
  73105. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73106. */
  73107. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  73108. if (rightHanded === void 0) { rightHanded = false; }
  73109. var rightHandedFactor = rightHanded ? -1 : 1;
  73110. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  73111. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  73112. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  73113. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  73114. var xScale = 2.0 / (leftTan + rightTan);
  73115. var yScale = 2.0 / (upTan + downTan);
  73116. var m = result._m;
  73117. m[0] = xScale;
  73118. m[1] = m[2] = m[3] = m[4] = 0.0;
  73119. m[5] = yScale;
  73120. m[6] = m[7] = 0.0;
  73121. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  73122. m[9] = -((upTan - downTan) * yScale * 0.5);
  73123. m[10] = -zfar / (znear - zfar);
  73124. m[11] = 1.0 * rightHandedFactor;
  73125. m[12] = m[13] = m[15] = 0.0;
  73126. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  73127. result._markAsUpdated();
  73128. };
  73129. /**
  73130. * Computes a complete transformation matrix
  73131. * @param viewport defines the viewport to use
  73132. * @param world defines the world matrix
  73133. * @param view defines the view matrix
  73134. * @param projection defines the projection matrix
  73135. * @param zmin defines the near clip plane
  73136. * @param zmax defines the far clip plane
  73137. * @returns the transformation matrix
  73138. */
  73139. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  73140. var cw = viewport.width;
  73141. var ch = viewport.height;
  73142. var cx = viewport.x;
  73143. var cy = viewport.y;
  73144. 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);
  73145. var matrix = MathTmp.Matrix[0];
  73146. world.multiplyToRef(view, matrix);
  73147. matrix.multiplyToRef(projection, matrix);
  73148. return matrix.multiply(viewportMatrix);
  73149. };
  73150. /**
  73151. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73152. * @param matrix defines the matrix to use
  73153. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73154. */
  73155. Matrix.GetAsMatrix2x2 = function (matrix) {
  73156. var m = matrix.m;
  73157. return new Float32Array([m[0], m[1], m[4], m[5]]);
  73158. };
  73159. /**
  73160. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73161. * @param matrix defines the matrix to use
  73162. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73163. */
  73164. Matrix.GetAsMatrix3x3 = function (matrix) {
  73165. var m = matrix.m;
  73166. return new Float32Array([
  73167. m[0], m[1], m[2],
  73168. m[4], m[5], m[6],
  73169. m[8], m[9], m[10]
  73170. ]);
  73171. };
  73172. /**
  73173. * Compute the transpose of a given matrix
  73174. * @param matrix defines the matrix to transpose
  73175. * @returns the new matrix
  73176. */
  73177. Matrix.Transpose = function (matrix) {
  73178. var result = new Matrix();
  73179. Matrix.TransposeToRef(matrix, result);
  73180. return result;
  73181. };
  73182. /**
  73183. * Compute the transpose of a matrix and store it in a target matrix
  73184. * @param matrix defines the matrix to transpose
  73185. * @param result defines the target matrix
  73186. */
  73187. Matrix.TransposeToRef = function (matrix, result) {
  73188. var rm = result._m;
  73189. var mm = matrix.m;
  73190. rm[0] = mm[0];
  73191. rm[1] = mm[4];
  73192. rm[2] = mm[8];
  73193. rm[3] = mm[12];
  73194. rm[4] = mm[1];
  73195. rm[5] = mm[5];
  73196. rm[6] = mm[9];
  73197. rm[7] = mm[13];
  73198. rm[8] = mm[2];
  73199. rm[9] = mm[6];
  73200. rm[10] = mm[10];
  73201. rm[11] = mm[14];
  73202. rm[12] = mm[3];
  73203. rm[13] = mm[7];
  73204. rm[14] = mm[11];
  73205. rm[15] = mm[15];
  73206. // identity-ness does not change when transposing
  73207. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73208. };
  73209. /**
  73210. * Computes a reflection matrix from a plane
  73211. * @param plane defines the reflection plane
  73212. * @returns a new matrix
  73213. */
  73214. Matrix.Reflection = function (plane) {
  73215. var matrix = new Matrix();
  73216. Matrix.ReflectionToRef(plane, matrix);
  73217. return matrix;
  73218. };
  73219. /**
  73220. * Computes a reflection matrix from a plane
  73221. * @param plane defines the reflection plane
  73222. * @param result defines the target matrix
  73223. */
  73224. Matrix.ReflectionToRef = function (plane, result) {
  73225. plane.normalize();
  73226. var x = plane.normal.x;
  73227. var y = plane.normal.y;
  73228. var z = plane.normal.z;
  73229. var temp = -2 * x;
  73230. var temp2 = -2 * y;
  73231. var temp3 = -2 * z;
  73232. 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);
  73233. };
  73234. /**
  73235. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73236. * @param xaxis defines the value of the 1st axis
  73237. * @param yaxis defines the value of the 2nd axis
  73238. * @param zaxis defines the value of the 3rd axis
  73239. * @param result defines the target matrix
  73240. */
  73241. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73242. 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);
  73243. };
  73244. /**
  73245. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73246. * @param quat defines the quaternion to use
  73247. * @param result defines the target matrix
  73248. */
  73249. Matrix.FromQuaternionToRef = function (quat, result) {
  73250. var xx = quat.x * quat.x;
  73251. var yy = quat.y * quat.y;
  73252. var zz = quat.z * quat.z;
  73253. var xy = quat.x * quat.y;
  73254. var zw = quat.z * quat.w;
  73255. var zx = quat.z * quat.x;
  73256. var yw = quat.y * quat.w;
  73257. var yz = quat.y * quat.z;
  73258. var xw = quat.x * quat.w;
  73259. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73260. result._m[1] = 2.0 * (xy + zw);
  73261. result._m[2] = 2.0 * (zx - yw);
  73262. result._m[3] = 0.0;
  73263. result._m[4] = 2.0 * (xy - zw);
  73264. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73265. result._m[6] = 2.0 * (yz + xw);
  73266. result._m[7] = 0.0;
  73267. result._m[8] = 2.0 * (zx + yw);
  73268. result._m[9] = 2.0 * (yz - xw);
  73269. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73270. result._m[11] = 0.0;
  73271. result._m[12] = 0.0;
  73272. result._m[13] = 0.0;
  73273. result._m[14] = 0.0;
  73274. result._m[15] = 1.0;
  73275. result._markAsUpdated();
  73276. };
  73277. Matrix._updateFlagSeed = 0;
  73278. Matrix._identityReadOnly = Matrix.Identity();
  73279. return Matrix;
  73280. }());
  73281. /**
  73282. * Represens a plane by the equation ax + by + cz + d = 0
  73283. */
  73284. var Plane = /** @class */ (function () {
  73285. /**
  73286. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73287. * @param a a component of the plane
  73288. * @param b b component of the plane
  73289. * @param c c component of the plane
  73290. * @param d d component of the plane
  73291. */
  73292. function Plane(a, b, c, d) {
  73293. this.normal = new Vector3(a, b, c);
  73294. this.d = d;
  73295. }
  73296. /**
  73297. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73298. */
  73299. Plane.prototype.asArray = function () {
  73300. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73301. };
  73302. // Methods
  73303. /**
  73304. * @returns a new plane copied from the current Plane.
  73305. */
  73306. Plane.prototype.clone = function () {
  73307. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73308. };
  73309. /**
  73310. * @returns the string "Plane".
  73311. */
  73312. Plane.prototype.getClassName = function () {
  73313. return "Plane";
  73314. };
  73315. /**
  73316. * @returns the Plane hash code.
  73317. */
  73318. Plane.prototype.getHashCode = function () {
  73319. var hash = this.normal.getHashCode();
  73320. hash = (hash * 397) ^ (this.d || 0);
  73321. return hash;
  73322. };
  73323. /**
  73324. * Normalize the current Plane in place.
  73325. * @returns the updated Plane.
  73326. */
  73327. Plane.prototype.normalize = function () {
  73328. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73329. var magnitude = 0.0;
  73330. if (norm !== 0) {
  73331. magnitude = 1.0 / norm;
  73332. }
  73333. this.normal.x *= magnitude;
  73334. this.normal.y *= magnitude;
  73335. this.normal.z *= magnitude;
  73336. this.d *= magnitude;
  73337. return this;
  73338. };
  73339. /**
  73340. * Applies a transformation the plane and returns the result
  73341. * @param transformation the transformation matrix to be applied to the plane
  73342. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73343. */
  73344. Plane.prototype.transform = function (transformation) {
  73345. var transposedMatrix = MathTmp.Matrix[0];
  73346. Matrix.TransposeToRef(transformation, transposedMatrix);
  73347. var m = transposedMatrix.m;
  73348. var x = this.normal.x;
  73349. var y = this.normal.y;
  73350. var z = this.normal.z;
  73351. var d = this.d;
  73352. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73353. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73354. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73355. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73356. return new Plane(normalX, normalY, normalZ, finalD);
  73357. };
  73358. /**
  73359. * Calcualtte the dot product between the point and the plane normal
  73360. * @param point point to calculate the dot product with
  73361. * @returns the dot product (float) of the point coordinates and the plane normal.
  73362. */
  73363. Plane.prototype.dotCoordinate = function (point) {
  73364. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73365. };
  73366. /**
  73367. * Updates the current Plane from the plane defined by the three given points.
  73368. * @param point1 one of the points used to contruct the plane
  73369. * @param point2 one of the points used to contruct the plane
  73370. * @param point3 one of the points used to contruct the plane
  73371. * @returns the updated Plane.
  73372. */
  73373. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73374. var x1 = point2.x - point1.x;
  73375. var y1 = point2.y - point1.y;
  73376. var z1 = point2.z - point1.z;
  73377. var x2 = point3.x - point1.x;
  73378. var y2 = point3.y - point1.y;
  73379. var z2 = point3.z - point1.z;
  73380. var yz = (y1 * z2) - (z1 * y2);
  73381. var xz = (z1 * x2) - (x1 * z2);
  73382. var xy = (x1 * y2) - (y1 * x2);
  73383. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73384. var invPyth;
  73385. if (pyth !== 0) {
  73386. invPyth = 1.0 / pyth;
  73387. }
  73388. else {
  73389. invPyth = 0.0;
  73390. }
  73391. this.normal.x = yz * invPyth;
  73392. this.normal.y = xz * invPyth;
  73393. this.normal.z = xy * invPyth;
  73394. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73395. return this;
  73396. };
  73397. /**
  73398. * Checks if the plane is facing a given direction
  73399. * @param direction the direction to check if the plane is facing
  73400. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73401. * @returns True is the vector "direction" is the same side than the plane normal.
  73402. */
  73403. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73404. var dot = Vector3.Dot(this.normal, direction);
  73405. return (dot <= epsilon);
  73406. };
  73407. /**
  73408. * Calculates the distance to a point
  73409. * @param point point to calculate distance to
  73410. * @returns the signed distance (float) from the given point to the Plane.
  73411. */
  73412. Plane.prototype.signedDistanceTo = function (point) {
  73413. return Vector3.Dot(point, this.normal) + this.d;
  73414. };
  73415. // Statics
  73416. /**
  73417. * Creates a plane from an array
  73418. * @param array the array to create a plane from
  73419. * @returns a new Plane from the given array.
  73420. */
  73421. Plane.FromArray = function (array) {
  73422. return new Plane(array[0], array[1], array[2], array[3]);
  73423. };
  73424. /**
  73425. * Creates a plane from three points
  73426. * @param point1 point used to create the plane
  73427. * @param point2 point used to create the plane
  73428. * @param point3 point used to create the plane
  73429. * @returns a new Plane defined by the three given points.
  73430. */
  73431. Plane.FromPoints = function (point1, point2, point3) {
  73432. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73433. result.copyFromPoints(point1, point2, point3);
  73434. return result;
  73435. };
  73436. /**
  73437. * Creates a plane from an origin point and a normal
  73438. * @param origin origin of the plane to be constructed
  73439. * @param normal normal of the plane to be constructed
  73440. * @returns a new Plane the normal vector to this plane at the given origin point.
  73441. * Note : the vector "normal" is updated because normalized.
  73442. */
  73443. Plane.FromPositionAndNormal = function (origin, normal) {
  73444. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73445. normal.normalize();
  73446. result.normal = normal;
  73447. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73448. return result;
  73449. };
  73450. /**
  73451. * Calculates the distance from a plane and a point
  73452. * @param origin origin of the plane to be constructed
  73453. * @param normal normal of the plane to be constructed
  73454. * @param point point to calculate distance to
  73455. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73456. */
  73457. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  73458. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73459. return Vector3.Dot(point, normal) + d;
  73460. };
  73461. return Plane;
  73462. }());
  73463. /**
  73464. * Class used to represent a viewport on screen
  73465. */
  73466. var Viewport = /** @class */ (function () {
  73467. /**
  73468. * Creates a Viewport object located at (x, y) and sized (width, height)
  73469. * @param x defines viewport left coordinate
  73470. * @param y defines viewport top coordinate
  73471. * @param width defines the viewport width
  73472. * @param height defines the viewport height
  73473. */
  73474. function Viewport(
  73475. /** viewport left coordinate */
  73476. x,
  73477. /** viewport top coordinate */
  73478. y,
  73479. /**viewport width */
  73480. width,
  73481. /** viewport height */
  73482. height) {
  73483. this.x = x;
  73484. this.y = y;
  73485. this.width = width;
  73486. this.height = height;
  73487. }
  73488. /**
  73489. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73490. * @param renderWidth defines the rendering width
  73491. * @param renderHeight defines the rendering height
  73492. * @returns a new Viewport
  73493. */
  73494. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  73495. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  73496. };
  73497. /**
  73498. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73499. * @param renderWidth defines the rendering width
  73500. * @param renderHeight defines the rendering height
  73501. * @param ref defines the target viewport
  73502. * @returns the current viewport
  73503. */
  73504. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  73505. ref.x = this.x * renderWidth;
  73506. ref.y = this.y * renderHeight;
  73507. ref.width = this.width * renderWidth;
  73508. ref.height = this.height * renderHeight;
  73509. return this;
  73510. };
  73511. /**
  73512. * Returns a new Viewport copied from the current one
  73513. * @returns a new Viewport
  73514. */
  73515. Viewport.prototype.clone = function () {
  73516. return new Viewport(this.x, this.y, this.width, this.height);
  73517. };
  73518. return Viewport;
  73519. }());
  73520. /**
  73521. * Reprasents a camera frustum
  73522. */
  73523. var Frustum = /** @class */ (function () {
  73524. function Frustum() {
  73525. }
  73526. /**
  73527. * Gets the planes representing the frustum
  73528. * @param transform matrix to be applied to the returned planes
  73529. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  73530. */
  73531. Frustum.GetPlanes = function (transform) {
  73532. var frustumPlanes = [];
  73533. for (var index = 0; index < 6; index++) {
  73534. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  73535. }
  73536. Frustum.GetPlanesToRef(transform, frustumPlanes);
  73537. return frustumPlanes;
  73538. };
  73539. /**
  73540. * Gets the near frustum plane transformed by the transform matrix
  73541. * @param transform transformation matrix to be applied to the resulting frustum plane
  73542. * @param frustumPlane the resuling frustum plane
  73543. */
  73544. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  73545. var m = transform.m;
  73546. frustumPlane.normal.x = m[3] + m[2];
  73547. frustumPlane.normal.y = m[7] + m[6];
  73548. frustumPlane.normal.z = m[11] + m[10];
  73549. frustumPlane.d = m[15] + m[14];
  73550. frustumPlane.normalize();
  73551. };
  73552. /**
  73553. * Gets the far frustum plane transformed by the transform matrix
  73554. * @param transform transformation matrix to be applied to the resulting frustum plane
  73555. * @param frustumPlane the resuling frustum plane
  73556. */
  73557. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  73558. var m = transform.m;
  73559. frustumPlane.normal.x = m[3] - m[2];
  73560. frustumPlane.normal.y = m[7] - m[6];
  73561. frustumPlane.normal.z = m[11] - m[10];
  73562. frustumPlane.d = m[15] - m[14];
  73563. frustumPlane.normalize();
  73564. };
  73565. /**
  73566. * Gets the left frustum plane transformed by the transform matrix
  73567. * @param transform transformation matrix to be applied to the resulting frustum plane
  73568. * @param frustumPlane the resuling frustum plane
  73569. */
  73570. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  73571. var m = transform.m;
  73572. frustumPlane.normal.x = m[3] + m[0];
  73573. frustumPlane.normal.y = m[7] + m[4];
  73574. frustumPlane.normal.z = m[11] + m[8];
  73575. frustumPlane.d = m[15] + m[12];
  73576. frustumPlane.normalize();
  73577. };
  73578. /**
  73579. * Gets the right frustum plane transformed by the transform matrix
  73580. * @param transform transformation matrix to be applied to the resulting frustum plane
  73581. * @param frustumPlane the resuling frustum plane
  73582. */
  73583. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73584. var m = transform.m;
  73585. frustumPlane.normal.x = m[3] - m[0];
  73586. frustumPlane.normal.y = m[7] - m[4];
  73587. frustumPlane.normal.z = m[11] - m[8];
  73588. frustumPlane.d = m[15] - m[12];
  73589. frustumPlane.normalize();
  73590. };
  73591. /**
  73592. * Gets the top frustum plane transformed by the transform matrix
  73593. * @param transform transformation matrix to be applied to the resulting frustum plane
  73594. * @param frustumPlane the resuling frustum plane
  73595. */
  73596. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73597. var m = transform.m;
  73598. frustumPlane.normal.x = m[3] - m[1];
  73599. frustumPlane.normal.y = m[7] - m[5];
  73600. frustumPlane.normal.z = m[11] - m[9];
  73601. frustumPlane.d = m[15] - m[13];
  73602. frustumPlane.normalize();
  73603. };
  73604. /**
  73605. * Gets the bottom frustum plane transformed by the transform matrix
  73606. * @param transform transformation matrix to be applied to the resulting frustum plane
  73607. * @param frustumPlane the resuling frustum plane
  73608. */
  73609. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73610. var m = transform.m;
  73611. frustumPlane.normal.x = m[3] + m[1];
  73612. frustumPlane.normal.y = m[7] + m[5];
  73613. frustumPlane.normal.z = m[11] + m[9];
  73614. frustumPlane.d = m[15] + m[13];
  73615. frustumPlane.normalize();
  73616. };
  73617. /**
  73618. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73619. * @param transform transformation matrix to be applied to the resulting frustum planes
  73620. * @param frustumPlanes the resuling frustum planes
  73621. */
  73622. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73623. // Near
  73624. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73625. // Far
  73626. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73627. // Left
  73628. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73629. // Right
  73630. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73631. // Top
  73632. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73633. // Bottom
  73634. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73635. };
  73636. return Frustum;
  73637. }());
  73638. /** Defines supported spaces */
  73639. var Space;
  73640. (function (Space) {
  73641. /** Local (object) space */
  73642. Space[Space["LOCAL"] = 0] = "LOCAL";
  73643. /** World space */
  73644. Space[Space["WORLD"] = 1] = "WORLD";
  73645. /** Bone space */
  73646. Space[Space["BONE"] = 2] = "BONE";
  73647. })(Space || (Space = {}));
  73648. /** Defines the 3 main axes */
  73649. var Axis = /** @class */ (function () {
  73650. function Axis() {
  73651. }
  73652. /** X axis */
  73653. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73654. /** Y axis */
  73655. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73656. /** Z axis */
  73657. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73658. return Axis;
  73659. }());
  73660. /** Class used to represent a Bezier curve */
  73661. var BezierCurve = /** @class */ (function () {
  73662. function BezierCurve() {
  73663. }
  73664. /**
  73665. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73666. * @param t defines the time
  73667. * @param x1 defines the left coordinate on X axis
  73668. * @param y1 defines the left coordinate on Y axis
  73669. * @param x2 defines the right coordinate on X axis
  73670. * @param y2 defines the right coordinate on Y axis
  73671. * @returns the interpolated value
  73672. */
  73673. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73674. // Extract X (which is equal to time here)
  73675. var f0 = 1 - 3 * x2 + 3 * x1;
  73676. var f1 = 3 * x2 - 6 * x1;
  73677. var f2 = 3 * x1;
  73678. var refinedT = t;
  73679. for (var i = 0; i < 5; i++) {
  73680. var refinedT2 = refinedT * refinedT;
  73681. var refinedT3 = refinedT2 * refinedT;
  73682. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73683. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73684. refinedT -= (x - t) * slope;
  73685. refinedT = Math.min(1, Math.max(0, refinedT));
  73686. }
  73687. // Resolve cubic bezier for the given x
  73688. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73689. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73690. Math.pow(refinedT, 3);
  73691. };
  73692. return BezierCurve;
  73693. }());
  73694. /**
  73695. * Defines potential orientation for back face culling
  73696. */
  73697. var Orientation;
  73698. (function (Orientation) {
  73699. /**
  73700. * Clockwise
  73701. */
  73702. Orientation[Orientation["CW"] = 0] = "CW";
  73703. /** Counter clockwise */
  73704. Orientation[Orientation["CCW"] = 1] = "CCW";
  73705. })(Orientation || (Orientation = {}));
  73706. /**
  73707. * Defines angle representation
  73708. */
  73709. var Angle = /** @class */ (function () {
  73710. /**
  73711. * Creates an Angle object of "radians" radians (float).
  73712. * @param radians the angle in radians
  73713. */
  73714. function Angle(radians) {
  73715. this._radians = radians;
  73716. if (this._radians < 0.0) {
  73717. this._radians += (2.0 * Math.PI);
  73718. }
  73719. }
  73720. /**
  73721. * Get value in degrees
  73722. * @returns the Angle value in degrees (float)
  73723. */
  73724. Angle.prototype.degrees = function () {
  73725. return this._radians * 180.0 / Math.PI;
  73726. };
  73727. /**
  73728. * Get value in radians
  73729. * @returns the Angle value in radians (float)
  73730. */
  73731. Angle.prototype.radians = function () {
  73732. return this._radians;
  73733. };
  73734. /**
  73735. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73736. * @param a defines first vector
  73737. * @param b defines second vector
  73738. * @returns a new Angle
  73739. */
  73740. Angle.BetweenTwoPoints = function (a, b) {
  73741. var delta = b.subtract(a);
  73742. var theta = Math.atan2(delta.y, delta.x);
  73743. return new Angle(theta);
  73744. };
  73745. /**
  73746. * Gets a new Angle object from the given float in radians
  73747. * @param radians defines the angle value in radians
  73748. * @returns a new Angle
  73749. */
  73750. Angle.FromRadians = function (radians) {
  73751. return new Angle(radians);
  73752. };
  73753. /**
  73754. * Gets a new Angle object from the given float in degrees
  73755. * @param degrees defines the angle value in degrees
  73756. * @returns a new Angle
  73757. */
  73758. Angle.FromDegrees = function (degrees) {
  73759. return new Angle(degrees * Math.PI / 180.0);
  73760. };
  73761. return Angle;
  73762. }());
  73763. /**
  73764. * This represents an arc in a 2d space.
  73765. */
  73766. var Arc2 = /** @class */ (function () {
  73767. /**
  73768. * Creates an Arc object from the three given points : start, middle and end.
  73769. * @param startPoint Defines the start point of the arc
  73770. * @param midPoint Defines the midlle point of the arc
  73771. * @param endPoint Defines the end point of the arc
  73772. */
  73773. function Arc2(
  73774. /** Defines the start point of the arc */
  73775. startPoint,
  73776. /** Defines the mid point of the arc */
  73777. midPoint,
  73778. /** Defines the end point of the arc */
  73779. endPoint) {
  73780. this.startPoint = startPoint;
  73781. this.midPoint = midPoint;
  73782. this.endPoint = endPoint;
  73783. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73784. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73785. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73786. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73787. this.centerPoint = new Vector2((startToMid * (midPoint.y - endPoint.y) - midToEnd * (startPoint.y - midPoint.y)) / det, ((startPoint.x - midPoint.x) * midToEnd - (midPoint.x - endPoint.x) * startToMid) / det);
  73788. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73789. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73790. var a1 = this.startAngle.degrees();
  73791. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73792. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73793. // angles correction
  73794. if (a2 - a1 > +180.0) {
  73795. a2 -= 360.0;
  73796. }
  73797. if (a2 - a1 < -180.0) {
  73798. a2 += 360.0;
  73799. }
  73800. if (a3 - a2 > +180.0) {
  73801. a3 -= 360.0;
  73802. }
  73803. if (a3 - a2 < -180.0) {
  73804. a3 += 360.0;
  73805. }
  73806. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73807. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73808. }
  73809. return Arc2;
  73810. }());
  73811. /**
  73812. * Represents a 2D path made up of multiple 2D points
  73813. */
  73814. var Path2 = /** @class */ (function () {
  73815. /**
  73816. * Creates a Path2 object from the starting 2D coordinates x and y.
  73817. * @param x the starting points x value
  73818. * @param y the starting points y value
  73819. */
  73820. function Path2(x, y) {
  73821. this._points = new Array();
  73822. this._length = 0.0;
  73823. /**
  73824. * If the path start and end point are the same
  73825. */
  73826. this.closed = false;
  73827. this._points.push(new Vector2(x, y));
  73828. }
  73829. /**
  73830. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73831. * @param x the added points x value
  73832. * @param y the added points y value
  73833. * @returns the updated Path2.
  73834. */
  73835. Path2.prototype.addLineTo = function (x, y) {
  73836. if (this.closed) {
  73837. return this;
  73838. }
  73839. var newPoint = new Vector2(x, y);
  73840. var previousPoint = this._points[this._points.length - 1];
  73841. this._points.push(newPoint);
  73842. this._length += newPoint.subtract(previousPoint).length();
  73843. return this;
  73844. };
  73845. /**
  73846. * 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.
  73847. * @param midX middle point x value
  73848. * @param midY middle point y value
  73849. * @param endX end point x value
  73850. * @param endY end point y value
  73851. * @param numberOfSegments (default: 36)
  73852. * @returns the updated Path2.
  73853. */
  73854. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73855. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73856. if (this.closed) {
  73857. return this;
  73858. }
  73859. var startPoint = this._points[this._points.length - 1];
  73860. var midPoint = new Vector2(midX, midY);
  73861. var endPoint = new Vector2(endX, endY);
  73862. var arc = new Arc2(startPoint, midPoint, endPoint);
  73863. var increment = arc.angle.radians() / numberOfSegments;
  73864. if (arc.orientation === Orientation.CW) {
  73865. increment *= -1;
  73866. }
  73867. var currentAngle = arc.startAngle.radians() + increment;
  73868. for (var i = 0; i < numberOfSegments; i++) {
  73869. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73870. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73871. this.addLineTo(x, y);
  73872. currentAngle += increment;
  73873. }
  73874. return this;
  73875. };
  73876. /**
  73877. * Closes the Path2.
  73878. * @returns the Path2.
  73879. */
  73880. Path2.prototype.close = function () {
  73881. this.closed = true;
  73882. return this;
  73883. };
  73884. /**
  73885. * Gets the sum of the distance between each sequential point in the path
  73886. * @returns the Path2 total length (float).
  73887. */
  73888. Path2.prototype.length = function () {
  73889. var result = this._length;
  73890. if (!this.closed) {
  73891. var lastPoint = this._points[this._points.length - 1];
  73892. var firstPoint = this._points[0];
  73893. result += (firstPoint.subtract(lastPoint).length());
  73894. }
  73895. return result;
  73896. };
  73897. /**
  73898. * Gets the points which construct the path
  73899. * @returns the Path2 internal array of points.
  73900. */
  73901. Path2.prototype.getPoints = function () {
  73902. return this._points;
  73903. };
  73904. /**
  73905. * Retreives the point at the distance aways from the starting point
  73906. * @param normalizedLengthPosition the length along the path to retreive the point from
  73907. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73908. */
  73909. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  73910. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  73911. return Vector2.Zero();
  73912. }
  73913. var lengthPosition = normalizedLengthPosition * this.length();
  73914. var previousOffset = 0;
  73915. for (var i = 0; i < this._points.length; i++) {
  73916. var j = (i + 1) % this._points.length;
  73917. var a = this._points[i];
  73918. var b = this._points[j];
  73919. var bToA = b.subtract(a);
  73920. var nextOffset = (bToA.length() + previousOffset);
  73921. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  73922. var dir = bToA.normalize();
  73923. var localOffset = lengthPosition - previousOffset;
  73924. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  73925. }
  73926. previousOffset = nextOffset;
  73927. }
  73928. return Vector2.Zero();
  73929. };
  73930. /**
  73931. * Creates a new path starting from an x and y position
  73932. * @param x starting x value
  73933. * @param y starting y value
  73934. * @returns a new Path2 starting at the coordinates (x, y).
  73935. */
  73936. Path2.StartingAt = function (x, y) {
  73937. return new Path2(x, y);
  73938. };
  73939. return Path2;
  73940. }());
  73941. /**
  73942. * Represents a 3D path made up of multiple 3D points
  73943. */
  73944. var Path3D = /** @class */ (function () {
  73945. /**
  73946. * new Path3D(path, normal, raw)
  73947. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73948. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73949. * @param path an array of Vector3, the curve axis of the Path3D
  73950. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73951. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73952. */
  73953. function Path3D(
  73954. /**
  73955. * an array of Vector3, the curve axis of the Path3D
  73956. */
  73957. path, firstNormal, raw) {
  73958. if (firstNormal === void 0) { firstNormal = null; }
  73959. this.path = path;
  73960. this._curve = new Array();
  73961. this._distances = new Array();
  73962. this._tangents = new Array();
  73963. this._normals = new Array();
  73964. this._binormals = new Array();
  73965. for (var p = 0; p < path.length; p++) {
  73966. this._curve[p] = path[p].clone(); // hard copy
  73967. }
  73968. this._raw = raw || false;
  73969. this._compute(firstNormal);
  73970. }
  73971. /**
  73972. * Returns the Path3D array of successive Vector3 designing its curve.
  73973. * @returns the Path3D array of successive Vector3 designing its curve.
  73974. */
  73975. Path3D.prototype.getCurve = function () {
  73976. return this._curve;
  73977. };
  73978. /**
  73979. * Returns an array populated with tangent vectors on each Path3D curve point.
  73980. * @returns an array populated with tangent vectors on each Path3D curve point.
  73981. */
  73982. Path3D.prototype.getTangents = function () {
  73983. return this._tangents;
  73984. };
  73985. /**
  73986. * Returns an array populated with normal vectors on each Path3D curve point.
  73987. * @returns an array populated with normal vectors on each Path3D curve point.
  73988. */
  73989. Path3D.prototype.getNormals = function () {
  73990. return this._normals;
  73991. };
  73992. /**
  73993. * Returns an array populated with binormal vectors on each Path3D curve point.
  73994. * @returns an array populated with binormal vectors on each Path3D curve point.
  73995. */
  73996. Path3D.prototype.getBinormals = function () {
  73997. return this._binormals;
  73998. };
  73999. /**
  74000. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74001. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74002. */
  74003. Path3D.prototype.getDistances = function () {
  74004. return this._distances;
  74005. };
  74006. /**
  74007. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74008. * @param path path which all values are copied into the curves points
  74009. * @param firstNormal which should be projected onto the curve
  74010. * @returns the same object updated.
  74011. */
  74012. Path3D.prototype.update = function (path, firstNormal) {
  74013. if (firstNormal === void 0) { firstNormal = null; }
  74014. for (var p = 0; p < path.length; p++) {
  74015. this._curve[p].x = path[p].x;
  74016. this._curve[p].y = path[p].y;
  74017. this._curve[p].z = path[p].z;
  74018. }
  74019. this._compute(firstNormal);
  74020. return this;
  74021. };
  74022. // private function compute() : computes tangents, normals and binormals
  74023. Path3D.prototype._compute = function (firstNormal) {
  74024. var l = this._curve.length;
  74025. // first and last tangents
  74026. this._tangents[0] = this._getFirstNonNullVector(0);
  74027. if (!this._raw) {
  74028. this._tangents[0].normalize();
  74029. }
  74030. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  74031. if (!this._raw) {
  74032. this._tangents[l - 1].normalize();
  74033. }
  74034. // normals and binormals at first point : arbitrary vector with _normalVector()
  74035. var tg0 = this._tangents[0];
  74036. var pp0 = this._normalVector(tg0, firstNormal);
  74037. this._normals[0] = pp0;
  74038. if (!this._raw) {
  74039. this._normals[0].normalize();
  74040. }
  74041. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  74042. if (!this._raw) {
  74043. this._binormals[0].normalize();
  74044. }
  74045. this._distances[0] = 0.0;
  74046. // normals and binormals : next points
  74047. var prev; // previous vector (segment)
  74048. var cur; // current vector (segment)
  74049. var curTang; // current tangent
  74050. // previous normal
  74051. var prevBinor; // previous binormal
  74052. for (var i = 1; i < l; i++) {
  74053. // tangents
  74054. prev = this._getLastNonNullVector(i);
  74055. if (i < l - 1) {
  74056. cur = this._getFirstNonNullVector(i);
  74057. this._tangents[i] = prev.add(cur);
  74058. this._tangents[i].normalize();
  74059. }
  74060. this._distances[i] = this._distances[i - 1] + prev.length();
  74061. // normals and binormals
  74062. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  74063. curTang = this._tangents[i];
  74064. prevBinor = this._binormals[i - 1];
  74065. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  74066. if (!this._raw) {
  74067. this._normals[i].normalize();
  74068. }
  74069. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  74070. if (!this._raw) {
  74071. this._binormals[i].normalize();
  74072. }
  74073. }
  74074. };
  74075. // private function getFirstNonNullVector(index)
  74076. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  74077. Path3D.prototype._getFirstNonNullVector = function (index) {
  74078. var i = 1;
  74079. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  74080. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  74081. i++;
  74082. nNVector = this._curve[index + i].subtract(this._curve[index]);
  74083. }
  74084. return nNVector;
  74085. };
  74086. // private function getLastNonNullVector(index)
  74087. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  74088. Path3D.prototype._getLastNonNullVector = function (index) {
  74089. var i = 1;
  74090. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  74091. while (nLVector.length() === 0 && index > i + 1) {
  74092. i++;
  74093. nLVector = this._curve[index].subtract(this._curve[index - i]);
  74094. }
  74095. return nLVector;
  74096. };
  74097. // private function normalVector(v0, vt, va) :
  74098. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  74099. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  74100. Path3D.prototype._normalVector = function (vt, va) {
  74101. var normal0;
  74102. var tgl = vt.length();
  74103. if (tgl === 0.0) {
  74104. tgl = 1.0;
  74105. }
  74106. if (va === undefined || va === null) {
  74107. var point;
  74108. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  74109. point = new Vector3(0.0, -1.0, 0.0);
  74110. }
  74111. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  74112. point = new Vector3(1.0, 0.0, 0.0);
  74113. }
  74114. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  74115. point = new Vector3(0.0, 0.0, 1.0);
  74116. }
  74117. else {
  74118. point = Vector3.Zero();
  74119. }
  74120. normal0 = Vector3.Cross(vt, point);
  74121. }
  74122. else {
  74123. normal0 = Vector3.Cross(vt, va);
  74124. Vector3.CrossToRef(normal0, vt, normal0);
  74125. }
  74126. normal0.normalize();
  74127. return normal0;
  74128. };
  74129. return Path3D;
  74130. }());
  74131. /**
  74132. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74133. * A Curve3 is designed from a series of successive Vector3.
  74134. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74135. */
  74136. var Curve3 = /** @class */ (function () {
  74137. /**
  74138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74139. * A Curve3 is designed from a series of successive Vector3.
  74140. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74141. * @param points points which make up the curve
  74142. */
  74143. function Curve3(points) {
  74144. this._length = 0.0;
  74145. this._points = points;
  74146. this._length = this._computeLength(points);
  74147. }
  74148. /**
  74149. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74150. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74151. * @param v1 (Vector3) the control point
  74152. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74153. * @param nbPoints (integer) the wanted number of points in the curve
  74154. * @returns the created Curve3
  74155. */
  74156. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  74157. nbPoints = nbPoints > 2 ? nbPoints : 3;
  74158. var bez = new Array();
  74159. var equation = function (t, val0, val1, val2) {
  74160. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  74161. return res;
  74162. };
  74163. for (var i = 0; i <= nbPoints; i++) {
  74164. bez.push(new Vector3(equation(i / nbPoints, v0.x, v1.x, v2.x), equation(i / nbPoints, v0.y, v1.y, v2.y), equation(i / nbPoints, v0.z, v1.z, v2.z)));
  74165. }
  74166. return new Curve3(bez);
  74167. };
  74168. /**
  74169. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74170. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74171. * @param v1 (Vector3) the first control point
  74172. * @param v2 (Vector3) the second control point
  74173. * @param v3 (Vector3) the end point of the Cubic Bezier
  74174. * @param nbPoints (integer) the wanted number of points in the curve
  74175. * @returns the created Curve3
  74176. */
  74177. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  74178. nbPoints = nbPoints > 3 ? nbPoints : 4;
  74179. var bez = new Array();
  74180. var equation = function (t, val0, val1, val2, val3) {
  74181. 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;
  74182. return res;
  74183. };
  74184. for (var i = 0; i <= nbPoints; i++) {
  74185. bez.push(new Vector3(equation(i / nbPoints, v0.x, v1.x, v2.x, v3.x), equation(i / nbPoints, v0.y, v1.y, v2.y, v3.y), equation(i / nbPoints, v0.z, v1.z, v2.z, v3.z)));
  74186. }
  74187. return new Curve3(bez);
  74188. };
  74189. /**
  74190. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74191. * @param p1 (Vector3) the origin point of the Hermite Spline
  74192. * @param t1 (Vector3) the tangent vector at the origin point
  74193. * @param p2 (Vector3) the end point of the Hermite Spline
  74194. * @param t2 (Vector3) the tangent vector at the end point
  74195. * @param nbPoints (integer) the wanted number of points in the curve
  74196. * @returns the created Curve3
  74197. */
  74198. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74199. var hermite = new Array();
  74200. var step = 1.0 / nbPoints;
  74201. for (var i = 0; i <= nbPoints; i++) {
  74202. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74203. }
  74204. return new Curve3(hermite);
  74205. };
  74206. /**
  74207. * Returns a Curve3 object along a CatmullRom Spline curve :
  74208. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74209. * @param nbPoints (integer) the wanted number of points between each curve control points
  74210. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74211. * @returns the created Curve3
  74212. */
  74213. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74214. var catmullRom = new Array();
  74215. var step = 1.0 / nbPoints;
  74216. var amount = 0.0;
  74217. if (closed) {
  74218. var pointsCount = points.length;
  74219. for (var i = 0; i < pointsCount; i++) {
  74220. amount = 0;
  74221. for (var c = 0; c < nbPoints; c++) {
  74222. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74223. amount += step;
  74224. }
  74225. }
  74226. catmullRom.push(catmullRom[0]);
  74227. }
  74228. else {
  74229. var totalPoints = new Array();
  74230. totalPoints.push(points[0].clone());
  74231. Array.prototype.push.apply(totalPoints, points);
  74232. totalPoints.push(points[points.length - 1].clone());
  74233. for (var i = 0; i < totalPoints.length - 3; i++) {
  74234. amount = 0;
  74235. for (var c = 0; c < nbPoints; c++) {
  74236. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74237. amount += step;
  74238. }
  74239. }
  74240. i--;
  74241. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74242. }
  74243. return new Curve3(catmullRom);
  74244. };
  74245. /**
  74246. * @returns the Curve3 stored array of successive Vector3
  74247. */
  74248. Curve3.prototype.getPoints = function () {
  74249. return this._points;
  74250. };
  74251. /**
  74252. * @returns the computed length (float) of the curve.
  74253. */
  74254. Curve3.prototype.length = function () {
  74255. return this._length;
  74256. };
  74257. /**
  74258. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74259. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74260. * curveA and curveB keep unchanged.
  74261. * @param curve the curve to continue from this curve
  74262. * @returns the newly constructed curve
  74263. */
  74264. Curve3.prototype.continue = function (curve) {
  74265. var lastPoint = this._points[this._points.length - 1];
  74266. var continuedPoints = this._points.slice();
  74267. var curvePoints = curve.getPoints();
  74268. for (var i = 1; i < curvePoints.length; i++) {
  74269. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74270. }
  74271. var continuedCurve = new Curve3(continuedPoints);
  74272. return continuedCurve;
  74273. };
  74274. Curve3.prototype._computeLength = function (path) {
  74275. var l = 0;
  74276. for (var i = 1; i < path.length; i++) {
  74277. l += (path[i].subtract(path[i - 1])).length();
  74278. }
  74279. return l;
  74280. };
  74281. return Curve3;
  74282. }());
  74283. // Vertex formats
  74284. /**
  74285. * Contains position and normal vectors for a vertex
  74286. */
  74287. var PositionNormalVertex = /** @class */ (function () {
  74288. /**
  74289. * Creates a PositionNormalVertex
  74290. * @param position the position of the vertex (defaut: 0,0,0)
  74291. * @param normal the normal of the vertex (defaut: 0,1,0)
  74292. */
  74293. function PositionNormalVertex(
  74294. /** the position of the vertex (defaut: 0,0,0) */
  74295. position,
  74296. /** the normal of the vertex (defaut: 0,1,0) */
  74297. normal) {
  74298. if (position === void 0) { position = Vector3.Zero(); }
  74299. if (normal === void 0) { normal = Vector3.Up(); }
  74300. this.position = position;
  74301. this.normal = normal;
  74302. }
  74303. /**
  74304. * Clones the PositionNormalVertex
  74305. * @returns the cloned PositionNormalVertex
  74306. */
  74307. PositionNormalVertex.prototype.clone = function () {
  74308. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74309. };
  74310. return PositionNormalVertex;
  74311. }());
  74312. /**
  74313. * Contains position, normal and uv vectors for a vertex
  74314. */
  74315. var PositionNormalTextureVertex = /** @class */ (function () {
  74316. /**
  74317. * Creates a PositionNormalTextureVertex
  74318. * @param position the position of the vertex (defaut: 0,0,0)
  74319. * @param normal the normal of the vertex (defaut: 0,1,0)
  74320. * @param uv the uv of the vertex (default: 0,0)
  74321. */
  74322. function PositionNormalTextureVertex(
  74323. /** the position of the vertex (defaut: 0,0,0) */
  74324. position,
  74325. /** the normal of the vertex (defaut: 0,1,0) */
  74326. normal,
  74327. /** the uv of the vertex (default: 0,0) */
  74328. uv) {
  74329. if (position === void 0) { position = Vector3.Zero(); }
  74330. if (normal === void 0) { normal = Vector3.Up(); }
  74331. if (uv === void 0) { uv = Vector2.Zero(); }
  74332. this.position = position;
  74333. this.normal = normal;
  74334. this.uv = uv;
  74335. }
  74336. /**
  74337. * Clones the PositionNormalTextureVertex
  74338. * @returns the cloned PositionNormalTextureVertex
  74339. */
  74340. PositionNormalTextureVertex.prototype.clone = function () {
  74341. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74342. };
  74343. return PositionNormalTextureVertex;
  74344. }());
  74345. // Temporary pre-allocated objects for engine internal use
  74346. // usage in any internal function :
  74347. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74348. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74349. /**
  74350. * @hidden
  74351. */
  74352. var Tmp = /** @class */ (function () {
  74353. function Tmp() {
  74354. }
  74355. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74356. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74357. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74358. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74359. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74360. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74361. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74362. return Tmp;
  74363. }());
  74364. /**
  74365. * @hidden
  74366. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74367. */
  74368. var MathTmp = /** @class */ (function () {
  74369. function MathTmp() {
  74370. }
  74371. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74372. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74373. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74374. return MathTmp;
  74375. }());
  74376. /***/ }),
  74377. /***/ "./Maths/sphericalPolynomial.ts":
  74378. /*!**************************************!*\
  74379. !*** ./Maths/sphericalPolynomial.ts ***!
  74380. \**************************************/
  74381. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74383. "use strict";
  74384. __webpack_require__.r(__webpack_exports__);
  74385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74387. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74388. /**
  74389. * Class representing spherical polynomial coefficients to the 3rd degree
  74390. */
  74391. var SphericalPolynomial = /** @class */ (function () {
  74392. function SphericalPolynomial() {
  74393. /**
  74394. * The x coefficients of the spherical polynomial
  74395. */
  74396. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74397. /**
  74398. * The y coefficients of the spherical polynomial
  74399. */
  74400. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74401. /**
  74402. * The z coefficients of the spherical polynomial
  74403. */
  74404. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74405. /**
  74406. * The xx coefficients of the spherical polynomial
  74407. */
  74408. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74409. /**
  74410. * The yy coefficients of the spherical polynomial
  74411. */
  74412. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74413. /**
  74414. * The zz coefficients of the spherical polynomial
  74415. */
  74416. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74417. /**
  74418. * The xy coefficients of the spherical polynomial
  74419. */
  74420. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74421. /**
  74422. * The yz coefficients of the spherical polynomial
  74423. */
  74424. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74425. /**
  74426. * The zx coefficients of the spherical polynomial
  74427. */
  74428. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74429. }
  74430. /**
  74431. * Adds an ambient color to the spherical polynomial
  74432. * @param color the color to add
  74433. */
  74434. SphericalPolynomial.prototype.addAmbient = function (color) {
  74435. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74436. this.xx = this.xx.add(colorVector);
  74437. this.yy = this.yy.add(colorVector);
  74438. this.zz = this.zz.add(colorVector);
  74439. };
  74440. /**
  74441. * Scales the spherical polynomial by the given amount
  74442. * @param scale the amount to scale
  74443. */
  74444. SphericalPolynomial.prototype.scale = function (scale) {
  74445. this.x = this.x.scale(scale);
  74446. this.y = this.y.scale(scale);
  74447. this.z = this.z.scale(scale);
  74448. this.xx = this.xx.scale(scale);
  74449. this.yy = this.yy.scale(scale);
  74450. this.zz = this.zz.scale(scale);
  74451. this.yz = this.yz.scale(scale);
  74452. this.zx = this.zx.scale(scale);
  74453. this.xy = this.xy.scale(scale);
  74454. };
  74455. /**
  74456. * Gets the spherical polynomial from harmonics
  74457. * @param harmonics the spherical harmonics
  74458. * @returns the spherical polynomial
  74459. */
  74460. SphericalPolynomial.FromHarmonics = function (harmonics) {
  74461. var result = new SphericalPolynomial();
  74462. result.x = harmonics.l11.scale(1.02333);
  74463. result.y = harmonics.l1_1.scale(1.02333);
  74464. result.z = harmonics.l10.scale(1.02333);
  74465. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  74466. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  74467. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  74468. result.yz = harmonics.l2_1.scale(0.858086);
  74469. result.zx = harmonics.l21.scale(0.858086);
  74470. result.xy = harmonics.l2_2.scale(0.858086);
  74471. result.scale(1.0 / Math.PI);
  74472. return result;
  74473. };
  74474. /**
  74475. * Constructs a spherical polynomial from an array.
  74476. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  74477. * @returns the spherical polynomial
  74478. */
  74479. SphericalPolynomial.FromArray = function (data) {
  74480. var sp = new SphericalPolynomial();
  74481. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  74482. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  74483. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  74484. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  74485. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  74486. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  74487. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  74488. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  74489. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  74490. return sp;
  74491. };
  74492. return SphericalPolynomial;
  74493. }());
  74494. /**
  74495. * Class representing spherical harmonics coefficients to the 3rd degree
  74496. */
  74497. var SphericalHarmonics = /** @class */ (function () {
  74498. function SphericalHarmonics() {
  74499. /**
  74500. * The l0,0 coefficients of the spherical harmonics
  74501. */
  74502. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74503. /**
  74504. * The l1,-1 coefficients of the spherical harmonics
  74505. */
  74506. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74507. /**
  74508. * The l1,0 coefficients of the spherical harmonics
  74509. */
  74510. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74511. /**
  74512. * The l1,1 coefficients of the spherical harmonics
  74513. */
  74514. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74515. /**
  74516. * The l2,-2 coefficients of the spherical harmonics
  74517. */
  74518. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74519. /**
  74520. * The l2,-1 coefficients of the spherical harmonics
  74521. */
  74522. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74523. /**
  74524. * The l2,0 coefficients of the spherical harmonics
  74525. */
  74526. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74527. /**
  74528. * The l2,1 coefficients of the spherical harmonics
  74529. */
  74530. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74531. /**
  74532. * The l2,2 coefficients of the spherical harmonics
  74533. */
  74534. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74535. }
  74536. /**
  74537. * Adds a light to the spherical harmonics
  74538. * @param direction the direction of the light
  74539. * @param color the color of the light
  74540. * @param deltaSolidAngle the delta solid angle of the light
  74541. */
  74542. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  74543. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74544. var c = colorVector.scale(deltaSolidAngle);
  74545. this.l00 = this.l00.add(c.scale(0.282095));
  74546. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  74547. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  74548. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  74549. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  74550. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  74551. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  74552. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  74553. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  74554. };
  74555. /**
  74556. * Scales the spherical harmonics by the given amount
  74557. * @param scale the amount to scale
  74558. */
  74559. SphericalHarmonics.prototype.scale = function (scale) {
  74560. this.l00 = this.l00.scale(scale);
  74561. this.l1_1 = this.l1_1.scale(scale);
  74562. this.l10 = this.l10.scale(scale);
  74563. this.l11 = this.l11.scale(scale);
  74564. this.l2_2 = this.l2_2.scale(scale);
  74565. this.l2_1 = this.l2_1.scale(scale);
  74566. this.l20 = this.l20.scale(scale);
  74567. this.l21 = this.l21.scale(scale);
  74568. this.lL22 = this.lL22.scale(scale);
  74569. };
  74570. /**
  74571. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  74572. *
  74573. * ```
  74574. * E_lm = A_l * L_lm
  74575. * ```
  74576. *
  74577. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  74578. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  74579. * the scaling factors are given in equation 9.
  74580. */
  74581. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  74582. // Constant (Band 0)
  74583. this.l00 = this.l00.scale(3.141593);
  74584. // Linear (Band 1)
  74585. this.l1_1 = this.l1_1.scale(2.094395);
  74586. this.l10 = this.l10.scale(2.094395);
  74587. this.l11 = this.l11.scale(2.094395);
  74588. // Quadratic (Band 2)
  74589. this.l2_2 = this.l2_2.scale(0.785398);
  74590. this.l2_1 = this.l2_1.scale(0.785398);
  74591. this.l20 = this.l20.scale(0.785398);
  74592. this.l21 = this.l21.scale(0.785398);
  74593. this.lL22 = this.lL22.scale(0.785398);
  74594. };
  74595. /**
  74596. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74597. *
  74598. * ```
  74599. * L = (1/pi) * E * rho
  74600. * ```
  74601. *
  74602. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74603. */
  74604. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74605. this.scale(1.0 / Math.PI);
  74606. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74607. // (The pixel shader must apply albedo after texture fetches, etc).
  74608. };
  74609. /**
  74610. * Gets the spherical harmonics from polynomial
  74611. * @param polynomial the spherical polynomial
  74612. * @returns the spherical harmonics
  74613. */
  74614. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74615. var result = new SphericalHarmonics();
  74616. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74617. result.l1_1 = polynomial.y.scale(0.977204);
  74618. result.l10 = polynomial.z.scale(0.977204);
  74619. result.l11 = polynomial.x.scale(0.977204);
  74620. result.l2_2 = polynomial.xy.scale(1.16538);
  74621. result.l2_1 = polynomial.yz.scale(1.16538);
  74622. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74623. result.l21 = polynomial.zx.scale(1.16538);
  74624. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74625. result.scale(Math.PI);
  74626. return result;
  74627. };
  74628. /**
  74629. * Constructs a spherical harmonics from an array.
  74630. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74631. * @returns the spherical harmonics
  74632. */
  74633. SphericalHarmonics.FromArray = function (data) {
  74634. var sh = new SphericalHarmonics();
  74635. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74636. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74637. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74638. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74639. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74640. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74641. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74642. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74643. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74644. return sh;
  74645. };
  74646. return SphericalHarmonics;
  74647. }());
  74648. /***/ }),
  74649. /***/ "./Meshes/Builders/boxBuilder.ts":
  74650. /*!***************************************!*\
  74651. !*** ./Meshes/Builders/boxBuilder.ts ***!
  74652. \***************************************/
  74653. /*! exports provided: BoxBuilder */
  74654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74655. "use strict";
  74656. __webpack_require__.r(__webpack_exports__);
  74657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  74658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74659. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74660. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74661. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  74662. var normalsSource = [
  74663. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  74664. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  74665. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  74666. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  74667. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  74668. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  74669. ];
  74670. var indices = [];
  74671. var positions = [];
  74672. var normals = [];
  74673. var uvs = [];
  74674. var width = options.width || options.size || 1;
  74675. var height = options.height || options.size || 1;
  74676. var depth = options.depth || options.size || 1;
  74677. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74678. var faceUV = options.faceUV || new Array(6);
  74679. var faceColors = options.faceColors;
  74680. var colors = [];
  74681. // default face colors and UV if undefined
  74682. for (var f = 0; f < 6; f++) {
  74683. if (faceUV[f] === undefined) {
  74684. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74685. }
  74686. if (faceColors && faceColors[f] === undefined) {
  74687. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74688. }
  74689. }
  74690. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  74691. // Create each face in turn.
  74692. for (var index = 0; index < normalsSource.length; index++) {
  74693. var normal = normalsSource[index];
  74694. // Get two vectors perpendicular to the face normal and to each other.
  74695. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  74696. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  74697. // Six indices (two triangles) per face.
  74698. var verticesLength = positions.length / 3;
  74699. indices.push(verticesLength);
  74700. indices.push(verticesLength + 1);
  74701. indices.push(verticesLength + 2);
  74702. indices.push(verticesLength);
  74703. indices.push(verticesLength + 2);
  74704. indices.push(verticesLength + 3);
  74705. // Four vertices per face.
  74706. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  74707. positions.push(vertex.x, vertex.y, vertex.z);
  74708. normals.push(normal.x, normal.y, normal.z);
  74709. uvs.push(faceUV[index].z, faceUV[index].w);
  74710. if (faceColors) {
  74711. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74712. }
  74713. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  74714. positions.push(vertex.x, vertex.y, vertex.z);
  74715. normals.push(normal.x, normal.y, normal.z);
  74716. uvs.push(faceUV[index].x, faceUV[index].w);
  74717. if (faceColors) {
  74718. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74719. }
  74720. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  74721. positions.push(vertex.x, vertex.y, vertex.z);
  74722. normals.push(normal.x, normal.y, normal.z);
  74723. uvs.push(faceUV[index].x, faceUV[index].y);
  74724. if (faceColors) {
  74725. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74726. }
  74727. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  74728. positions.push(vertex.x, vertex.y, vertex.z);
  74729. normals.push(normal.x, normal.y, normal.z);
  74730. uvs.push(faceUV[index].z, faceUV[index].y);
  74731. if (faceColors) {
  74732. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74733. }
  74734. }
  74735. // sides
  74736. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74737. // Result
  74738. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74739. vertexData.indices = indices;
  74740. vertexData.positions = positions;
  74741. vertexData.normals = normals;
  74742. vertexData.uvs = uvs;
  74743. if (faceColors) {
  74744. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  74745. vertexData.colors = totalColors;
  74746. }
  74747. return vertexData;
  74748. };
  74749. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  74750. if (scene === void 0) { scene = null; }
  74751. var options = {
  74752. size: size,
  74753. sideOrientation: sideOrientation,
  74754. updatable: updatable
  74755. };
  74756. return BoxBuilder.CreateBox(name, options, scene);
  74757. };
  74758. /**
  74759. * Class containing static functions to help procedurally build meshes
  74760. */
  74761. var BoxBuilder = /** @class */ (function () {
  74762. function BoxBuilder() {
  74763. }
  74764. /**
  74765. * Creates a box mesh
  74766. * * The parameter `size` sets the size (float) of each box side (default 1)
  74767. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74768. * * 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)
  74769. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74771. * * 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
  74772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74773. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74774. * @param name defines the name of the mesh
  74775. * @param options defines the options used to create the mesh
  74776. * @param scene defines the hosting scene
  74777. * @returns the box mesh
  74778. */
  74779. BoxBuilder.CreateBox = function (name, options, scene) {
  74780. if (scene === void 0) { scene = null; }
  74781. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74782. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74783. box._originalBuilderSideOrientation = options.sideOrientation;
  74784. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  74785. vertexData.applyToMesh(box, options.updatable);
  74786. return box;
  74787. };
  74788. return BoxBuilder;
  74789. }());
  74790. /***/ }),
  74791. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  74792. /*!********************************************!*\
  74793. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  74794. \********************************************/
  74795. /*! exports provided: CylinderBuilder */
  74796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74797. "use strict";
  74798. __webpack_require__.r(__webpack_exports__);
  74799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  74800. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74801. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74802. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74803. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  74804. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  74805. var height = options.height || 2;
  74806. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  74807. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  74808. var tessellation = options.tessellation || 24;
  74809. var subdivisions = options.subdivisions || 1;
  74810. var hasRings = options.hasRings ? true : false;
  74811. var enclose = options.enclose ? true : false;
  74812. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  74813. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74814. var faceUV = options.faceUV || new Array(3);
  74815. var faceColors = options.faceColors;
  74816. // default face colors and UV if undefined
  74817. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  74818. var ringNb = (hasRings) ? subdivisions : 1;
  74819. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  74820. var f;
  74821. for (f = 0; f < surfaceNb; f++) {
  74822. if (faceColors && faceColors[f] === undefined) {
  74823. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74824. }
  74825. }
  74826. for (f = 0; f < surfaceNb; f++) {
  74827. if (faceUV && faceUV[f] === undefined) {
  74828. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74829. }
  74830. }
  74831. var indices = new Array();
  74832. var positions = new Array();
  74833. var normals = new Array();
  74834. var uvs = new Array();
  74835. var colors = new Array();
  74836. var angle_step = Math.PI * 2 * arc / tessellation;
  74837. var angle;
  74838. var h;
  74839. var radius;
  74840. var tan = (diameterBottom - diameterTop) / 2 / height;
  74841. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74842. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74843. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74844. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74845. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74846. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  74847. // positions, normals, uvs
  74848. var i;
  74849. var j;
  74850. var r;
  74851. var ringIdx = 1;
  74852. var s = 1; // surface index
  74853. var cs = 0;
  74854. var v = 0;
  74855. for (i = 0; i <= subdivisions; i++) {
  74856. h = i / subdivisions;
  74857. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  74858. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  74859. for (r = 0; r < ringIdx; r++) {
  74860. if (hasRings) {
  74861. s += r;
  74862. }
  74863. if (enclose) {
  74864. s += 2 * r;
  74865. }
  74866. for (j = 0; j <= tessellation; j++) {
  74867. angle = j * angle_step;
  74868. // position
  74869. ringVertex.x = Math.cos(-angle) * radius;
  74870. ringVertex.y = -height / 2 + h * height;
  74871. ringVertex.z = Math.sin(-angle) * radius;
  74872. // normal
  74873. if (diameterTop === 0 && i === subdivisions) {
  74874. // if no top cap, reuse former normals
  74875. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  74876. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  74877. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  74878. }
  74879. else {
  74880. ringNormal.x = ringVertex.x;
  74881. ringNormal.z = ringVertex.z;
  74882. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  74883. ringNormal.normalize();
  74884. }
  74885. // keep first ring vertex values for enclose
  74886. if (j === 0) {
  74887. ringFirstVertex.copyFrom(ringVertex);
  74888. ringFirstNormal.copyFrom(ringNormal);
  74889. }
  74890. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  74891. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  74892. if (hasRings) {
  74893. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  74894. }
  74895. else {
  74896. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  74897. }
  74898. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  74899. if (faceColors) {
  74900. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  74901. }
  74902. }
  74903. // if enclose, add four vertices and their dedicated normals
  74904. if (arc !== 1 && enclose) {
  74905. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  74906. positions.push(0, ringVertex.y, 0);
  74907. positions.push(0, ringVertex.y, 0);
  74908. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  74909. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  74910. quadNormal.normalize();
  74911. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  74912. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  74913. quadNormal.normalize();
  74914. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  74915. if (hasRings) {
  74916. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  74917. }
  74918. else {
  74919. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  74920. }
  74921. uvs.push(faceUV[s + 1].x, v);
  74922. uvs.push(faceUV[s + 1].z, v);
  74923. if (hasRings) {
  74924. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  74925. }
  74926. else {
  74927. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  74928. }
  74929. uvs.push(faceUV[s + 2].x, v);
  74930. uvs.push(faceUV[s + 2].z, v);
  74931. if (faceColors) {
  74932. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  74933. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  74934. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  74935. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  74936. }
  74937. }
  74938. if (cs !== s) {
  74939. cs = s;
  74940. }
  74941. }
  74942. }
  74943. // indices
  74944. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  74945. var s;
  74946. i = 0;
  74947. for (s = 0; s < subdivisions; s++) {
  74948. var i0 = 0;
  74949. var i1 = 0;
  74950. var i2 = 0;
  74951. var i3 = 0;
  74952. for (j = 0; j < tessellation; j++) {
  74953. i0 = i * (e + 1) + j;
  74954. i1 = (i + 1) * (e + 1) + j;
  74955. i2 = i * (e + 1) + (j + 1);
  74956. i3 = (i + 1) * (e + 1) + (j + 1);
  74957. indices.push(i0, i1, i2);
  74958. indices.push(i3, i2, i1);
  74959. }
  74960. if (arc !== 1 && enclose) { // if enclose, add two quads
  74961. indices.push(i0 + 2, i1 + 2, i2 + 2);
  74962. indices.push(i3 + 2, i2 + 2, i1 + 2);
  74963. indices.push(i0 + 4, i1 + 4, i2 + 4);
  74964. indices.push(i3 + 4, i2 + 4, i1 + 4);
  74965. }
  74966. i = (hasRings) ? (i + 2) : (i + 1);
  74967. }
  74968. // Caps
  74969. var createCylinderCap = function (isTop) {
  74970. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  74971. if (radius === 0) {
  74972. return;
  74973. }
  74974. // Cap positions, normals & uvs
  74975. var angle;
  74976. var circleVector;
  74977. var i;
  74978. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  74979. var c = null;
  74980. if (faceColors) {
  74981. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  74982. }
  74983. // cap center
  74984. var vbase = positions.length / 3;
  74985. var offset = isTop ? height / 2 : -height / 2;
  74986. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  74987. positions.push(center.x, center.y, center.z);
  74988. normals.push(0, isTop ? 1 : -1, 0);
  74989. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  74990. if (c) {
  74991. colors.push(c.r, c.g, c.b, c.a);
  74992. }
  74993. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  74994. for (i = 0; i <= tessellation; i++) {
  74995. angle = Math.PI * 2 * i * arc / tessellation;
  74996. var cos = Math.cos(-angle);
  74997. var sin = Math.sin(-angle);
  74998. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  74999. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  75000. positions.push(circleVector.x, circleVector.y, circleVector.z);
  75001. normals.push(0, isTop ? 1 : -1, 0);
  75002. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  75003. if (c) {
  75004. colors.push(c.r, c.g, c.b, c.a);
  75005. }
  75006. }
  75007. // Cap indices
  75008. for (i = 0; i < tessellation; i++) {
  75009. if (!isTop) {
  75010. indices.push(vbase);
  75011. indices.push(vbase + (i + 1));
  75012. indices.push(vbase + (i + 2));
  75013. }
  75014. else {
  75015. indices.push(vbase);
  75016. indices.push(vbase + (i + 2));
  75017. indices.push(vbase + (i + 1));
  75018. }
  75019. }
  75020. };
  75021. // add caps to geometry
  75022. createCylinderCap(false);
  75023. createCylinderCap(true);
  75024. // Sides
  75025. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75026. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75027. vertexData.indices = indices;
  75028. vertexData.positions = positions;
  75029. vertexData.normals = normals;
  75030. vertexData.uvs = uvs;
  75031. if (faceColors) {
  75032. vertexData.colors = colors;
  75033. }
  75034. return vertexData;
  75035. };
  75036. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  75037. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  75038. if (scene !== undefined) {
  75039. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  75040. updatable = scene;
  75041. }
  75042. scene = subdivisions;
  75043. subdivisions = 1;
  75044. }
  75045. var options = {
  75046. height: height,
  75047. diameterTop: diameterTop,
  75048. diameterBottom: diameterBottom,
  75049. tessellation: tessellation,
  75050. subdivisions: subdivisions,
  75051. sideOrientation: sideOrientation,
  75052. updatable: updatable
  75053. };
  75054. return CylinderBuilder.CreateCylinder(name, options, scene);
  75055. };
  75056. /**
  75057. * Class containing static functions to help procedurally build meshes
  75058. */
  75059. var CylinderBuilder = /** @class */ (function () {
  75060. function CylinderBuilder() {
  75061. }
  75062. /**
  75063. * Creates a cylinder or a cone mesh
  75064. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  75065. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  75066. * * 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.
  75067. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  75068. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  75069. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  75070. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  75071. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  75072. * * 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).
  75073. * * 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
  75074. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  75075. * * 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
  75076. * * 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.
  75077. * * If `enclose` is false, a ring surface is one element.
  75078. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  75079. * * 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
  75080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75081. * * 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
  75082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75083. * @param name defines the name of the mesh
  75084. * @param options defines the options used to create the mesh
  75085. * @param scene defines the hosting scene
  75086. * @returns the cylinder mesh
  75087. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  75088. */
  75089. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  75090. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75091. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75092. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  75093. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  75094. vertexData.applyToMesh(cylinder, options.updatable);
  75095. return cylinder;
  75096. };
  75097. return CylinderBuilder;
  75098. }());
  75099. /***/ }),
  75100. /***/ "./Meshes/Builders/decalBuilder.ts":
  75101. /*!*****************************************!*\
  75102. !*** ./Meshes/Builders/decalBuilder.ts ***!
  75103. \*****************************************/
  75104. /*! exports provided: DecalBuilder */
  75105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75106. "use strict";
  75107. __webpack_require__.r(__webpack_exports__);
  75108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  75109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75110. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75111. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  75112. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75113. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  75114. var options = {
  75115. position: position,
  75116. normal: normal,
  75117. size: size,
  75118. angle: angle
  75119. };
  75120. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  75121. };
  75122. /**
  75123. * Class containing static functions to help procedurally build meshes
  75124. */
  75125. var DecalBuilder = /** @class */ (function () {
  75126. function DecalBuilder() {
  75127. }
  75128. /**
  75129. * Creates a decal mesh.
  75130. * 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
  75131. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  75132. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  75133. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  75134. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  75135. * @param name defines the name of the mesh
  75136. * @param sourceMesh defines the mesh where the decal must be applied
  75137. * @param options defines the options used to create the mesh
  75138. * @param scene defines the hosting scene
  75139. * @returns the decal mesh
  75140. * @see https://doc.babylonjs.com/how_to/decals
  75141. */
  75142. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  75143. var indices = sourceMesh.getIndices();
  75144. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  75145. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  75146. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75147. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  75148. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  75149. var angle = options.angle || 0;
  75150. // Getting correct rotation
  75151. if (!normal) {
  75152. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  75153. var camera = sourceMesh.getScene().activeCamera;
  75154. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  75155. normal = camera.globalPosition.subtract(cameraWorldTarget);
  75156. }
  75157. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  75158. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  75159. var pitch = Math.atan2(normal.y, len);
  75160. // Matrix
  75161. var decalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(position.x, position.y, position.z));
  75162. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  75163. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  75164. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  75165. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  75166. vertexData.indices = [];
  75167. vertexData.positions = [];
  75168. vertexData.normals = [];
  75169. vertexData.uvs = [];
  75170. var currentVertexDataIndex = 0;
  75171. var extractDecalVector3 = function (indexId) {
  75172. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  75173. if (!indices || !positions || !normals) {
  75174. return result;
  75175. }
  75176. var vertexId = indices[indexId];
  75177. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  75178. // Send vector to decal local world
  75179. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  75180. // Get normal
  75181. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75182. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75183. return result;
  75184. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75185. var clip = function (vertices, axis) {
  75186. if (vertices.length === 0) {
  75187. return vertices;
  75188. }
  75189. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75190. var clipVertices = function (v0, v1) {
  75191. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75192. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  75193. };
  75194. var result = new Array();
  75195. for (var index = 0; index < vertices.length; index += 3) {
  75196. var v1Out;
  75197. var v2Out;
  75198. var v3Out;
  75199. var total = 0;
  75200. var nV1 = null;
  75201. var nV2 = null;
  75202. var nV3 = null;
  75203. var nV4 = null;
  75204. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75205. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75206. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75207. v1Out = d1 > 0;
  75208. v2Out = d2 > 0;
  75209. v3Out = d3 > 0;
  75210. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75211. switch (total) {
  75212. case 0:
  75213. result.push(vertices[index]);
  75214. result.push(vertices[index + 1]);
  75215. result.push(vertices[index + 2]);
  75216. break;
  75217. case 1:
  75218. if (v1Out) {
  75219. nV1 = vertices[index + 1];
  75220. nV2 = vertices[index + 2];
  75221. nV3 = clipVertices(vertices[index], nV1);
  75222. nV4 = clipVertices(vertices[index], nV2);
  75223. }
  75224. if (v2Out) {
  75225. nV1 = vertices[index];
  75226. nV2 = vertices[index + 2];
  75227. nV3 = clipVertices(vertices[index + 1], nV1);
  75228. nV4 = clipVertices(vertices[index + 1], nV2);
  75229. result.push(nV3);
  75230. result.push(nV2.clone());
  75231. result.push(nV1.clone());
  75232. result.push(nV2.clone());
  75233. result.push(nV3.clone());
  75234. result.push(nV4);
  75235. break;
  75236. }
  75237. if (v3Out) {
  75238. nV1 = vertices[index];
  75239. nV2 = vertices[index + 1];
  75240. nV3 = clipVertices(vertices[index + 2], nV1);
  75241. nV4 = clipVertices(vertices[index + 2], nV2);
  75242. }
  75243. if (nV1 && nV2 && nV3 && nV4) {
  75244. result.push(nV1.clone());
  75245. result.push(nV2.clone());
  75246. result.push(nV3);
  75247. result.push(nV4);
  75248. result.push(nV3.clone());
  75249. result.push(nV2.clone());
  75250. }
  75251. break;
  75252. case 2:
  75253. if (!v1Out) {
  75254. nV1 = vertices[index].clone();
  75255. nV2 = clipVertices(nV1, vertices[index + 1]);
  75256. nV3 = clipVertices(nV1, vertices[index + 2]);
  75257. result.push(nV1);
  75258. result.push(nV2);
  75259. result.push(nV3);
  75260. }
  75261. if (!v2Out) {
  75262. nV1 = vertices[index + 1].clone();
  75263. nV2 = clipVertices(nV1, vertices[index + 2]);
  75264. nV3 = clipVertices(nV1, vertices[index]);
  75265. result.push(nV1);
  75266. result.push(nV2);
  75267. result.push(nV3);
  75268. }
  75269. if (!v3Out) {
  75270. nV1 = vertices[index + 2].clone();
  75271. nV2 = clipVertices(nV1, vertices[index]);
  75272. nV3 = clipVertices(nV1, vertices[index + 1]);
  75273. result.push(nV1);
  75274. result.push(nV2);
  75275. result.push(nV3);
  75276. }
  75277. break;
  75278. case 3:
  75279. break;
  75280. }
  75281. }
  75282. return result;
  75283. };
  75284. for (var index = 0; index < indices.length; index += 3) {
  75285. var faceVertices = new Array();
  75286. faceVertices.push(extractDecalVector3(index));
  75287. faceVertices.push(extractDecalVector3(index + 1));
  75288. faceVertices.push(extractDecalVector3(index + 2));
  75289. // Clip
  75290. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75291. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75292. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75293. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75294. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75295. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75296. if (faceVertices.length === 0) {
  75297. continue;
  75298. }
  75299. // Add UVs and get back to world
  75300. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75301. var vertex = faceVertices[vIndex];
  75302. //TODO check for Int32Array | Uint32Array | Uint16Array
  75303. vertexData.indices.push(currentVertexDataIndex);
  75304. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75305. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75306. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75307. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75308. currentVertexDataIndex++;
  75309. }
  75310. }
  75311. // Return mesh
  75312. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75313. vertexData.applyToMesh(decal);
  75314. decal.position = position.clone();
  75315. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75316. return decal;
  75317. };
  75318. return DecalBuilder;
  75319. }());
  75320. /***/ }),
  75321. /***/ "./Meshes/Builders/discBuilder.ts":
  75322. /*!****************************************!*\
  75323. !*** ./Meshes/Builders/discBuilder.ts ***!
  75324. \****************************************/
  75325. /*! exports provided: DiscBuilder */
  75326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75327. "use strict";
  75328. __webpack_require__.r(__webpack_exports__);
  75329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75330. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75331. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75332. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75333. var positions = new Array();
  75334. var indices = new Array();
  75335. var normals = new Array();
  75336. var uvs = new Array();
  75337. var radius = options.radius || 0.5;
  75338. var tessellation = options.tessellation || 64;
  75339. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75340. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75341. // positions and uvs
  75342. positions.push(0, 0, 0); // disc center first
  75343. uvs.push(0.5, 0.5);
  75344. var theta = Math.PI * 2 * arc;
  75345. var step = theta / tessellation;
  75346. for (var a = 0; a < theta; a += step) {
  75347. var x = Math.cos(a);
  75348. var y = Math.sin(a);
  75349. var u = (x + 1) / 2;
  75350. var v = (1 - y) / 2;
  75351. positions.push(radius * x, radius * y, 0);
  75352. uvs.push(u, v);
  75353. }
  75354. if (arc === 1) {
  75355. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75356. uvs.push(uvs[2], uvs[3]);
  75357. }
  75358. //indices
  75359. var vertexNb = positions.length / 3;
  75360. for (var i = 1; i < vertexNb - 1; i++) {
  75361. indices.push(i + 1, 0, i);
  75362. }
  75363. // result
  75364. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75365. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75366. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75367. vertexData.indices = indices;
  75368. vertexData.positions = positions;
  75369. vertexData.normals = normals;
  75370. vertexData.uvs = uvs;
  75371. return vertexData;
  75372. };
  75373. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75374. if (scene === void 0) { scene = null; }
  75375. var options = {
  75376. radius: radius,
  75377. tessellation: tessellation,
  75378. sideOrientation: sideOrientation,
  75379. updatable: updatable
  75380. };
  75381. return DiscBuilder.CreateDisc(name, options, scene);
  75382. };
  75383. /**
  75384. * Class containing static functions to help procedurally build meshes
  75385. */
  75386. var DiscBuilder = /** @class */ (function () {
  75387. function DiscBuilder() {
  75388. }
  75389. /**
  75390. * Creates a plane polygonal mesh. By default, this is a disc
  75391. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75392. * * 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
  75393. * * 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
  75394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75395. * * 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
  75396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75397. * @param name defines the name of the mesh
  75398. * @param options defines the options used to create the mesh
  75399. * @param scene defines the hosting scene
  75400. * @returns the plane polygonal mesh
  75401. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75402. */
  75403. DiscBuilder.CreateDisc = function (name, options, scene) {
  75404. if (scene === void 0) { scene = null; }
  75405. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75406. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75407. disc._originalBuilderSideOrientation = options.sideOrientation;
  75408. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75409. vertexData.applyToMesh(disc, options.updatable);
  75410. return disc;
  75411. };
  75412. return DiscBuilder;
  75413. }());
  75414. /***/ }),
  75415. /***/ "./Meshes/Builders/groundBuilder.ts":
  75416. /*!******************************************!*\
  75417. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75418. \******************************************/
  75419. /*! exports provided: GroundBuilder */
  75420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75421. "use strict";
  75422. __webpack_require__.r(__webpack_exports__);
  75423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  75424. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75425. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75426. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75427. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  75428. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  75429. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  75430. var indices = [];
  75431. var positions = [];
  75432. var normals = [];
  75433. var uvs = [];
  75434. var row, col;
  75435. var width = options.width || 1;
  75436. var height = options.height || 1;
  75437. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75438. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75439. for (row = 0; row <= subdivisionsY; row++) {
  75440. for (col = 0; col <= subdivisionsX; col++) {
  75441. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  75442. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75443. positions.push(position.x, position.y, position.z);
  75444. normals.push(normal.x, normal.y, normal.z);
  75445. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  75446. }
  75447. }
  75448. for (row = 0; row < subdivisionsY; row++) {
  75449. for (col = 0; col < subdivisionsX; col++) {
  75450. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75451. indices.push(col + 1 + row * (subdivisionsX + 1));
  75452. indices.push(col + row * (subdivisionsX + 1));
  75453. indices.push(col + (row + 1) * (subdivisionsX + 1));
  75454. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75455. indices.push(col + row * (subdivisionsX + 1));
  75456. }
  75457. }
  75458. // Result
  75459. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75460. vertexData.indices = indices;
  75461. vertexData.positions = positions;
  75462. vertexData.normals = normals;
  75463. vertexData.uvs = uvs;
  75464. return vertexData;
  75465. };
  75466. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  75467. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  75468. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  75469. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  75470. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  75471. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  75472. var precision = options.precision || { w: 1, h: 1 };
  75473. var indices = new Array();
  75474. var positions = new Array();
  75475. var normals = new Array();
  75476. var uvs = new Array();
  75477. var row, col, tileRow, tileCol;
  75478. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  75479. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  75480. precision.w = (precision.w < 1) ? 1 : precision.w;
  75481. precision.h = (precision.h < 1) ? 1 : precision.h;
  75482. var tileSize = {
  75483. 'w': (xmax - xmin) / subdivisions.w,
  75484. 'h': (zmax - zmin) / subdivisions.h
  75485. };
  75486. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  75487. // Indices
  75488. var base = positions.length / 3;
  75489. var rowLength = precision.w + 1;
  75490. for (row = 0; row < precision.h; row++) {
  75491. for (col = 0; col < precision.w; col++) {
  75492. var square = [
  75493. base + col + row * rowLength,
  75494. base + (col + 1) + row * rowLength,
  75495. base + (col + 1) + (row + 1) * rowLength,
  75496. base + col + (row + 1) * rowLength
  75497. ];
  75498. indices.push(square[1]);
  75499. indices.push(square[2]);
  75500. indices.push(square[3]);
  75501. indices.push(square[0]);
  75502. indices.push(square[1]);
  75503. indices.push(square[3]);
  75504. }
  75505. }
  75506. // Position, normals and uvs
  75507. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75508. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75509. for (row = 0; row <= precision.h; row++) {
  75510. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  75511. for (col = 0; col <= precision.w; col++) {
  75512. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  75513. position.y = 0;
  75514. positions.push(position.x, position.y, position.z);
  75515. normals.push(normal.x, normal.y, normal.z);
  75516. uvs.push(col / precision.w, row / precision.h);
  75517. }
  75518. }
  75519. }
  75520. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  75521. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  75522. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  75523. }
  75524. }
  75525. // Result
  75526. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75527. vertexData.indices = indices;
  75528. vertexData.positions = positions;
  75529. vertexData.normals = normals;
  75530. vertexData.uvs = uvs;
  75531. return vertexData;
  75532. };
  75533. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  75534. var indices = [];
  75535. var positions = [];
  75536. var normals = [];
  75537. var uvs = [];
  75538. var row, col;
  75539. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75540. var alphaFilter = options.alphaFilter || 0.0;
  75541. // Vertices
  75542. for (row = 0; row <= options.subdivisions; row++) {
  75543. for (col = 0; col <= options.subdivisions; col++) {
  75544. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * options.width) / options.subdivisions - (options.width / 2.0), 0, ((options.subdivisions - row) * options.height) / options.subdivisions - (options.height / 2.0));
  75545. // Compute height
  75546. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  75547. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  75548. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  75549. var r = options.buffer[pos] / 255.0;
  75550. var g = options.buffer[pos + 1] / 255.0;
  75551. var b = options.buffer[pos + 2] / 255.0;
  75552. var a = options.buffer[pos + 3] / 255.0;
  75553. var gradient = r * filter.r + g * filter.g + b * filter.b;
  75554. // If our alpha channel is not within our filter then we will assign a 'special' height
  75555. // Then when building the indices, we will ignore any vertex that is using the special height
  75556. if (a >= alphaFilter) {
  75557. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  75558. }
  75559. else {
  75560. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  75561. }
  75562. // Add vertex
  75563. positions.push(position.x, position.y, position.z);
  75564. normals.push(0, 0, 0);
  75565. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  75566. }
  75567. }
  75568. // Indices
  75569. for (row = 0; row < options.subdivisions; row++) {
  75570. for (col = 0; col < options.subdivisions; col++) {
  75571. // Calculate Indices
  75572. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  75573. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  75574. var idx3 = (col + row * (options.subdivisions + 1));
  75575. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  75576. // Check that all indices are visible (based on our special height)
  75577. // Only display the vertex if all Indices are visible
  75578. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  75579. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  75580. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  75581. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  75582. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  75583. indices.push(idx1);
  75584. indices.push(idx2);
  75585. indices.push(idx3);
  75586. }
  75587. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  75588. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  75589. indices.push(idx4);
  75590. indices.push(idx1);
  75591. indices.push(idx3);
  75592. }
  75593. }
  75594. }
  75595. // Normals
  75596. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  75597. // Result
  75598. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75599. vertexData.indices = indices;
  75600. vertexData.positions = positions;
  75601. vertexData.normals = normals;
  75602. vertexData.uvs = uvs;
  75603. return vertexData;
  75604. };
  75605. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  75606. var options = {
  75607. width: width,
  75608. height: height,
  75609. subdivisions: subdivisions,
  75610. updatable: updatable
  75611. };
  75612. return GroundBuilder.CreateGround(name, options, scene);
  75613. };
  75614. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  75615. var options = {
  75616. xmin: xmin,
  75617. zmin: zmin,
  75618. xmax: xmax,
  75619. zmax: zmax,
  75620. subdivisions: subdivisions,
  75621. precision: precision,
  75622. updatable: updatable
  75623. };
  75624. return GroundBuilder.CreateTiledGround(name, options, scene);
  75625. };
  75626. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  75627. var options = {
  75628. width: width,
  75629. height: height,
  75630. subdivisions: subdivisions,
  75631. minHeight: minHeight,
  75632. maxHeight: maxHeight,
  75633. updatable: updatable,
  75634. onReady: onReady,
  75635. alphaFilter: alphaFilter
  75636. };
  75637. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  75638. };
  75639. /**
  75640. * Class containing static functions to help procedurally build meshes
  75641. */
  75642. var GroundBuilder = /** @class */ (function () {
  75643. function GroundBuilder() {
  75644. }
  75645. /**
  75646. * Creates a ground mesh
  75647. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  75648. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  75649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75650. * @param name defines the name of the mesh
  75651. * @param options defines the options used to create the mesh
  75652. * @param scene defines the hosting scene
  75653. * @returns the ground mesh
  75654. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  75655. */
  75656. GroundBuilder.CreateGround = function (name, options, scene) {
  75657. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75658. ground._setReady(false);
  75659. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75660. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75661. ground._width = options.width || 1;
  75662. ground._height = options.height || 1;
  75663. ground._maxX = ground._width / 2;
  75664. ground._maxZ = ground._height / 2;
  75665. ground._minX = -ground._maxX;
  75666. ground._minZ = -ground._maxZ;
  75667. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  75668. vertexData.applyToMesh(ground, options.updatable);
  75669. ground._setReady(true);
  75670. return ground;
  75671. };
  75672. /**
  75673. * Creates a tiled ground mesh
  75674. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  75675. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  75676. * * 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
  75677. * * 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
  75678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75679. * @param name defines the name of the mesh
  75680. * @param options defines the options used to create the mesh
  75681. * @param scene defines the hosting scene
  75682. * @returns the tiled ground mesh
  75683. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  75684. */
  75685. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  75686. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75687. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  75688. vertexData.applyToMesh(tiledGround, options.updatable);
  75689. return tiledGround;
  75690. };
  75691. /**
  75692. * Creates a ground mesh from a height map
  75693. * * The parameter `url` sets the URL of the height map image resource.
  75694. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  75695. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  75696. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  75697. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  75698. * * 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.
  75699. * * 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).
  75700. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75702. * @param name defines the name of the mesh
  75703. * @param url defines the url to the height map
  75704. * @param options defines the options used to create the mesh
  75705. * @param scene defines the hosting scene
  75706. * @returns the ground mesh
  75707. * @see https://doc.babylonjs.com/babylon101/height_map
  75708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  75709. */
  75710. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  75711. var width = options.width || 10.0;
  75712. var height = options.height || 10.0;
  75713. var subdivisions = options.subdivisions || 1 | 0;
  75714. var minHeight = options.minHeight || 0.0;
  75715. var maxHeight = options.maxHeight || 1.0;
  75716. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75717. var alphaFilter = options.alphaFilter || 0.0;
  75718. var updatable = options.updatable;
  75719. var onReady = options.onReady;
  75720. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75721. ground._subdivisionsX = subdivisions;
  75722. ground._subdivisionsY = subdivisions;
  75723. ground._width = width;
  75724. ground._height = height;
  75725. ground._maxX = ground._width / 2.0;
  75726. ground._maxZ = ground._height / 2.0;
  75727. ground._minX = -ground._maxX;
  75728. ground._minZ = -ground._maxZ;
  75729. ground._setReady(false);
  75730. var onload = function (img) {
  75731. // Getting height map data
  75732. var canvas = document.createElement("canvas");
  75733. var context = canvas.getContext("2d");
  75734. if (!context) {
  75735. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  75736. }
  75737. if (scene.isDisposed) {
  75738. return;
  75739. }
  75740. var bufferWidth = img.width;
  75741. var bufferHeight = img.height;
  75742. canvas.width = bufferWidth;
  75743. canvas.height = bufferHeight;
  75744. context.drawImage(img, 0, 0);
  75745. // Create VertexData from map data
  75746. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  75747. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  75748. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  75749. width: width, height: height,
  75750. subdivisions: subdivisions,
  75751. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  75752. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  75753. alphaFilter: alphaFilter
  75754. });
  75755. vertexData.applyToMesh(ground, updatable);
  75756. //execute ready callback, if set
  75757. if (onReady) {
  75758. onReady(ground);
  75759. }
  75760. ground._setReady(true);
  75761. };
  75762. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  75763. return ground;
  75764. };
  75765. return GroundBuilder;
  75766. }());
  75767. /***/ }),
  75768. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  75769. /*!*********************************************!*\
  75770. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  75771. \*********************************************/
  75772. /*! exports provided: IcoSphereBuilder */
  75773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75774. "use strict";
  75775. __webpack_require__.r(__webpack_exports__);
  75776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  75777. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75778. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75779. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75780. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  75781. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75782. var radius = options.radius || 1;
  75783. var flat = (options.flat === undefined) ? true : options.flat;
  75784. var subdivisions = options.subdivisions || 4;
  75785. var radiusX = options.radiusX || radius;
  75786. var radiusY = options.radiusY || radius;
  75787. var radiusZ = options.radiusZ || radius;
  75788. var t = (1 + Math.sqrt(5)) / 2;
  75789. // 12 vertex x,y,z
  75790. var ico_vertices = [
  75791. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  75792. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  75793. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  75794. ];
  75795. // index of 3 vertex makes a face of icopshere
  75796. var ico_indices = [
  75797. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  75798. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  75799. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  75800. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  75801. ];
  75802. // vertex for uv have aliased position, not for UV
  75803. var vertices_unalias_id = [
  75804. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  75805. // vertex alias
  75806. 0,
  75807. 2,
  75808. 3,
  75809. 3,
  75810. 3,
  75811. 4,
  75812. 7,
  75813. 8,
  75814. 9,
  75815. 9,
  75816. 10,
  75817. 11 // 23: B + 12
  75818. ];
  75819. // uv as integer step (not pixels !)
  75820. var ico_vertexuv = [
  75821. 5, 1, 3, 1, 6, 4, 0, 0,
  75822. 5, 3, 4, 2, 2, 2, 4, 0,
  75823. 2, 0, 1, 1, 6, 0, 6, 2,
  75824. // vertex alias (for same vertex on different faces)
  75825. 0, 4,
  75826. 3, 3,
  75827. 4, 4,
  75828. 3, 1,
  75829. 4, 2,
  75830. 4, 4,
  75831. 0, 2,
  75832. 1, 1,
  75833. 2, 2,
  75834. 3, 3,
  75835. 1, 3,
  75836. 2, 4 // 23: B + 12
  75837. ];
  75838. // Vertices[0, 1, ...9, A, B] : position on UV plane
  75839. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  75840. // First island of uv mapping
  75841. // v = 4h 3+ 2
  75842. // v = 3h 9+ 4
  75843. // v = 2h 9+ 5 B
  75844. // v = 1h 9 1 0
  75845. // v = 0h 3 8 7 A
  75846. // u = 0 1 2 3 4 5 6 *a
  75847. // Second island of uv mapping
  75848. // v = 4h 0+ B+ 4+
  75849. // v = 3h A+ 2+
  75850. // v = 2h 7+ 6 3+
  75851. // v = 1h 8+ 3+
  75852. // v = 0h
  75853. // u = 0 1 2 3 4 5 6 *a
  75854. // Face layout on texture UV mapping
  75855. // ============
  75856. // \ 4 /\ 16 / ======
  75857. // \ / \ / /\ 11 /
  75858. // \/ 7 \/ / \ /
  75859. // ======= / 10 \/
  75860. // /\ 17 /\ =======
  75861. // / \ / \ \ 15 /\
  75862. // / 8 \/ 12 \ \ / \
  75863. // ============ \/ 6 \
  75864. // \ 18 /\ ============
  75865. // \ / \ \ 5 /\ 0 /
  75866. // \/ 13 \ \ / \ /
  75867. // ======= \/ 1 \/
  75868. // =============
  75869. // /\ 19 /\ 2 /\
  75870. // / \ / \ / \
  75871. // / 14 \/ 9 \/ 3 \
  75872. // ===================
  75873. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  75874. var ustep = 138 / 1024;
  75875. var vstep = 239 / 1024;
  75876. var uoffset = 60 / 1024;
  75877. var voffset = 26 / 1024;
  75878. // Second island should have margin, not to touch the first island
  75879. // avoid any borderline artefact in pixel rounding
  75880. var island_u_offset = -40 / 1024;
  75881. var island_v_offset = +20 / 1024;
  75882. // face is either island 0 or 1 :
  75883. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  75884. var island = [
  75885. 0, 0, 0, 0, 1,
  75886. 0, 0, 1, 1, 0,
  75887. 0, 0, 1, 1, 0,
  75888. 0, 1, 1, 1, 0 // 15 - 19
  75889. ];
  75890. var indices = new Array();
  75891. var positions = new Array();
  75892. var normals = new Array();
  75893. var uvs = new Array();
  75894. var current_indice = 0;
  75895. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  75896. var face_vertex_pos = new Array(3);
  75897. var face_vertex_uv = new Array(3);
  75898. var v012;
  75899. for (v012 = 0; v012 < 3; v012++) {
  75900. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75901. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  75902. }
  75903. // create all with normals
  75904. for (var face = 0; face < 20; face++) {
  75905. // 3 vertex per face
  75906. for (v012 = 0; v012 < 3; v012++) {
  75907. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  75908. var v_id = ico_indices[3 * face + v012];
  75909. // vertex have 3D position (x,y,z)
  75910. 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]);
  75911. // Normalize to get normal, then scale to radius
  75912. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  75913. // uv Coordinates from vertex ID
  75914. 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);
  75915. }
  75916. // Subdivide the face (interpolate pos, norm, uv)
  75917. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  75918. // - norm is linear interpolation of vertex corner normal
  75919. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  75920. // - uv is linear interpolation
  75921. //
  75922. // Topology is as below for sub-divide by 2
  75923. // vertex shown as v0,v1,v2
  75924. // interp index is i1 to progress in range [v0,v1[
  75925. // interp index is i2 to progress in range [v0,v2[
  75926. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  75927. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  75928. //
  75929. //
  75930. // i2 v2
  75931. // ^ ^
  75932. // / / \
  75933. // / / \
  75934. // / / \
  75935. // / / (0,1) \
  75936. // / #---------\
  75937. // / / \ (0,0)'/ \
  75938. // / / \ / \
  75939. // / / \ / \
  75940. // / / (0,0) \ / (1,0) \
  75941. // / #---------#---------\
  75942. // v0 v1
  75943. //
  75944. // --------------------> i1
  75945. //
  75946. // interp of (i1,i2):
  75947. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  75948. // along i1 : lerp(x0,x1, i1/(S-i2))
  75949. //
  75950. // centroid of triangle is needed to get help normal computation
  75951. // (c1,c2) are used for centroid location
  75952. var interp_vertex = function (i1, i2, c1, c2) {
  75953. // vertex is interpolated from
  75954. // - face_vertex_pos[0..2]
  75955. // - face_vertex_uv[0..2]
  75956. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  75957. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  75958. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  75959. pos_interp.normalize();
  75960. var vertex_normal;
  75961. if (flat) {
  75962. // in flat mode, recalculate normal as face centroid normal
  75963. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  75964. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  75965. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  75966. }
  75967. else {
  75968. // in smooth mode, recalculate normal from each single vertex position
  75969. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  75970. }
  75971. // Vertex normal need correction due to X,Y,Z radius scaling
  75972. vertex_normal.x /= radiusX;
  75973. vertex_normal.y /= radiusY;
  75974. vertex_normal.z /= radiusZ;
  75975. vertex_normal.normalize();
  75976. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  75977. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  75978. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  75979. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  75980. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  75981. uvs.push(uv_interp.x, uv_interp.y);
  75982. // push each vertex has member of a face
  75983. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  75984. indices.push(current_indice);
  75985. current_indice++;
  75986. };
  75987. for (var i2 = 0; i2 < subdivisions; i2++) {
  75988. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  75989. // face : (i1,i2) for /\ :
  75990. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  75991. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75992. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75993. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75994. if (i1 + i2 + 1 < subdivisions) {
  75995. // face : (i1,i2)' for \/ :
  75996. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  75997. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  75998. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  75999. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76000. }
  76001. }
  76002. }
  76003. }
  76004. // Sides
  76005. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76006. // Result
  76007. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76008. vertexData.indices = indices;
  76009. vertexData.positions = positions;
  76010. vertexData.normals = normals;
  76011. vertexData.uvs = uvs;
  76012. return vertexData;
  76013. };
  76014. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  76015. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  76016. };
  76017. /**
  76018. * Class containing static functions to help procedurally build meshes
  76019. */
  76020. var IcoSphereBuilder = /** @class */ (function () {
  76021. function IcoSphereBuilder() {
  76022. }
  76023. /**
  76024. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76025. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76026. * * 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`)
  76027. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76028. * * 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
  76029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76030. * * 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
  76031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76032. * @param name defines the name of the mesh
  76033. * @param options defines the options used to create the mesh
  76034. * @param scene defines the hosting scene
  76035. * @returns the icosahedron mesh
  76036. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76037. */
  76038. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  76039. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76040. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76041. sphere._originalBuilderSideOrientation = options.sideOrientation;
  76042. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  76043. vertexData.applyToMesh(sphere, options.updatable);
  76044. return sphere;
  76045. };
  76046. return IcoSphereBuilder;
  76047. }());
  76048. /***/ }),
  76049. /***/ "./Meshes/Builders/index.ts":
  76050. /*!**********************************!*\
  76051. !*** ./Meshes/Builders/index.ts ***!
  76052. \**********************************/
  76053. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  76054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76055. "use strict";
  76056. __webpack_require__.r(__webpack_exports__);
  76057. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  76058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  76059. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  76060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  76061. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  76063. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  76064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  76065. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  76066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  76067. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  76068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  76069. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  76070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  76071. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  76072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  76073. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  76074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  76075. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  76076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  76077. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  76078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  76079. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  76080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  76081. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  76082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  76083. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  76084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  76085. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  76086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  76087. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  76088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  76089. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  76090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  76091. /***/ }),
  76092. /***/ "./Meshes/Builders/latheBuilder.ts":
  76093. /*!*****************************************!*\
  76094. !*** ./Meshes/Builders/latheBuilder.ts ***!
  76095. \*****************************************/
  76096. /*! exports provided: LatheBuilder */
  76097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76098. "use strict";
  76099. __webpack_require__.r(__webpack_exports__);
  76100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  76101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76102. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76103. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76104. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  76105. var options = {
  76106. shape: shape,
  76107. radius: radius,
  76108. tessellation: tessellation,
  76109. sideOrientation: sideOrientation,
  76110. updatable: updatable
  76111. };
  76112. return LatheBuilder.CreateLathe(name, options, scene);
  76113. };
  76114. /**
  76115. * Class containing static functions to help procedurally build meshes
  76116. */
  76117. var LatheBuilder = /** @class */ (function () {
  76118. function LatheBuilder() {
  76119. }
  76120. /**
  76121. * Creates lathe mesh.
  76122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  76123. * * 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
  76124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  76125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  76126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  76127. * * 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
  76128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  76129. * * 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
  76130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76131. * * 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
  76132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76134. * @param name defines the name of the mesh
  76135. * @param options defines the options used to create the mesh
  76136. * @param scene defines the hosting scene
  76137. * @returns the lathe mesh
  76138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  76139. */
  76140. LatheBuilder.CreateLathe = function (name, options, scene) {
  76141. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  76142. var closed = (options.closed === undefined) ? true : options.closed;
  76143. var shape = options.shape;
  76144. var radius = options.radius || 1;
  76145. var tessellation = options.tessellation || 64;
  76146. var clip = options.clip || 0;
  76147. var updatable = options.updatable;
  76148. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76149. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  76150. var pi2 = Math.PI * 2;
  76151. var paths = new Array();
  76152. var invertUV = options.invertUV || false;
  76153. var i = 0;
  76154. var p = 0;
  76155. var step = pi2 / tessellation * arc;
  76156. var rotated;
  76157. var path = new Array();
  76158. for (i = 0; i <= tessellation - clip; i++) {
  76159. var path = [];
  76160. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76161. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  76162. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  76163. }
  76164. for (p = 0; p < shape.length; p++) {
  76165. rotated = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  76166. path.push(rotated);
  76167. }
  76168. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76169. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[shape.length - 1].x * radius, shape[shape.length - 1].y, Math.sin(i * step) * shape[shape.length - 1].x * radius));
  76170. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  76171. }
  76172. paths.push(path);
  76173. }
  76174. // lathe ribbon
  76175. 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);
  76176. return lathe;
  76177. };
  76178. return LatheBuilder;
  76179. }());
  76180. /***/ }),
  76181. /***/ "./Meshes/Builders/linesBuilder.ts":
  76182. /*!*****************************************!*\
  76183. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76184. \*****************************************/
  76185. /*! exports provided: LinesBuilder */
  76186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76187. "use strict";
  76188. __webpack_require__.r(__webpack_exports__);
  76189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76190. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76191. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76192. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76193. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76194. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76195. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76196. var indices = [];
  76197. var positions = [];
  76198. var lines = options.lines;
  76199. var colors = options.colors;
  76200. var vertexColors = [];
  76201. var idx = 0;
  76202. for (var l = 0; l < lines.length; l++) {
  76203. var points = lines[l];
  76204. for (var index = 0; index < points.length; index++) {
  76205. positions.push(points[index].x, points[index].y, points[index].z);
  76206. if (colors) {
  76207. var color = colors[l];
  76208. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76209. }
  76210. if (index > 0) {
  76211. indices.push(idx - 1);
  76212. indices.push(idx);
  76213. }
  76214. idx++;
  76215. }
  76216. }
  76217. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76218. vertexData.indices = indices;
  76219. vertexData.positions = positions;
  76220. if (colors) {
  76221. vertexData.colors = vertexColors;
  76222. }
  76223. return vertexData;
  76224. };
  76225. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76226. var dashSize = options.dashSize || 3;
  76227. var gapSize = options.gapSize || 1;
  76228. var dashNb = options.dashNb || 200;
  76229. var points = options.points;
  76230. var positions = new Array();
  76231. var indices = new Array();
  76232. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76233. var lg = 0;
  76234. var nb = 0;
  76235. var shft = 0;
  76236. var dashshft = 0;
  76237. var curshft = 0;
  76238. var idx = 0;
  76239. var i = 0;
  76240. for (i = 0; i < points.length - 1; i++) {
  76241. points[i + 1].subtractToRef(points[i], curvect);
  76242. lg += curvect.length();
  76243. }
  76244. shft = lg / dashNb;
  76245. dashshft = dashSize * shft / (dashSize + gapSize);
  76246. for (i = 0; i < points.length - 1; i++) {
  76247. points[i + 1].subtractToRef(points[i], curvect);
  76248. nb = Math.floor(curvect.length() / shft);
  76249. curvect.normalize();
  76250. for (var j = 0; j < nb; j++) {
  76251. curshft = shft * j;
  76252. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76253. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76254. indices.push(idx, idx + 1);
  76255. idx += 2;
  76256. }
  76257. }
  76258. // Result
  76259. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76260. vertexData.positions = positions;
  76261. vertexData.indices = indices;
  76262. return vertexData;
  76263. };
  76264. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76265. if (scene === void 0) { scene = null; }
  76266. if (updatable === void 0) { updatable = false; }
  76267. if (instance === void 0) { instance = null; }
  76268. var options = {
  76269. points: points,
  76270. updatable: updatable,
  76271. instance: instance
  76272. };
  76273. return LinesBuilder.CreateLines(name, options, scene);
  76274. };
  76275. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76276. if (scene === void 0) { scene = null; }
  76277. var options = {
  76278. points: points,
  76279. dashSize: dashSize,
  76280. gapSize: gapSize,
  76281. dashNb: dashNb,
  76282. updatable: updatable,
  76283. instance: instance
  76284. };
  76285. return LinesBuilder.CreateDashedLines(name, options, scene);
  76286. };
  76287. /**
  76288. * Class containing static functions to help procedurally build meshes
  76289. */
  76290. var LinesBuilder = /** @class */ (function () {
  76291. function LinesBuilder() {
  76292. }
  76293. /**
  76294. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76295. * * 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
  76296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76297. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76298. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76299. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76300. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76301. * * 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
  76302. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76305. * @param name defines the name of the new line system
  76306. * @param options defines the options used to create the line system
  76307. * @param scene defines the hosting scene
  76308. * @returns a new line system mesh
  76309. */
  76310. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76311. var instance = options.instance;
  76312. var lines = options.lines;
  76313. var colors = options.colors;
  76314. if (instance) { // lines update
  76315. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76316. var vertexColor;
  76317. var lineColors;
  76318. if (colors) {
  76319. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76320. }
  76321. var i = 0;
  76322. var c = 0;
  76323. for (var l = 0; l < lines.length; l++) {
  76324. var points = lines[l];
  76325. for (var p = 0; p < points.length; p++) {
  76326. positions[i] = points[p].x;
  76327. positions[i + 1] = points[p].y;
  76328. positions[i + 2] = points[p].z;
  76329. if (colors && vertexColor) {
  76330. lineColors = colors[l];
  76331. vertexColor[c] = lineColors[p].r;
  76332. vertexColor[c + 1] = lineColors[p].g;
  76333. vertexColor[c + 2] = lineColors[p].b;
  76334. vertexColor[c + 3] = lineColors[p].a;
  76335. c += 4;
  76336. }
  76337. i += 3;
  76338. }
  76339. }
  76340. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76341. if (colors && vertexColor) {
  76342. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76343. }
  76344. return instance;
  76345. }
  76346. // line system creation
  76347. var useVertexColor = (colors) ? true : false;
  76348. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76349. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76350. vertexData.applyToMesh(lineSystem, options.updatable);
  76351. return lineSystem;
  76352. };
  76353. /**
  76354. * Creates a line mesh
  76355. * 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
  76356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76357. * * The parameter `points` is an array successive Vector3
  76358. * * 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
  76359. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76361. * * When updating an instance, remember that only point positions can change, not the number of points
  76362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76364. * @param name defines the name of the new line system
  76365. * @param options defines the options used to create the line system
  76366. * @param scene defines the hosting scene
  76367. * @returns a new line mesh
  76368. */
  76369. LinesBuilder.CreateLines = function (name, options, scene) {
  76370. if (scene === void 0) { scene = null; }
  76371. var colors = (options.colors) ? [options.colors] : null;
  76372. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76373. return lines;
  76374. };
  76375. /**
  76376. * Creates a dashed line mesh
  76377. * * 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
  76378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76379. * * The parameter `points` is an array successive Vector3
  76380. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76381. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76382. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76383. * * 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
  76384. * * When updating an instance, remember that only point positions can change, not the number of points
  76385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76386. * @param name defines the name of the mesh
  76387. * @param options defines the options used to create the mesh
  76388. * @param scene defines the hosting scene
  76389. * @returns the dashed line mesh
  76390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76391. */
  76392. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76393. if (scene === void 0) { scene = null; }
  76394. var points = options.points;
  76395. var instance = options.instance;
  76396. var gapSize = options.gapSize || 1;
  76397. var dashSize = options.dashSize || 3;
  76398. if (instance) { // dashed lines update
  76399. var positionFunction = function (positions) {
  76400. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76401. var nbSeg = positions.length / 6;
  76402. var lg = 0;
  76403. var nb = 0;
  76404. var shft = 0;
  76405. var dashshft = 0;
  76406. var curshft = 0;
  76407. var p = 0;
  76408. var i = 0;
  76409. var j = 0;
  76410. for (i = 0; i < points.length - 1; i++) {
  76411. points[i + 1].subtractToRef(points[i], curvect);
  76412. lg += curvect.length();
  76413. }
  76414. shft = lg / nbSeg;
  76415. var dashSize = instance._creationDataStorage.dashSize;
  76416. var gapSize = instance._creationDataStorage.gapSize;
  76417. dashshft = dashSize * shft / (dashSize + gapSize);
  76418. for (i = 0; i < points.length - 1; i++) {
  76419. points[i + 1].subtractToRef(points[i], curvect);
  76420. nb = Math.floor(curvect.length() / shft);
  76421. curvect.normalize();
  76422. j = 0;
  76423. while (j < nb && p < positions.length) {
  76424. curshft = shft * j;
  76425. positions[p] = points[i].x + curshft * curvect.x;
  76426. positions[p + 1] = points[i].y + curshft * curvect.y;
  76427. positions[p + 2] = points[i].z + curshft * curvect.z;
  76428. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  76429. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  76430. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  76431. p += 6;
  76432. j++;
  76433. }
  76434. }
  76435. while (p < positions.length) {
  76436. positions[p] = points[i].x;
  76437. positions[p + 1] = points[i].y;
  76438. positions[p + 2] = points[i].z;
  76439. p += 3;
  76440. }
  76441. };
  76442. instance.updateMeshPositions(positionFunction, false);
  76443. return instance;
  76444. }
  76445. // dashed lines creation
  76446. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  76447. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  76448. vertexData.applyToMesh(dashedLines, options.updatable);
  76449. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  76450. dashedLines._creationDataStorage.dashSize = dashSize;
  76451. dashedLines._creationDataStorage.gapSize = gapSize;
  76452. return dashedLines;
  76453. };
  76454. return LinesBuilder;
  76455. }());
  76456. /***/ }),
  76457. /***/ "./Meshes/Builders/planeBuilder.ts":
  76458. /*!*****************************************!*\
  76459. !*** ./Meshes/Builders/planeBuilder.ts ***!
  76460. \*****************************************/
  76461. /*! exports provided: PlaneBuilder */
  76462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76463. "use strict";
  76464. __webpack_require__.r(__webpack_exports__);
  76465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  76466. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76467. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76468. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  76469. var indices = [];
  76470. var positions = [];
  76471. var normals = [];
  76472. var uvs = [];
  76473. var width = options.width || options.size || 1;
  76474. var height = options.height || options.size || 1;
  76475. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76476. // Vertices
  76477. var halfWidth = width / 2.0;
  76478. var halfHeight = height / 2.0;
  76479. positions.push(-halfWidth, -halfHeight, 0);
  76480. normals.push(0, 0, -1.0);
  76481. uvs.push(0.0, 0.0);
  76482. positions.push(halfWidth, -halfHeight, 0);
  76483. normals.push(0, 0, -1.0);
  76484. uvs.push(1.0, 0.0);
  76485. positions.push(halfWidth, halfHeight, 0);
  76486. normals.push(0, 0, -1.0);
  76487. uvs.push(1.0, 1.0);
  76488. positions.push(-halfWidth, halfHeight, 0);
  76489. normals.push(0, 0, -1.0);
  76490. uvs.push(0.0, 1.0);
  76491. // Indices
  76492. indices.push(0);
  76493. indices.push(1);
  76494. indices.push(2);
  76495. indices.push(0);
  76496. indices.push(2);
  76497. indices.push(3);
  76498. // Sides
  76499. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76500. // Result
  76501. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76502. vertexData.indices = indices;
  76503. vertexData.positions = positions;
  76504. vertexData.normals = normals;
  76505. vertexData.uvs = uvs;
  76506. return vertexData;
  76507. };
  76508. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  76509. var options = {
  76510. size: size,
  76511. width: size,
  76512. height: size,
  76513. sideOrientation: sideOrientation,
  76514. updatable: updatable
  76515. };
  76516. return PlaneBuilder.CreatePlane(name, options, scene);
  76517. };
  76518. /**
  76519. * Class containing static functions to help procedurally build meshes
  76520. */
  76521. var PlaneBuilder = /** @class */ (function () {
  76522. function PlaneBuilder() {
  76523. }
  76524. /**
  76525. * Creates a plane mesh
  76526. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  76527. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  76528. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  76529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76530. * * 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
  76531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76532. * @param name defines the name of the mesh
  76533. * @param options defines the options used to create the mesh
  76534. * @param scene defines the hosting scene
  76535. * @returns the plane mesh
  76536. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  76537. */
  76538. PlaneBuilder.CreatePlane = function (name, options, scene) {
  76539. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76540. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76541. plane._originalBuilderSideOrientation = options.sideOrientation;
  76542. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  76543. vertexData.applyToMesh(plane, options.updatable);
  76544. if (options.sourcePlane) {
  76545. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  76546. plane.setDirection(options.sourcePlane.normal.scale(-1));
  76547. }
  76548. return plane;
  76549. };
  76550. return PlaneBuilder;
  76551. }());
  76552. /***/ }),
  76553. /***/ "./Meshes/Builders/polygonBuilder.ts":
  76554. /*!*******************************************!*\
  76555. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  76556. \*******************************************/
  76557. /*! exports provided: PolygonBuilder */
  76558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76559. "use strict";
  76560. __webpack_require__.r(__webpack_exports__);
  76561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  76562. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76563. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76564. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76565. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  76566. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76567. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  76568. var faceUV = fUV || new Array(3);
  76569. var faceColors = fColors;
  76570. var colors = [];
  76571. // default face colors and UV if undefined
  76572. for (var f = 0; f < 3; f++) {
  76573. if (faceUV[f] === undefined) {
  76574. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76575. }
  76576. if (faceColors && faceColors[f] === undefined) {
  76577. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76578. }
  76579. }
  76580. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76581. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  76582. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  76583. var indices = polygon.getIndices();
  76584. // set face colours and textures
  76585. var idx = 0;
  76586. var face = 0;
  76587. for (var index = 0; index < normals.length; index += 3) {
  76588. //Edge Face no. 1
  76589. if (Math.abs(normals[index + 1]) < 0.001) {
  76590. face = 1;
  76591. }
  76592. //Top Face no. 0
  76593. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  76594. face = 0;
  76595. }
  76596. //Bottom Face no. 2
  76597. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  76598. face = 2;
  76599. }
  76600. idx = index / 3;
  76601. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  76602. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  76603. if (faceColors) {
  76604. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  76605. }
  76606. }
  76607. // sides
  76608. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  76609. // Result
  76610. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76611. vertexData.indices = indices;
  76612. vertexData.positions = positions;
  76613. vertexData.normals = normals;
  76614. vertexData.uvs = uvs;
  76615. if (faceColors) {
  76616. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76617. vertexData.colors = totalColors;
  76618. }
  76619. return vertexData;
  76620. };
  76621. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  76622. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76623. var options = {
  76624. shape: shape,
  76625. holes: holes,
  76626. updatable: updatable,
  76627. sideOrientation: sideOrientation
  76628. };
  76629. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76630. };
  76631. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  76632. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76633. var options = {
  76634. shape: shape,
  76635. holes: holes,
  76636. depth: depth,
  76637. updatable: updatable,
  76638. sideOrientation: sideOrientation
  76639. };
  76640. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  76641. };
  76642. /**
  76643. * Class containing static functions to help procedurally build meshes
  76644. */
  76645. var PolygonBuilder = /** @class */ (function () {
  76646. function PolygonBuilder() {
  76647. }
  76648. /**
  76649. * Creates a polygon mesh
  76650. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  76651. * * 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
  76652. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76654. * * 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)
  76655. * * Remember you can only change the shape positions, not their number when updating a polygon
  76656. * @param name defines the name of the mesh
  76657. * @param options defines the options used to create the mesh
  76658. * @param scene defines the hosting scene
  76659. * @param earcutInjection can be used to inject your own earcut reference
  76660. * @returns the polygon mesh
  76661. */
  76662. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  76663. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76664. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76665. var shape = options.shape;
  76666. var holes = options.holes || [];
  76667. var depth = options.depth || 0;
  76668. var contours = [];
  76669. var hole = [];
  76670. for (var i = 0; i < shape.length; i++) {
  76671. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  76672. }
  76673. var epsilon = 0.00000001;
  76674. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  76675. contours.pop();
  76676. }
  76677. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  76678. for (var hNb = 0; hNb < holes.length; hNb++) {
  76679. hole = [];
  76680. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  76681. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  76682. }
  76683. polygonTriangulation.addHole(hole);
  76684. }
  76685. var polygon = polygonTriangulation.build(options.updatable, depth);
  76686. polygon._originalBuilderSideOrientation = options.sideOrientation;
  76687. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  76688. vertexData.applyToMesh(polygon, options.updatable);
  76689. return polygon;
  76690. };
  76691. /**
  76692. * Creates an extruded polygon mesh, with depth in the Y direction.
  76693. * * 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)
  76694. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76695. * @param name defines the name of the mesh
  76696. * @param options defines the options used to create the mesh
  76697. * @param scene defines the hosting scene
  76698. * @param earcutInjection can be used to inject your own earcut reference
  76699. * @returns the polygon mesh
  76700. */
  76701. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  76702. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76703. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76704. };
  76705. return PolygonBuilder;
  76706. }());
  76707. /***/ }),
  76708. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  76709. /*!**********************************************!*\
  76710. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  76711. \**********************************************/
  76712. /*! exports provided: PolyhedronBuilder */
  76713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76714. "use strict";
  76715. __webpack_require__.r(__webpack_exports__);
  76716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  76717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76718. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76719. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76720. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  76721. // provided polyhedron types :
  76722. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  76723. // 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)
  76724. var polyhedra = [];
  76725. 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]] };
  76726. 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]] };
  76727. polyhedra[2] = {
  76728. 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]],
  76729. 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]]
  76730. };
  76731. polyhedra[3] = {
  76732. 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]],
  76733. 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]]
  76734. };
  76735. polyhedra[4] = {
  76736. 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]],
  76737. 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]]
  76738. };
  76739. 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]] };
  76740. 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]] };
  76741. 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]] };
  76742. 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]] };
  76743. 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]] };
  76744. 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]] };
  76745. 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]] };
  76746. 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]] };
  76747. 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]] };
  76748. polyhedra[14] = {
  76749. 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]],
  76750. 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]]
  76751. };
  76752. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  76753. var size = options.size;
  76754. var sizeX = options.sizeX || size || 1;
  76755. var sizeY = options.sizeY || size || 1;
  76756. var sizeZ = options.sizeZ || size || 1;
  76757. var data = options.custom || polyhedra[type];
  76758. var nbfaces = data.face.length;
  76759. var faceUV = options.faceUV || new Array(nbfaces);
  76760. var faceColors = options.faceColors;
  76761. var flat = (options.flat === undefined) ? true : options.flat;
  76762. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76763. var positions = new Array();
  76764. var indices = new Array();
  76765. var normals = new Array();
  76766. var uvs = new Array();
  76767. var colors = new Array();
  76768. var index = 0;
  76769. var faceIdx = 0; // face cursor in the array "indexes"
  76770. var indexes = new Array();
  76771. var i = 0;
  76772. var f = 0;
  76773. var u, v, ang, x, y, tmp;
  76774. // default face colors and UV if undefined
  76775. if (flat) {
  76776. for (f = 0; f < nbfaces; f++) {
  76777. if (faceColors && faceColors[f] === undefined) {
  76778. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76779. }
  76780. if (faceUV && faceUV[f] === undefined) {
  76781. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76782. }
  76783. }
  76784. }
  76785. if (!flat) {
  76786. for (i = 0; i < data.vertex.length; i++) {
  76787. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  76788. uvs.push(0, 0);
  76789. }
  76790. for (f = 0; f < nbfaces; f++) {
  76791. for (i = 0; i < data.face[f].length - 2; i++) {
  76792. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  76793. }
  76794. }
  76795. }
  76796. else {
  76797. for (f = 0; f < nbfaces; f++) {
  76798. var fl = data.face[f].length; // number of vertices of the current face
  76799. ang = 2 * Math.PI / fl;
  76800. x = 0.5 * Math.tan(ang / 2);
  76801. y = 0.5;
  76802. // positions, uvs, colors
  76803. for (i = 0; i < fl; i++) {
  76804. // positions
  76805. 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);
  76806. indexes.push(index);
  76807. index++;
  76808. // uvs
  76809. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  76810. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  76811. uvs.push(u, v);
  76812. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  76813. y = x * Math.sin(ang) + y * Math.cos(ang);
  76814. x = tmp;
  76815. // colors
  76816. if (faceColors) {
  76817. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  76818. }
  76819. }
  76820. // indices from indexes
  76821. for (i = 0; i < fl - 2; i++) {
  76822. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  76823. }
  76824. faceIdx += fl;
  76825. }
  76826. }
  76827. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76828. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76829. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76830. vertexData.positions = positions;
  76831. vertexData.indices = indices;
  76832. vertexData.normals = normals;
  76833. vertexData.uvs = uvs;
  76834. if (faceColors && flat) {
  76835. vertexData.colors = colors;
  76836. }
  76837. return vertexData;
  76838. };
  76839. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  76840. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  76841. };
  76842. /**
  76843. * Class containing static functions to help procedurally build meshes
  76844. */
  76845. var PolyhedronBuilder = /** @class */ (function () {
  76846. function PolyhedronBuilder() {
  76847. }
  76848. /**
  76849. * Creates a polyhedron mesh
  76850. * * 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
  76851. * * The parameter `size` (positive float, default 1) sets the polygon size
  76852. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76853. * * 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`
  76854. * * 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
  76855. * * 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)`)
  76856. * * 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
  76857. * * 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
  76858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76859. * * 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
  76860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76861. * @param name defines the name of the mesh
  76862. * @param options defines the options used to create the mesh
  76863. * @param scene defines the hosting scene
  76864. * @returns the polyhedron mesh
  76865. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  76866. */
  76867. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  76868. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76869. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76870. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  76871. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  76872. vertexData.applyToMesh(polyhedron, options.updatable);
  76873. return polyhedron;
  76874. };
  76875. return PolyhedronBuilder;
  76876. }());
  76877. /***/ }),
  76878. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  76879. /*!******************************************!*\
  76880. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  76881. \******************************************/
  76882. /*! exports provided: RibbonBuilder */
  76883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76884. "use strict";
  76885. __webpack_require__.r(__webpack_exports__);
  76886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  76887. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76888. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76889. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  76890. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76891. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  76892. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  76893. var pathArray = options.pathArray;
  76894. var closeArray = options.closeArray || false;
  76895. var closePath = options.closePath || false;
  76896. var invertUV = options.invertUV || false;
  76897. var defaultOffset = Math.floor(pathArray[0].length / 2);
  76898. var offset = options.offset || defaultOffset;
  76899. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  76900. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  76901. var customUV = options.uvs;
  76902. var customColors = options.colors;
  76903. var positions = [];
  76904. var indices = [];
  76905. var normals = [];
  76906. var uvs = [];
  76907. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  76908. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  76909. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  76910. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  76911. var minlg; // minimal length among all paths from pathArray
  76912. var lg = []; // array of path lengths : nb of vertex per path
  76913. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  76914. var p; // path iterator
  76915. var i; // point iterator
  76916. var j; // point iterator
  76917. // if single path in pathArray
  76918. if (pathArray.length < 2) {
  76919. var ar1 = [];
  76920. var ar2 = [];
  76921. for (i = 0; i < pathArray[0].length - offset; i++) {
  76922. ar1.push(pathArray[0][i]);
  76923. ar2.push(pathArray[0][i + offset]);
  76924. }
  76925. pathArray = [ar1, ar2];
  76926. }
  76927. // positions and horizontal distances (u)
  76928. var idc = 0;
  76929. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  76930. var path;
  76931. var l;
  76932. minlg = pathArray[0].length;
  76933. var vectlg;
  76934. var dist;
  76935. for (p = 0; p < pathArray.length; p++) {
  76936. uTotalDistance[p] = 0;
  76937. us[p] = [0];
  76938. path = pathArray[p];
  76939. l = path.length;
  76940. minlg = (minlg < l) ? minlg : l;
  76941. j = 0;
  76942. while (j < l) {
  76943. positions.push(path[j].x, path[j].y, path[j].z);
  76944. if (j > 0) {
  76945. vectlg = path[j].subtract(path[j - 1]).length();
  76946. dist = vectlg + uTotalDistance[p];
  76947. us[p].push(dist);
  76948. uTotalDistance[p] = dist;
  76949. }
  76950. j++;
  76951. }
  76952. if (closePath) { // an extra hidden vertex is added in the "positions" array
  76953. j--;
  76954. positions.push(path[0].x, path[0].y, path[0].z);
  76955. vectlg = path[j].subtract(path[0]).length();
  76956. dist = vectlg + uTotalDistance[p];
  76957. us[p].push(dist);
  76958. uTotalDistance[p] = dist;
  76959. }
  76960. lg[p] = l + closePathCorr;
  76961. idx[p] = idc;
  76962. idc += (l + closePathCorr);
  76963. }
  76964. // vertical distances (v)
  76965. var path1;
  76966. var path2;
  76967. var vertex1 = null;
  76968. var vertex2 = null;
  76969. for (i = 0; i < minlg + closePathCorr; i++) {
  76970. vTotalDistance[i] = 0;
  76971. vs[i] = [0];
  76972. for (p = 0; p < pathArray.length - 1; p++) {
  76973. path1 = pathArray[p];
  76974. path2 = pathArray[p + 1];
  76975. if (i === minlg) { // closePath
  76976. vertex1 = path1[0];
  76977. vertex2 = path2[0];
  76978. }
  76979. else {
  76980. vertex1 = path1[i];
  76981. vertex2 = path2[i];
  76982. }
  76983. vectlg = vertex2.subtract(vertex1).length();
  76984. dist = vectlg + vTotalDistance[i];
  76985. vs[i].push(dist);
  76986. vTotalDistance[i] = dist;
  76987. }
  76988. if (closeArray && vertex2 && vertex1) {
  76989. path1 = pathArray[p];
  76990. path2 = pathArray[0];
  76991. if (i === minlg) { // closePath
  76992. vertex2 = path2[0];
  76993. }
  76994. vectlg = vertex2.subtract(vertex1).length();
  76995. dist = vectlg + vTotalDistance[i];
  76996. vTotalDistance[i] = dist;
  76997. }
  76998. }
  76999. // uvs
  77000. var u;
  77001. var v;
  77002. if (customUV) {
  77003. for (p = 0; p < customUV.length; p++) {
  77004. uvs.push(customUV[p].x, customUV[p].y);
  77005. }
  77006. }
  77007. else {
  77008. for (p = 0; p < pathArray.length; p++) {
  77009. for (i = 0; i < minlg + closePathCorr; i++) {
  77010. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  77011. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  77012. if (invertUV) {
  77013. uvs.push(v, u);
  77014. }
  77015. else {
  77016. uvs.push(u, v);
  77017. }
  77018. }
  77019. }
  77020. }
  77021. // indices
  77022. p = 0; // path index
  77023. var pi = 0; // positions array index
  77024. var l1 = lg[p] - 1; // path1 length
  77025. var l2 = lg[p + 1] - 1; // path2 length
  77026. var min = (l1 < l2) ? l1 : l2; // current path stop index
  77027. var shft = idx[1] - idx[0]; // shift
  77028. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  77029. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  77030. // 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
  77031. indices.push(pi, pi + shft, pi + 1);
  77032. indices.push(pi + shft + 1, pi + 1, pi + shft);
  77033. pi += 1;
  77034. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  77035. p++;
  77036. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  77037. shft = idx[0] - idx[p];
  77038. l1 = lg[p] - 1;
  77039. l2 = lg[0] - 1;
  77040. }
  77041. else {
  77042. shft = idx[p + 1] - idx[p];
  77043. l1 = lg[p] - 1;
  77044. l2 = lg[p + 1] - 1;
  77045. }
  77046. pi = idx[p];
  77047. min = (l1 < l2) ? l1 + pi : l2 + pi;
  77048. }
  77049. }
  77050. // normals
  77051. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  77052. if (closePath) { // update both the first and last vertex normals to their average value
  77053. var indexFirst = 0;
  77054. var indexLast = 0;
  77055. for (p = 0; p < pathArray.length; p++) {
  77056. indexFirst = idx[p] * 3;
  77057. if (p + 1 < pathArray.length) {
  77058. indexLast = (idx[p + 1] - 1) * 3;
  77059. }
  77060. else {
  77061. indexLast = normals.length - 3;
  77062. }
  77063. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77064. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77065. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77066. normals[indexLast] = normals[indexFirst];
  77067. normals[indexLast + 1] = normals[indexFirst + 1];
  77068. normals[indexLast + 2] = normals[indexFirst + 2];
  77069. }
  77070. }
  77071. // sides
  77072. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77073. // Colors
  77074. var colors = null;
  77075. if (customColors) {
  77076. colors = new Float32Array(customColors.length * 4);
  77077. for (var c = 0; c < customColors.length; c++) {
  77078. colors[c * 4] = customColors[c].r;
  77079. colors[c * 4 + 1] = customColors[c].g;
  77080. colors[c * 4 + 2] = customColors[c].b;
  77081. colors[c * 4 + 3] = customColors[c].a;
  77082. }
  77083. }
  77084. // Result
  77085. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77086. var positions32 = new Float32Array(positions);
  77087. var normals32 = new Float32Array(normals);
  77088. var uvs32 = new Float32Array(uvs);
  77089. vertexData.indices = indices;
  77090. vertexData.positions = positions32;
  77091. vertexData.normals = normals32;
  77092. vertexData.uvs = uvs32;
  77093. if (colors) {
  77094. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77095. }
  77096. if (closePath) {
  77097. vertexData._idx = idx;
  77098. }
  77099. return vertexData;
  77100. };
  77101. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  77102. if (closeArray === void 0) { closeArray = false; }
  77103. if (updatable === void 0) { updatable = false; }
  77104. return RibbonBuilder.CreateRibbon(name, {
  77105. pathArray: pathArray,
  77106. closeArray: closeArray,
  77107. closePath: closePath,
  77108. offset: offset,
  77109. updatable: updatable,
  77110. sideOrientation: sideOrientation,
  77111. instance: instance
  77112. }, scene);
  77113. };
  77114. /**
  77115. * Class containing static functions to help procedurally build meshes
  77116. */
  77117. var RibbonBuilder = /** @class */ (function () {
  77118. function RibbonBuilder() {
  77119. }
  77120. /**
  77121. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77122. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  77123. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  77124. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  77125. * * 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
  77126. * * 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
  77127. * * 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
  77128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77129. * * 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
  77130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77131. * * 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
  77132. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  77133. * * 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
  77134. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  77135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77136. * @param name defines the name of the mesh
  77137. * @param options defines the options used to create the mesh
  77138. * @param scene defines the hosting scene
  77139. * @returns the ribbon mesh
  77140. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  77141. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77142. */
  77143. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  77144. if (scene === void 0) { scene = null; }
  77145. var pathArray = options.pathArray;
  77146. var closeArray = options.closeArray;
  77147. var closePath = options.closePath;
  77148. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77149. var instance = options.instance;
  77150. var updatable = options.updatable;
  77151. if (instance) { // existing ribbon instance update
  77152. // positionFunction : ribbon case
  77153. // only pathArray and sideOrientation parameters are taken into account for positions update
  77154. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  77155. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  77156. var positionFunction = function (positions) {
  77157. var minlg = pathArray[0].length;
  77158. var mesh = instance;
  77159. var i = 0;
  77160. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  77161. for (var si = 1; si <= ns; ++si) {
  77162. for (var p = 0; p < pathArray.length; ++p) {
  77163. var path = pathArray[p];
  77164. var l = path.length;
  77165. minlg = (minlg < l) ? minlg : l;
  77166. for (var j = 0; j < minlg; ++j) {
  77167. var pathPoint = path[j];
  77168. positions[i] = pathPoint.x;
  77169. positions[i + 1] = pathPoint.y;
  77170. positions[i + 2] = pathPoint.z;
  77171. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77172. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77173. i += 3;
  77174. }
  77175. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  77176. var pathPoint = path[0];
  77177. positions[i] = pathPoint.x;
  77178. positions[i + 1] = pathPoint.y;
  77179. positions[i + 2] = pathPoint.z;
  77180. i += 3;
  77181. }
  77182. }
  77183. }
  77184. };
  77185. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77186. positionFunction(positions);
  77187. if (instance._boundingInfo) {
  77188. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77189. }
  77190. else {
  77191. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77192. }
  77193. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77194. if (options.colors) {
  77195. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77196. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77197. var color = options.colors[c];
  77198. colors[colorIndex] = color.r;
  77199. colors[colorIndex + 1] = color.g;
  77200. colors[colorIndex + 2] = color.b;
  77201. colors[colorIndex + 3] = color.a;
  77202. }
  77203. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77204. }
  77205. if (options.uvs) {
  77206. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77207. for (var i = 0; i < options.uvs.length; i++) {
  77208. uvs[i * 2] = options.uvs[i].x;
  77209. uvs[i * 2 + 1] = options.uvs[i].y;
  77210. }
  77211. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77212. }
  77213. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77214. var indices = instance.getIndices();
  77215. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77216. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77217. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77218. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77219. var indexFirst = 0;
  77220. var indexLast = 0;
  77221. for (var p = 0; p < pathArray.length; p++) {
  77222. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77223. if (p + 1 < pathArray.length) {
  77224. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77225. }
  77226. else {
  77227. indexLast = normals.length - 3;
  77228. }
  77229. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77230. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77231. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77232. normals[indexLast] = normals[indexFirst];
  77233. normals[indexLast + 1] = normals[indexFirst + 1];
  77234. normals[indexLast + 2] = normals[indexFirst + 2];
  77235. }
  77236. }
  77237. if (!(instance.areNormalsFrozen)) {
  77238. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77239. }
  77240. }
  77241. return instance;
  77242. }
  77243. else { // new ribbon creation
  77244. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77245. ribbon._originalBuilderSideOrientation = sideOrientation;
  77246. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77247. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77248. if (closePath) {
  77249. ribbon._creationDataStorage.idx = vertexData._idx;
  77250. }
  77251. ribbon._creationDataStorage.closePath = closePath;
  77252. ribbon._creationDataStorage.closeArray = closeArray;
  77253. vertexData.applyToMesh(ribbon, updatable);
  77254. return ribbon;
  77255. }
  77256. };
  77257. return RibbonBuilder;
  77258. }());
  77259. /***/ }),
  77260. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77261. /*!*****************************************!*\
  77262. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77263. \*****************************************/
  77264. /*! exports provided: ShapeBuilder */
  77265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77266. "use strict";
  77267. __webpack_require__.r(__webpack_exports__);
  77268. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77269. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77270. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77271. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77272. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77273. if (scene === void 0) { scene = null; }
  77274. var options = {
  77275. shape: shape,
  77276. path: path,
  77277. scale: scale,
  77278. rotation: rotation,
  77279. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77280. sideOrientation: sideOrientation,
  77281. instance: instance,
  77282. updatable: updatable
  77283. };
  77284. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77285. };
  77286. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77287. var options = {
  77288. shape: shape,
  77289. path: path,
  77290. scaleFunction: scaleFunction,
  77291. rotationFunction: rotationFunction,
  77292. ribbonCloseArray: ribbonCloseArray,
  77293. ribbonClosePath: ribbonClosePath,
  77294. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77295. sideOrientation: sideOrientation,
  77296. instance: instance,
  77297. updatable: updatable
  77298. };
  77299. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77300. };
  77301. /**
  77302. * Class containing static functions to help procedurally build meshes
  77303. */
  77304. var ShapeBuilder = /** @class */ (function () {
  77305. function ShapeBuilder() {
  77306. }
  77307. /**
  77308. * 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.
  77309. * * 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.
  77310. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77311. * * 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.
  77312. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77313. * * 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
  77314. * * 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
  77315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77317. * * 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
  77318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77320. * @param name defines the name of the mesh
  77321. * @param options defines the options used to create the mesh
  77322. * @param scene defines the hosting scene
  77323. * @returns the extruded shape mesh
  77324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77326. */
  77327. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77328. if (scene === void 0) { scene = null; }
  77329. var path = options.path;
  77330. var shape = options.shape;
  77331. var scale = options.scale || 1;
  77332. var rotation = options.rotation || 0;
  77333. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77334. var updatable = options.updatable;
  77335. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77336. var instance = options.instance || null;
  77337. var invertUV = options.invertUV || false;
  77338. 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);
  77339. };
  77340. /**
  77341. * Creates an custom extruded shape mesh.
  77342. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77343. * * 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.
  77344. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77345. * * 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
  77346. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77347. * * 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
  77348. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77349. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77350. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77351. * * 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
  77352. * * 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
  77353. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77355. * * 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
  77356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77358. * @param name defines the name of the mesh
  77359. * @param options defines the options used to create the mesh
  77360. * @param scene defines the hosting scene
  77361. * @returns the custom extruded shape mesh
  77362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77365. */
  77366. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77367. var path = options.path;
  77368. var shape = options.shape;
  77369. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77370. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77371. var ribbonCloseArray = options.ribbonCloseArray || false;
  77372. var ribbonClosePath = options.ribbonClosePath || false;
  77373. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77374. var updatable = options.updatable;
  77375. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77376. var instance = options.instance;
  77377. var invertUV = options.invertUV || false;
  77378. 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);
  77379. };
  77380. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77381. // extrusion geometry
  77382. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77383. var tangents = path3D.getTangents();
  77384. var normals = path3D.getNormals();
  77385. var binormals = path3D.getBinormals();
  77386. var distances = path3D.getDistances();
  77387. var angle = 0;
  77388. var returnScale = function () { return scale !== null ? scale : 1; };
  77389. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77390. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77391. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77392. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77393. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77394. for (var i = 0; i < curve.length; i++) {
  77395. var shapePath = new Array();
  77396. var angleStep = rotate(i, distances[i]);
  77397. var scaleRatio = scl(i, distances[i]);
  77398. for (var p = 0; p < shape.length; p++) {
  77399. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77400. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77401. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77402. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77403. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77404. shapePath[p] = rotated;
  77405. }
  77406. shapePaths[index] = shapePath;
  77407. angle += angleStep;
  77408. index++;
  77409. }
  77410. // cap
  77411. var capPath = function (shapePath) {
  77412. var pointCap = Array();
  77413. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77414. var i;
  77415. for (i = 0; i < shapePath.length; i++) {
  77416. barycenter.addInPlace(shapePath[i]);
  77417. }
  77418. barycenter.scaleInPlace(1.0 / shapePath.length);
  77419. for (i = 0; i < shapePath.length; i++) {
  77420. pointCap.push(barycenter);
  77421. }
  77422. return pointCap;
  77423. };
  77424. switch (cap) {
  77425. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77426. break;
  77427. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77428. shapePaths[0] = capPath(shapePaths[2]);
  77429. shapePaths[1] = shapePaths[2];
  77430. break;
  77431. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77432. shapePaths[index] = shapePaths[index - 1];
  77433. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77434. break;
  77435. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77436. shapePaths[0] = capPath(shapePaths[2]);
  77437. shapePaths[1] = shapePaths[2];
  77438. shapePaths[index] = shapePaths[index - 1];
  77439. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77440. break;
  77441. default:
  77442. break;
  77443. }
  77444. return shapePaths;
  77445. };
  77446. var path3D;
  77447. var pathArray;
  77448. if (instance) { // instance update
  77449. var storage = instance._creationDataStorage;
  77450. path3D = storage.path3D.update(curve);
  77451. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  77452. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  77453. return instance;
  77454. }
  77455. // extruded shape creation
  77456. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  77457. var newShapePaths = new Array();
  77458. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77459. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  77460. 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);
  77461. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  77462. extrudedGeneric._creationDataStorage.path3D = path3D;
  77463. extrudedGeneric._creationDataStorage.cap = cap;
  77464. return extrudedGeneric;
  77465. };
  77466. return ShapeBuilder;
  77467. }());
  77468. /***/ }),
  77469. /***/ "./Meshes/Builders/sphereBuilder.ts":
  77470. /*!******************************************!*\
  77471. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  77472. \******************************************/
  77473. /*! exports provided: SphereBuilder */
  77474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77475. "use strict";
  77476. __webpack_require__.r(__webpack_exports__);
  77477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  77478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77479. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77480. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77481. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  77482. var segments = options.segments || 32;
  77483. var diameterX = options.diameterX || options.diameter || 1;
  77484. var diameterY = options.diameterY || options.diameter || 1;
  77485. var diameterZ = options.diameterZ || options.diameter || 1;
  77486. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77487. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  77488. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77489. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  77490. var totalZRotationSteps = 2 + segments;
  77491. var totalYRotationSteps = 2 * totalZRotationSteps;
  77492. var indices = [];
  77493. var positions = [];
  77494. var normals = [];
  77495. var uvs = [];
  77496. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  77497. var normalizedZ = zRotationStep / totalZRotationSteps;
  77498. var angleZ = normalizedZ * Math.PI * slice;
  77499. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  77500. var normalizedY = yRotationStep / totalYRotationSteps;
  77501. var angleY = normalizedY * Math.PI * 2 * arc;
  77502. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  77503. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  77504. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  77505. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  77506. var vertex = complete.multiply(radius);
  77507. var normal = complete.divide(radius).normalize();
  77508. positions.push(vertex.x, vertex.y, vertex.z);
  77509. normals.push(normal.x, normal.y, normal.z);
  77510. uvs.push(normalizedY, normalizedZ);
  77511. }
  77512. if (zRotationStep > 0) {
  77513. var verticesCount = positions.length / 3;
  77514. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  77515. indices.push((firstIndex));
  77516. indices.push((firstIndex + 1));
  77517. indices.push(firstIndex + totalYRotationSteps + 1);
  77518. indices.push((firstIndex + totalYRotationSteps + 1));
  77519. indices.push((firstIndex + 1));
  77520. indices.push((firstIndex + totalYRotationSteps + 2));
  77521. }
  77522. }
  77523. }
  77524. // Sides
  77525. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77526. // Result
  77527. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77528. vertexData.indices = indices;
  77529. vertexData.positions = positions;
  77530. vertexData.normals = normals;
  77531. vertexData.uvs = uvs;
  77532. return vertexData;
  77533. };
  77534. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  77535. var options = {
  77536. segments: segments,
  77537. diameterX: diameter,
  77538. diameterY: diameter,
  77539. diameterZ: diameter,
  77540. sideOrientation: sideOrientation,
  77541. updatable: updatable
  77542. };
  77543. return SphereBuilder.CreateSphere(name, options, scene);
  77544. };
  77545. /**
  77546. * Class containing static functions to help procedurally build meshes
  77547. */
  77548. var SphereBuilder = /** @class */ (function () {
  77549. function SphereBuilder() {
  77550. }
  77551. /**
  77552. * Creates a sphere mesh
  77553. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  77554. * * 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`)
  77555. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  77556. * * 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
  77557. * * 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)
  77558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77559. * * 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
  77560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77561. * @param name defines the name of the mesh
  77562. * @param options defines the options used to create the mesh
  77563. * @param scene defines the hosting scene
  77564. * @returns the sphere mesh
  77565. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  77566. */
  77567. SphereBuilder.CreateSphere = function (name, options, scene) {
  77568. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77569. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77570. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77571. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  77572. vertexData.applyToMesh(sphere, options.updatable);
  77573. return sphere;
  77574. };
  77575. return SphereBuilder;
  77576. }());
  77577. /***/ }),
  77578. /***/ "./Meshes/Builders/torusBuilder.ts":
  77579. /*!*****************************************!*\
  77580. !*** ./Meshes/Builders/torusBuilder.ts ***!
  77581. \*****************************************/
  77582. /*! exports provided: TorusBuilder */
  77583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77584. "use strict";
  77585. __webpack_require__.r(__webpack_exports__);
  77586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  77587. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77588. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77589. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77590. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  77591. var indices = [];
  77592. var positions = [];
  77593. var normals = [];
  77594. var uvs = [];
  77595. var diameter = options.diameter || 1;
  77596. var thickness = options.thickness || 0.5;
  77597. var tessellation = options.tessellation || 16;
  77598. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77599. var stride = tessellation + 1;
  77600. for (var i = 0; i <= tessellation; i++) {
  77601. var u = i / tessellation;
  77602. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  77603. var transform = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(diameter / 2.0, 0, 0).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(outerAngle));
  77604. for (var j = 0; j <= tessellation; j++) {
  77605. var v = 1 - j / tessellation;
  77606. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  77607. var dx = Math.cos(innerAngle);
  77608. var dy = Math.sin(innerAngle);
  77609. // Create a vertex.
  77610. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  77611. var position = normal.scale(thickness / 2);
  77612. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  77613. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  77614. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  77615. positions.push(position.x, position.y, position.z);
  77616. normals.push(normal.x, normal.y, normal.z);
  77617. uvs.push(textureCoordinate.x, textureCoordinate.y);
  77618. // And create indices for two triangles.
  77619. var nextI = (i + 1) % stride;
  77620. var nextJ = (j + 1) % stride;
  77621. indices.push(i * stride + j);
  77622. indices.push(i * stride + nextJ);
  77623. indices.push(nextI * stride + j);
  77624. indices.push(i * stride + nextJ);
  77625. indices.push(nextI * stride + nextJ);
  77626. indices.push(nextI * stride + j);
  77627. }
  77628. }
  77629. // Sides
  77630. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77631. // Result
  77632. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77633. vertexData.indices = indices;
  77634. vertexData.positions = positions;
  77635. vertexData.normals = normals;
  77636. vertexData.uvs = uvs;
  77637. return vertexData;
  77638. };
  77639. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  77640. var options = {
  77641. diameter: diameter,
  77642. thickness: thickness,
  77643. tessellation: tessellation,
  77644. sideOrientation: sideOrientation,
  77645. updatable: updatable
  77646. };
  77647. return TorusBuilder.CreateTorus(name, options, scene);
  77648. };
  77649. /**
  77650. * Class containing static functions to help procedurally build meshes
  77651. */
  77652. var TorusBuilder = /** @class */ (function () {
  77653. function TorusBuilder() {
  77654. }
  77655. /**
  77656. * Creates a torus mesh
  77657. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  77658. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  77659. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  77660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77661. * * 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
  77662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77663. * @param name defines the name of the mesh
  77664. * @param options defines the options used to create the mesh
  77665. * @param scene defines the hosting scene
  77666. * @returns the torus mesh
  77667. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  77668. */
  77669. TorusBuilder.CreateTorus = function (name, options, scene) {
  77670. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77671. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77672. torus._originalBuilderSideOrientation = options.sideOrientation;
  77673. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  77674. vertexData.applyToMesh(torus, options.updatable);
  77675. return torus;
  77676. };
  77677. return TorusBuilder;
  77678. }());
  77679. /***/ }),
  77680. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  77681. /*!*********************************************!*\
  77682. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  77683. \*********************************************/
  77684. /*! exports provided: TorusKnotBuilder */
  77685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77686. "use strict";
  77687. __webpack_require__.r(__webpack_exports__);
  77688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  77689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77690. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77691. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77692. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  77693. var indices = new Array();
  77694. var positions = new Array();
  77695. var normals = new Array();
  77696. var uvs = new Array();
  77697. var radius = options.radius || 2;
  77698. var tube = options.tube || 0.5;
  77699. var radialSegments = options.radialSegments || 32;
  77700. var tubularSegments = options.tubularSegments || 32;
  77701. var p = options.p || 2;
  77702. var q = options.q || 3;
  77703. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77704. // Helper
  77705. var getPos = function (angle) {
  77706. var cu = Math.cos(angle);
  77707. var su = Math.sin(angle);
  77708. var quOverP = q / p * angle;
  77709. var cs = Math.cos(quOverP);
  77710. var tx = radius * (2 + cs) * 0.5 * cu;
  77711. var ty = radius * (2 + cs) * su * 0.5;
  77712. var tz = radius * Math.sin(quOverP) * 0.5;
  77713. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  77714. };
  77715. // Vertices
  77716. var i;
  77717. var j;
  77718. for (i = 0; i <= radialSegments; i++) {
  77719. var modI = i % radialSegments;
  77720. var u = modI / radialSegments * 2 * p * Math.PI;
  77721. var p1 = getPos(u);
  77722. var p2 = getPos(u + 0.01);
  77723. var tang = p2.subtract(p1);
  77724. var n = p2.add(p1);
  77725. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  77726. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  77727. bitan.normalize();
  77728. n.normalize();
  77729. for (j = 0; j < tubularSegments; j++) {
  77730. var modJ = j % tubularSegments;
  77731. var v = modJ / tubularSegments * 2 * Math.PI;
  77732. var cx = -tube * Math.cos(v);
  77733. var cy = tube * Math.sin(v);
  77734. positions.push(p1.x + cx * n.x + cy * bitan.x);
  77735. positions.push(p1.y + cx * n.y + cy * bitan.y);
  77736. positions.push(p1.z + cx * n.z + cy * bitan.z);
  77737. uvs.push(i / radialSegments);
  77738. uvs.push(j / tubularSegments);
  77739. }
  77740. }
  77741. for (i = 0; i < radialSegments; i++) {
  77742. for (j = 0; j < tubularSegments; j++) {
  77743. var jNext = (j + 1) % tubularSegments;
  77744. var a = i * tubularSegments + j;
  77745. var b = (i + 1) * tubularSegments + j;
  77746. var c = (i + 1) * tubularSegments + jNext;
  77747. var d = i * tubularSegments + jNext;
  77748. indices.push(d);
  77749. indices.push(b);
  77750. indices.push(a);
  77751. indices.push(d);
  77752. indices.push(c);
  77753. indices.push(b);
  77754. }
  77755. }
  77756. // Normals
  77757. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77758. // Sides
  77759. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77760. // Result
  77761. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77762. vertexData.indices = indices;
  77763. vertexData.positions = positions;
  77764. vertexData.normals = normals;
  77765. vertexData.uvs = uvs;
  77766. return vertexData;
  77767. };
  77768. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  77769. var options = {
  77770. radius: radius,
  77771. tube: tube,
  77772. radialSegments: radialSegments,
  77773. tubularSegments: tubularSegments,
  77774. p: p,
  77775. q: q,
  77776. sideOrientation: sideOrientation,
  77777. updatable: updatable
  77778. };
  77779. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  77780. };
  77781. /**
  77782. * Class containing static functions to help procedurally build meshes
  77783. */
  77784. var TorusKnotBuilder = /** @class */ (function () {
  77785. function TorusKnotBuilder() {
  77786. }
  77787. /**
  77788. * Creates a torus knot mesh
  77789. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  77790. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  77791. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  77792. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  77793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77794. * * 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
  77795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77796. * @param name defines the name of the mesh
  77797. * @param options defines the options used to create the mesh
  77798. * @param scene defines the hosting scene
  77799. * @returns the torus knot mesh
  77800. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  77801. */
  77802. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  77803. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77804. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77805. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  77806. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  77807. vertexData.applyToMesh(torusKnot, options.updatable);
  77808. return torusKnot;
  77809. };
  77810. return TorusKnotBuilder;
  77811. }());
  77812. /***/ }),
  77813. /***/ "./Meshes/Builders/tubeBuilder.ts":
  77814. /*!****************************************!*\
  77815. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  77816. \****************************************/
  77817. /*! exports provided: TubeBuilder */
  77818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77819. "use strict";
  77820. __webpack_require__.r(__webpack_exports__);
  77821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  77822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77823. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77824. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77825. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  77826. var options = {
  77827. path: path,
  77828. radius: radius,
  77829. tessellation: tessellation,
  77830. radiusFunction: radiusFunction,
  77831. arc: 1,
  77832. cap: cap,
  77833. updatable: updatable,
  77834. sideOrientation: sideOrientation,
  77835. instance: instance
  77836. };
  77837. return TubeBuilder.CreateTube(name, options, scene);
  77838. };
  77839. /**
  77840. * Class containing static functions to help procedurally build meshes
  77841. */
  77842. var TubeBuilder = /** @class */ (function () {
  77843. function TubeBuilder() {
  77844. }
  77845. /**
  77846. * Creates a tube mesh.
  77847. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77848. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  77849. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  77850. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  77851. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  77852. * * 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)
  77853. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  77854. * * 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
  77855. * * 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
  77856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77857. * * 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
  77858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77860. * @param name defines the name of the mesh
  77861. * @param options defines the options used to create the mesh
  77862. * @param scene defines the hosting scene
  77863. * @returns the tube mesh
  77864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77865. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  77866. */
  77867. TubeBuilder.CreateTube = function (name, options, scene) {
  77868. var path = options.path;
  77869. var instance = options.instance;
  77870. var radius = 1.0;
  77871. if (options.radius !== undefined) {
  77872. radius = options.radius;
  77873. }
  77874. else if (instance) {
  77875. radius = instance._creationDataStorage.radius;
  77876. }
  77877. var tessellation = options.tessellation || 64 | 0;
  77878. var radiusFunction = options.radiusFunction || null;
  77879. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77880. var invertUV = options.invertUV || false;
  77881. var updatable = options.updatable;
  77882. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77883. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  77884. // tube geometry
  77885. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  77886. var tangents = path3D.getTangents();
  77887. var normals = path3D.getNormals();
  77888. var distances = path3D.getDistances();
  77889. var pi2 = Math.PI * 2;
  77890. var step = pi2 / tessellation * arc;
  77891. var returnRadius = function () { return radius; };
  77892. var radiusFunctionFinal = radiusFunction || returnRadius;
  77893. var circlePath;
  77894. var rad;
  77895. var normal;
  77896. var rotated;
  77897. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77898. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77899. for (var i = 0; i < path.length; i++) {
  77900. rad = radiusFunctionFinal(i, distances[i]); // current radius
  77901. circlePath = Array(); // current circle array
  77902. normal = normals[i]; // current normal
  77903. for (var t = 0; t < tessellation; t++) {
  77904. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  77905. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77906. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  77907. rotated.scaleInPlace(rad).addInPlace(path[i]);
  77908. circlePath[t] = rotated;
  77909. }
  77910. circlePaths[index] = circlePath;
  77911. index++;
  77912. }
  77913. // cap
  77914. var capPath = function (nbPoints, pathIndex) {
  77915. var pointCap = Array();
  77916. for (var i = 0; i < nbPoints; i++) {
  77917. pointCap.push(path[pathIndex]);
  77918. }
  77919. return pointCap;
  77920. };
  77921. switch (cap) {
  77922. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77923. break;
  77924. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77925. circlePaths[0] = capPath(tessellation, 0);
  77926. circlePaths[1] = circlePaths[2].slice(0);
  77927. break;
  77928. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77929. circlePaths[index] = circlePaths[index - 1].slice(0);
  77930. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  77931. break;
  77932. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77933. circlePaths[0] = capPath(tessellation, 0);
  77934. circlePaths[1] = circlePaths[2].slice(0);
  77935. circlePaths[index] = circlePaths[index - 1].slice(0);
  77936. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  77937. break;
  77938. default:
  77939. break;
  77940. }
  77941. return circlePaths;
  77942. };
  77943. var path3D;
  77944. var pathArray;
  77945. if (instance) { // tube update
  77946. var storage = instance._creationDataStorage;
  77947. var arc = options.arc || storage.arc;
  77948. path3D = storage.path3D.update(path);
  77949. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  77950. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  77951. // Update mode, no need to recreate the storage.
  77952. storage.path3D = path3D;
  77953. storage.pathArray = pathArray;
  77954. storage.arc = arc;
  77955. storage.radius = radius;
  77956. return instance;
  77957. }
  77958. // tube creation
  77959. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  77960. var newPathArray = new Array();
  77961. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77962. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  77963. 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);
  77964. tube._creationDataStorage.pathArray = pathArray;
  77965. tube._creationDataStorage.path3D = path3D;
  77966. tube._creationDataStorage.tessellation = tessellation;
  77967. tube._creationDataStorage.cap = cap;
  77968. tube._creationDataStorage.arc = options.arc;
  77969. tube._creationDataStorage.radius = radius;
  77970. return tube;
  77971. };
  77972. return TubeBuilder;
  77973. }());
  77974. /***/ }),
  77975. /***/ "./Meshes/Compression/dracoCompression.ts":
  77976. /*!************************************************!*\
  77977. !*** ./Meshes/Compression/dracoCompression.ts ***!
  77978. \************************************************/
  77979. /*! exports provided: DracoCompression */
  77980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77981. "use strict";
  77982. __webpack_require__.r(__webpack_exports__);
  77983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  77984. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  77985. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77986. /**
  77987. * Draco compression (https://google.github.io/draco/)
  77988. *
  77989. * This class wraps the Draco module.
  77990. *
  77991. * **Encoder**
  77992. *
  77993. * The encoder is not currently implemented.
  77994. *
  77995. * **Decoder**
  77996. *
  77997. * 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.
  77998. *
  77999. * To update the configuration, use the following code:
  78000. * ```javascript
  78001. * DracoCompression.Configuration = {
  78002. * decoder: {
  78003. * wasmUrl: "<url to the WebAssembly library>",
  78004. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  78005. * fallbackUrl: "<url to the fallback JavaScript library>",
  78006. * }
  78007. * };
  78008. * ```
  78009. *
  78010. * 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.
  78011. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  78012. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  78013. *
  78014. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  78015. * ```javascript
  78016. * var dracoCompression = new DracoCompression();
  78017. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  78018. * [VertexBuffer.PositionKind]: 0
  78019. * });
  78020. * ```
  78021. *
  78022. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  78023. */
  78024. var DracoCompression = /** @class */ (function () {
  78025. /**
  78026. * Constructor
  78027. */
  78028. function DracoCompression() {
  78029. }
  78030. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  78031. /**
  78032. * Returns true if the decoder is available.
  78033. */
  78034. get: function () {
  78035. if (typeof DracoDecoderModule !== "undefined") {
  78036. return true;
  78037. }
  78038. var decoder = DracoCompression.Configuration.decoder;
  78039. if (decoder) {
  78040. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78041. return true;
  78042. }
  78043. if (decoder.fallbackUrl) {
  78044. return true;
  78045. }
  78046. }
  78047. return false;
  78048. },
  78049. enumerable: true,
  78050. configurable: true
  78051. });
  78052. /**
  78053. * Stop all async operations and release resources.
  78054. */
  78055. DracoCompression.prototype.dispose = function () {
  78056. };
  78057. /**
  78058. * Decode Draco compressed mesh data to vertex data.
  78059. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  78060. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  78061. * @returns A promise that resolves with the decoded vertex data
  78062. */
  78063. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  78064. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  78065. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  78066. var module = wrappedModule.module;
  78067. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78068. var buffer = new module.DecoderBuffer();
  78069. buffer.Init(dataView, dataView.byteLength);
  78070. var decoder = new module.Decoder();
  78071. var geometry;
  78072. var status;
  78073. try {
  78074. var type = decoder.GetEncodedGeometryType(buffer);
  78075. switch (type) {
  78076. case module.TRIANGULAR_MESH:
  78077. geometry = new module.Mesh();
  78078. status = decoder.DecodeBufferToMesh(buffer, geometry);
  78079. break;
  78080. case module.POINT_CLOUD:
  78081. geometry = new module.PointCloud();
  78082. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  78083. break;
  78084. default:
  78085. throw new Error("Invalid geometry type " + type);
  78086. }
  78087. if (!status.ok() || !geometry.ptr) {
  78088. throw new Error(status.error_msg());
  78089. }
  78090. var numPoints = geometry.num_points();
  78091. if (type === module.TRIANGULAR_MESH) {
  78092. var numFaces = geometry.num_faces();
  78093. var faceIndices = new module.DracoInt32Array();
  78094. try {
  78095. var indices = new Uint32Array(numFaces * 3);
  78096. for (var i = 0; i < numFaces; i++) {
  78097. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  78098. var offset = i * 3;
  78099. indices[offset + 0] = faceIndices.GetValue(0);
  78100. indices[offset + 1] = faceIndices.GetValue(1);
  78101. indices[offset + 2] = faceIndices.GetValue(2);
  78102. }
  78103. vertexData.indices = indices;
  78104. }
  78105. finally {
  78106. module.destroy(faceIndices);
  78107. }
  78108. }
  78109. for (var kind in attributes) {
  78110. var uniqueId = attributes[kind];
  78111. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  78112. var dracoData = new module.DracoFloat32Array();
  78113. try {
  78114. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  78115. var babylonData = new Float32Array(numPoints * attribute.num_components());
  78116. for (var i = 0; i < babylonData.length; i++) {
  78117. babylonData[i] = dracoData.GetValue(i);
  78118. }
  78119. vertexData.set(babylonData, kind);
  78120. }
  78121. finally {
  78122. module.destroy(dracoData);
  78123. }
  78124. }
  78125. }
  78126. finally {
  78127. if (geometry) {
  78128. module.destroy(geometry);
  78129. }
  78130. module.destroy(decoder);
  78131. module.destroy(buffer);
  78132. }
  78133. return vertexData;
  78134. });
  78135. };
  78136. DracoCompression._GetDecoderModule = function () {
  78137. if (!DracoCompression._DecoderModulePromise) {
  78138. var promise = null;
  78139. var config_1 = {};
  78140. if (typeof DracoDecoderModule !== "undefined") {
  78141. promise = Promise.resolve();
  78142. }
  78143. else {
  78144. var decoder = DracoCompression.Configuration.decoder;
  78145. if (decoder) {
  78146. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78147. promise = Promise.all([
  78148. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  78149. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  78150. config_1.wasmBinary = data;
  78151. })
  78152. ]);
  78153. }
  78154. else if (decoder.fallbackUrl) {
  78155. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  78156. }
  78157. }
  78158. }
  78159. if (!promise) {
  78160. throw new Error("Draco decoder module is not available");
  78161. }
  78162. DracoCompression._DecoderModulePromise = promise.then(function () {
  78163. return new Promise(function (resolve) {
  78164. config_1.onModuleLoaded = function (decoderModule) {
  78165. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  78166. resolve({ module: decoderModule });
  78167. };
  78168. DracoDecoderModule(config_1);
  78169. });
  78170. });
  78171. }
  78172. return DracoCompression._DecoderModulePromise;
  78173. };
  78174. DracoCompression._LoadScriptAsync = function (url) {
  78175. return new Promise(function (resolve, reject) {
  78176. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  78177. resolve();
  78178. }, function (message) {
  78179. reject(new Error(message));
  78180. });
  78181. });
  78182. };
  78183. DracoCompression._LoadFileAsync = function (url) {
  78184. return new Promise(function (resolve, reject) {
  78185. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78186. resolve(data);
  78187. }, undefined, undefined, true, function (request, exception) {
  78188. reject(exception);
  78189. });
  78190. });
  78191. };
  78192. /**
  78193. * The configuration. Defaults to the following urls:
  78194. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78195. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78196. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78197. */
  78198. DracoCompression.Configuration = {
  78199. decoder: {
  78200. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78201. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78202. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78203. }
  78204. };
  78205. return DracoCompression;
  78206. }());
  78207. /***/ }),
  78208. /***/ "./Meshes/Compression/index.ts":
  78209. /*!*************************************!*\
  78210. !*** ./Meshes/Compression/index.ts ***!
  78211. \*************************************/
  78212. /*! exports provided: DracoCompression */
  78213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78214. "use strict";
  78215. __webpack_require__.r(__webpack_exports__);
  78216. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78218. /***/ }),
  78219. /***/ "./Meshes/abstractMesh.ts":
  78220. /*!********************************!*\
  78221. !*** ./Meshes/abstractMesh.ts ***!
  78222. \********************************/
  78223. /*! exports provided: AbstractMesh */
  78224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78225. "use strict";
  78226. __webpack_require__.r(__webpack_exports__);
  78227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78228. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78229. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78230. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78232. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78233. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78234. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78235. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78236. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78237. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78238. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78239. /** @hidden */
  78240. var _FacetDataStorage = /** @class */ (function () {
  78241. function _FacetDataStorage() {
  78242. this.facetNb = 0; // facet number
  78243. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78244. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78245. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78246. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78247. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78248. this.subDiv = {
  78249. max: 1,
  78250. X: 1,
  78251. Y: 1,
  78252. Z: 1
  78253. };
  78254. this.facetDepthSort = false; // is the facet depth sort to be computed
  78255. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78256. }
  78257. return _FacetDataStorage;
  78258. }());
  78259. /**
  78260. * Class used to store all common mesh properties
  78261. */
  78262. var AbstractMesh = /** @class */ (function (_super) {
  78263. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78264. // Constructor
  78265. /**
  78266. * Creates a new AbstractMesh
  78267. * @param name defines the name of the mesh
  78268. * @param scene defines the hosting scene
  78269. */
  78270. function AbstractMesh(name, scene) {
  78271. if (scene === void 0) { scene = null; }
  78272. var _this = _super.call(this, name, scene, false) || this;
  78273. _this._facetData = new _FacetDataStorage();
  78274. /**
  78275. * The culling strategy to use to check whether the mesh must be rendered or not.
  78276. * This value can be changed at any time and will be used on the next render mesh selection.
  78277. * The possible values are :
  78278. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78279. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78281. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78282. * Please read each static variable documentation to get details about the culling process.
  78283. * */
  78284. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78285. // Events
  78286. /**
  78287. * An event triggered when this mesh collides with another one
  78288. */
  78289. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78290. /**
  78291. * An event triggered when the collision's position changes
  78292. */
  78293. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78294. /**
  78295. * An event triggered when material is changed
  78296. */
  78297. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78298. // Properties
  78299. /**
  78300. * Gets or sets the orientation for POV movement & rotation
  78301. */
  78302. _this.definedFacingForward = true;
  78303. _this._visibility = 1.0;
  78304. /** Gets or sets the alpha index used to sort transparent meshes
  78305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78306. */
  78307. _this.alphaIndex = Number.MAX_VALUE;
  78308. /**
  78309. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78310. */
  78311. _this.isVisible = true;
  78312. /**
  78313. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78314. */
  78315. _this.isPickable = true;
  78316. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78317. _this.showSubMeshesBoundingBox = false;
  78318. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78320. */
  78321. _this.isBlocker = false;
  78322. /**
  78323. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78324. */
  78325. _this.enablePointerMoveEvents = false;
  78326. /**
  78327. * Specifies the rendering group id for this mesh (0 by default)
  78328. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78329. */
  78330. _this.renderingGroupId = 0;
  78331. _this._receiveShadows = false;
  78332. /** Defines color to use when rendering outline */
  78333. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78334. /** Define width to use when rendering outline */
  78335. _this.outlineWidth = 0.02;
  78336. /** Defines color to use when rendering overlay */
  78337. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78338. /** Defines alpha to use when rendering overlay */
  78339. _this.overlayAlpha = 0.5;
  78340. _this._hasVertexAlpha = false;
  78341. _this._useVertexColors = true;
  78342. _this._computeBonesUsingShaders = true;
  78343. _this._numBoneInfluencers = 4;
  78344. _this._applyFog = true;
  78345. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78346. _this.useOctreeForRenderingSelection = true;
  78347. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78348. _this.useOctreeForPicking = true;
  78349. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78350. _this.useOctreeForCollisions = true;
  78351. _this._layerMask = 0x0FFFFFFF;
  78352. /**
  78353. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78354. */
  78355. _this.alwaysSelectAsActiveMesh = false;
  78356. /**
  78357. * Gets or sets the current action manager
  78358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78359. */
  78360. _this.actionManager = null;
  78361. // Collisions
  78362. _this._checkCollisions = false;
  78363. _this._collisionMask = -1;
  78364. _this._collisionGroup = -1;
  78365. /**
  78366. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78367. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78368. */
  78369. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78370. /**
  78371. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78373. */
  78374. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78375. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78376. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78377. // Edges
  78378. /**
  78379. * Defines edge width used when edgesRenderer is enabled
  78380. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78381. */
  78382. _this.edgesWidth = 1;
  78383. /**
  78384. * Defines edge color used when edgesRenderer is enabled
  78385. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78386. */
  78387. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78388. /** @hidden */
  78389. _this._renderId = 0;
  78390. /** @hidden */
  78391. _this._intersectionsInProgress = new Array();
  78392. /** @hidden */
  78393. _this._unIndexed = false;
  78394. /** @hidden */
  78395. _this._lightSources = new Array();
  78396. /**
  78397. * An event triggered when the mesh is rebuilt.
  78398. */
  78399. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78400. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78401. if (collidedMesh === void 0) { collidedMesh = null; }
  78402. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78403. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78404. _this.position.addInPlace(_this._diffPositionForCollisions);
  78405. }
  78406. if (collidedMesh) {
  78407. _this.onCollideObservable.notifyObservers(collidedMesh);
  78408. }
  78409. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78410. };
  78411. _this.getScene().addMesh(_this);
  78412. _this._resyncLightSources();
  78413. return _this;
  78414. }
  78415. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78416. /**
  78417. * No billboard
  78418. */
  78419. get: function () {
  78420. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78421. },
  78422. enumerable: true,
  78423. configurable: true
  78424. });
  78425. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  78426. /** Billboard on X axis */
  78427. get: function () {
  78428. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  78429. },
  78430. enumerable: true,
  78431. configurable: true
  78432. });
  78433. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  78434. /** Billboard on Y axis */
  78435. get: function () {
  78436. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  78437. },
  78438. enumerable: true,
  78439. configurable: true
  78440. });
  78441. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  78442. /** Billboard on Z axis */
  78443. get: function () {
  78444. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  78445. },
  78446. enumerable: true,
  78447. configurable: true
  78448. });
  78449. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  78450. /** Billboard on all axes */
  78451. get: function () {
  78452. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  78453. },
  78454. enumerable: true,
  78455. configurable: true
  78456. });
  78457. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  78458. /**
  78459. * Gets the number of facets in the mesh
  78460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78461. */
  78462. get: function () {
  78463. return this._facetData.facetNb;
  78464. },
  78465. enumerable: true,
  78466. configurable: true
  78467. });
  78468. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  78469. /**
  78470. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78472. */
  78473. get: function () {
  78474. return this._facetData.partitioningSubdivisions;
  78475. },
  78476. set: function (nb) {
  78477. this._facetData.partitioningSubdivisions = nb;
  78478. },
  78479. enumerable: true,
  78480. configurable: true
  78481. });
  78482. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  78483. /**
  78484. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78485. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78487. */
  78488. get: function () {
  78489. return this._facetData.partitioningBBoxRatio;
  78490. },
  78491. set: function (ratio) {
  78492. this._facetData.partitioningBBoxRatio = ratio;
  78493. },
  78494. enumerable: true,
  78495. configurable: true
  78496. });
  78497. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  78498. /**
  78499. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78500. * Works only for updatable meshes.
  78501. * Doesn't work with multi-materials
  78502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78503. */
  78504. get: function () {
  78505. return this._facetData.facetDepthSort;
  78506. },
  78507. set: function (sort) {
  78508. this._facetData.facetDepthSort = sort;
  78509. },
  78510. enumerable: true,
  78511. configurable: true
  78512. });
  78513. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  78514. /**
  78515. * The location (Vector3) where the facet depth sort must be computed from.
  78516. * By default, the active camera position.
  78517. * Used only when facet depth sort is enabled
  78518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78519. */
  78520. get: function () {
  78521. return this._facetData.facetDepthSortFrom;
  78522. },
  78523. set: function (location) {
  78524. this._facetData.facetDepthSortFrom = location;
  78525. },
  78526. enumerable: true,
  78527. configurable: true
  78528. });
  78529. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  78530. /**
  78531. * gets a boolean indicating if facetData is enabled
  78532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78533. */
  78534. get: function () {
  78535. return this._facetData.facetDataEnabled;
  78536. },
  78537. enumerable: true,
  78538. configurable: true
  78539. });
  78540. /** @hidden */
  78541. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  78542. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  78543. return false;
  78544. }
  78545. this._markSubMeshesAsMiscDirty();
  78546. return true;
  78547. };
  78548. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  78549. /** Set a function to call when this mesh collides with another one */
  78550. set: function (callback) {
  78551. if (this._onCollideObserver) {
  78552. this.onCollideObservable.remove(this._onCollideObserver);
  78553. }
  78554. this._onCollideObserver = this.onCollideObservable.add(callback);
  78555. },
  78556. enumerable: true,
  78557. configurable: true
  78558. });
  78559. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  78560. /** Set a function to call when the collision's position changes */
  78561. set: function (callback) {
  78562. if (this._onCollisionPositionChangeObserver) {
  78563. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  78564. }
  78565. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  78566. },
  78567. enumerable: true,
  78568. configurable: true
  78569. });
  78570. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  78571. /**
  78572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78573. */
  78574. get: function () {
  78575. return this._visibility;
  78576. },
  78577. /**
  78578. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78579. */
  78580. set: function (value) {
  78581. if (this._visibility === value) {
  78582. return;
  78583. }
  78584. this._visibility = value;
  78585. this._markSubMeshesAsMiscDirty();
  78586. },
  78587. enumerable: true,
  78588. configurable: true
  78589. });
  78590. Object.defineProperty(AbstractMesh.prototype, "material", {
  78591. /** Gets or sets current material */
  78592. get: function () {
  78593. return this._material;
  78594. },
  78595. set: function (value) {
  78596. if (this._material === value) {
  78597. return;
  78598. }
  78599. // remove from material mesh map id needed
  78600. if (this._material && this._material.meshMap) {
  78601. this._material.meshMap[this.uniqueId] = undefined;
  78602. }
  78603. this._material = value;
  78604. if (value && value.meshMap) {
  78605. value.meshMap[this.uniqueId] = this;
  78606. }
  78607. if (this.onMaterialChangedObservable.hasObservers) {
  78608. this.onMaterialChangedObservable.notifyObservers(this);
  78609. }
  78610. if (!this.subMeshes) {
  78611. return;
  78612. }
  78613. this._unBindEffect();
  78614. },
  78615. enumerable: true,
  78616. configurable: true
  78617. });
  78618. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  78619. /**
  78620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  78621. * @see http://doc.babylonjs.com/babylon101/shadows
  78622. */
  78623. get: function () {
  78624. return this._receiveShadows;
  78625. },
  78626. set: function (value) {
  78627. if (this._receiveShadows === value) {
  78628. return;
  78629. }
  78630. this._receiveShadows = value;
  78631. this._markSubMeshesAsLightDirty();
  78632. },
  78633. enumerable: true,
  78634. configurable: true
  78635. });
  78636. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  78637. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  78638. get: function () {
  78639. return this._hasVertexAlpha;
  78640. },
  78641. set: function (value) {
  78642. if (this._hasVertexAlpha === value) {
  78643. return;
  78644. }
  78645. this._hasVertexAlpha = value;
  78646. this._markSubMeshesAsAttributesDirty();
  78647. this._markSubMeshesAsMiscDirty();
  78648. },
  78649. enumerable: true,
  78650. configurable: true
  78651. });
  78652. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  78653. /** 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) */
  78654. get: function () {
  78655. return this._useVertexColors;
  78656. },
  78657. set: function (value) {
  78658. if (this._useVertexColors === value) {
  78659. return;
  78660. }
  78661. this._useVertexColors = value;
  78662. this._markSubMeshesAsAttributesDirty();
  78663. },
  78664. enumerable: true,
  78665. configurable: true
  78666. });
  78667. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  78668. /**
  78669. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  78670. */
  78671. get: function () {
  78672. return this._computeBonesUsingShaders;
  78673. },
  78674. set: function (value) {
  78675. if (this._computeBonesUsingShaders === value) {
  78676. return;
  78677. }
  78678. this._computeBonesUsingShaders = value;
  78679. this._markSubMeshesAsAttributesDirty();
  78680. },
  78681. enumerable: true,
  78682. configurable: true
  78683. });
  78684. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  78685. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  78686. get: function () {
  78687. return this._numBoneInfluencers;
  78688. },
  78689. set: function (value) {
  78690. if (this._numBoneInfluencers === value) {
  78691. return;
  78692. }
  78693. this._numBoneInfluencers = value;
  78694. this._markSubMeshesAsAttributesDirty();
  78695. },
  78696. enumerable: true,
  78697. configurable: true
  78698. });
  78699. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  78700. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  78701. get: function () {
  78702. return this._applyFog;
  78703. },
  78704. set: function (value) {
  78705. if (this._applyFog === value) {
  78706. return;
  78707. }
  78708. this._applyFog = value;
  78709. this._markSubMeshesAsMiscDirty();
  78710. },
  78711. enumerable: true,
  78712. configurable: true
  78713. });
  78714. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  78715. /**
  78716. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  78717. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  78718. */
  78719. get: function () {
  78720. return this._layerMask;
  78721. },
  78722. set: function (value) {
  78723. if (value === this._layerMask) {
  78724. return;
  78725. }
  78726. this._layerMask = value;
  78727. this._resyncLightSources();
  78728. },
  78729. enumerable: true,
  78730. configurable: true
  78731. });
  78732. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  78733. /**
  78734. * Gets or sets a collision mask used to mask collisions (default is -1).
  78735. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78736. */
  78737. get: function () {
  78738. return this._collisionMask;
  78739. },
  78740. set: function (mask) {
  78741. this._collisionMask = !isNaN(mask) ? mask : -1;
  78742. },
  78743. enumerable: true,
  78744. configurable: true
  78745. });
  78746. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  78747. /**
  78748. * Gets or sets the current collision group mask (-1 by default).
  78749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78750. */
  78751. get: function () {
  78752. return this._collisionGroup;
  78753. },
  78754. set: function (mask) {
  78755. this._collisionGroup = !isNaN(mask) ? mask : -1;
  78756. },
  78757. enumerable: true,
  78758. configurable: true
  78759. });
  78760. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  78761. /** @hidden */
  78762. get: function () {
  78763. return null;
  78764. },
  78765. enumerable: true,
  78766. configurable: true
  78767. });
  78768. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  78769. get: function () {
  78770. return this._skeleton;
  78771. },
  78772. /**
  78773. * Gets or sets a skeleton to apply skining transformations
  78774. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78775. */
  78776. set: function (value) {
  78777. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  78778. this._skeleton._unregisterMeshWithPoseMatrix(this);
  78779. }
  78780. if (value && value.needInitialSkinMatrix) {
  78781. value._registerMeshWithPoseMatrix(this);
  78782. }
  78783. this._skeleton = value;
  78784. if (!this._skeleton) {
  78785. this._bonesTransformMatrices = null;
  78786. }
  78787. this._markSubMeshesAsAttributesDirty();
  78788. },
  78789. enumerable: true,
  78790. configurable: true
  78791. });
  78792. /**
  78793. * Returns the string "AbstractMesh"
  78794. * @returns "AbstractMesh"
  78795. */
  78796. AbstractMesh.prototype.getClassName = function () {
  78797. return "AbstractMesh";
  78798. };
  78799. /**
  78800. * Gets a string representation of the current mesh
  78801. * @param fullDetails defines a boolean indicating if full details must be included
  78802. * @returns a string representation of the current mesh
  78803. */
  78804. AbstractMesh.prototype.toString = function (fullDetails) {
  78805. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  78806. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  78807. if (this._skeleton) {
  78808. ret += ", skeleton: " + this._skeleton.name;
  78809. }
  78810. if (fullDetails) {
  78811. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  78812. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  78813. }
  78814. return ret;
  78815. };
  78816. /** @hidden */
  78817. AbstractMesh.prototype._rebuild = function () {
  78818. this.onRebuildObservable.notifyObservers(this);
  78819. if (this._occlusionQuery) {
  78820. this._occlusionQuery = null;
  78821. }
  78822. if (!this.subMeshes) {
  78823. return;
  78824. }
  78825. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78826. var subMesh = _a[_i];
  78827. subMesh._rebuild();
  78828. }
  78829. };
  78830. /** @hidden */
  78831. AbstractMesh.prototype._resyncLightSources = function () {
  78832. this._lightSources.length = 0;
  78833. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  78834. var light = _a[_i];
  78835. if (!light.isEnabled()) {
  78836. continue;
  78837. }
  78838. if (light.canAffectMesh(this)) {
  78839. this._lightSources.push(light);
  78840. }
  78841. }
  78842. this._markSubMeshesAsLightDirty();
  78843. };
  78844. /** @hidden */
  78845. AbstractMesh.prototype._resyncLighSource = function (light) {
  78846. var isIn = light.isEnabled() && light.canAffectMesh(this);
  78847. var index = this._lightSources.indexOf(light);
  78848. if (index === -1) {
  78849. if (!isIn) {
  78850. return;
  78851. }
  78852. this._lightSources.push(light);
  78853. }
  78854. else {
  78855. if (isIn) {
  78856. return;
  78857. }
  78858. this._lightSources.splice(index, 1);
  78859. }
  78860. this._markSubMeshesAsLightDirty();
  78861. };
  78862. /** @hidden */
  78863. AbstractMesh.prototype._unBindEffect = function () {
  78864. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78865. var subMesh = _a[_i];
  78866. subMesh.setEffect(null);
  78867. }
  78868. };
  78869. /** @hidden */
  78870. AbstractMesh.prototype._removeLightSource = function (light) {
  78871. var index = this._lightSources.indexOf(light);
  78872. if (index === -1) {
  78873. return;
  78874. }
  78875. this._lightSources.splice(index, 1);
  78876. this._markSubMeshesAsLightDirty();
  78877. };
  78878. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  78879. if (!this.subMeshes) {
  78880. return;
  78881. }
  78882. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78883. var subMesh = _a[_i];
  78884. if (subMesh._materialDefines) {
  78885. func(subMesh._materialDefines);
  78886. }
  78887. }
  78888. };
  78889. /** @hidden */
  78890. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  78891. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  78892. };
  78893. /** @hidden */
  78894. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  78895. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  78896. };
  78897. /** @hidden */
  78898. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  78899. if (!this.subMeshes) {
  78900. return;
  78901. }
  78902. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78903. var subMesh = _a[_i];
  78904. var material = subMesh.getMaterial();
  78905. if (material) {
  78906. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  78907. }
  78908. }
  78909. };
  78910. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  78911. /**
  78912. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  78913. */
  78914. get: function () {
  78915. return this._scaling;
  78916. },
  78917. set: function (newScaling) {
  78918. this._scaling = newScaling;
  78919. if (this.physicsImpostor) {
  78920. this.physicsImpostor.forceUpdate();
  78921. }
  78922. },
  78923. enumerable: true,
  78924. configurable: true
  78925. });
  78926. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  78927. // Methods
  78928. /**
  78929. * Returns true if the mesh is blocked. Implemented by child classes
  78930. */
  78931. get: function () {
  78932. return false;
  78933. },
  78934. enumerable: true,
  78935. configurable: true
  78936. });
  78937. /**
  78938. * Returns the mesh itself by default. Implemented by child classes
  78939. * @param camera defines the camera to use to pick the right LOD level
  78940. * @returns the currentAbstractMesh
  78941. */
  78942. AbstractMesh.prototype.getLOD = function (camera) {
  78943. return this;
  78944. };
  78945. /**
  78946. * Returns 0 by default. Implemented by child classes
  78947. * @returns an integer
  78948. */
  78949. AbstractMesh.prototype.getTotalVertices = function () {
  78950. return 0;
  78951. };
  78952. /**
  78953. * Returns a positive integer : the total number of indices in this mesh geometry.
  78954. * @returns the numner of indices or zero if the mesh has no geometry.
  78955. */
  78956. AbstractMesh.prototype.getTotalIndices = function () {
  78957. return 0;
  78958. };
  78959. /**
  78960. * Returns null by default. Implemented by child classes
  78961. * @returns null
  78962. */
  78963. AbstractMesh.prototype.getIndices = function () {
  78964. return null;
  78965. };
  78966. /**
  78967. * Returns the array of the requested vertex data kind. Implemented by child classes
  78968. * @param kind defines the vertex data kind to use
  78969. * @returns null
  78970. */
  78971. AbstractMesh.prototype.getVerticesData = function (kind) {
  78972. return null;
  78973. };
  78974. /**
  78975. * Sets the vertex data of the mesh geometry for the requested `kind`.
  78976. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  78977. * Note that a new underlying VertexBuffer object is created each call.
  78978. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  78979. * @param kind defines vertex data kind:
  78980. * * VertexBuffer.PositionKind
  78981. * * VertexBuffer.UVKind
  78982. * * VertexBuffer.UV2Kind
  78983. * * VertexBuffer.UV3Kind
  78984. * * VertexBuffer.UV4Kind
  78985. * * VertexBuffer.UV5Kind
  78986. * * VertexBuffer.UV6Kind
  78987. * * VertexBuffer.ColorKind
  78988. * * VertexBuffer.MatricesIndicesKind
  78989. * * VertexBuffer.MatricesIndicesExtraKind
  78990. * * VertexBuffer.MatricesWeightsKind
  78991. * * VertexBuffer.MatricesWeightsExtraKind
  78992. * @param data defines the data source
  78993. * @param updatable defines if the data must be flagged as updatable (or static)
  78994. * @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
  78995. * @returns the current mesh
  78996. */
  78997. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  78998. return this;
  78999. };
  79000. /**
  79001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79002. * If the mesh has no geometry, it is simply returned as it is.
  79003. * @param kind defines vertex data kind:
  79004. * * VertexBuffer.PositionKind
  79005. * * VertexBuffer.UVKind
  79006. * * VertexBuffer.UV2Kind
  79007. * * VertexBuffer.UV3Kind
  79008. * * VertexBuffer.UV4Kind
  79009. * * VertexBuffer.UV5Kind
  79010. * * VertexBuffer.UV6Kind
  79011. * * VertexBuffer.ColorKind
  79012. * * VertexBuffer.MatricesIndicesKind
  79013. * * VertexBuffer.MatricesIndicesExtraKind
  79014. * * VertexBuffer.MatricesWeightsKind
  79015. * * VertexBuffer.MatricesWeightsExtraKind
  79016. * @param data defines the data source
  79017. * @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
  79018. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79019. * @returns the current mesh
  79020. */
  79021. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79022. return this;
  79023. };
  79024. /**
  79025. * Sets the mesh indices,
  79026. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79027. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79028. * @param totalVertices Defines the total number of vertices
  79029. * @returns the current mesh
  79030. */
  79031. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  79032. return this;
  79033. };
  79034. /**
  79035. * Gets a boolean indicating if specific vertex data is present
  79036. * @param kind defines the vertex data kind to use
  79037. * @returns true is data kind is present
  79038. */
  79039. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  79040. return false;
  79041. };
  79042. /**
  79043. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79044. * @returns a BoundingInfo
  79045. */
  79046. AbstractMesh.prototype.getBoundingInfo = function () {
  79047. if (this._masterMesh) {
  79048. return this._masterMesh.getBoundingInfo();
  79049. }
  79050. if (!this._boundingInfo) {
  79051. // this._boundingInfo is being created here
  79052. this._updateBoundingInfo();
  79053. }
  79054. // cannot be null.
  79055. return this._boundingInfo;
  79056. };
  79057. /**
  79058. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79059. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79060. * @returns the current mesh
  79061. */
  79062. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  79063. if (includeDescendants === void 0) { includeDescendants = true; }
  79064. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  79065. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  79066. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  79067. if (maxDimension === 0) {
  79068. return this;
  79069. }
  79070. var scale = 1 / maxDimension;
  79071. this.scaling.scaleInPlace(scale);
  79072. return this;
  79073. };
  79074. /**
  79075. * Overwrite the current bounding info
  79076. * @param boundingInfo defines the new bounding info
  79077. * @returns the current mesh
  79078. */
  79079. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  79080. this._boundingInfo = boundingInfo;
  79081. return this;
  79082. };
  79083. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  79084. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79085. get: function () {
  79086. 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));
  79087. },
  79088. enumerable: true,
  79089. configurable: true
  79090. });
  79091. /** @hidden */
  79092. AbstractMesh.prototype._preActivate = function () {
  79093. };
  79094. /** @hidden */
  79095. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  79096. };
  79097. /** @hidden */
  79098. AbstractMesh.prototype._activate = function (renderId) {
  79099. this._renderId = renderId;
  79100. };
  79101. /**
  79102. * Gets the current world matrix
  79103. * @returns a Matrix
  79104. */
  79105. AbstractMesh.prototype.getWorldMatrix = function () {
  79106. if (this._masterMesh) {
  79107. return this._masterMesh.getWorldMatrix();
  79108. }
  79109. return _super.prototype.getWorldMatrix.call(this);
  79110. };
  79111. /** @hidden */
  79112. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  79113. if (this._masterMesh) {
  79114. return this._masterMesh._getWorldMatrixDeterminant();
  79115. }
  79116. return _super.prototype._getWorldMatrixDeterminant.call(this);
  79117. };
  79118. // ================================== Point of View Movement =================================
  79119. /**
  79120. * Perform relative position change from the point of view of behind the front of the mesh.
  79121. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79122. * Supports definition of mesh facing forward or backward
  79123. * @param amountRight defines the distance on the right axis
  79124. * @param amountUp defines the distance on the up axis
  79125. * @param amountForward defines the distance on the forward axis
  79126. * @returns the current mesh
  79127. */
  79128. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  79129. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  79130. return this;
  79131. };
  79132. /**
  79133. * Calculate relative position change from the point of view of behind the front of the mesh.
  79134. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79135. * Supports definition of mesh facing forward or backward
  79136. * @param amountRight defines the distance on the right axis
  79137. * @param amountUp defines the distance on the up axis
  79138. * @param amountForward defines the distance on the forward axis
  79139. * @returns the new displacement vector
  79140. */
  79141. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  79142. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  79143. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  79144. rotQuaternion.toRotationMatrix(rotMatrix);
  79145. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79146. var defForwardMult = this.definedFacingForward ? -1 : 1;
  79147. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  79148. return translationDelta;
  79149. };
  79150. // ================================== Point of View Rotation =================================
  79151. /**
  79152. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79153. * Supports definition of mesh facing forward or backward
  79154. * @param flipBack defines the flip
  79155. * @param twirlClockwise defines the twirl
  79156. * @param tiltRight defines the tilt
  79157. * @returns the current mesh
  79158. */
  79159. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79160. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  79161. return this;
  79162. };
  79163. /**
  79164. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79165. * Supports definition of mesh facing forward or backward.
  79166. * @param flipBack defines the flip
  79167. * @param twirlClockwise defines the twirl
  79168. * @param tiltRight defines the tilt
  79169. * @returns the new rotation vector
  79170. */
  79171. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79172. var defForwardMult = this.definedFacingForward ? 1 : -1;
  79173. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  79174. };
  79175. /**
  79176. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79177. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79178. * @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
  79179. * @returns the new bounding vectors
  79180. */
  79181. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79182. if (includeDescendants === void 0) { includeDescendants = true; }
  79183. if (predicate === void 0) { predicate = null; }
  79184. // Ensures that all world matrix will be recomputed.
  79185. this.getScene().incrementRenderId();
  79186. this.computeWorldMatrix(true);
  79187. var min;
  79188. var max;
  79189. var boundingInfo = this.getBoundingInfo();
  79190. if (!this.subMeshes) {
  79191. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79192. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79193. }
  79194. else {
  79195. min = boundingInfo.boundingBox.minimumWorld;
  79196. max = boundingInfo.boundingBox.maximumWorld;
  79197. }
  79198. if (includeDescendants) {
  79199. var descendants = this.getDescendants(false);
  79200. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79201. var descendant = descendants_1[_i];
  79202. var childMesh = descendant;
  79203. childMesh.computeWorldMatrix(true);
  79204. // Filters meshes based on custom predicate function.
  79205. if (predicate && !predicate(childMesh)) {
  79206. continue;
  79207. }
  79208. //make sure we have the needed params to get mix and max
  79209. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79210. continue;
  79211. }
  79212. var childBoundingInfo = childMesh.getBoundingInfo();
  79213. var boundingBox = childBoundingInfo.boundingBox;
  79214. var minBox = boundingBox.minimumWorld;
  79215. var maxBox = boundingBox.maximumWorld;
  79216. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79217. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79218. }
  79219. }
  79220. return {
  79221. min: min,
  79222. max: max
  79223. };
  79224. };
  79225. /**
  79226. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79227. * This means the mesh underlying bounding box and sphere are recomputed.
  79228. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79229. * @returns the current mesh
  79230. */
  79231. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79232. if (applySkeleton === void 0) { applySkeleton = false; }
  79233. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79234. return this;
  79235. }
  79236. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79237. return this;
  79238. };
  79239. /** @hidden */
  79240. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79241. if (data) {
  79242. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79243. if (this._boundingInfo) {
  79244. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79245. }
  79246. else {
  79247. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79248. }
  79249. }
  79250. if (this.subMeshes) {
  79251. for (var index = 0; index < this.subMeshes.length; index++) {
  79252. this.subMeshes[index].refreshBoundingInfo();
  79253. }
  79254. }
  79255. this._updateBoundingInfo();
  79256. };
  79257. /** @hidden */
  79258. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79259. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79260. if (data && applySkeleton && this.skeleton) {
  79261. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79262. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79263. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79264. if (matricesWeightsData && matricesIndicesData) {
  79265. var needExtras = this.numBoneInfluencers > 4;
  79266. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79267. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79268. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79269. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79270. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79271. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79272. var matWeightIdx = 0;
  79273. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79274. finalMatrix.reset();
  79275. var inf;
  79276. var weight;
  79277. for (inf = 0; inf < 4; inf++) {
  79278. weight = matricesWeightsData[matWeightIdx + inf];
  79279. if (weight > 0) {
  79280. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79281. finalMatrix.addToSelf(tempMatrix);
  79282. }
  79283. }
  79284. if (needExtras) {
  79285. for (inf = 0; inf < 4; inf++) {
  79286. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79287. if (weight > 0) {
  79288. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79289. finalMatrix.addToSelf(tempMatrix);
  79290. }
  79291. }
  79292. }
  79293. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79294. tempVector.toArray(data, index);
  79295. }
  79296. }
  79297. }
  79298. return data;
  79299. };
  79300. /** @hidden */
  79301. AbstractMesh.prototype._updateBoundingInfo = function () {
  79302. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79303. if (this._boundingInfo) {
  79304. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79305. }
  79306. else {
  79307. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79308. }
  79309. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79310. return this;
  79311. };
  79312. /** @hidden */
  79313. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79314. if (!this.subMeshes) {
  79315. return this;
  79316. }
  79317. var count = this.subMeshes.length;
  79318. for (var subIndex = 0; subIndex < count; subIndex++) {
  79319. var subMesh = this.subMeshes[subIndex];
  79320. if (count > 1 || !subMesh.IsGlobal) {
  79321. subMesh.updateBoundingInfo(matrix);
  79322. }
  79323. }
  79324. return this;
  79325. };
  79326. /** @hidden */
  79327. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79328. // Bounding info
  79329. this._updateBoundingInfo();
  79330. };
  79331. /**
  79332. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79333. * A mesh is in the frustum if its bounding box intersects the frustum
  79334. * @param frustumPlanes defines the frustum to test
  79335. * @returns true if the mesh is in the frustum planes
  79336. */
  79337. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79338. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79339. };
  79340. /**
  79341. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79342. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79343. * @param frustumPlanes defines the frustum to test
  79344. * @returns true if the mesh is completely in the frustum planes
  79345. */
  79346. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79347. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79348. };
  79349. /**
  79350. * True if the mesh intersects another mesh or a SolidParticle object
  79351. * @param mesh defines a target mesh or SolidParticle to test
  79352. * @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)
  79353. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79354. * @returns true if there is an intersection
  79355. */
  79356. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79357. if (precise === void 0) { precise = false; }
  79358. if (!this._boundingInfo || !mesh._boundingInfo) {
  79359. return false;
  79360. }
  79361. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79362. return true;
  79363. }
  79364. if (includeDescendants) {
  79365. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79366. var child = _a[_i];
  79367. if (child.intersectsMesh(mesh, precise, true)) {
  79368. return true;
  79369. }
  79370. }
  79371. }
  79372. return false;
  79373. };
  79374. /**
  79375. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79376. * @param point defines the point to test
  79377. * @returns true if there is an intersection
  79378. */
  79379. AbstractMesh.prototype.intersectsPoint = function (point) {
  79380. if (!this._boundingInfo) {
  79381. return false;
  79382. }
  79383. return this._boundingInfo.intersectsPoint(point);
  79384. };
  79385. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79386. // Collisions
  79387. /**
  79388. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79390. */
  79391. get: function () {
  79392. return this._checkCollisions;
  79393. },
  79394. set: function (collisionEnabled) {
  79395. this._checkCollisions = collisionEnabled;
  79396. },
  79397. enumerable: true,
  79398. configurable: true
  79399. });
  79400. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79401. /**
  79402. * Gets Collider object used to compute collisions (not physics)
  79403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79404. */
  79405. get: function () {
  79406. return this._collider;
  79407. },
  79408. enumerable: true,
  79409. configurable: true
  79410. });
  79411. /**
  79412. * Move the mesh using collision engine
  79413. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79414. * @param displacement defines the requested displacement vector
  79415. * @returns the current mesh
  79416. */
  79417. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  79418. var globalPosition = this.getAbsolutePosition();
  79419. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  79420. var coordinator = this.getScene().collisionCoordinator;
  79421. if (!this._collider) {
  79422. this._collider = coordinator.createCollider();
  79423. }
  79424. this._collider._radius = this.ellipsoid;
  79425. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  79426. return this;
  79427. };
  79428. // Collisions
  79429. /** @hidden */
  79430. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  79431. this._generatePointsArray();
  79432. if (!this._positions) {
  79433. return this;
  79434. }
  79435. // Transformation
  79436. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  79437. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  79438. subMesh._lastColliderWorldVertices = [];
  79439. subMesh._trianglePlanes = [];
  79440. var start = subMesh.verticesStart;
  79441. var end = (subMesh.verticesStart + subMesh.verticesCount);
  79442. for (var i = start; i < end; i++) {
  79443. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  79444. }
  79445. }
  79446. // Collide
  79447. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  79448. if (collider.collisionFound) {
  79449. collider.collidedMesh = this;
  79450. }
  79451. return this;
  79452. };
  79453. /** @hidden */
  79454. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  79455. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  79456. var len = subMeshes.length;
  79457. for (var index = 0; index < len; index++) {
  79458. var subMesh = subMeshes.data[index];
  79459. // Bounding test
  79460. if (len > 1 && !subMesh._checkCollision(collider)) {
  79461. continue;
  79462. }
  79463. this._collideForSubMesh(subMesh, transformMatrix, collider);
  79464. }
  79465. return this;
  79466. };
  79467. /** @hidden */
  79468. AbstractMesh.prototype._checkCollision = function (collider) {
  79469. // Bounding box test
  79470. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  79471. return this;
  79472. }
  79473. // Transformation matrix
  79474. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79475. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79476. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  79477. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  79478. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  79479. return this;
  79480. };
  79481. // Picking
  79482. /** @hidden */
  79483. AbstractMesh.prototype._generatePointsArray = function () {
  79484. return false;
  79485. };
  79486. /**
  79487. * Checks if the passed Ray intersects with the mesh
  79488. * @param ray defines the ray to use
  79489. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79490. * @returns the picking info
  79491. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79492. */
  79493. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  79494. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  79495. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  79496. var boundingInfo = this._boundingInfo;
  79497. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  79498. return pickingInfo;
  79499. }
  79500. if (!this._generatePointsArray()) {
  79501. return pickingInfo;
  79502. }
  79503. var intersectInfo = null;
  79504. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  79505. var len = subMeshes.length;
  79506. for (var index = 0; index < len; index++) {
  79507. var subMesh = subMeshes.data[index];
  79508. // Bounding test
  79509. if (len > 1 && !subMesh.canIntersects(ray)) {
  79510. continue;
  79511. }
  79512. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  79513. if (currentIntersectInfo) {
  79514. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  79515. intersectInfo = currentIntersectInfo;
  79516. intersectInfo.subMeshId = index;
  79517. if (fastCheck) {
  79518. break;
  79519. }
  79520. }
  79521. }
  79522. }
  79523. if (intersectInfo) {
  79524. // Get picked point
  79525. var world = this.getWorldMatrix();
  79526. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79527. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79528. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  79529. ray.direction.scaleToRef(intersectInfo.distance, direction);
  79530. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  79531. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  79532. // Return result
  79533. pickingInfo.hit = true;
  79534. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  79535. pickingInfo.pickedPoint = pickedPoint;
  79536. pickingInfo.pickedMesh = this;
  79537. pickingInfo.bu = intersectInfo.bu || 0;
  79538. pickingInfo.bv = intersectInfo.bv || 0;
  79539. pickingInfo.faceId = intersectInfo.faceId;
  79540. pickingInfo.subMeshId = intersectInfo.subMeshId;
  79541. return pickingInfo;
  79542. }
  79543. return pickingInfo;
  79544. };
  79545. /**
  79546. * Clones the current mesh
  79547. * @param name defines the mesh name
  79548. * @param newParent defines the new mesh parent
  79549. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79550. * @returns the new mesh
  79551. */
  79552. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79553. return null;
  79554. };
  79555. /**
  79556. * Disposes all the submeshes of the current meshnp
  79557. * @returns the current mesh
  79558. */
  79559. AbstractMesh.prototype.releaseSubMeshes = function () {
  79560. if (this.subMeshes) {
  79561. while (this.subMeshes.length) {
  79562. this.subMeshes[0].dispose();
  79563. }
  79564. }
  79565. else {
  79566. this.subMeshes = new Array();
  79567. }
  79568. return this;
  79569. };
  79570. /**
  79571. * Releases resources associated with this abstract mesh.
  79572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79574. */
  79575. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79576. var _this = this;
  79577. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79578. var index;
  79579. // Smart Array Retainers.
  79580. this.getScene().freeActiveMeshes();
  79581. this.getScene().freeRenderingGroups();
  79582. // Action manager
  79583. if (this.actionManager !== undefined && this.actionManager !== null) {
  79584. this.actionManager.dispose();
  79585. this.actionManager = null;
  79586. }
  79587. // Skeleton
  79588. this._skeleton = null;
  79589. // Intersections in progress
  79590. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  79591. var other = this._intersectionsInProgress[index];
  79592. var pos = other._intersectionsInProgress.indexOf(this);
  79593. other._intersectionsInProgress.splice(pos, 1);
  79594. }
  79595. this._intersectionsInProgress = [];
  79596. // Lights
  79597. var lights = this.getScene().lights;
  79598. lights.forEach(function (light) {
  79599. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  79600. if (meshIndex !== -1) {
  79601. light.includedOnlyMeshes.splice(meshIndex, 1);
  79602. }
  79603. meshIndex = light.excludedMeshes.indexOf(_this);
  79604. if (meshIndex !== -1) {
  79605. light.excludedMeshes.splice(meshIndex, 1);
  79606. }
  79607. // Shadow generators
  79608. var generator = light.getShadowGenerator();
  79609. if (generator) {
  79610. var shadowMap = generator.getShadowMap();
  79611. if (shadowMap && shadowMap.renderList) {
  79612. meshIndex = shadowMap.renderList.indexOf(_this);
  79613. if (meshIndex !== -1) {
  79614. shadowMap.renderList.splice(meshIndex, 1);
  79615. }
  79616. }
  79617. }
  79618. });
  79619. // SubMeshes
  79620. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  79621. this.releaseSubMeshes();
  79622. }
  79623. // Query
  79624. var engine = this.getScene().getEngine();
  79625. if (this._occlusionQuery) {
  79626. this.isOcclusionQueryInProgress = false;
  79627. engine.deleteQuery(this._occlusionQuery);
  79628. this._occlusionQuery = null;
  79629. }
  79630. // Engine
  79631. engine.wipeCaches();
  79632. // Remove from scene
  79633. this.getScene().removeMesh(this);
  79634. if (disposeMaterialAndTextures) {
  79635. if (this.material) {
  79636. this.material.dispose(false, true);
  79637. }
  79638. }
  79639. if (!doNotRecurse) {
  79640. // Particles
  79641. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  79642. if (this.getScene().particleSystems[index].emitter === this) {
  79643. this.getScene().particleSystems[index].dispose();
  79644. index--;
  79645. }
  79646. }
  79647. }
  79648. // facet data
  79649. if (this._facetData.facetDataEnabled) {
  79650. this.disableFacetData();
  79651. }
  79652. this.onAfterWorldMatrixUpdateObservable.clear();
  79653. this.onCollideObservable.clear();
  79654. this.onCollisionPositionChangeObservable.clear();
  79655. this.onRebuildObservable.clear();
  79656. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79657. };
  79658. /**
  79659. * Adds the passed mesh as a child to the current mesh
  79660. * @param mesh defines the child mesh
  79661. * @returns the current mesh
  79662. */
  79663. AbstractMesh.prototype.addChild = function (mesh) {
  79664. mesh.setParent(this);
  79665. return this;
  79666. };
  79667. /**
  79668. * Removes the passed mesh from the current mesh children list
  79669. * @param mesh defines the child mesh
  79670. * @returns the current mesh
  79671. */
  79672. AbstractMesh.prototype.removeChild = function (mesh) {
  79673. mesh.setParent(null);
  79674. return this;
  79675. };
  79676. // Facet data
  79677. /** @hidden */
  79678. AbstractMesh.prototype._initFacetData = function () {
  79679. var data = this._facetData;
  79680. if (!data.facetNormals) {
  79681. data.facetNormals = new Array();
  79682. }
  79683. if (!data.facetPositions) {
  79684. data.facetPositions = new Array();
  79685. }
  79686. if (!data.facetPartitioning) {
  79687. data.facetPartitioning = new Array();
  79688. }
  79689. data.facetNb = (this.getIndices().length / 3) | 0;
  79690. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  79691. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  79692. for (var f = 0; f < data.facetNb; f++) {
  79693. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79694. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79695. }
  79696. data.facetDataEnabled = true;
  79697. return this;
  79698. };
  79699. /**
  79700. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79701. * This method can be called within the render loop.
  79702. * 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
  79703. * @returns the current mesh
  79704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79705. */
  79706. AbstractMesh.prototype.updateFacetData = function () {
  79707. var data = this._facetData;
  79708. if (!data.facetDataEnabled) {
  79709. this._initFacetData();
  79710. }
  79711. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79712. var indices = this.getIndices();
  79713. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79714. var bInfo = this.getBoundingInfo();
  79715. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  79716. // init arrays, matrix and sort function on first call
  79717. data.facetDepthSortEnabled = true;
  79718. if (indices instanceof Uint16Array) {
  79719. data.depthSortedIndices = new Uint16Array(indices);
  79720. }
  79721. else if (indices instanceof Uint32Array) {
  79722. data.depthSortedIndices = new Uint32Array(indices);
  79723. }
  79724. else {
  79725. var needs32bits = false;
  79726. for (var i = 0; i < indices.length; i++) {
  79727. if (indices[i] > 65535) {
  79728. needs32bits = true;
  79729. break;
  79730. }
  79731. }
  79732. if (needs32bits) {
  79733. data.depthSortedIndices = new Uint32Array(indices);
  79734. }
  79735. else {
  79736. data.depthSortedIndices = new Uint16Array(indices);
  79737. }
  79738. }
  79739. data.facetDepthSortFunction = function (f1, f2) {
  79740. return (f2.sqDistance - f1.sqDistance);
  79741. };
  79742. if (!data.facetDepthSortFrom) {
  79743. var camera = this.getScene().activeCamera;
  79744. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79745. }
  79746. data.depthSortedFacets = [];
  79747. for (var f = 0; f < data.facetNb; f++) {
  79748. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  79749. data.depthSortedFacets.push(depthSortedFacet);
  79750. }
  79751. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  79752. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79753. }
  79754. data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.x - bInfo.minimum.x : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  79755. data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.y - bInfo.minimum.y : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  79756. data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.z - bInfo.minimum.z : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  79757. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  79758. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  79759. data.subDiv.max = data.partitioningSubdivisions;
  79760. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  79761. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  79762. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  79763. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  79764. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  79765. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  79766. // set the parameters for ComputeNormals()
  79767. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  79768. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  79769. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  79770. data.facetParameters.bInfo = bInfo;
  79771. data.facetParameters.bbSize = data.bbSize;
  79772. data.facetParameters.subDiv = data.subDiv;
  79773. data.facetParameters.ratio = this.partitioningBBoxRatio;
  79774. data.facetParameters.depthSort = data.facetDepthSort;
  79775. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79776. this.computeWorldMatrix(true);
  79777. this._worldMatrix.invertToRef(data.invertedMatrix);
  79778. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  79779. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  79780. }
  79781. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  79782. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  79783. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79784. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  79785. var l = (data.depthSortedIndices.length / 3) | 0;
  79786. for (var f = 0; f < l; f++) {
  79787. var sind = data.depthSortedFacets[f].ind;
  79788. data.depthSortedIndices[f * 3] = indices[sind];
  79789. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  79790. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  79791. }
  79792. this.updateIndices(data.depthSortedIndices);
  79793. }
  79794. return this;
  79795. };
  79796. /**
  79797. * Returns the facetLocalNormals array.
  79798. * The normals are expressed in the mesh local spac
  79799. * @returns an array of Vector3
  79800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79801. */
  79802. AbstractMesh.prototype.getFacetLocalNormals = function () {
  79803. if (!this._facetData.facetNormals) {
  79804. this.updateFacetData();
  79805. }
  79806. return this._facetData.facetNormals;
  79807. };
  79808. /**
  79809. * Returns the facetLocalPositions array.
  79810. * The facet positions are expressed in the mesh local space
  79811. * @returns an array of Vector3
  79812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79813. */
  79814. AbstractMesh.prototype.getFacetLocalPositions = function () {
  79815. if (!this._facetData.facetPositions) {
  79816. this.updateFacetData();
  79817. }
  79818. return this._facetData.facetPositions;
  79819. };
  79820. /**
  79821. * Returns the facetLocalPartioning array
  79822. * @returns an array of array of numbers
  79823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79824. */
  79825. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  79826. if (!this._facetData.facetPartitioning) {
  79827. this.updateFacetData();
  79828. }
  79829. return this._facetData.facetPartitioning;
  79830. };
  79831. /**
  79832. * Returns the i-th facet position in the world system.
  79833. * This method allocates a new Vector3 per call
  79834. * @param i defines the facet index
  79835. * @returns a new Vector3
  79836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79837. */
  79838. AbstractMesh.prototype.getFacetPosition = function (i) {
  79839. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79840. this.getFacetPositionToRef(i, pos);
  79841. return pos;
  79842. };
  79843. /**
  79844. * Sets the reference Vector3 with the i-th facet position in the world system
  79845. * @param i defines the facet index
  79846. * @param ref defines the target vector
  79847. * @returns the current mesh
  79848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79849. */
  79850. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  79851. var localPos = (this.getFacetLocalPositions())[i];
  79852. var world = this.getWorldMatrix();
  79853. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  79854. return this;
  79855. };
  79856. /**
  79857. * Returns the i-th facet normal in the world system.
  79858. * This method allocates a new Vector3 per call
  79859. * @param i defines the facet index
  79860. * @returns a new Vector3
  79861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79862. */
  79863. AbstractMesh.prototype.getFacetNormal = function (i) {
  79864. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79865. this.getFacetNormalToRef(i, norm);
  79866. return norm;
  79867. };
  79868. /**
  79869. * Sets the reference Vector3 with the i-th facet normal in the world system
  79870. * @param i defines the facet index
  79871. * @param ref defines the target vector
  79872. * @returns the current mesh
  79873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79874. */
  79875. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  79876. var localNorm = (this.getFacetLocalNormals())[i];
  79877. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  79878. return this;
  79879. };
  79880. /**
  79881. * 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)
  79882. * @param x defines x coordinate
  79883. * @param y defines y coordinate
  79884. * @param z defines z coordinate
  79885. * @returns the array of facet indexes
  79886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79887. */
  79888. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  79889. var bInfo = this.getBoundingInfo();
  79890. var data = this._facetData;
  79891. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  79892. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  79893. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  79894. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  79895. return null;
  79896. }
  79897. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  79898. };
  79899. /**
  79900. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79901. * @param projected sets as the (x,y,z) world projection on the facet
  79902. * @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
  79903. * @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
  79904. * @param x defines x coordinate
  79905. * @param y defines y coordinate
  79906. * @param z defines z coordinate
  79907. * @returns the face index if found (or null instead)
  79908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79909. */
  79910. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  79911. if (checkFace === void 0) { checkFace = false; }
  79912. if (facing === void 0) { facing = true; }
  79913. var world = this.getWorldMatrix();
  79914. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  79915. world.invertToRef(invMat);
  79916. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  79917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  79918. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  79919. if (projected) {
  79920. // tranform the local computed projected vector to world coordinates
  79921. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  79922. }
  79923. return closest;
  79924. };
  79925. /**
  79926. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79927. * @param projected sets as the (x,y,z) local projection on the facet
  79928. * @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
  79929. * @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
  79930. * @param x defines x coordinate
  79931. * @param y defines y coordinate
  79932. * @param z defines z coordinate
  79933. * @returns the face index if found (or null instead)
  79934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79935. */
  79936. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  79937. if (checkFace === void 0) { checkFace = false; }
  79938. if (facing === void 0) { facing = true; }
  79939. var closest = null;
  79940. var tmpx = 0.0;
  79941. var tmpy = 0.0;
  79942. var tmpz = 0.0;
  79943. var d = 0.0; // tmp dot facet normal * facet position
  79944. var t0 = 0.0;
  79945. var projx = 0.0;
  79946. var projy = 0.0;
  79947. var projz = 0.0;
  79948. // Get all the facets in the same partitioning block than (x, y, z)
  79949. var facetPositions = this.getFacetLocalPositions();
  79950. var facetNormals = this.getFacetLocalNormals();
  79951. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  79952. if (!facetsInBlock) {
  79953. return null;
  79954. }
  79955. // Get the closest facet to (x, y, z)
  79956. var shortest = Number.MAX_VALUE; // init distance vars
  79957. var tmpDistance = shortest;
  79958. var fib; // current facet in the block
  79959. var norm; // current facet normal
  79960. var p0; // current facet barycenter position
  79961. // loop on all the facets in the current partitioning block
  79962. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  79963. fib = facetsInBlock[idx];
  79964. norm = facetNormals[fib];
  79965. p0 = facetPositions[fib];
  79966. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  79967. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  79968. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  79969. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  79970. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  79971. projx = x + norm.x * t0;
  79972. projy = y + norm.y * t0;
  79973. projz = z + norm.z * t0;
  79974. tmpx = projx - x;
  79975. tmpy = projy - y;
  79976. tmpz = projz - z;
  79977. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  79978. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  79979. shortest = tmpDistance;
  79980. closest = fib;
  79981. if (projected) {
  79982. projected.x = projx;
  79983. projected.y = projy;
  79984. projected.z = projz;
  79985. }
  79986. }
  79987. }
  79988. }
  79989. return closest;
  79990. };
  79991. /**
  79992. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79993. * @returns the parameters
  79994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79995. */
  79996. AbstractMesh.prototype.getFacetDataParameters = function () {
  79997. return this._facetData.facetParameters;
  79998. };
  79999. /**
  80000. * Disables the feature FacetData and frees the related memory
  80001. * @returns the current mesh
  80002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80003. */
  80004. AbstractMesh.prototype.disableFacetData = function () {
  80005. if (this._facetData.facetDataEnabled) {
  80006. this._facetData.facetDataEnabled = false;
  80007. this._facetData.facetPositions = new Array();
  80008. this._facetData.facetNormals = new Array();
  80009. this._facetData.facetPartitioning = new Array();
  80010. this._facetData.facetParameters = null;
  80011. this._facetData.depthSortedIndices = new Uint32Array(0);
  80012. }
  80013. return this;
  80014. };
  80015. /**
  80016. * Updates the AbstractMesh indices array
  80017. * @param indices defines the data source
  80018. * @returns the current mesh
  80019. */
  80020. AbstractMesh.prototype.updateIndices = function (indices) {
  80021. return this;
  80022. };
  80023. /**
  80024. * Creates new normals data for the mesh
  80025. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80026. * @returns the current mesh
  80027. */
  80028. AbstractMesh.prototype.createNormals = function (updatable) {
  80029. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80030. var indices = this.getIndices();
  80031. var normals;
  80032. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  80033. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80034. }
  80035. else {
  80036. normals = [];
  80037. }
  80038. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  80039. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  80040. return this;
  80041. };
  80042. /**
  80043. * Align the mesh with a normal
  80044. * @param normal defines the normal to use
  80045. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80046. * @returns the current mesh
  80047. */
  80048. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  80049. if (!upDirection) {
  80050. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  80051. }
  80052. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80053. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80054. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  80055. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  80056. if (this.rotationQuaternion) {
  80057. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  80058. }
  80059. else {
  80060. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  80061. }
  80062. return this;
  80063. };
  80064. /** @hidden */
  80065. AbstractMesh.prototype._checkOcclusionQuery = function () {
  80066. return false;
  80067. };
  80068. /** No occlusion */
  80069. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  80070. /** Occlusion set to optimisitic */
  80071. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  80072. /** Occlusion set to strict */
  80073. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  80074. /** Use an accurante occlusion algorithm */
  80075. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  80076. /** Use a conservative occlusion algorithm */
  80077. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  80078. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80079. * Test order :
  80080. * Is the bounding sphere outside the frustum ?
  80081. * If not, are the bounding box vertices outside the frustum ?
  80082. * It not, then the cullable object is in the frustum.
  80083. */
  80084. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  80085. /** Culling strategy : Bounding Sphere Only.
  80086. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80087. * It's also less accurate than the standard because some not visible objects can still be selected.
  80088. * Test : is the bounding sphere outside the frustum ?
  80089. * If not, then the cullable object is in the frustum.
  80090. */
  80091. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  80092. /** Culling strategy : Optimistic Inclusion.
  80093. * This in an inclusion test first, then the standard exclusion test.
  80094. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80095. * 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.
  80096. * Anyway, it's as accurate as the standard strategy.
  80097. * Test :
  80098. * Is the cullable object bounding sphere center in the frustum ?
  80099. * If not, apply the default culling strategy.
  80100. */
  80101. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  80102. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80103. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80104. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80105. * 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.
  80106. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80107. * Test :
  80108. * Is the cullable object bounding sphere center in the frustum ?
  80109. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80110. */
  80111. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  80112. return AbstractMesh;
  80113. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  80114. /***/ }),
  80115. /***/ "./Meshes/buffer.ts":
  80116. /*!**************************!*\
  80117. !*** ./Meshes/buffer.ts ***!
  80118. \**************************/
  80119. /*! exports provided: Buffer, VertexBuffer */
  80120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80121. "use strict";
  80122. __webpack_require__.r(__webpack_exports__);
  80123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  80124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  80125. /**
  80126. * Class used to store data that will be store in GPU memory
  80127. */
  80128. var Buffer = /** @class */ (function () {
  80129. /**
  80130. * Constructor
  80131. * @param engine the engine
  80132. * @param data the data to use for this buffer
  80133. * @param updatable whether the data is updatable
  80134. * @param stride the stride (optional)
  80135. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80136. * @param instanced whether the buffer is instanced (optional)
  80137. * @param useBytes set to true if the stride in in bytes (optional)
  80138. */
  80139. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  80140. if (stride === void 0) { stride = 0; }
  80141. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  80142. if (instanced === void 0) { instanced = false; }
  80143. if (useBytes === void 0) { useBytes = false; }
  80144. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  80145. this._engine = engine.getScene().getEngine();
  80146. }
  80147. else {
  80148. this._engine = engine;
  80149. }
  80150. this._updatable = updatable;
  80151. this._instanced = instanced;
  80152. this._data = data;
  80153. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  80154. if (!postponeInternalCreation) { // by default
  80155. this.create();
  80156. }
  80157. }
  80158. /**
  80159. * Create a new VertexBuffer based on the current buffer
  80160. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80161. * @param offset defines offset in the buffer (0 by default)
  80162. * @param size defines the size in floats of attributes (position is 3 for instance)
  80163. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80164. * @param instanced defines if the vertex buffer contains indexed data
  80165. * @param useBytes defines if the offset and stride are in bytes
  80166. * @returns the new vertex buffer
  80167. */
  80168. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  80169. if (useBytes === void 0) { useBytes = false; }
  80170. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  80171. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  80172. // a lot of these parameters are ignored as they are overriden by the buffer
  80173. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  80174. };
  80175. // Properties
  80176. /**
  80177. * Gets a boolean indicating if the Buffer is updatable?
  80178. * @returns true if the buffer is updatable
  80179. */
  80180. Buffer.prototype.isUpdatable = function () {
  80181. return this._updatable;
  80182. };
  80183. /**
  80184. * Gets current buffer's data
  80185. * @returns a DataArray or null
  80186. */
  80187. Buffer.prototype.getData = function () {
  80188. return this._data;
  80189. };
  80190. /**
  80191. * Gets underlying native buffer
  80192. * @returns underlying native buffer
  80193. */
  80194. Buffer.prototype.getBuffer = function () {
  80195. return this._buffer;
  80196. };
  80197. /**
  80198. * Gets the stride in float32 units (i.e. byte stride / 4).
  80199. * May not be an integer if the byte stride is not divisible by 4.
  80200. * DEPRECATED. Use byteStride instead.
  80201. * @returns the stride in float32 units
  80202. */
  80203. Buffer.prototype.getStrideSize = function () {
  80204. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80205. };
  80206. // Methods
  80207. /**
  80208. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80209. * @param data defines the data to store
  80210. */
  80211. Buffer.prototype.create = function (data) {
  80212. if (data === void 0) { data = null; }
  80213. if (!data && this._buffer) {
  80214. return; // nothing to do
  80215. }
  80216. data = data || this._data;
  80217. if (!data) {
  80218. return;
  80219. }
  80220. if (!this._buffer) { // create buffer
  80221. if (this._updatable) {
  80222. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80223. this._data = data;
  80224. }
  80225. else {
  80226. this._buffer = this._engine.createVertexBuffer(data);
  80227. }
  80228. }
  80229. else if (this._updatable) { // update buffer
  80230. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80231. this._data = data;
  80232. }
  80233. };
  80234. /** @hidden */
  80235. Buffer.prototype._rebuild = function () {
  80236. this._buffer = null;
  80237. this.create(this._data);
  80238. };
  80239. /**
  80240. * Update current buffer data
  80241. * @param data defines the data to store
  80242. */
  80243. Buffer.prototype.update = function (data) {
  80244. this.create(data);
  80245. };
  80246. /**
  80247. * Updates the data directly.
  80248. * @param data the new data
  80249. * @param offset the new offset
  80250. * @param vertexCount the vertex count (optional)
  80251. * @param useBytes set to true if the offset is in bytes
  80252. */
  80253. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80254. if (useBytes === void 0) { useBytes = false; }
  80255. if (!this._buffer) {
  80256. return;
  80257. }
  80258. if (this._updatable) { // update buffer
  80259. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80260. this._data = null;
  80261. }
  80262. };
  80263. /**
  80264. * Release all resources
  80265. */
  80266. Buffer.prototype.dispose = function () {
  80267. if (!this._buffer) {
  80268. return;
  80269. }
  80270. if (this._engine._releaseBuffer(this._buffer)) {
  80271. this._buffer = null;
  80272. }
  80273. };
  80274. return Buffer;
  80275. }());
  80276. /**
  80277. * Specialized buffer used to store vertex data
  80278. */
  80279. var VertexBuffer = /** @class */ (function () {
  80280. /**
  80281. * Constructor
  80282. * @param engine the engine
  80283. * @param data the data to use for this vertex buffer
  80284. * @param kind the vertex buffer kind
  80285. * @param updatable whether the data is updatable
  80286. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80287. * @param stride the stride (optional)
  80288. * @param instanced whether the buffer is instanced (optional)
  80289. * @param offset the offset of the data (optional)
  80290. * @param size the number of components (optional)
  80291. * @param type the type of the component (optional)
  80292. * @param normalized whether the data contains normalized data (optional)
  80293. * @param useBytes set to true if stride and offset are in bytes (optional)
  80294. */
  80295. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80296. if (normalized === void 0) { normalized = false; }
  80297. if (useBytes === void 0) { useBytes = false; }
  80298. if (data instanceof Buffer) {
  80299. this._buffer = data;
  80300. this._ownsBuffer = false;
  80301. }
  80302. else {
  80303. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80304. this._ownsBuffer = true;
  80305. }
  80306. this._kind = kind;
  80307. if (type == undefined) {
  80308. var data_1 = this.getData();
  80309. this.type = VertexBuffer.FLOAT;
  80310. if (data_1 instanceof Int8Array) {
  80311. this.type = VertexBuffer.BYTE;
  80312. }
  80313. else if (data_1 instanceof Uint8Array) {
  80314. this.type = VertexBuffer.UNSIGNED_BYTE;
  80315. }
  80316. else if (data_1 instanceof Int16Array) {
  80317. this.type = VertexBuffer.SHORT;
  80318. }
  80319. else if (data_1 instanceof Uint16Array) {
  80320. this.type = VertexBuffer.UNSIGNED_SHORT;
  80321. }
  80322. else if (data_1 instanceof Int32Array) {
  80323. this.type = VertexBuffer.INT;
  80324. }
  80325. else if (data_1 instanceof Uint32Array) {
  80326. this.type = VertexBuffer.UNSIGNED_INT;
  80327. }
  80328. }
  80329. else {
  80330. this.type = type;
  80331. }
  80332. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80333. if (useBytes) {
  80334. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80335. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80336. this.byteOffset = offset || 0;
  80337. }
  80338. else {
  80339. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80340. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80341. this.byteOffset = (offset || 0) * typeByteLength;
  80342. }
  80343. this.normalized = normalized;
  80344. this._instanced = instanced !== undefined ? instanced : false;
  80345. this._instanceDivisor = instanced ? 1 : 0;
  80346. }
  80347. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80348. /**
  80349. * Gets or sets the instance divisor when in instanced mode
  80350. */
  80351. get: function () {
  80352. return this._instanceDivisor;
  80353. },
  80354. set: function (value) {
  80355. this._instanceDivisor = value;
  80356. if (value == 0) {
  80357. this._instanced = false;
  80358. }
  80359. else {
  80360. this._instanced = true;
  80361. }
  80362. },
  80363. enumerable: true,
  80364. configurable: true
  80365. });
  80366. /** @hidden */
  80367. VertexBuffer.prototype._rebuild = function () {
  80368. if (!this._buffer) {
  80369. return;
  80370. }
  80371. this._buffer._rebuild();
  80372. };
  80373. /**
  80374. * Returns the kind of the VertexBuffer (string)
  80375. * @returns a string
  80376. */
  80377. VertexBuffer.prototype.getKind = function () {
  80378. return this._kind;
  80379. };
  80380. // Properties
  80381. /**
  80382. * Gets a boolean indicating if the VertexBuffer is updatable?
  80383. * @returns true if the buffer is updatable
  80384. */
  80385. VertexBuffer.prototype.isUpdatable = function () {
  80386. return this._buffer.isUpdatable();
  80387. };
  80388. /**
  80389. * Gets current buffer's data
  80390. * @returns a DataArray or null
  80391. */
  80392. VertexBuffer.prototype.getData = function () {
  80393. return this._buffer.getData();
  80394. };
  80395. /**
  80396. * Gets underlying native buffer
  80397. * @returns underlying native buffer
  80398. */
  80399. VertexBuffer.prototype.getBuffer = function () {
  80400. return this._buffer.getBuffer();
  80401. };
  80402. /**
  80403. * Gets the stride in float32 units (i.e. byte stride / 4).
  80404. * May not be an integer if the byte stride is not divisible by 4.
  80405. * DEPRECATED. Use byteStride instead.
  80406. * @returns the stride in float32 units
  80407. */
  80408. VertexBuffer.prototype.getStrideSize = function () {
  80409. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  80410. };
  80411. /**
  80412. * Returns the offset as a multiple of the type byte length.
  80413. * DEPRECATED. Use byteOffset instead.
  80414. * @returns the offset in bytes
  80415. */
  80416. VertexBuffer.prototype.getOffset = function () {
  80417. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  80418. };
  80419. /**
  80420. * Returns the number of components per vertex attribute (integer)
  80421. * @returns the size in float
  80422. */
  80423. VertexBuffer.prototype.getSize = function () {
  80424. return this._size;
  80425. };
  80426. /**
  80427. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80428. * @returns true if this buffer is instanced
  80429. */
  80430. VertexBuffer.prototype.getIsInstanced = function () {
  80431. return this._instanced;
  80432. };
  80433. /**
  80434. * Returns the instancing divisor, zero for non-instanced (integer).
  80435. * @returns a number
  80436. */
  80437. VertexBuffer.prototype.getInstanceDivisor = function () {
  80438. return this._instanceDivisor;
  80439. };
  80440. // Methods
  80441. /**
  80442. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80443. * @param data defines the data to store
  80444. */
  80445. VertexBuffer.prototype.create = function (data) {
  80446. this._buffer.create(data);
  80447. };
  80448. /**
  80449. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80450. * This function will create a new buffer if the current one is not updatable
  80451. * @param data defines the data to store
  80452. */
  80453. VertexBuffer.prototype.update = function (data) {
  80454. this._buffer.update(data);
  80455. };
  80456. /**
  80457. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80458. * Returns the directly updated WebGLBuffer.
  80459. * @param data the new data
  80460. * @param offset the new offset
  80461. * @param useBytes set to true if the offset is in bytes
  80462. */
  80463. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  80464. if (useBytes === void 0) { useBytes = false; }
  80465. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  80466. };
  80467. /**
  80468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80469. */
  80470. VertexBuffer.prototype.dispose = function () {
  80471. if (this._ownsBuffer) {
  80472. this._buffer.dispose();
  80473. }
  80474. };
  80475. /**
  80476. * Enumerates each value of this vertex buffer as numbers.
  80477. * @param count the number of values to enumerate
  80478. * @param callback the callback function called for each value
  80479. */
  80480. VertexBuffer.prototype.forEach = function (count, callback) {
  80481. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  80482. };
  80483. /**
  80484. * Deduces the stride given a kind.
  80485. * @param kind The kind string to deduce
  80486. * @returns The deduced stride
  80487. */
  80488. VertexBuffer.DeduceStride = function (kind) {
  80489. switch (kind) {
  80490. case VertexBuffer.UVKind:
  80491. case VertexBuffer.UV2Kind:
  80492. case VertexBuffer.UV3Kind:
  80493. case VertexBuffer.UV4Kind:
  80494. case VertexBuffer.UV5Kind:
  80495. case VertexBuffer.UV6Kind:
  80496. return 2;
  80497. case VertexBuffer.NormalKind:
  80498. case VertexBuffer.PositionKind:
  80499. return 3;
  80500. case VertexBuffer.ColorKind:
  80501. case VertexBuffer.MatricesIndicesKind:
  80502. case VertexBuffer.MatricesIndicesExtraKind:
  80503. case VertexBuffer.MatricesWeightsKind:
  80504. case VertexBuffer.MatricesWeightsExtraKind:
  80505. case VertexBuffer.TangentKind:
  80506. return 4;
  80507. default:
  80508. throw new Error("Invalid kind '" + kind + "'");
  80509. }
  80510. };
  80511. /**
  80512. * Gets the byte length of the given type.
  80513. * @param type the type
  80514. * @returns the number of bytes
  80515. */
  80516. VertexBuffer.GetTypeByteLength = function (type) {
  80517. switch (type) {
  80518. case VertexBuffer.BYTE:
  80519. case VertexBuffer.UNSIGNED_BYTE:
  80520. return 1;
  80521. case VertexBuffer.SHORT:
  80522. case VertexBuffer.UNSIGNED_SHORT:
  80523. return 2;
  80524. case VertexBuffer.INT:
  80525. case VertexBuffer.FLOAT:
  80526. return 4;
  80527. default:
  80528. throw new Error("Invalid type '" + type + "'");
  80529. }
  80530. };
  80531. /**
  80532. * Enumerates each value of the given parameters as numbers.
  80533. * @param data the data to enumerate
  80534. * @param byteOffset the byte offset of the data
  80535. * @param byteStride the byte stride of the data
  80536. * @param componentCount the number of components per element
  80537. * @param componentType the type of the component
  80538. * @param count the total number of components
  80539. * @param normalized whether the data is normalized
  80540. * @param callback the callback function called for each value
  80541. */
  80542. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  80543. if (data instanceof Array) {
  80544. var offset = byteOffset / 4;
  80545. var stride = byteStride / 4;
  80546. for (var index = 0; index < count; index += componentCount) {
  80547. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80548. callback(data[offset + componentIndex], index + componentIndex);
  80549. }
  80550. offset += stride;
  80551. }
  80552. }
  80553. else {
  80554. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  80555. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  80556. for (var index = 0; index < count; index += componentCount) {
  80557. var componentByteOffset = byteOffset;
  80558. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80559. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  80560. callback(value, index + componentIndex);
  80561. componentByteOffset += componentByteLength;
  80562. }
  80563. byteOffset += byteStride;
  80564. }
  80565. }
  80566. };
  80567. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  80568. switch (type) {
  80569. case VertexBuffer.BYTE: {
  80570. var value = dataView.getInt8(byteOffset);
  80571. if (normalized) {
  80572. value = Math.max(value / 127, -1);
  80573. }
  80574. return value;
  80575. }
  80576. case VertexBuffer.UNSIGNED_BYTE: {
  80577. var value = dataView.getUint8(byteOffset);
  80578. if (normalized) {
  80579. value = value / 255;
  80580. }
  80581. return value;
  80582. }
  80583. case VertexBuffer.SHORT: {
  80584. var value = dataView.getInt16(byteOffset, true);
  80585. if (normalized) {
  80586. value = Math.max(value / 16383, -1);
  80587. }
  80588. return value;
  80589. }
  80590. case VertexBuffer.UNSIGNED_SHORT: {
  80591. var value = dataView.getUint16(byteOffset, true);
  80592. if (normalized) {
  80593. value = value / 65535;
  80594. }
  80595. return value;
  80596. }
  80597. case VertexBuffer.FLOAT: {
  80598. return dataView.getFloat32(byteOffset, true);
  80599. }
  80600. default: {
  80601. throw new Error("Invalid component type " + type);
  80602. }
  80603. }
  80604. };
  80605. /**
  80606. * The byte type.
  80607. */
  80608. VertexBuffer.BYTE = 5120;
  80609. /**
  80610. * The unsigned byte type.
  80611. */
  80612. VertexBuffer.UNSIGNED_BYTE = 5121;
  80613. /**
  80614. * The short type.
  80615. */
  80616. VertexBuffer.SHORT = 5122;
  80617. /**
  80618. * The unsigned short type.
  80619. */
  80620. VertexBuffer.UNSIGNED_SHORT = 5123;
  80621. /**
  80622. * The integer type.
  80623. */
  80624. VertexBuffer.INT = 5124;
  80625. /**
  80626. * The unsigned integer type.
  80627. */
  80628. VertexBuffer.UNSIGNED_INT = 5125;
  80629. /**
  80630. * The float type.
  80631. */
  80632. VertexBuffer.FLOAT = 5126;
  80633. // Enums
  80634. /**
  80635. * Positions
  80636. */
  80637. VertexBuffer.PositionKind = "position";
  80638. /**
  80639. * Normals
  80640. */
  80641. VertexBuffer.NormalKind = "normal";
  80642. /**
  80643. * Tangents
  80644. */
  80645. VertexBuffer.TangentKind = "tangent";
  80646. /**
  80647. * Texture coordinates
  80648. */
  80649. VertexBuffer.UVKind = "uv";
  80650. /**
  80651. * Texture coordinates 2
  80652. */
  80653. VertexBuffer.UV2Kind = "uv2";
  80654. /**
  80655. * Texture coordinates 3
  80656. */
  80657. VertexBuffer.UV3Kind = "uv3";
  80658. /**
  80659. * Texture coordinates 4
  80660. */
  80661. VertexBuffer.UV4Kind = "uv4";
  80662. /**
  80663. * Texture coordinates 5
  80664. */
  80665. VertexBuffer.UV5Kind = "uv5";
  80666. /**
  80667. * Texture coordinates 6
  80668. */
  80669. VertexBuffer.UV6Kind = "uv6";
  80670. /**
  80671. * Colors
  80672. */
  80673. VertexBuffer.ColorKind = "color";
  80674. /**
  80675. * Matrix indices (for bones)
  80676. */
  80677. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  80678. /**
  80679. * Matrix weights (for bones)
  80680. */
  80681. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  80682. /**
  80683. * Additional matrix indices (for bones)
  80684. */
  80685. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  80686. /**
  80687. * Additional matrix weights (for bones)
  80688. */
  80689. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  80690. return VertexBuffer;
  80691. }());
  80692. /***/ }),
  80693. /***/ "./Meshes/csg.ts":
  80694. /*!***********************!*\
  80695. !*** ./Meshes/csg.ts ***!
  80696. \***********************/
  80697. /*! exports provided: CSG */
  80698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80699. "use strict";
  80700. __webpack_require__.r(__webpack_exports__);
  80701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  80702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80703. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80704. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  80705. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80706. /**
  80707. * Unique ID when we import meshes from Babylon to CSG
  80708. */
  80709. var currentCSGMeshId = 0;
  80710. /**
  80711. * Represents a vertex of a polygon. Use your own vertex class instead of this
  80712. * one to provide additional features like texture coordinates and vertex
  80713. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  80714. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  80715. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  80716. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  80717. * is not used anywhere else.
  80718. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  80719. */
  80720. var Vertex = /** @class */ (function () {
  80721. /**
  80722. * Initializes the vertex
  80723. * @param pos The position of the vertex
  80724. * @param normal The normal of the vertex
  80725. * @param uv The texture coordinate of the vertex
  80726. */
  80727. function Vertex(
  80728. /**
  80729. * The position of the vertex
  80730. */
  80731. pos,
  80732. /**
  80733. * The normal of the vertex
  80734. */
  80735. normal,
  80736. /**
  80737. * The texture coordinate of the vertex
  80738. */
  80739. uv) {
  80740. this.pos = pos;
  80741. this.normal = normal;
  80742. this.uv = uv;
  80743. }
  80744. /**
  80745. * Make a clone, or deep copy, of the vertex
  80746. * @returns A new Vertex
  80747. */
  80748. Vertex.prototype.clone = function () {
  80749. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  80750. };
  80751. /**
  80752. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  80753. * orientation of a polygon is flipped.
  80754. */
  80755. Vertex.prototype.flip = function () {
  80756. this.normal = this.normal.scale(-1);
  80757. };
  80758. /**
  80759. * Create a new vertex between this vertex and `other` by linearly
  80760. * interpolating all properties using a parameter of `t`. Subclasses should
  80761. * override this to interpolate additional properties.
  80762. * @param other the vertex to interpolate against
  80763. * @param t The factor used to linearly interpolate between the vertices
  80764. */
  80765. Vertex.prototype.interpolate = function (other, t) {
  80766. return new Vertex(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.pos, other.pos, t), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.normal, other.normal, t), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(this.uv, other.uv, t));
  80767. };
  80768. return Vertex;
  80769. }());
  80770. /**
  80771. * Represents a plane in 3D space.
  80772. */
  80773. var Plane = /** @class */ (function () {
  80774. /**
  80775. * Initializes the plane
  80776. * @param normal The normal for the plane
  80777. * @param w
  80778. */
  80779. function Plane(normal, w) {
  80780. this.normal = normal;
  80781. this.w = w;
  80782. }
  80783. /**
  80784. * Construct a plane from three points
  80785. * @param a Point a
  80786. * @param b Point b
  80787. * @param c Point c
  80788. */
  80789. Plane.FromPoints = function (a, b, c) {
  80790. var v0 = c.subtract(a);
  80791. var v1 = b.subtract(a);
  80792. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  80793. return null;
  80794. }
  80795. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  80796. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  80797. };
  80798. /**
  80799. * Clone, or make a deep copy of the plane
  80800. * @returns a new Plane
  80801. */
  80802. Plane.prototype.clone = function () {
  80803. return new Plane(this.normal.clone(), this.w);
  80804. };
  80805. /**
  80806. * Flip the face of the plane
  80807. */
  80808. Plane.prototype.flip = function () {
  80809. this.normal.scaleInPlace(-1);
  80810. this.w = -this.w;
  80811. };
  80812. /**
  80813. * Split `polygon` by this plane if needed, then put the polygon or polygon
  80814. * fragments in the appropriate lists. Coplanar polygons go into either
  80815. `* coplanarFront` or `coplanarBack` depending on their orientation with
  80816. * respect to this plane. Polygons in front or in back of this plane go into
  80817. * either `front` or `back`
  80818. * @param polygon The polygon to be split
  80819. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  80820. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  80821. * @param front Will contain the polygons in front of the plane
  80822. * @param back Will contain the polygons begind the plane
  80823. */
  80824. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  80825. var COPLANAR = 0;
  80826. var FRONT = 1;
  80827. var BACK = 2;
  80828. var SPANNING = 3;
  80829. // Classify each point as well as the entire polygon into one of the above
  80830. // four classes.
  80831. var polygonType = 0;
  80832. var types = [];
  80833. var i;
  80834. var t;
  80835. for (i = 0; i < polygon.vertices.length; i++) {
  80836. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  80837. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  80838. polygonType |= type;
  80839. types.push(type);
  80840. }
  80841. // Put the polygon in the correct list, splitting it when necessary
  80842. switch (polygonType) {
  80843. case COPLANAR:
  80844. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  80845. break;
  80846. case FRONT:
  80847. front.push(polygon);
  80848. break;
  80849. case BACK:
  80850. back.push(polygon);
  80851. break;
  80852. case SPANNING:
  80853. var f = [], b = [];
  80854. for (i = 0; i < polygon.vertices.length; i++) {
  80855. var j = (i + 1) % polygon.vertices.length;
  80856. var ti = types[i], tj = types[j];
  80857. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  80858. if (ti !== BACK) {
  80859. f.push(vi);
  80860. }
  80861. if (ti !== FRONT) {
  80862. b.push(ti !== BACK ? vi.clone() : vi);
  80863. }
  80864. if ((ti | tj) === SPANNING) {
  80865. t = (this.w - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vi.pos)) / _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vj.pos.subtract(vi.pos));
  80866. var v = vi.interpolate(vj, t);
  80867. f.push(v);
  80868. b.push(v.clone());
  80869. }
  80870. }
  80871. var poly;
  80872. if (f.length >= 3) {
  80873. poly = new Polygon(f, polygon.shared);
  80874. if (poly.plane) {
  80875. front.push(poly);
  80876. }
  80877. }
  80878. if (b.length >= 3) {
  80879. poly = new Polygon(b, polygon.shared);
  80880. if (poly.plane) {
  80881. back.push(poly);
  80882. }
  80883. }
  80884. break;
  80885. }
  80886. };
  80887. /**
  80888. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  80889. * point is on the plane
  80890. */
  80891. Plane.EPSILON = 1e-5;
  80892. return Plane;
  80893. }());
  80894. /**
  80895. * Represents a convex polygon. The vertices used to initialize a polygon must
  80896. * be coplanar and form a convex loop.
  80897. *
  80898. * Each convex polygon has a `shared` property, which is shared between all
  80899. * polygons that are clones of each other or were split from the same polygon.
  80900. * This can be used to define per-polygon properties (such as surface color)
  80901. */
  80902. var Polygon = /** @class */ (function () {
  80903. /**
  80904. * Initializes the polygon
  80905. * @param vertices The vertices of the polygon
  80906. * @param shared The properties shared across all polygons
  80907. */
  80908. function Polygon(vertices, shared) {
  80909. this.vertices = vertices;
  80910. this.shared = shared;
  80911. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  80912. }
  80913. /**
  80914. * Clones, or makes a deep copy, or the polygon
  80915. */
  80916. Polygon.prototype.clone = function () {
  80917. var vertices = this.vertices.map(function (v) { return v.clone(); });
  80918. return new Polygon(vertices, this.shared);
  80919. };
  80920. /**
  80921. * Flips the faces of the polygon
  80922. */
  80923. Polygon.prototype.flip = function () {
  80924. this.vertices.reverse().map(function (v) { v.flip(); });
  80925. this.plane.flip();
  80926. };
  80927. return Polygon;
  80928. }());
  80929. /**
  80930. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  80931. * by picking a polygon to split along. That polygon (and all other coplanar
  80932. * polygons) are added directly to that node and the other polygons are added to
  80933. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  80934. * no distinction between internal and leaf nodes
  80935. */
  80936. var Node = /** @class */ (function () {
  80937. /**
  80938. * Initializes the node
  80939. * @param polygons A collection of polygons held in the node
  80940. */
  80941. function Node(polygons) {
  80942. this.plane = null;
  80943. this.front = null;
  80944. this.back = null;
  80945. this.polygons = new Array();
  80946. if (polygons) {
  80947. this.build(polygons);
  80948. }
  80949. }
  80950. /**
  80951. * Clones, or makes a deep copy, of the node
  80952. * @returns The cloned node
  80953. */
  80954. Node.prototype.clone = function () {
  80955. var node = new Node();
  80956. node.plane = this.plane && this.plane.clone();
  80957. node.front = this.front && this.front.clone();
  80958. node.back = this.back && this.back.clone();
  80959. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  80960. return node;
  80961. };
  80962. /**
  80963. * Convert solid space to empty space and empty space to solid space
  80964. */
  80965. Node.prototype.invert = function () {
  80966. for (var i = 0; i < this.polygons.length; i++) {
  80967. this.polygons[i].flip();
  80968. }
  80969. if (this.plane) {
  80970. this.plane.flip();
  80971. }
  80972. if (this.front) {
  80973. this.front.invert();
  80974. }
  80975. if (this.back) {
  80976. this.back.invert();
  80977. }
  80978. var temp = this.front;
  80979. this.front = this.back;
  80980. this.back = temp;
  80981. };
  80982. /**
  80983. * Recursively remove all polygons in `polygons` that are inside this BSP
  80984. * tree.
  80985. * @param polygons Polygons to remove from the BSP
  80986. * @returns Polygons clipped from the BSP
  80987. */
  80988. Node.prototype.clipPolygons = function (polygons) {
  80989. if (!this.plane) {
  80990. return polygons.slice();
  80991. }
  80992. var front = new Array(), back = new Array();
  80993. for (var i = 0; i < polygons.length; i++) {
  80994. this.plane.splitPolygon(polygons[i], front, back, front, back);
  80995. }
  80996. if (this.front) {
  80997. front = this.front.clipPolygons(front);
  80998. }
  80999. if (this.back) {
  81000. back = this.back.clipPolygons(back);
  81001. }
  81002. else {
  81003. back = [];
  81004. }
  81005. return front.concat(back);
  81006. };
  81007. /**
  81008. * Remove all polygons in this BSP tree that are inside the other BSP tree
  81009. * `bsp`.
  81010. * @param bsp BSP containing polygons to remove from this BSP
  81011. */
  81012. Node.prototype.clipTo = function (bsp) {
  81013. this.polygons = bsp.clipPolygons(this.polygons);
  81014. if (this.front) {
  81015. this.front.clipTo(bsp);
  81016. }
  81017. if (this.back) {
  81018. this.back.clipTo(bsp);
  81019. }
  81020. };
  81021. /**
  81022. * Return a list of all polygons in this BSP tree
  81023. * @returns List of all polygons in this BSP tree
  81024. */
  81025. Node.prototype.allPolygons = function () {
  81026. var polygons = this.polygons.slice();
  81027. if (this.front) {
  81028. polygons = polygons.concat(this.front.allPolygons());
  81029. }
  81030. if (this.back) {
  81031. polygons = polygons.concat(this.back.allPolygons());
  81032. }
  81033. return polygons;
  81034. };
  81035. /**
  81036. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  81037. * new polygons are filtered down to the bottom of the tree and become new
  81038. * nodes there. Each set of polygons is partitioned using the first polygon
  81039. * (no heuristic is used to pick a good split)
  81040. * @param polygons Polygons used to construct the BSP tree
  81041. */
  81042. Node.prototype.build = function (polygons) {
  81043. if (!polygons.length) {
  81044. return;
  81045. }
  81046. if (!this.plane) {
  81047. this.plane = polygons[0].plane.clone();
  81048. }
  81049. var front = new Array(), back = new Array();
  81050. for (var i = 0; i < polygons.length; i++) {
  81051. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  81052. }
  81053. if (front.length) {
  81054. if (!this.front) {
  81055. this.front = new Node();
  81056. }
  81057. this.front.build(front);
  81058. }
  81059. if (back.length) {
  81060. if (!this.back) {
  81061. this.back = new Node();
  81062. }
  81063. this.back.build(back);
  81064. }
  81065. };
  81066. return Node;
  81067. }());
  81068. /**
  81069. * Class for building Constructive Solid Geometry
  81070. */
  81071. var CSG = /** @class */ (function () {
  81072. function CSG() {
  81073. this.polygons = new Array();
  81074. }
  81075. /**
  81076. * Convert the Mesh to CSG
  81077. * @param mesh The Mesh to convert to CSG
  81078. * @returns A new CSG from the Mesh
  81079. */
  81080. CSG.FromMesh = function (mesh) {
  81081. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  81082. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  81083. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  81084. mesh.computeWorldMatrix(true);
  81085. matrix = mesh.getWorldMatrix();
  81086. meshPosition = mesh.position.clone();
  81087. meshRotation = mesh.rotation.clone();
  81088. if (mesh.rotationQuaternion) {
  81089. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  81090. }
  81091. meshScaling = mesh.scaling.clone();
  81092. }
  81093. else {
  81094. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  81095. }
  81096. 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);
  81097. var subMeshes = mesh.subMeshes;
  81098. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  81099. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  81100. vertices = [];
  81101. for (var j = 0; j < 3; j++) {
  81102. var sourceNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[indices[i + j] * 3], normals[indices[i + j] * 3 + 1], normals[indices[i + j] * 3 + 2]);
  81103. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  81104. var sourcePosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[indices[i + j] * 3], positions[indices[i + j] * 3 + 1], positions[indices[i + j] * 3 + 2]);
  81105. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  81106. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  81107. vertex = new Vertex(position, normal, uv);
  81108. vertices.push(vertex);
  81109. }
  81110. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  81111. // To handle the case of degenerated triangle
  81112. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  81113. if (polygon.plane) {
  81114. polygons.push(polygon);
  81115. }
  81116. }
  81117. }
  81118. var csg = CSG.FromPolygons(polygons);
  81119. csg.matrix = matrix;
  81120. csg.position = meshPosition;
  81121. csg.rotation = meshRotation;
  81122. csg.scaling = meshScaling;
  81123. csg.rotationQuaternion = meshRotationQuaternion;
  81124. currentCSGMeshId++;
  81125. return csg;
  81126. };
  81127. /**
  81128. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  81129. * @param polygons Polygons used to construct a CSG solid
  81130. */
  81131. CSG.FromPolygons = function (polygons) {
  81132. var csg = new CSG();
  81133. csg.polygons = polygons;
  81134. return csg;
  81135. };
  81136. /**
  81137. * Clones, or makes a deep copy, of the CSG
  81138. * @returns A new CSG
  81139. */
  81140. CSG.prototype.clone = function () {
  81141. var csg = new CSG();
  81142. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  81143. csg.copyTransformAttributes(this);
  81144. return csg;
  81145. };
  81146. /**
  81147. * Unions this CSG with another CSG
  81148. * @param csg The CSG to union against this CSG
  81149. * @returns The unioned CSG
  81150. */
  81151. CSG.prototype.union = function (csg) {
  81152. var a = new Node(this.clone().polygons);
  81153. var b = new Node(csg.clone().polygons);
  81154. a.clipTo(b);
  81155. b.clipTo(a);
  81156. b.invert();
  81157. b.clipTo(a);
  81158. b.invert();
  81159. a.build(b.allPolygons());
  81160. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81161. };
  81162. /**
  81163. * Unions this CSG with another CSG in place
  81164. * @param csg The CSG to union against this CSG
  81165. */
  81166. CSG.prototype.unionInPlace = function (csg) {
  81167. var a = new Node(this.polygons);
  81168. var b = new Node(csg.polygons);
  81169. a.clipTo(b);
  81170. b.clipTo(a);
  81171. b.invert();
  81172. b.clipTo(a);
  81173. b.invert();
  81174. a.build(b.allPolygons());
  81175. this.polygons = a.allPolygons();
  81176. };
  81177. /**
  81178. * Subtracts this CSG with another CSG
  81179. * @param csg The CSG to subtract against this CSG
  81180. * @returns A new CSG
  81181. */
  81182. CSG.prototype.subtract = function (csg) {
  81183. var a = new Node(this.clone().polygons);
  81184. var b = new Node(csg.clone().polygons);
  81185. a.invert();
  81186. a.clipTo(b);
  81187. b.clipTo(a);
  81188. b.invert();
  81189. b.clipTo(a);
  81190. b.invert();
  81191. a.build(b.allPolygons());
  81192. a.invert();
  81193. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81194. };
  81195. /**
  81196. * Subtracts this CSG with another CSG in place
  81197. * @param csg The CSG to subtact against this CSG
  81198. */
  81199. CSG.prototype.subtractInPlace = function (csg) {
  81200. var a = new Node(this.polygons);
  81201. var b = new Node(csg.polygons);
  81202. a.invert();
  81203. a.clipTo(b);
  81204. b.clipTo(a);
  81205. b.invert();
  81206. b.clipTo(a);
  81207. b.invert();
  81208. a.build(b.allPolygons());
  81209. a.invert();
  81210. this.polygons = a.allPolygons();
  81211. };
  81212. /**
  81213. * Intersect this CSG with another CSG
  81214. * @param csg The CSG to intersect against this CSG
  81215. * @returns A new CSG
  81216. */
  81217. CSG.prototype.intersect = function (csg) {
  81218. var a = new Node(this.clone().polygons);
  81219. var b = new Node(csg.clone().polygons);
  81220. a.invert();
  81221. b.clipTo(a);
  81222. b.invert();
  81223. a.clipTo(b);
  81224. b.clipTo(a);
  81225. a.build(b.allPolygons());
  81226. a.invert();
  81227. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81228. };
  81229. /**
  81230. * Intersects this CSG with another CSG in place
  81231. * @param csg The CSG to intersect against this CSG
  81232. */
  81233. CSG.prototype.intersectInPlace = function (csg) {
  81234. var a = new Node(this.polygons);
  81235. var b = new Node(csg.polygons);
  81236. a.invert();
  81237. b.clipTo(a);
  81238. b.invert();
  81239. a.clipTo(b);
  81240. b.clipTo(a);
  81241. a.build(b.allPolygons());
  81242. a.invert();
  81243. this.polygons = a.allPolygons();
  81244. };
  81245. /**
  81246. * Return a new CSG solid with solid and empty space switched. This solid is
  81247. * not modified.
  81248. * @returns A new CSG solid with solid and empty space switched
  81249. */
  81250. CSG.prototype.inverse = function () {
  81251. var csg = this.clone();
  81252. csg.inverseInPlace();
  81253. return csg;
  81254. };
  81255. /**
  81256. * Inverses the CSG in place
  81257. */
  81258. CSG.prototype.inverseInPlace = function () {
  81259. this.polygons.map(function (p) { p.flip(); });
  81260. };
  81261. /**
  81262. * This is used to keep meshes transformations so they can be restored
  81263. * when we build back a Babylon Mesh
  81264. * NB : All CSG operations are performed in world coordinates
  81265. * @param csg The CSG to copy the transform attributes from
  81266. * @returns This CSG
  81267. */
  81268. CSG.prototype.copyTransformAttributes = function (csg) {
  81269. this.matrix = csg.matrix;
  81270. this.position = csg.position;
  81271. this.rotation = csg.rotation;
  81272. this.scaling = csg.scaling;
  81273. this.rotationQuaternion = csg.rotationQuaternion;
  81274. return this;
  81275. };
  81276. /**
  81277. * Build Raw mesh from CSG
  81278. * Coordinates here are in world space
  81279. * @param name The name of the mesh geometry
  81280. * @param scene The Scene
  81281. * @param keepSubMeshes Specifies if the submeshes should be kept
  81282. * @returns A new Mesh
  81283. */
  81284. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81285. var matrix = this.matrix.clone();
  81286. matrix.invert();
  81287. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene), vertices = [], indices = [], normals = [], uvs = [], vertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), uv = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), polygons = this.polygons, polygonIndices = [0, 0, 0], polygon, vertice_dict = {}, vertex_idx, currentIndex = 0, subMesh_dict = {}, subMesh_obj;
  81288. if (keepSubMeshes) {
  81289. // Sort Polygons, since subMeshes are indices range
  81290. polygons.sort(function (a, b) {
  81291. if (a.shared.meshId === b.shared.meshId) {
  81292. return a.shared.subMeshId - b.shared.subMeshId;
  81293. }
  81294. else {
  81295. return a.shared.meshId - b.shared.meshId;
  81296. }
  81297. });
  81298. }
  81299. for (var i = 0, il = polygons.length; i < il; i++) {
  81300. polygon = polygons[i];
  81301. // Building SubMeshes
  81302. if (!subMesh_dict[polygon.shared.meshId]) {
  81303. subMesh_dict[polygon.shared.meshId] = {};
  81304. }
  81305. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81306. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81307. indexStart: +Infinity,
  81308. indexEnd: -Infinity,
  81309. materialIndex: polygon.shared.materialIndex
  81310. };
  81311. }
  81312. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81313. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81314. polygonIndices[0] = 0;
  81315. polygonIndices[1] = j - 1;
  81316. polygonIndices[2] = j;
  81317. for (var k = 0; k < 3; k++) {
  81318. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81319. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81320. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81321. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81322. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81323. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81324. // Check if 2 points can be merged
  81325. if (!(typeof vertex_idx !== 'undefined' &&
  81326. normals[vertex_idx * 3] === localNormal.x &&
  81327. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81328. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81329. uvs[vertex_idx * 2] === uv.x &&
  81330. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81331. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81332. uvs.push(uv.x, uv.y);
  81333. normals.push(normal.x, normal.y, normal.z);
  81334. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81335. }
  81336. indices.push(vertex_idx);
  81337. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81338. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81339. currentIndex++;
  81340. }
  81341. }
  81342. }
  81343. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81344. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81345. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81346. mesh.setIndices(indices, null);
  81347. if (keepSubMeshes) {
  81348. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81349. var materialIndexOffset = 0, materialMaxIndex;
  81350. mesh.subMeshes = new Array();
  81351. for (var m in subMesh_dict) {
  81352. materialMaxIndex = -1;
  81353. for (var sm in subMesh_dict[m]) {
  81354. subMesh_obj = subMesh_dict[m][sm];
  81355. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81356. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81357. }
  81358. materialIndexOffset += ++materialMaxIndex;
  81359. }
  81360. }
  81361. return mesh;
  81362. };
  81363. /**
  81364. * Build Mesh from CSG taking material and transforms into account
  81365. * @param name The name of the Mesh
  81366. * @param material The material of the Mesh
  81367. * @param scene The Scene
  81368. * @param keepSubMeshes Specifies if submeshes should be kept
  81369. * @returns The new Mesh
  81370. */
  81371. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81372. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81373. mesh.material = material;
  81374. mesh.position.copyFrom(this.position);
  81375. mesh.rotation.copyFrom(this.rotation);
  81376. if (this.rotationQuaternion) {
  81377. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81378. }
  81379. mesh.scaling.copyFrom(this.scaling);
  81380. mesh.computeWorldMatrix(true);
  81381. return mesh;
  81382. };
  81383. return CSG;
  81384. }());
  81385. /***/ }),
  81386. /***/ "./Meshes/geometry.ts":
  81387. /*!****************************!*\
  81388. !*** ./Meshes/geometry.ts ***!
  81389. \****************************/
  81390. /*! exports provided: Geometry */
  81391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81392. "use strict";
  81393. __webpack_require__.r(__webpack_exports__);
  81394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81395. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81396. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81397. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81398. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81399. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81400. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81401. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81402. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81403. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  81404. /**
  81405. * Class used to store geometry data (vertex buffers + index buffer)
  81406. */
  81407. var Geometry = /** @class */ (function () {
  81408. /**
  81409. * Creates a new geometry
  81410. * @param id defines the unique ID
  81411. * @param scene defines the hosting scene
  81412. * @param vertexData defines the VertexData used to get geometry data
  81413. * @param updatable defines if geometry must be updatable (false by default)
  81414. * @param mesh defines the mesh that will be associated with the geometry
  81415. */
  81416. function Geometry(id, scene, vertexData, updatable, mesh) {
  81417. if (updatable === void 0) { updatable = false; }
  81418. if (mesh === void 0) { mesh = null; }
  81419. /**
  81420. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81421. */
  81422. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81423. this._totalVertices = 0;
  81424. this._isDisposed = false;
  81425. this._indexBufferIsUpdatable = false;
  81426. this.id = id;
  81427. this.uniqueId = scene.getUniqueId();
  81428. this._engine = scene.getEngine();
  81429. this._meshes = [];
  81430. this._scene = scene;
  81431. //Init vertex buffer cache
  81432. this._vertexBuffers = {};
  81433. this._indices = [];
  81434. this._updatable = updatable;
  81435. // vertexData
  81436. if (vertexData) {
  81437. this.setAllVerticesData(vertexData, updatable);
  81438. }
  81439. else {
  81440. this._totalVertices = 0;
  81441. this._indices = [];
  81442. }
  81443. if (this._engine.getCaps().vertexArrayObject) {
  81444. this._vertexArrayObjects = {};
  81445. }
  81446. // applyToMesh
  81447. if (mesh) {
  81448. this.applyToMesh(mesh);
  81449. mesh.computeWorldMatrix(true);
  81450. }
  81451. }
  81452. Object.defineProperty(Geometry.prototype, "boundingBias", {
  81453. /**
  81454. * 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
  81455. */
  81456. get: function () {
  81457. return this._boundingBias;
  81458. },
  81459. /**
  81460. * 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
  81461. */
  81462. set: function (value) {
  81463. if (this._boundingBias) {
  81464. this._boundingBias.copyFrom(value);
  81465. }
  81466. else {
  81467. this._boundingBias = value.clone();
  81468. }
  81469. this._updateBoundingInfo(true, null);
  81470. },
  81471. enumerable: true,
  81472. configurable: true
  81473. });
  81474. /**
  81475. * Static function used to attach a new empty geometry to a mesh
  81476. * @param mesh defines the mesh to attach the geometry to
  81477. * @returns the new Geometry
  81478. */
  81479. Geometry.CreateGeometryForMesh = function (mesh) {
  81480. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  81481. geometry.applyToMesh(mesh);
  81482. return geometry;
  81483. };
  81484. Object.defineProperty(Geometry.prototype, "extend", {
  81485. /**
  81486. * Gets the current extend of the geometry
  81487. */
  81488. get: function () {
  81489. return this._extend;
  81490. },
  81491. enumerable: true,
  81492. configurable: true
  81493. });
  81494. /**
  81495. * Gets the hosting scene
  81496. * @returns the hosting Scene
  81497. */
  81498. Geometry.prototype.getScene = function () {
  81499. return this._scene;
  81500. };
  81501. /**
  81502. * Gets the hosting engine
  81503. * @returns the hosting Engine
  81504. */
  81505. Geometry.prototype.getEngine = function () {
  81506. return this._engine;
  81507. };
  81508. /**
  81509. * Defines if the geometry is ready to use
  81510. * @returns true if the geometry is ready to be used
  81511. */
  81512. Geometry.prototype.isReady = function () {
  81513. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81514. };
  81515. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  81516. /**
  81517. * Gets a value indicating that the geometry should not be serialized
  81518. */
  81519. get: function () {
  81520. for (var index = 0; index < this._meshes.length; index++) {
  81521. if (!this._meshes[index].doNotSerialize) {
  81522. return false;
  81523. }
  81524. }
  81525. return true;
  81526. },
  81527. enumerable: true,
  81528. configurable: true
  81529. });
  81530. /** @hidden */
  81531. Geometry.prototype._rebuild = function () {
  81532. if (this._vertexArrayObjects) {
  81533. this._vertexArrayObjects = {};
  81534. }
  81535. // Index buffer
  81536. if (this._meshes.length !== 0 && this._indices) {
  81537. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81538. }
  81539. // Vertex buffers
  81540. for (var key in this._vertexBuffers) {
  81541. var vertexBuffer = this._vertexBuffers[key];
  81542. vertexBuffer._rebuild();
  81543. }
  81544. };
  81545. /**
  81546. * Affects all geometry data in one call
  81547. * @param vertexData defines the geometry data
  81548. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81549. */
  81550. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  81551. vertexData.applyToGeometry(this, updatable);
  81552. this.notifyUpdate();
  81553. };
  81554. /**
  81555. * Set specific vertex data
  81556. * @param kind defines the data kind (Position, normal, etc...)
  81557. * @param data defines the vertex data to use
  81558. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81559. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81560. */
  81561. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81562. if (updatable === void 0) { updatable = false; }
  81563. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  81564. this.setVerticesBuffer(buffer);
  81565. };
  81566. /**
  81567. * Removes a specific vertex data
  81568. * @param kind defines the data kind (Position, normal, etc...)
  81569. */
  81570. Geometry.prototype.removeVerticesData = function (kind) {
  81571. if (this._vertexBuffers[kind]) {
  81572. this._vertexBuffers[kind].dispose();
  81573. delete this._vertexBuffers[kind];
  81574. }
  81575. };
  81576. /**
  81577. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81578. * @param buffer defines the vertex buffer to use
  81579. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81580. */
  81581. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  81582. if (totalVertices === void 0) { totalVertices = null; }
  81583. var kind = buffer.getKind();
  81584. if (this._vertexBuffers[kind]) {
  81585. this._vertexBuffers[kind].dispose();
  81586. }
  81587. this._vertexBuffers[kind] = buffer;
  81588. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81589. var data = buffer.getData();
  81590. if (totalVertices != null) {
  81591. this._totalVertices = totalVertices;
  81592. }
  81593. else {
  81594. if (data != null) {
  81595. this._totalVertices = data.length / (buffer.byteStride / 4);
  81596. }
  81597. }
  81598. this._updateExtend(data);
  81599. this._resetPointsArrayCache();
  81600. var meshes = this._meshes;
  81601. var numOfMeshes = meshes.length;
  81602. for (var index = 0; index < numOfMeshes; index++) {
  81603. var mesh = meshes[index];
  81604. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81605. mesh._createGlobalSubMesh(false);
  81606. mesh.computeWorldMatrix(true);
  81607. }
  81608. }
  81609. this.notifyUpdate(kind);
  81610. if (this._vertexArrayObjects) {
  81611. this._disposeVertexArrayObjects();
  81612. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  81613. }
  81614. };
  81615. /**
  81616. * Update a specific vertex buffer
  81617. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81618. * It will do nothing if the buffer is not updatable
  81619. * @param kind defines the data kind (Position, normal, etc...)
  81620. * @param data defines the data to use
  81621. * @param offset defines the offset in the target buffer where to store the data
  81622. * @param useBytes set to true if the offset is in bytes
  81623. */
  81624. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  81625. if (useBytes === void 0) { useBytes = false; }
  81626. var vertexBuffer = this.getVertexBuffer(kind);
  81627. if (!vertexBuffer) {
  81628. return;
  81629. }
  81630. vertexBuffer.updateDirectly(data, offset, useBytes);
  81631. this.notifyUpdate(kind);
  81632. };
  81633. /**
  81634. * Update a specific vertex buffer
  81635. * This function will create a new buffer if the current one is not updatable
  81636. * @param kind defines the data kind (Position, normal, etc...)
  81637. * @param data defines the data to use
  81638. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81639. */
  81640. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  81641. if (updateExtends === void 0) { updateExtends = false; }
  81642. var vertexBuffer = this.getVertexBuffer(kind);
  81643. if (!vertexBuffer) {
  81644. return;
  81645. }
  81646. vertexBuffer.update(data);
  81647. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81648. this._updateBoundingInfo(updateExtends, data);
  81649. }
  81650. this.notifyUpdate(kind);
  81651. };
  81652. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  81653. if (updateExtends) {
  81654. this._updateExtend(data);
  81655. }
  81656. this._resetPointsArrayCache();
  81657. if (updateExtends) {
  81658. var meshes = this._meshes;
  81659. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81660. var mesh = meshes_1[_i];
  81661. if (mesh._boundingInfo) {
  81662. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  81663. }
  81664. else {
  81665. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81666. }
  81667. var subMeshes = mesh.subMeshes;
  81668. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  81669. var subMesh = subMeshes_1[_a];
  81670. subMesh.refreshBoundingInfo();
  81671. }
  81672. }
  81673. }
  81674. };
  81675. /** @hidden */
  81676. Geometry.prototype._bind = function (effect, indexToBind) {
  81677. if (!effect) {
  81678. return;
  81679. }
  81680. if (indexToBind === undefined) {
  81681. indexToBind = this._indexBuffer;
  81682. }
  81683. var vbs = this.getVertexBuffers();
  81684. if (!vbs) {
  81685. return;
  81686. }
  81687. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  81688. this._engine.bindBuffers(vbs, indexToBind, effect);
  81689. return;
  81690. }
  81691. // Using VAO
  81692. if (!this._vertexArrayObjects[effect.key]) {
  81693. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  81694. }
  81695. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  81696. };
  81697. /**
  81698. * Gets total number of vertices
  81699. * @returns the total number of vertices
  81700. */
  81701. Geometry.prototype.getTotalVertices = function () {
  81702. if (!this.isReady()) {
  81703. return 0;
  81704. }
  81705. return this._totalVertices;
  81706. };
  81707. /**
  81708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81709. * @param kind defines the data kind (Position, normal, etc...)
  81710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81712. * @returns a float array containing vertex data
  81713. */
  81714. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  81715. var vertexBuffer = this.getVertexBuffer(kind);
  81716. if (!vertexBuffer) {
  81717. return null;
  81718. }
  81719. var data = vertexBuffer.getData();
  81720. if (!data) {
  81721. return null;
  81722. }
  81723. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  81724. var count = this._totalVertices * vertexBuffer.getSize();
  81725. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  81726. var copy_1 = [];
  81727. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  81728. return copy_1;
  81729. }
  81730. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  81731. if (data instanceof Array) {
  81732. var offset = vertexBuffer.byteOffset / 4;
  81733. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  81734. }
  81735. else if (data instanceof ArrayBuffer) {
  81736. return new Float32Array(data, vertexBuffer.byteOffset, count);
  81737. }
  81738. else {
  81739. var offset = data.byteOffset + vertexBuffer.byteOffset;
  81740. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81741. var result = new Float32Array(count);
  81742. var source = new Float32Array(data.buffer, offset, count);
  81743. result.set(source);
  81744. return result;
  81745. }
  81746. return new Float32Array(data.buffer, offset, count);
  81747. }
  81748. }
  81749. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81750. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  81751. }
  81752. return data;
  81753. };
  81754. /**
  81755. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81756. * @param kind defines the data kind (Position, normal, etc...)
  81757. * @returns true if the vertex buffer with the specified kind is updatable
  81758. */
  81759. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  81760. var vb = this._vertexBuffers[kind];
  81761. if (!vb) {
  81762. return false;
  81763. }
  81764. return vb.isUpdatable();
  81765. };
  81766. /**
  81767. * Gets a specific vertex buffer
  81768. * @param kind defines the data kind (Position, normal, etc...)
  81769. * @returns a VertexBuffer
  81770. */
  81771. Geometry.prototype.getVertexBuffer = function (kind) {
  81772. if (!this.isReady()) {
  81773. return null;
  81774. }
  81775. return this._vertexBuffers[kind];
  81776. };
  81777. /**
  81778. * Returns all vertex buffers
  81779. * @return an object holding all vertex buffers indexed by kind
  81780. */
  81781. Geometry.prototype.getVertexBuffers = function () {
  81782. if (!this.isReady()) {
  81783. return null;
  81784. }
  81785. return this._vertexBuffers;
  81786. };
  81787. /**
  81788. * Gets a boolean indicating if specific vertex buffer is present
  81789. * @param kind defines the data kind (Position, normal, etc...)
  81790. * @returns true if data is present
  81791. */
  81792. Geometry.prototype.isVerticesDataPresent = function (kind) {
  81793. if (!this._vertexBuffers) {
  81794. if (this._delayInfo) {
  81795. return this._delayInfo.indexOf(kind) !== -1;
  81796. }
  81797. return false;
  81798. }
  81799. return this._vertexBuffers[kind] !== undefined;
  81800. };
  81801. /**
  81802. * Gets a list of all attached data kinds (Position, normal, etc...)
  81803. * @returns a list of string containing all kinds
  81804. */
  81805. Geometry.prototype.getVerticesDataKinds = function () {
  81806. var result = [];
  81807. var kind;
  81808. if (!this._vertexBuffers && this._delayInfo) {
  81809. for (kind in this._delayInfo) {
  81810. result.push(kind);
  81811. }
  81812. }
  81813. else {
  81814. for (kind in this._vertexBuffers) {
  81815. result.push(kind);
  81816. }
  81817. }
  81818. return result;
  81819. };
  81820. /**
  81821. * Update index buffer
  81822. * @param indices defines the indices to store in the index buffer
  81823. * @param offset defines the offset in the target buffer where to store the data
  81824. */
  81825. Geometry.prototype.updateIndices = function (indices, offset) {
  81826. if (!this._indexBuffer) {
  81827. return;
  81828. }
  81829. if (!this._indexBufferIsUpdatable) {
  81830. this.setIndices(indices, null, true);
  81831. }
  81832. else {
  81833. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  81834. this._indices = indices;
  81835. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  81836. if (needToUpdateSubMeshes) {
  81837. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81838. var mesh = _a[_i];
  81839. mesh._createGlobalSubMesh(true);
  81840. }
  81841. }
  81842. }
  81843. };
  81844. /**
  81845. * Creates a new index buffer
  81846. * @param indices defines the indices to store in the index buffer
  81847. * @param totalVertices defines the total number of vertices (could be null)
  81848. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81849. */
  81850. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  81851. if (totalVertices === void 0) { totalVertices = null; }
  81852. if (updatable === void 0) { updatable = false; }
  81853. if (this._indexBuffer) {
  81854. this._engine._releaseBuffer(this._indexBuffer);
  81855. }
  81856. this._disposeVertexArrayObjects();
  81857. this._indices = indices;
  81858. this._indexBufferIsUpdatable = updatable;
  81859. if (this._meshes.length !== 0 && this._indices) {
  81860. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  81861. }
  81862. if (totalVertices != undefined) { // including null and undefined
  81863. this._totalVertices = totalVertices;
  81864. }
  81865. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81866. var mesh = _a[_i];
  81867. mesh._createGlobalSubMesh(true);
  81868. }
  81869. this.notifyUpdate();
  81870. };
  81871. /**
  81872. * Return the total number of indices
  81873. * @returns the total number of indices
  81874. */
  81875. Geometry.prototype.getTotalIndices = function () {
  81876. if (!this.isReady()) {
  81877. return 0;
  81878. }
  81879. return this._indices.length;
  81880. };
  81881. /**
  81882. * Gets the index buffer array
  81883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81885. * @returns the index buffer array
  81886. */
  81887. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  81888. if (!this.isReady()) {
  81889. return null;
  81890. }
  81891. var orig = this._indices;
  81892. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  81893. return orig;
  81894. }
  81895. else {
  81896. var len = orig.length;
  81897. var copy = [];
  81898. for (var i = 0; i < len; i++) {
  81899. copy.push(orig[i]);
  81900. }
  81901. return copy;
  81902. }
  81903. };
  81904. /**
  81905. * Gets the index buffer
  81906. * @return the index buffer
  81907. */
  81908. Geometry.prototype.getIndexBuffer = function () {
  81909. if (!this.isReady()) {
  81910. return null;
  81911. }
  81912. return this._indexBuffer;
  81913. };
  81914. /** @hidden */
  81915. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  81916. if (effect === void 0) { effect = null; }
  81917. if (!effect || !this._vertexArrayObjects) {
  81918. return;
  81919. }
  81920. if (this._vertexArrayObjects[effect.key]) {
  81921. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  81922. delete this._vertexArrayObjects[effect.key];
  81923. }
  81924. };
  81925. /**
  81926. * Release the associated resources for a specific mesh
  81927. * @param mesh defines the source mesh
  81928. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81929. */
  81930. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  81931. var meshes = this._meshes;
  81932. var index = meshes.indexOf(mesh);
  81933. if (index === -1) {
  81934. return;
  81935. }
  81936. meshes.splice(index, 1);
  81937. mesh._geometry = null;
  81938. if (meshes.length === 0 && shouldDispose) {
  81939. this.dispose();
  81940. }
  81941. };
  81942. /**
  81943. * Apply current geometry to a given mesh
  81944. * @param mesh defines the mesh to apply geometry to
  81945. */
  81946. Geometry.prototype.applyToMesh = function (mesh) {
  81947. if (mesh._geometry === this) {
  81948. return;
  81949. }
  81950. var previousGeometry = mesh._geometry;
  81951. if (previousGeometry) {
  81952. previousGeometry.releaseForMesh(mesh);
  81953. }
  81954. var meshes = this._meshes;
  81955. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  81956. mesh._geometry = this;
  81957. this._scene.pushGeometry(this);
  81958. meshes.push(mesh);
  81959. if (this.isReady()) {
  81960. this._applyToMesh(mesh);
  81961. }
  81962. else {
  81963. mesh._boundingInfo = this._boundingInfo;
  81964. }
  81965. };
  81966. Geometry.prototype._updateExtend = function (data) {
  81967. if (data === void 0) { data = null; }
  81968. if (!data) {
  81969. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  81970. }
  81971. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  81972. };
  81973. Geometry.prototype._applyToMesh = function (mesh) {
  81974. var numOfMeshes = this._meshes.length;
  81975. // vertexBuffers
  81976. for (var kind in this._vertexBuffers) {
  81977. if (numOfMeshes === 1) {
  81978. this._vertexBuffers[kind].create();
  81979. }
  81980. var buffer = this._vertexBuffers[kind].getBuffer();
  81981. if (buffer) {
  81982. buffer.references = numOfMeshes;
  81983. }
  81984. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81985. if (!this._extend) {
  81986. this._updateExtend();
  81987. }
  81988. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81989. mesh._createGlobalSubMesh(false);
  81990. //bounding info was just created again, world matrix should be applied again.
  81991. mesh._updateBoundingInfo();
  81992. }
  81993. }
  81994. // indexBuffer
  81995. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  81996. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81997. }
  81998. if (this._indexBuffer) {
  81999. this._indexBuffer.references = numOfMeshes;
  82000. }
  82001. // morphTargets
  82002. mesh._syncGeometryWithMorphTargetManager();
  82003. // instances
  82004. mesh.synchronizeInstances();
  82005. };
  82006. Geometry.prototype.notifyUpdate = function (kind) {
  82007. if (this.onGeometryUpdated) {
  82008. this.onGeometryUpdated(this, kind);
  82009. }
  82010. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82011. var mesh = _a[_i];
  82012. mesh._markSubMeshesAsAttributesDirty();
  82013. }
  82014. };
  82015. /**
  82016. * Load the geometry if it was flagged as delay loaded
  82017. * @param scene defines the hosting scene
  82018. * @param onLoaded defines a callback called when the geometry is loaded
  82019. */
  82020. Geometry.prototype.load = function (scene, onLoaded) {
  82021. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  82022. return;
  82023. }
  82024. if (this.isReady()) {
  82025. if (onLoaded) {
  82026. onLoaded();
  82027. }
  82028. return;
  82029. }
  82030. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  82031. this._queueLoad(scene, onLoaded);
  82032. };
  82033. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  82034. var _this = this;
  82035. if (!this.delayLoadingFile) {
  82036. return;
  82037. }
  82038. scene._addPendingData(this);
  82039. scene._loadFile(this.delayLoadingFile, function (data) {
  82040. if (!_this._delayLoadingFunction) {
  82041. return;
  82042. }
  82043. _this._delayLoadingFunction(JSON.parse(data), _this);
  82044. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  82045. _this._delayInfo = [];
  82046. scene._removePendingData(_this);
  82047. var meshes = _this._meshes;
  82048. var numOfMeshes = meshes.length;
  82049. for (var index = 0; index < numOfMeshes; index++) {
  82050. _this._applyToMesh(meshes[index]);
  82051. }
  82052. if (onLoaded) {
  82053. onLoaded();
  82054. }
  82055. }, undefined, true);
  82056. };
  82057. /**
  82058. * Invert the geometry to move from a right handed system to a left handed one.
  82059. */
  82060. Geometry.prototype.toLeftHanded = function () {
  82061. // Flip faces
  82062. var tIndices = this.getIndices(false);
  82063. if (tIndices != null && tIndices.length > 0) {
  82064. for (var i = 0; i < tIndices.length; i += 3) {
  82065. var tTemp = tIndices[i + 0];
  82066. tIndices[i + 0] = tIndices[i + 2];
  82067. tIndices[i + 2] = tTemp;
  82068. }
  82069. this.setIndices(tIndices);
  82070. }
  82071. // Negate position.z
  82072. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  82073. if (tPositions != null && tPositions.length > 0) {
  82074. for (var i = 0; i < tPositions.length; i += 3) {
  82075. tPositions[i + 2] = -tPositions[i + 2];
  82076. }
  82077. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  82078. }
  82079. // Negate normal.z
  82080. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  82081. if (tNormals != null && tNormals.length > 0) {
  82082. for (var i = 0; i < tNormals.length; i += 3) {
  82083. tNormals[i + 2] = -tNormals[i + 2];
  82084. }
  82085. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  82086. }
  82087. };
  82088. // Cache
  82089. /** @hidden */
  82090. Geometry.prototype._resetPointsArrayCache = function () {
  82091. this._positions = null;
  82092. };
  82093. /** @hidden */
  82094. Geometry.prototype._generatePointsArray = function () {
  82095. if (this._positions) {
  82096. return true;
  82097. }
  82098. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82099. if (!data || data.length === 0) {
  82100. return false;
  82101. }
  82102. this._positions = [];
  82103. for (var index = 0; index < data.length; index += 3) {
  82104. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  82105. }
  82106. return true;
  82107. };
  82108. /**
  82109. * Gets a value indicating if the geometry is disposed
  82110. * @returns true if the geometry was disposed
  82111. */
  82112. Geometry.prototype.isDisposed = function () {
  82113. return this._isDisposed;
  82114. };
  82115. Geometry.prototype._disposeVertexArrayObjects = function () {
  82116. if (this._vertexArrayObjects) {
  82117. for (var kind in this._vertexArrayObjects) {
  82118. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  82119. }
  82120. this._vertexArrayObjects = {};
  82121. }
  82122. };
  82123. /**
  82124. * Free all associated resources
  82125. */
  82126. Geometry.prototype.dispose = function () {
  82127. var meshes = this._meshes;
  82128. var numOfMeshes = meshes.length;
  82129. var index;
  82130. for (index = 0; index < numOfMeshes; index++) {
  82131. this.releaseForMesh(meshes[index]);
  82132. }
  82133. this._meshes = [];
  82134. this._disposeVertexArrayObjects();
  82135. for (var kind in this._vertexBuffers) {
  82136. this._vertexBuffers[kind].dispose();
  82137. }
  82138. this._vertexBuffers = {};
  82139. this._totalVertices = 0;
  82140. if (this._indexBuffer) {
  82141. this._engine._releaseBuffer(this._indexBuffer);
  82142. }
  82143. this._indexBuffer = null;
  82144. this._indices = [];
  82145. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82146. this.delayLoadingFile = null;
  82147. this._delayLoadingFunction = null;
  82148. this._delayInfo = [];
  82149. this._boundingInfo = null;
  82150. this._scene.removeGeometry(this);
  82151. this._isDisposed = true;
  82152. };
  82153. /**
  82154. * Clone the current geometry into a new geometry
  82155. * @param id defines the unique ID of the new geometry
  82156. * @returns a new geometry object
  82157. */
  82158. Geometry.prototype.copy = function (id) {
  82159. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  82160. vertexData.indices = [];
  82161. var indices = this.getIndices();
  82162. if (indices) {
  82163. for (var index = 0; index < indices.length; index++) {
  82164. vertexData.indices.push(indices[index]);
  82165. }
  82166. }
  82167. var updatable = false;
  82168. var stopChecking = false;
  82169. var kind;
  82170. for (kind in this._vertexBuffers) {
  82171. // using slice() to make a copy of the array and not just reference it
  82172. var data = this.getVerticesData(kind);
  82173. if (data) {
  82174. if (data instanceof Float32Array) {
  82175. vertexData.set(new Float32Array(data), kind);
  82176. }
  82177. else {
  82178. vertexData.set(data.slice(0), kind);
  82179. }
  82180. if (!stopChecking) {
  82181. var vb = this.getVertexBuffer(kind);
  82182. if (vb) {
  82183. updatable = vb.isUpdatable();
  82184. stopChecking = !updatable;
  82185. }
  82186. }
  82187. }
  82188. }
  82189. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82190. geometry.delayLoadState = this.delayLoadState;
  82191. geometry.delayLoadingFile = this.delayLoadingFile;
  82192. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82193. for (kind in this._delayInfo) {
  82194. geometry._delayInfo = geometry._delayInfo || [];
  82195. geometry._delayInfo.push(kind);
  82196. }
  82197. // Bounding info
  82198. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82199. return geometry;
  82200. };
  82201. /**
  82202. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82203. * @return a JSON representation of the current geometry data (without the vertices data)
  82204. */
  82205. Geometry.prototype.serialize = function () {
  82206. var serializationObject = {};
  82207. serializationObject.id = this.id;
  82208. serializationObject.updatable = this._updatable;
  82209. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82210. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82211. }
  82212. return serializationObject;
  82213. };
  82214. Geometry.prototype.toNumberArray = function (origin) {
  82215. if (Array.isArray(origin)) {
  82216. return origin;
  82217. }
  82218. else {
  82219. return Array.prototype.slice.call(origin);
  82220. }
  82221. };
  82222. /**
  82223. * Serialize all vertices data into a JSON oject
  82224. * @returns a JSON representation of the current geometry data
  82225. */
  82226. Geometry.prototype.serializeVerticeData = function () {
  82227. var serializationObject = this.serialize();
  82228. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82229. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82230. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82231. serializationObject.positions._updatable = true;
  82232. }
  82233. }
  82234. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82235. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82236. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82237. serializationObject.normals._updatable = true;
  82238. }
  82239. }
  82240. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82241. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82242. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82243. serializationObject.tangets._updatable = true;
  82244. }
  82245. }
  82246. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82247. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82248. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82249. serializationObject.uvs._updatable = true;
  82250. }
  82251. }
  82252. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82253. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82254. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82255. serializationObject.uv2s._updatable = true;
  82256. }
  82257. }
  82258. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82259. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82260. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82261. serializationObject.uv3s._updatable = true;
  82262. }
  82263. }
  82264. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82265. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82266. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82267. serializationObject.uv4s._updatable = true;
  82268. }
  82269. }
  82270. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82271. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82272. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82273. serializationObject.uv5s._updatable = true;
  82274. }
  82275. }
  82276. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82277. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82278. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82279. serializationObject.uv6s._updatable = true;
  82280. }
  82281. }
  82282. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82283. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82284. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82285. serializationObject.colors._updatable = true;
  82286. }
  82287. }
  82288. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82289. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82290. serializationObject.matricesIndices._isExpanded = true;
  82291. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82292. serializationObject.matricesIndices._updatable = true;
  82293. }
  82294. }
  82295. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82296. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82297. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82298. serializationObject.matricesWeights._updatable = true;
  82299. }
  82300. }
  82301. serializationObject.indices = this.toNumberArray(this.getIndices());
  82302. return serializationObject;
  82303. };
  82304. // Statics
  82305. /**
  82306. * Extracts a clone of a mesh geometry
  82307. * @param mesh defines the source mesh
  82308. * @param id defines the unique ID of the new geometry object
  82309. * @returns the new geometry object
  82310. */
  82311. Geometry.ExtractFromMesh = function (mesh, id) {
  82312. var geometry = mesh._geometry;
  82313. if (!geometry) {
  82314. return null;
  82315. }
  82316. return geometry.copy(id);
  82317. };
  82318. /**
  82319. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82320. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82321. * Be aware Math.random() could cause collisions, but:
  82322. * "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"
  82323. * @returns a string containing a new GUID
  82324. */
  82325. Geometry.RandomId = function () {
  82326. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82327. };
  82328. /** @hidden */
  82329. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82330. var scene = mesh.getScene();
  82331. // Geometry
  82332. var geometryId = parsedGeometry.geometryId;
  82333. if (geometryId) {
  82334. var geometry = scene.getGeometryByID(geometryId);
  82335. if (geometry) {
  82336. geometry.applyToMesh(mesh);
  82337. }
  82338. }
  82339. else if (parsedGeometry instanceof ArrayBuffer) {
  82340. var binaryInfo = mesh._binaryInfo;
  82341. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82342. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82343. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82344. }
  82345. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82346. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82347. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82348. }
  82349. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82350. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82351. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82352. }
  82353. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82354. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82355. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82356. }
  82357. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82358. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82359. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82360. }
  82361. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82362. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82363. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82364. }
  82365. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82366. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82367. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82368. }
  82369. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82370. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82371. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82372. }
  82373. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82374. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82375. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82376. }
  82377. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82378. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82379. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82380. }
  82381. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82382. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82383. var floatIndices = [];
  82384. for (var i = 0; i < matricesIndicesData.length; i++) {
  82385. var index = matricesIndicesData[i];
  82386. floatIndices.push(index & 0x000000FF);
  82387. floatIndices.push((index & 0x0000FF00) >> 8);
  82388. floatIndices.push((index & 0x00FF0000) >> 16);
  82389. floatIndices.push(index >> 24);
  82390. }
  82391. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82392. }
  82393. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82394. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82395. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82396. }
  82397. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82398. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82399. mesh.setIndices(indicesData, null);
  82400. }
  82401. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82402. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82403. mesh.subMeshes = [];
  82404. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  82405. var materialIndex = subMeshesData[(i * 5) + 0];
  82406. var verticesStart = subMeshesData[(i * 5) + 1];
  82407. var verticesCount = subMeshesData[(i * 5) + 2];
  82408. var indexStart = subMeshesData[(i * 5) + 3];
  82409. var indexCount = subMeshesData[(i * 5) + 4];
  82410. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  82411. }
  82412. }
  82413. }
  82414. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  82415. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  82416. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  82417. if (parsedGeometry.tangents) {
  82418. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  82419. }
  82420. if (parsedGeometry.uvs) {
  82421. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  82422. }
  82423. if (parsedGeometry.uvs2) {
  82424. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  82425. }
  82426. if (parsedGeometry.uvs3) {
  82427. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  82428. }
  82429. if (parsedGeometry.uvs4) {
  82430. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  82431. }
  82432. if (parsedGeometry.uvs5) {
  82433. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  82434. }
  82435. if (parsedGeometry.uvs6) {
  82436. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  82437. }
  82438. if (parsedGeometry.colors) {
  82439. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  82440. }
  82441. if (parsedGeometry.matricesIndices) {
  82442. if (!parsedGeometry.matricesIndices._isExpanded) {
  82443. var floatIndices = [];
  82444. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  82445. var matricesIndex = parsedGeometry.matricesIndices[i];
  82446. floatIndices.push(matricesIndex & 0x000000FF);
  82447. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82448. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82449. floatIndices.push(matricesIndex >> 24);
  82450. }
  82451. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  82452. }
  82453. else {
  82454. delete parsedGeometry.matricesIndices._isExpanded;
  82455. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  82456. }
  82457. }
  82458. if (parsedGeometry.matricesIndicesExtra) {
  82459. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  82460. var floatIndices = [];
  82461. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  82462. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  82463. floatIndices.push(matricesIndex & 0x000000FF);
  82464. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82465. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82466. floatIndices.push(matricesIndex >> 24);
  82467. }
  82468. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  82469. }
  82470. else {
  82471. delete parsedGeometry.matricesIndices._isExpanded;
  82472. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  82473. }
  82474. }
  82475. if (parsedGeometry.matricesWeights) {
  82476. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  82477. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  82478. }
  82479. if (parsedGeometry.matricesWeightsExtra) {
  82480. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  82481. }
  82482. mesh.setIndices(parsedGeometry.indices, null);
  82483. }
  82484. // SubMeshes
  82485. if (parsedGeometry.subMeshes) {
  82486. mesh.subMeshes = [];
  82487. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  82488. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  82489. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  82490. }
  82491. }
  82492. // Flat shading
  82493. if (mesh._shouldGenerateFlatShading) {
  82494. mesh.convertToFlatShadedMesh();
  82495. delete mesh._shouldGenerateFlatShading;
  82496. }
  82497. // Update
  82498. mesh.computeWorldMatrix(true);
  82499. scene.onMeshImportedObservable.notifyObservers(mesh);
  82500. };
  82501. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  82502. var epsilon = 1e-3;
  82503. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  82504. return;
  82505. }
  82506. var noInfluenceBoneIndex = 0.0;
  82507. if (parsedGeometry.skeletonId > -1) {
  82508. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  82509. if (!skeleton) {
  82510. return;
  82511. }
  82512. noInfluenceBoneIndex = skeleton.bones.length;
  82513. }
  82514. else {
  82515. return;
  82516. }
  82517. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82518. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  82519. var matricesWeights = parsedGeometry.matricesWeights;
  82520. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  82521. var influencers = parsedGeometry.numBoneInfluencer;
  82522. var size = matricesWeights.length;
  82523. for (var i = 0; i < size; i += 4) {
  82524. var weight = 0.0;
  82525. var firstZeroWeight = -1;
  82526. for (var j = 0; j < 4; j++) {
  82527. var w = matricesWeights[i + j];
  82528. weight += w;
  82529. if (w < epsilon && firstZeroWeight < 0) {
  82530. firstZeroWeight = j;
  82531. }
  82532. }
  82533. if (matricesWeightsExtra) {
  82534. for (var j = 0; j < 4; j++) {
  82535. var w = matricesWeightsExtra[i + j];
  82536. weight += w;
  82537. if (w < epsilon && firstZeroWeight < 0) {
  82538. firstZeroWeight = j + 4;
  82539. }
  82540. }
  82541. }
  82542. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  82543. firstZeroWeight = influencers - 1;
  82544. }
  82545. if (weight > epsilon) {
  82546. var mweight = 1.0 / weight;
  82547. for (var j = 0; j < 4; j++) {
  82548. matricesWeights[i + j] *= mweight;
  82549. }
  82550. if (matricesWeightsExtra) {
  82551. for (var j = 0; j < 4; j++) {
  82552. matricesWeightsExtra[i + j] *= mweight;
  82553. }
  82554. }
  82555. }
  82556. else {
  82557. if (firstZeroWeight >= 4) {
  82558. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  82559. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  82560. }
  82561. else {
  82562. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  82563. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  82564. }
  82565. }
  82566. }
  82567. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  82568. if (parsedGeometry.matricesWeightsExtra) {
  82569. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  82570. }
  82571. };
  82572. /**
  82573. * Create a new geometry from persisted data (Using .babylon file format)
  82574. * @param parsedVertexData defines the persisted data
  82575. * @param scene defines the hosting scene
  82576. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82577. * @returns the new geometry object
  82578. */
  82579. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  82580. if (scene.getGeometryByID(parsedVertexData.id)) {
  82581. return null; // null since geometry could be something else than a box...
  82582. }
  82583. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  82584. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  82585. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  82586. }
  82587. if (parsedVertexData.delayLoadingFile) {
  82588. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82589. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  82590. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  82591. geometry._delayInfo = [];
  82592. if (parsedVertexData.hasUVs) {
  82593. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82594. }
  82595. if (parsedVertexData.hasUVs2) {
  82596. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  82597. }
  82598. if (parsedVertexData.hasUVs3) {
  82599. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  82600. }
  82601. if (parsedVertexData.hasUVs4) {
  82602. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  82603. }
  82604. if (parsedVertexData.hasUVs5) {
  82605. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  82606. }
  82607. if (parsedVertexData.hasUVs6) {
  82608. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  82609. }
  82610. if (parsedVertexData.hasColors) {
  82611. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82612. }
  82613. if (parsedVertexData.hasMatricesIndices) {
  82614. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82615. }
  82616. if (parsedVertexData.hasMatricesWeights) {
  82617. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  82618. }
  82619. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  82620. }
  82621. else {
  82622. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  82623. }
  82624. scene.pushGeometry(geometry, true);
  82625. return geometry;
  82626. };
  82627. return Geometry;
  82628. }());
  82629. /***/ }),
  82630. /***/ "./Meshes/groundMesh.ts":
  82631. /*!******************************!*\
  82632. !*** ./Meshes/groundMesh.ts ***!
  82633. \******************************/
  82634. /*! exports provided: GroundMesh */
  82635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82636. "use strict";
  82637. __webpack_require__.r(__webpack_exports__);
  82638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  82639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82640. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82641. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82642. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82643. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  82644. return GroundMesh.Parse(parsedMesh, scene);
  82645. };
  82646. /**
  82647. * Mesh representing the gorund
  82648. */
  82649. var GroundMesh = /** @class */ (function (_super) {
  82650. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  82651. function GroundMesh(name, scene) {
  82652. var _this = _super.call(this, name, scene) || this;
  82653. /** If octree should be generated */
  82654. _this.generateOctree = false;
  82655. return _this;
  82656. }
  82657. /**
  82658. * "GroundMesh"
  82659. * @returns "GroundMesh"
  82660. */
  82661. GroundMesh.prototype.getClassName = function () {
  82662. return "GroundMesh";
  82663. };
  82664. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  82665. /**
  82666. * The minimum of x and y subdivisions
  82667. */
  82668. get: function () {
  82669. return Math.min(this._subdivisionsX, this._subdivisionsY);
  82670. },
  82671. enumerable: true,
  82672. configurable: true
  82673. });
  82674. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  82675. /**
  82676. * X subdivisions
  82677. */
  82678. get: function () {
  82679. return this._subdivisionsX;
  82680. },
  82681. enumerable: true,
  82682. configurable: true
  82683. });
  82684. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  82685. /**
  82686. * Y subdivisions
  82687. */
  82688. get: function () {
  82689. return this._subdivisionsY;
  82690. },
  82691. enumerable: true,
  82692. configurable: true
  82693. });
  82694. /**
  82695. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82696. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82697. * @param chunksCount the number of subdivisions for x and y
  82698. * @param octreeBlocksSize (Default: 32)
  82699. */
  82700. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  82701. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  82702. this._subdivisionsX = chunksCount;
  82703. this._subdivisionsY = chunksCount;
  82704. this.subdivide(chunksCount);
  82705. // Call the octree system optimization if it is defined.
  82706. var thisAsAny = this;
  82707. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  82708. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  82709. }
  82710. };
  82711. /**
  82712. * Returns a height (y) value in the Worl system :
  82713. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82714. * @param x x coordinate
  82715. * @param z z coordinate
  82716. * @returns the ground y position if (x, z) are outside the ground surface.
  82717. */
  82718. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  82719. var world = this.getWorldMatrix();
  82720. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82721. world.invertToRef(invMat);
  82722. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82723. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  82724. x = tmpVect.x;
  82725. z = tmpVect.z;
  82726. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82727. return this.position.y;
  82728. }
  82729. if (!this._heightQuads || this._heightQuads.length == 0) {
  82730. this._initHeightQuads();
  82731. this._computeHeightQuads();
  82732. }
  82733. var facet = this._getFacetAt(x, z);
  82734. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  82735. // return y in the World system
  82736. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  82737. return tmpVect.y;
  82738. };
  82739. /**
  82740. * Returns a normalized vector (Vector3) orthogonal to the ground
  82741. * at the ground coordinates (x, z) expressed in the World system.
  82742. * @param x x coordinate
  82743. * @param z z coordinate
  82744. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82745. */
  82746. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  82747. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  82748. this.getNormalAtCoordinatesToRef(x, z, normal);
  82749. return normal;
  82750. };
  82751. /**
  82752. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82753. * at the ground coordinates (x, z) expressed in the World system.
  82754. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82755. * @param x x coordinate
  82756. * @param z z coordinate
  82757. * @param ref vector to store the result
  82758. * @returns the GroundMesh.
  82759. */
  82760. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  82761. var world = this.getWorldMatrix();
  82762. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82763. world.invertToRef(tmpMat);
  82764. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82765. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  82766. x = tmpVect.x;
  82767. z = tmpVect.z;
  82768. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82769. return this;
  82770. }
  82771. if (!this._heightQuads || this._heightQuads.length == 0) {
  82772. this._initHeightQuads();
  82773. this._computeHeightQuads();
  82774. }
  82775. var facet = this._getFacetAt(x, z);
  82776. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  82777. return this;
  82778. };
  82779. /**
  82780. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82781. * if the ground has been updated.
  82782. * This can be used in the render loop.
  82783. * @returns the GroundMesh.
  82784. */
  82785. GroundMesh.prototype.updateCoordinateHeights = function () {
  82786. if (!this._heightQuads || this._heightQuads.length == 0) {
  82787. this._initHeightQuads();
  82788. }
  82789. this._computeHeightQuads();
  82790. return this;
  82791. };
  82792. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  82793. GroundMesh.prototype._getFacetAt = function (x, z) {
  82794. // retrieve col and row from x, z coordinates in the ground local system
  82795. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  82796. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  82797. var quad = this._heightQuads[row * this._subdivisionsX + col];
  82798. var facet;
  82799. if (z < quad.slope.x * x + quad.slope.y) {
  82800. facet = quad.facet1;
  82801. }
  82802. else {
  82803. facet = quad.facet2;
  82804. }
  82805. return facet;
  82806. };
  82807. // Creates and populates the heightMap array with "facet" elements :
  82808. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  82809. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82810. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82811. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82812. // Returns the GroundMesh.
  82813. GroundMesh.prototype._initHeightQuads = function () {
  82814. var subdivisionsX = this._subdivisionsX;
  82815. var subdivisionsY = this._subdivisionsY;
  82816. this._heightQuads = new Array();
  82817. for (var row = 0; row < subdivisionsY; row++) {
  82818. for (var col = 0; col < subdivisionsX; col++) {
  82819. var quad = { slope: _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), facet1: new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0), facet2: new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0) };
  82820. this._heightQuads[row * subdivisionsX + col] = quad;
  82821. }
  82822. }
  82823. return this;
  82824. };
  82825. // Compute each quad element values and update the the heightMap array :
  82826. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82827. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82828. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82829. // Returns the GroundMesh.
  82830. GroundMesh.prototype._computeHeightQuads = function () {
  82831. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82832. if (!positions) {
  82833. return this;
  82834. }
  82835. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  82836. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  82837. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  82838. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  82839. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  82840. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  82841. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  82842. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  82843. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82844. var i = 0;
  82845. var j = 0;
  82846. var k = 0;
  82847. var cd = 0; // 2D slope coefficient : z = cd * x + h
  82848. var h = 0;
  82849. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  82850. var d2 = 0;
  82851. var subdivisionsX = this._subdivisionsX;
  82852. var subdivisionsY = this._subdivisionsY;
  82853. for (var row = 0; row < subdivisionsY; row++) {
  82854. for (var col = 0; col < subdivisionsX; col++) {
  82855. i = col * 3;
  82856. j = row * (subdivisionsX + 1) * 3;
  82857. k = (row + 1) * (subdivisionsX + 1) * 3;
  82858. v1.x = positions[j + i];
  82859. v1.y = positions[j + i + 1];
  82860. v1.z = positions[j + i + 2];
  82861. v2.x = positions[j + i + 3];
  82862. v2.y = positions[j + i + 4];
  82863. v2.z = positions[j + i + 5];
  82864. v3.x = positions[k + i];
  82865. v3.y = positions[k + i + 1];
  82866. v3.z = positions[k + i + 2];
  82867. v4.x = positions[k + i + 3];
  82868. v4.y = positions[k + i + 4];
  82869. v4.z = positions[k + i + 5];
  82870. // 2D slope V1V4
  82871. cd = (v4.z - v1.z) / (v4.x - v1.x);
  82872. h = v1.z - cd * v1.x; // v1 belongs to the slope
  82873. // facet equations :
  82874. // we compute each facet normal vector
  82875. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  82876. // we compute the value d by applying the equation to v1 which belongs to the plane
  82877. // then we store the facet equation in a Vector4
  82878. v2.subtractToRef(v1, v1v2);
  82879. v3.subtractToRef(v1, v1v3);
  82880. v4.subtractToRef(v1, v1v4);
  82881. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  82882. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  82883. norm1.normalize();
  82884. norm2.normalize();
  82885. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  82886. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  82887. var quad = this._heightQuads[row * subdivisionsX + col];
  82888. quad.slope.copyFromFloats(cd, h);
  82889. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  82890. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  82891. }
  82892. }
  82893. return this;
  82894. };
  82895. /**
  82896. * Serializes this ground mesh
  82897. * @param serializationObject object to write serialization to
  82898. */
  82899. GroundMesh.prototype.serialize = function (serializationObject) {
  82900. _super.prototype.serialize.call(this, serializationObject);
  82901. serializationObject.subdivisionsX = this._subdivisionsX;
  82902. serializationObject.subdivisionsY = this._subdivisionsY;
  82903. serializationObject.minX = this._minX;
  82904. serializationObject.maxX = this._maxX;
  82905. serializationObject.minZ = this._minZ;
  82906. serializationObject.maxZ = this._maxZ;
  82907. serializationObject.width = this._width;
  82908. serializationObject.height = this._height;
  82909. };
  82910. /**
  82911. * Parses a serialized ground mesh
  82912. * @param parsedMesh the serialized mesh
  82913. * @param scene the scene to create the ground mesh in
  82914. * @returns the created ground mesh
  82915. */
  82916. GroundMesh.Parse = function (parsedMesh, scene) {
  82917. var result = new GroundMesh(parsedMesh.name, scene);
  82918. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  82919. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  82920. result._minX = parsedMesh.minX;
  82921. result._maxX = parsedMesh.maxX;
  82922. result._minZ = parsedMesh.minZ;
  82923. result._maxZ = parsedMesh.maxZ;
  82924. result._width = parsedMesh.width;
  82925. result._height = parsedMesh.height;
  82926. return result;
  82927. };
  82928. return GroundMesh;
  82929. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  82930. /***/ }),
  82931. /***/ "./Meshes/index.ts":
  82932. /*!*************************!*\
  82933. !*** ./Meshes/index.ts ***!
  82934. \*************************/
  82935. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  82936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82937. "use strict";
  82938. __webpack_require__.r(__webpack_exports__);
  82939. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  82940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  82941. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  82942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  82943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  82944. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  82945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  82946. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  82947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  82948. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  82949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  82950. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  82951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  82952. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  82953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  82954. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  82955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  82956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  82957. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  82958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  82959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  82960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  82961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  82962. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  82964. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  82965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  82966. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  82967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  82968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  82969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  82970. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  82971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  82972. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  82973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  82974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  82975. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  82976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  82977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  82978. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  82979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  82980. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  82981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["BoxBuilder"]; });
  82982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["SphereBuilder"]; });
  82983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["CylinderBuilder"]; });
  82984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LinesBuilder"]; });
  82985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PlaneBuilder"]; });
  82986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DiscBuilder"]; });
  82987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["RibbonBuilder"]; });
  82988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusBuilder"]; });
  82989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusKnotBuilder"]; });
  82990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolygonBuilder"]; });
  82991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["ShapeBuilder"]; });
  82992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LatheBuilder"]; });
  82993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["GroundBuilder"]; });
  82994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  82995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"]; });
  82996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  82997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  82998. /***/ }),
  82999. /***/ "./Meshes/instancedMesh.ts":
  83000. /*!*********************************!*\
  83001. !*** ./Meshes/instancedMesh.ts ***!
  83002. \*********************************/
  83003. /*! exports provided: InstancedMesh */
  83004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83005. "use strict";
  83006. __webpack_require__.r(__webpack_exports__);
  83007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  83008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83009. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83010. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  83011. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83012. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83013. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  83014. return new InstancedMesh(name, mesh);
  83015. };
  83016. /**
  83017. * Creates an instance based on a source mesh.
  83018. */
  83019. var InstancedMesh = /** @class */ (function (_super) {
  83020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  83021. function InstancedMesh(name, source) {
  83022. var _this = _super.call(this, name, source.getScene()) || this;
  83023. /** @hidden */
  83024. _this._indexInSourceMeshInstanceArray = -1;
  83025. source.addInstance(_this);
  83026. _this._sourceMesh = source;
  83027. _this.position.copyFrom(source.position);
  83028. _this.rotation.copyFrom(source.rotation);
  83029. _this.scaling.copyFrom(source.scaling);
  83030. if (source.rotationQuaternion) {
  83031. _this.rotationQuaternion = source.rotationQuaternion.clone();
  83032. }
  83033. _this.infiniteDistance = source.infiniteDistance;
  83034. _this.setPivotMatrix(source.getPivotMatrix());
  83035. _this.refreshBoundingInfo();
  83036. _this._syncSubMeshes();
  83037. return _this;
  83038. }
  83039. /**
  83040. * Returns the string "InstancedMesh".
  83041. */
  83042. InstancedMesh.prototype.getClassName = function () {
  83043. return "InstancedMesh";
  83044. };
  83045. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  83046. // Methods
  83047. /**
  83048. * If the source mesh receives shadows
  83049. */
  83050. get: function () {
  83051. return this._sourceMesh.receiveShadows;
  83052. },
  83053. enumerable: true,
  83054. configurable: true
  83055. });
  83056. Object.defineProperty(InstancedMesh.prototype, "material", {
  83057. /**
  83058. * The material of the source mesh
  83059. */
  83060. get: function () {
  83061. return this._sourceMesh.material;
  83062. },
  83063. enumerable: true,
  83064. configurable: true
  83065. });
  83066. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  83067. /**
  83068. * Visibility of the source mesh
  83069. */
  83070. get: function () {
  83071. return this._sourceMesh.visibility;
  83072. },
  83073. enumerable: true,
  83074. configurable: true
  83075. });
  83076. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  83077. /**
  83078. * Skeleton of the source mesh
  83079. */
  83080. get: function () {
  83081. return this._sourceMesh.skeleton;
  83082. },
  83083. enumerable: true,
  83084. configurable: true
  83085. });
  83086. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  83087. /**
  83088. * Rendering ground id of the source mesh
  83089. */
  83090. get: function () {
  83091. return this._sourceMesh.renderingGroupId;
  83092. },
  83093. set: function (value) {
  83094. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  83095. return;
  83096. }
  83097. //no-op with warning
  83098. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  83099. },
  83100. enumerable: true,
  83101. configurable: true
  83102. });
  83103. /**
  83104. * Returns the total number of vertices (integer).
  83105. */
  83106. InstancedMesh.prototype.getTotalVertices = function () {
  83107. return this._sourceMesh.getTotalVertices();
  83108. };
  83109. /**
  83110. * Returns a positive integer : the total number of indices in this mesh geometry.
  83111. * @returns the numner of indices or zero if the mesh has no geometry.
  83112. */
  83113. InstancedMesh.prototype.getTotalIndices = function () {
  83114. return this._sourceMesh.getTotalIndices();
  83115. };
  83116. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  83117. /**
  83118. * The source mesh of the instance
  83119. */
  83120. get: function () {
  83121. return this._sourceMesh;
  83122. },
  83123. enumerable: true,
  83124. configurable: true
  83125. });
  83126. /**
  83127. * Is this node ready to be used/rendered
  83128. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83129. * @return {boolean} is it ready
  83130. */
  83131. InstancedMesh.prototype.isReady = function (completeCheck) {
  83132. if (completeCheck === void 0) { completeCheck = false; }
  83133. return this._sourceMesh.isReady(completeCheck, true);
  83134. };
  83135. /**
  83136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83137. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83138. * @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.
  83139. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83140. */
  83141. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  83142. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  83143. };
  83144. /**
  83145. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83146. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83147. * The `data` are either a numeric array either a Float32Array.
  83148. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83149. * 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).
  83150. * Note that a new underlying VertexBuffer object is created each call.
  83151. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83152. *
  83153. * Possible `kind` values :
  83154. * - VertexBuffer.PositionKind
  83155. * - VertexBuffer.UVKind
  83156. * - VertexBuffer.UV2Kind
  83157. * - VertexBuffer.UV3Kind
  83158. * - VertexBuffer.UV4Kind
  83159. * - VertexBuffer.UV5Kind
  83160. * - VertexBuffer.UV6Kind
  83161. * - VertexBuffer.ColorKind
  83162. * - VertexBuffer.MatricesIndicesKind
  83163. * - VertexBuffer.MatricesIndicesExtraKind
  83164. * - VertexBuffer.MatricesWeightsKind
  83165. * - VertexBuffer.MatricesWeightsExtraKind
  83166. *
  83167. * Returns the Mesh.
  83168. */
  83169. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83170. if (this.sourceMesh) {
  83171. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  83172. }
  83173. return this.sourceMesh;
  83174. };
  83175. /**
  83176. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83177. * If the mesh has no geometry, it is simply returned as it is.
  83178. * The `data` are either a numeric array either a Float32Array.
  83179. * No new underlying VertexBuffer object is created.
  83180. * 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.
  83181. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83182. *
  83183. * Possible `kind` values :
  83184. * - VertexBuffer.PositionKind
  83185. * - VertexBuffer.UVKind
  83186. * - VertexBuffer.UV2Kind
  83187. * - VertexBuffer.UV3Kind
  83188. * - VertexBuffer.UV4Kind
  83189. * - VertexBuffer.UV5Kind
  83190. * - VertexBuffer.UV6Kind
  83191. * - VertexBuffer.ColorKind
  83192. * - VertexBuffer.MatricesIndicesKind
  83193. * - VertexBuffer.MatricesIndicesExtraKind
  83194. * - VertexBuffer.MatricesWeightsKind
  83195. * - VertexBuffer.MatricesWeightsExtraKind
  83196. *
  83197. * Returns the Mesh.
  83198. */
  83199. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83200. if (this.sourceMesh) {
  83201. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83202. }
  83203. return this.sourceMesh;
  83204. };
  83205. /**
  83206. * Sets the mesh indices.
  83207. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83209. * This method creates a new index buffer each call.
  83210. * Returns the Mesh.
  83211. */
  83212. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83213. if (totalVertices === void 0) { totalVertices = null; }
  83214. if (this.sourceMesh) {
  83215. this.sourceMesh.setIndices(indices, totalVertices);
  83216. }
  83217. return this.sourceMesh;
  83218. };
  83219. /**
  83220. * Boolean : True if the mesh owns the requested kind of data.
  83221. */
  83222. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83223. return this._sourceMesh.isVerticesDataPresent(kind);
  83224. };
  83225. /**
  83226. * Returns an array of indices (IndicesArray).
  83227. */
  83228. InstancedMesh.prototype.getIndices = function () {
  83229. return this._sourceMesh.getIndices();
  83230. };
  83231. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83232. get: function () {
  83233. return this._sourceMesh._positions;
  83234. },
  83235. enumerable: true,
  83236. configurable: true
  83237. });
  83238. /**
  83239. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83240. * This means the mesh underlying bounding box and sphere are recomputed.
  83241. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83242. * @returns the current mesh
  83243. */
  83244. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83245. if (applySkeleton === void 0) { applySkeleton = false; }
  83246. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83247. return this;
  83248. }
  83249. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83250. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83251. return this;
  83252. };
  83253. /** @hidden */
  83254. InstancedMesh.prototype._preActivate = function () {
  83255. if (this._currentLOD) {
  83256. this._currentLOD._preActivate();
  83257. }
  83258. return this;
  83259. };
  83260. /** @hidden */
  83261. InstancedMesh.prototype._activate = function (renderId) {
  83262. if (this._currentLOD) {
  83263. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83264. }
  83265. return this;
  83266. };
  83267. /**
  83268. * Returns the current associated LOD AbstractMesh.
  83269. */
  83270. InstancedMesh.prototype.getLOD = function (camera) {
  83271. if (!camera) {
  83272. return this;
  83273. }
  83274. var boundingInfo = this.getBoundingInfo();
  83275. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83276. if (this._currentLOD === this.sourceMesh) {
  83277. return this;
  83278. }
  83279. return this._currentLOD;
  83280. };
  83281. /** @hidden */
  83282. InstancedMesh.prototype._syncSubMeshes = function () {
  83283. this.releaseSubMeshes();
  83284. if (this._sourceMesh.subMeshes) {
  83285. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83286. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83287. }
  83288. }
  83289. return this;
  83290. };
  83291. /** @hidden */
  83292. InstancedMesh.prototype._generatePointsArray = function () {
  83293. return this._sourceMesh._generatePointsArray();
  83294. };
  83295. /**
  83296. * Creates a new InstancedMesh from the current mesh.
  83297. * - name (string) : the cloned mesh name
  83298. * - newParent (optional Node) : the optional Node to parent the clone to.
  83299. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83300. *
  83301. * Returns the clone.
  83302. */
  83303. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83304. var result = this._sourceMesh.createInstance(name);
  83305. // Deep copy
  83306. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83307. // Bounding info
  83308. this.refreshBoundingInfo();
  83309. // Parent
  83310. if (newParent) {
  83311. result.parent = newParent;
  83312. }
  83313. if (!doNotCloneChildren) {
  83314. // Children
  83315. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83316. var mesh = this.getScene().meshes[index];
  83317. if (mesh.parent === this) {
  83318. mesh.clone(mesh.name, result);
  83319. }
  83320. }
  83321. }
  83322. result.computeWorldMatrix(true);
  83323. return result;
  83324. };
  83325. /**
  83326. * Disposes the InstancedMesh.
  83327. * Returns nothing.
  83328. */
  83329. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83330. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83331. // Remove from mesh
  83332. this._sourceMesh.removeInstance(this);
  83333. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83334. };
  83335. return InstancedMesh;
  83336. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83337. /***/ }),
  83338. /***/ "./Meshes/linesMesh.ts":
  83339. /*!*****************************!*\
  83340. !*** ./Meshes/linesMesh.ts ***!
  83341. \*****************************/
  83342. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83344. "use strict";
  83345. __webpack_require__.r(__webpack_exports__);
  83346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83349. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83350. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83351. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83352. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83353. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83354. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83355. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83356. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83357. /**
  83358. * Line mesh
  83359. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83360. */
  83361. var LinesMesh = /** @class */ (function (_super) {
  83362. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83363. /**
  83364. * Creates a new LinesMesh
  83365. * @param name defines the name
  83366. * @param scene defines the hosting scene
  83367. * @param parent defines the parent mesh if any
  83368. * @param source defines the optional source LinesMesh used to clone data from
  83369. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83370. * When false, achieved by calling a clone(), also passing False.
  83371. * This will make creation of children, recursive.
  83372. * @param useVertexColor defines if this LinesMesh supports vertex color
  83373. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83374. */
  83375. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83376. /**
  83377. * If vertex color should be applied to the mesh
  83378. */
  83379. useVertexColor,
  83380. /**
  83381. * If vertex alpha should be applied to the mesh
  83382. */
  83383. useVertexAlpha) {
  83384. if (scene === void 0) { scene = null; }
  83385. if (parent === void 0) { parent = null; }
  83386. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83387. _this.useVertexColor = useVertexColor;
  83388. _this.useVertexAlpha = useVertexAlpha;
  83389. /**
  83390. * Color of the line (Default: White)
  83391. */
  83392. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83393. /**
  83394. * Alpha of the line (Default: 1)
  83395. */
  83396. _this.alpha = 1;
  83397. if (source) {
  83398. _this.color = source.color.clone();
  83399. _this.alpha = source.alpha;
  83400. _this.useVertexColor = source.useVertexColor;
  83401. _this.useVertexAlpha = source.useVertexAlpha;
  83402. }
  83403. _this.intersectionThreshold = 0.1;
  83404. var defines = [];
  83405. var options = {
  83406. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  83407. uniforms: ["world", "viewProjection"],
  83408. needAlphaBlending: true,
  83409. defines: defines
  83410. };
  83411. if (useVertexAlpha === false) {
  83412. options.needAlphaBlending = false;
  83413. }
  83414. if (!useVertexColor) {
  83415. options.uniforms.push("color");
  83416. }
  83417. else {
  83418. options.defines.push("#define VERTEXCOLOR");
  83419. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83420. }
  83421. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  83422. return _this;
  83423. }
  83424. /**
  83425. * Returns the string "LineMesh"
  83426. */
  83427. LinesMesh.prototype.getClassName = function () {
  83428. return "LinesMesh";
  83429. };
  83430. Object.defineProperty(LinesMesh.prototype, "material", {
  83431. /**
  83432. * @hidden
  83433. */
  83434. get: function () {
  83435. return this._colorShader;
  83436. },
  83437. /**
  83438. * @hidden
  83439. */
  83440. set: function (value) {
  83441. // Do nothing
  83442. },
  83443. enumerable: true,
  83444. configurable: true
  83445. });
  83446. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  83447. /**
  83448. * @hidden
  83449. */
  83450. get: function () {
  83451. return false;
  83452. },
  83453. enumerable: true,
  83454. configurable: true
  83455. });
  83456. /** @hidden */
  83457. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  83458. if (!this._geometry) {
  83459. return this;
  83460. }
  83461. // VBOs
  83462. this._geometry._bind(this._colorShader.getEffect());
  83463. // Color
  83464. if (!this.useVertexColor) {
  83465. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  83466. }
  83467. return this;
  83468. };
  83469. /** @hidden */
  83470. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  83471. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  83472. return this;
  83473. }
  83474. var engine = this.getScene().getEngine();
  83475. // Draw order
  83476. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  83477. return this;
  83478. };
  83479. /**
  83480. * Disposes of the line mesh
  83481. * @param doNotRecurse If children should be disposed
  83482. */
  83483. LinesMesh.prototype.dispose = function (doNotRecurse) {
  83484. this._colorShader.dispose(false, false, true);
  83485. _super.prototype.dispose.call(this, doNotRecurse);
  83486. };
  83487. /**
  83488. * Returns a new LineMesh object cloned from the current one.
  83489. */
  83490. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83491. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  83492. };
  83493. /**
  83494. * Creates a new InstancedLinesMesh object from the mesh model.
  83495. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83496. * @param name defines the name of the new instance
  83497. * @returns a new InstancedLinesMesh
  83498. */
  83499. LinesMesh.prototype.createInstance = function (name) {
  83500. return new InstancedLinesMesh(name, this);
  83501. };
  83502. return LinesMesh;
  83503. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83504. /**
  83505. * Creates an instance based on a source LinesMesh
  83506. */
  83507. var InstancedLinesMesh = /** @class */ (function (_super) {
  83508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  83509. function InstancedLinesMesh(name, source) {
  83510. var _this = _super.call(this, name, source) || this;
  83511. _this.intersectionThreshold = source.intersectionThreshold;
  83512. return _this;
  83513. }
  83514. /**
  83515. * Returns the string "InstancedLinesMesh".
  83516. */
  83517. InstancedLinesMesh.prototype.getClassName = function () {
  83518. return "InstancedLinesMesh";
  83519. };
  83520. return InstancedLinesMesh;
  83521. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  83522. /***/ }),
  83523. /***/ "./Meshes/mesh.ts":
  83524. /*!************************!*\
  83525. !*** ./Meshes/mesh.ts ***!
  83526. \************************/
  83527. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  83528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83529. "use strict";
  83530. __webpack_require__.r(__webpack_exports__);
  83531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  83532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  83533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  83534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  83535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83536. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83537. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83538. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83539. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83540. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83541. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  83542. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83543. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83544. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83545. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83546. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83547. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83548. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83549. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83550. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83551. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  83552. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83553. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  83554. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  83555. /**
  83556. * Class used to represent a specific level of detail of a mesh
  83557. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83558. */
  83559. var MeshLODLevel = /** @class */ (function () {
  83560. /**
  83561. * Creates a new LOD level
  83562. * @param distance defines the distance where this level should star being displayed
  83563. * @param mesh defines the mesh to use to render this level
  83564. */
  83565. function MeshLODLevel(
  83566. /** Defines the distance where this level should star being displayed */
  83567. distance,
  83568. /** Defines the mesh to use to render this level */
  83569. mesh) {
  83570. this.distance = distance;
  83571. this.mesh = mesh;
  83572. }
  83573. return MeshLODLevel;
  83574. }());
  83575. /**
  83576. * @hidden
  83577. **/
  83578. var _CreationDataStorage = /** @class */ (function () {
  83579. function _CreationDataStorage() {
  83580. }
  83581. return _CreationDataStorage;
  83582. }());
  83583. /**
  83584. * @hidden
  83585. **/
  83586. var _InstanceDataStorage = /** @class */ (function () {
  83587. function _InstanceDataStorage() {
  83588. this.visibleInstances = {};
  83589. this.renderIdForInstances = new Array();
  83590. this.batchCache = new _InstancesBatch();
  83591. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  83592. }
  83593. return _InstanceDataStorage;
  83594. }());
  83595. /**
  83596. * @hidden
  83597. **/
  83598. var _InstancesBatch = /** @class */ (function () {
  83599. function _InstancesBatch() {
  83600. this.mustReturn = false;
  83601. this.visibleInstances = new Array();
  83602. this.renderSelf = new Array();
  83603. }
  83604. return _InstancesBatch;
  83605. }());
  83606. /**
  83607. * Class used to represent renderable models
  83608. */
  83609. var Mesh = /** @class */ (function (_super) {
  83610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  83611. /**
  83612. * @constructor
  83613. * @param name The value used by scene.getMeshByName() to do a lookup.
  83614. * @param scene The scene to add this mesh to.
  83615. * @param parent The parent of this mesh, if it has one
  83616. * @param source An optional Mesh from which geometry is shared, cloned.
  83617. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83618. * When false, achieved by calling a clone(), also passing False.
  83619. * This will make creation of children, recursive.
  83620. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83621. */
  83622. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  83623. if (scene === void 0) { scene = null; }
  83624. if (parent === void 0) { parent = null; }
  83625. if (source === void 0) { source = null; }
  83626. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  83627. var _this = _super.call(this, name, scene) || this;
  83628. // Members
  83629. /**
  83630. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83631. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83632. */
  83633. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_NONE;
  83634. /**
  83635. * Gets the list of instances created from this mesh
  83636. * it is not supposed to be modified manually.
  83637. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83638. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83639. */
  83640. _this.instances = new Array();
  83641. _this._LODLevels = new Array();
  83642. /** @hidden */
  83643. _this._instanceDataStorage = new _InstanceDataStorage();
  83644. // Use by builder only to know what orientation were the mesh build in.
  83645. /** @hidden */
  83646. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  83647. /**
  83648. * Use this property to change the original side orientation defined at construction time
  83649. */
  83650. _this.overrideMaterialSideOrientation = null;
  83651. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  83652. // Will be used to save a source mesh reference, If any
  83653. _this._source = null;
  83654. /** @hidden */
  83655. _this._isMesh = true;
  83656. scene = _this.getScene();
  83657. if (source) {
  83658. // Geometry
  83659. if (source._geometry) {
  83660. source._geometry.applyToMesh(_this);
  83661. }
  83662. // Deep copy
  83663. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  83664. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  83665. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  83666. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  83667. "onDisposeObservable"
  83668. ], ["_poseMatrix"]);
  83669. // Source mesh
  83670. _this._source = source;
  83671. if (scene.useClonedMeshhMap) {
  83672. if (!source.meshMap) {
  83673. source.meshMap = {};
  83674. }
  83675. source.meshMap[_this.uniqueId] = _this;
  83676. }
  83677. // Construction Params
  83678. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  83679. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  83680. _this._creationDataStorage = source._creationDataStorage;
  83681. // Animation ranges
  83682. if (_this._source._ranges) {
  83683. var ranges = _this._source._ranges;
  83684. for (var name in ranges) {
  83685. if (!ranges.hasOwnProperty(name)) {
  83686. continue;
  83687. }
  83688. if (!ranges[name]) {
  83689. continue;
  83690. }
  83691. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  83692. }
  83693. }
  83694. // Metadata
  83695. if (source.metadata && source.metadata.clone) {
  83696. _this.metadata = source.metadata.clone();
  83697. }
  83698. else {
  83699. _this.metadata = source.metadata;
  83700. }
  83701. // Tags
  83702. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  83703. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  83704. }
  83705. // Parent
  83706. _this.parent = source.parent;
  83707. // Pivot
  83708. _this.setPivotMatrix(source.getPivotMatrix());
  83709. _this.id = name + "." + source.id;
  83710. // Material
  83711. _this.material = source.material;
  83712. var index;
  83713. if (!doNotCloneChildren) {
  83714. // Children
  83715. var directDescendants = source.getDescendants(true);
  83716. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  83717. var child = directDescendants[index_1];
  83718. if (child.clone) {
  83719. child.clone(name + "." + child.name, _this);
  83720. }
  83721. }
  83722. }
  83723. // Physics clone
  83724. var physicsEngine = _this.getScene().getPhysicsEngine();
  83725. if (clonePhysicsImpostor && physicsEngine) {
  83726. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  83727. if (impostor) {
  83728. _this.physicsImpostor = impostor.clone(_this);
  83729. }
  83730. }
  83731. // Particles
  83732. for (index = 0; index < scene.particleSystems.length; index++) {
  83733. var system = scene.particleSystems[index];
  83734. if (system.emitter === source) {
  83735. system.clone(system.name, _this);
  83736. }
  83737. }
  83738. _this.refreshBoundingInfo();
  83739. _this.computeWorldMatrix(true);
  83740. }
  83741. // Parent
  83742. if (parent !== null) {
  83743. _this.parent = parent;
  83744. }
  83745. return _this;
  83746. }
  83747. /**
  83748. * Gets the default side orientation.
  83749. * @param orientation the orientation to value to attempt to get
  83750. * @returns the default orientation
  83751. * @hidden
  83752. */
  83753. Mesh._GetDefaultSideOrientation = function (orientation) {
  83754. if (orientation == Mesh.DOUBLESIDE) {
  83755. return Mesh.DOUBLESIDE;
  83756. }
  83757. if (orientation === undefined || orientation === null) {
  83758. return Mesh.FRONTSIDE;
  83759. }
  83760. return orientation;
  83761. };
  83762. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  83763. /**
  83764. * An event triggered before rendering the mesh
  83765. */
  83766. get: function () {
  83767. if (!this._onBeforeRenderObservable) {
  83768. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83769. }
  83770. return this._onBeforeRenderObservable;
  83771. },
  83772. enumerable: true,
  83773. configurable: true
  83774. });
  83775. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  83776. /**
  83777. * An event triggered before binding the mesh
  83778. */
  83779. get: function () {
  83780. if (!this._onBeforeBindObservable) {
  83781. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83782. }
  83783. return this._onBeforeBindObservable;
  83784. },
  83785. enumerable: true,
  83786. configurable: true
  83787. });
  83788. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  83789. /**
  83790. * An event triggered after rendering the mesh
  83791. */
  83792. get: function () {
  83793. if (!this._onAfterRenderObservable) {
  83794. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83795. }
  83796. return this._onAfterRenderObservable;
  83797. },
  83798. enumerable: true,
  83799. configurable: true
  83800. });
  83801. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  83802. /**
  83803. * An event triggered before drawing the mesh
  83804. */
  83805. get: function () {
  83806. if (!this._onBeforeDrawObservable) {
  83807. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83808. }
  83809. return this._onBeforeDrawObservable;
  83810. },
  83811. enumerable: true,
  83812. configurable: true
  83813. });
  83814. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  83815. /**
  83816. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83817. */
  83818. set: function (callback) {
  83819. if (this._onBeforeDrawObserver) {
  83820. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  83821. }
  83822. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  83823. },
  83824. enumerable: true,
  83825. configurable: true
  83826. });
  83827. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  83828. /**
  83829. * Gets or sets the morph target manager
  83830. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83831. */
  83832. get: function () {
  83833. return this._morphTargetManager;
  83834. },
  83835. set: function (value) {
  83836. if (this._morphTargetManager === value) {
  83837. return;
  83838. }
  83839. this._morphTargetManager = value;
  83840. this._syncGeometryWithMorphTargetManager();
  83841. },
  83842. enumerable: true,
  83843. configurable: true
  83844. });
  83845. Object.defineProperty(Mesh.prototype, "source", {
  83846. /**
  83847. * Gets the source mesh (the one used to clone this one from)
  83848. */
  83849. get: function () {
  83850. return this._source;
  83851. },
  83852. enumerable: true,
  83853. configurable: true
  83854. });
  83855. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  83856. /**
  83857. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83858. */
  83859. get: function () {
  83860. return this._unIndexed;
  83861. },
  83862. set: function (value) {
  83863. if (this._unIndexed !== value) {
  83864. this._unIndexed = value;
  83865. this._markSubMeshesAsAttributesDirty();
  83866. }
  83867. },
  83868. enumerable: true,
  83869. configurable: true
  83870. });
  83871. // Methods
  83872. /**
  83873. * Gets the class name
  83874. * @returns the string "Mesh".
  83875. */
  83876. Mesh.prototype.getClassName = function () {
  83877. return "Mesh";
  83878. };
  83879. /**
  83880. * Returns a description of this mesh
  83881. * @param fullDetails define if full details about this mesh must be used
  83882. * @returns a descriptive string representing this mesh
  83883. */
  83884. Mesh.prototype.toString = function (fullDetails) {
  83885. var ret = _super.prototype.toString.call(this, fullDetails);
  83886. ret += ", n vertices: " + this.getTotalVertices();
  83887. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  83888. if (this.animations) {
  83889. for (var i = 0; i < this.animations.length; i++) {
  83890. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  83891. }
  83892. }
  83893. if (fullDetails) {
  83894. if (this._geometry) {
  83895. var ib = this.getIndices();
  83896. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83897. if (vb && ib) {
  83898. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  83899. }
  83900. }
  83901. else {
  83902. ret += ", flat shading: UNKNOWN";
  83903. }
  83904. }
  83905. return ret;
  83906. };
  83907. /** @hidden */
  83908. Mesh.prototype._unBindEffect = function () {
  83909. _super.prototype._unBindEffect.call(this);
  83910. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  83911. var instance = _a[_i];
  83912. instance._unBindEffect();
  83913. }
  83914. };
  83915. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  83916. /**
  83917. * Gets a boolean indicating if this mesh has LOD
  83918. */
  83919. get: function () {
  83920. return this._LODLevels.length > 0;
  83921. },
  83922. enumerable: true,
  83923. configurable: true
  83924. });
  83925. /**
  83926. * Gets the list of MeshLODLevel associated with the current mesh
  83927. * @returns an array of MeshLODLevel
  83928. */
  83929. Mesh.prototype.getLODLevels = function () {
  83930. return this._LODLevels;
  83931. };
  83932. Mesh.prototype._sortLODLevels = function () {
  83933. this._LODLevels.sort(function (a, b) {
  83934. if (a.distance < b.distance) {
  83935. return 1;
  83936. }
  83937. if (a.distance > b.distance) {
  83938. return -1;
  83939. }
  83940. return 0;
  83941. });
  83942. };
  83943. /**
  83944. * Add a mesh as LOD level triggered at the given distance.
  83945. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83946. * @param distance The distance from the center of the object to show this level
  83947. * @param mesh The mesh to be added as LOD level (can be null)
  83948. * @return This mesh (for chaining)
  83949. */
  83950. Mesh.prototype.addLODLevel = function (distance, mesh) {
  83951. if (mesh && mesh._masterMesh) {
  83952. _Misc_logger__WEBPACK_IMPORTED_MODULE_17__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  83953. return this;
  83954. }
  83955. var level = new MeshLODLevel(distance, mesh);
  83956. this._LODLevels.push(level);
  83957. if (mesh) {
  83958. mesh._masterMesh = this;
  83959. }
  83960. this._sortLODLevels();
  83961. return this;
  83962. };
  83963. /**
  83964. * Returns the LOD level mesh at the passed distance or null if not found.
  83965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83966. * @param distance The distance from the center of the object to show this level
  83967. * @returns a Mesh or `null`
  83968. */
  83969. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  83970. for (var index = 0; index < this._LODLevels.length; index++) {
  83971. var level = this._LODLevels[index];
  83972. if (level.distance === distance) {
  83973. return level.mesh;
  83974. }
  83975. }
  83976. return null;
  83977. };
  83978. /**
  83979. * Remove a mesh from the LOD array
  83980. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83981. * @param mesh defines the mesh to be removed
  83982. * @return This mesh (for chaining)
  83983. */
  83984. Mesh.prototype.removeLODLevel = function (mesh) {
  83985. for (var index = 0; index < this._LODLevels.length; index++) {
  83986. if (this._LODLevels[index].mesh === mesh) {
  83987. this._LODLevels.splice(index, 1);
  83988. if (mesh) {
  83989. mesh._masterMesh = null;
  83990. }
  83991. }
  83992. }
  83993. this._sortLODLevels();
  83994. return this;
  83995. };
  83996. /**
  83997. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83998. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83999. * @param camera defines the camera to use to compute distance
  84000. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  84001. * @return This mesh (for chaining)
  84002. */
  84003. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  84004. if (!this._LODLevels || this._LODLevels.length === 0) {
  84005. return this;
  84006. }
  84007. var bSphere;
  84008. if (boundingSphere) {
  84009. bSphere = boundingSphere;
  84010. }
  84011. else {
  84012. var boundingInfo = this.getBoundingInfo();
  84013. bSphere = boundingInfo.boundingSphere;
  84014. }
  84015. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  84016. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  84017. if (this.onLODLevelSelection) {
  84018. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  84019. }
  84020. return this;
  84021. }
  84022. for (var index = 0; index < this._LODLevels.length; index++) {
  84023. var level = this._LODLevels[index];
  84024. if (level.distance < distanceToCamera) {
  84025. if (level.mesh) {
  84026. level.mesh._preActivate();
  84027. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  84028. }
  84029. if (this.onLODLevelSelection) {
  84030. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  84031. }
  84032. return level.mesh;
  84033. }
  84034. }
  84035. if (this.onLODLevelSelection) {
  84036. this.onLODLevelSelection(distanceToCamera, this, this);
  84037. }
  84038. return this;
  84039. };
  84040. Object.defineProperty(Mesh.prototype, "geometry", {
  84041. /**
  84042. * Gets the mesh internal Geometry object
  84043. */
  84044. get: function () {
  84045. return this._geometry;
  84046. },
  84047. enumerable: true,
  84048. configurable: true
  84049. });
  84050. /**
  84051. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  84052. * @returns the total number of vertices
  84053. */
  84054. Mesh.prototype.getTotalVertices = function () {
  84055. if (this._geometry === null || this._geometry === undefined) {
  84056. return 0;
  84057. }
  84058. return this._geometry.getTotalVertices();
  84059. };
  84060. /**
  84061. * Returns the content of an associated vertex buffer
  84062. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84063. * - VertexBuffer.PositionKind
  84064. * - VertexBuffer.UVKind
  84065. * - VertexBuffer.UV2Kind
  84066. * - VertexBuffer.UV3Kind
  84067. * - VertexBuffer.UV4Kind
  84068. * - VertexBuffer.UV5Kind
  84069. * - VertexBuffer.UV6Kind
  84070. * - VertexBuffer.ColorKind
  84071. * - VertexBuffer.MatricesIndicesKind
  84072. * - VertexBuffer.MatricesIndicesExtraKind
  84073. * - VertexBuffer.MatricesWeightsKind
  84074. * - VertexBuffer.MatricesWeightsExtraKind
  84075. * @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
  84076. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  84077. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  84078. */
  84079. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84080. if (!this._geometry) {
  84081. return null;
  84082. }
  84083. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  84084. };
  84085. /**
  84086. * Returns the mesh VertexBuffer object from the requested `kind`
  84087. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84088. * - VertexBuffer.PositionKind
  84089. * - VertexBuffer.UVKind
  84090. * - VertexBuffer.UV2Kind
  84091. * - VertexBuffer.UV3Kind
  84092. * - VertexBuffer.UV4Kind
  84093. * - VertexBuffer.UV5Kind
  84094. * - VertexBuffer.UV6Kind
  84095. * - VertexBuffer.ColorKind
  84096. * - VertexBuffer.MatricesIndicesKind
  84097. * - VertexBuffer.MatricesIndicesExtraKind
  84098. * - VertexBuffer.MatricesWeightsKind
  84099. * - VertexBuffer.MatricesWeightsExtraKind
  84100. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  84101. */
  84102. Mesh.prototype.getVertexBuffer = function (kind) {
  84103. if (!this._geometry) {
  84104. return null;
  84105. }
  84106. return this._geometry.getVertexBuffer(kind);
  84107. };
  84108. /**
  84109. * Tests if a specific vertex buffer is associated with this mesh
  84110. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84111. * - VertexBuffer.PositionKind
  84112. * - VertexBuffer.UVKind
  84113. * - VertexBuffer.UV2Kind
  84114. * - VertexBuffer.UV3Kind
  84115. * - VertexBuffer.UV4Kind
  84116. * - VertexBuffer.UV5Kind
  84117. * - VertexBuffer.UV6Kind
  84118. * - VertexBuffer.ColorKind
  84119. * - VertexBuffer.MatricesIndicesKind
  84120. * - VertexBuffer.MatricesIndicesExtraKind
  84121. * - VertexBuffer.MatricesWeightsKind
  84122. * - VertexBuffer.MatricesWeightsExtraKind
  84123. * @returns a boolean
  84124. */
  84125. Mesh.prototype.isVerticesDataPresent = function (kind) {
  84126. if (!this._geometry) {
  84127. if (this._delayInfo) {
  84128. return this._delayInfo.indexOf(kind) !== -1;
  84129. }
  84130. return false;
  84131. }
  84132. return this._geometry.isVerticesDataPresent(kind);
  84133. };
  84134. /**
  84135. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  84136. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84137. * - VertexBuffer.PositionKind
  84138. * - VertexBuffer.UVKind
  84139. * - VertexBuffer.UV2Kind
  84140. * - VertexBuffer.UV3Kind
  84141. * - VertexBuffer.UV4Kind
  84142. * - VertexBuffer.UV5Kind
  84143. * - VertexBuffer.UV6Kind
  84144. * - VertexBuffer.ColorKind
  84145. * - VertexBuffer.MatricesIndicesKind
  84146. * - VertexBuffer.MatricesIndicesExtraKind
  84147. * - VertexBuffer.MatricesWeightsKind
  84148. * - VertexBuffer.MatricesWeightsExtraKind
  84149. * @returns a boolean
  84150. */
  84151. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  84152. if (!this._geometry) {
  84153. if (this._delayInfo) {
  84154. return this._delayInfo.indexOf(kind) !== -1;
  84155. }
  84156. return false;
  84157. }
  84158. return this._geometry.isVertexBufferUpdatable(kind);
  84159. };
  84160. /**
  84161. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  84162. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84163. * - VertexBuffer.PositionKind
  84164. * - VertexBuffer.UVKind
  84165. * - VertexBuffer.UV2Kind
  84166. * - VertexBuffer.UV3Kind
  84167. * - VertexBuffer.UV4Kind
  84168. * - VertexBuffer.UV5Kind
  84169. * - VertexBuffer.UV6Kind
  84170. * - VertexBuffer.ColorKind
  84171. * - VertexBuffer.MatricesIndicesKind
  84172. * - VertexBuffer.MatricesIndicesExtraKind
  84173. * - VertexBuffer.MatricesWeightsKind
  84174. * - VertexBuffer.MatricesWeightsExtraKind
  84175. * @returns an array of strings
  84176. */
  84177. Mesh.prototype.getVerticesDataKinds = function () {
  84178. if (!this._geometry) {
  84179. var result = new Array();
  84180. if (this._delayInfo) {
  84181. this._delayInfo.forEach(function (kind) {
  84182. result.push(kind);
  84183. });
  84184. }
  84185. return result;
  84186. }
  84187. return this._geometry.getVerticesDataKinds();
  84188. };
  84189. /**
  84190. * Returns a positive integer : the total number of indices in this mesh geometry.
  84191. * @returns the numner of indices or zero if the mesh has no geometry.
  84192. */
  84193. Mesh.prototype.getTotalIndices = function () {
  84194. if (!this._geometry) {
  84195. return 0;
  84196. }
  84197. return this._geometry.getTotalIndices();
  84198. };
  84199. /**
  84200. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84201. * @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.
  84202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84203. * @returns the indices array or an empty array if the mesh has no geometry
  84204. */
  84205. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84206. if (!this._geometry) {
  84207. return [];
  84208. }
  84209. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84210. };
  84211. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84212. get: function () {
  84213. return this._masterMesh !== null && this._masterMesh !== undefined;
  84214. },
  84215. enumerable: true,
  84216. configurable: true
  84217. });
  84218. /**
  84219. * Determine if the current mesh is ready to be rendered
  84220. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84221. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84222. * @returns true if all associated assets are ready (material, textures, shaders)
  84223. */
  84224. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84225. if (completeCheck === void 0) { completeCheck = false; }
  84226. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84227. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_LOADING) {
  84228. return false;
  84229. }
  84230. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84231. return false;
  84232. }
  84233. if (!this.subMeshes || this.subMeshes.length === 0) {
  84234. return true;
  84235. }
  84236. if (!completeCheck) {
  84237. return true;
  84238. }
  84239. var engine = this.getEngine();
  84240. var scene = this.getScene();
  84241. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84242. this.computeWorldMatrix();
  84243. var mat = this.material || scene.defaultMaterial;
  84244. if (mat) {
  84245. if (mat._storeEffectOnSubMeshes) {
  84246. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84247. var subMesh = _a[_i];
  84248. var effectiveMaterial = subMesh.getMaterial();
  84249. if (effectiveMaterial) {
  84250. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84251. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84252. return false;
  84253. }
  84254. }
  84255. else {
  84256. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84257. return false;
  84258. }
  84259. }
  84260. }
  84261. }
  84262. }
  84263. else {
  84264. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84265. return false;
  84266. }
  84267. }
  84268. }
  84269. // Shadows
  84270. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84271. var light = _c[_b];
  84272. var generator = light.getShadowGenerator();
  84273. if (generator) {
  84274. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84275. var subMesh = _e[_d];
  84276. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84277. return false;
  84278. }
  84279. }
  84280. }
  84281. }
  84282. // LOD
  84283. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84284. var lod = _g[_f];
  84285. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84286. return false;
  84287. }
  84288. }
  84289. return true;
  84290. };
  84291. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84292. /**
  84293. * 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.
  84294. */
  84295. get: function () {
  84296. return this._areNormalsFrozen;
  84297. },
  84298. enumerable: true,
  84299. configurable: true
  84300. });
  84301. /**
  84302. * 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.
  84303. * @returns the current mesh
  84304. */
  84305. Mesh.prototype.freezeNormals = function () {
  84306. this._areNormalsFrozen = true;
  84307. return this;
  84308. };
  84309. /**
  84310. * 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
  84311. * @returns the current mesh
  84312. */
  84313. Mesh.prototype.unfreezeNormals = function () {
  84314. this._areNormalsFrozen = false;
  84315. return this;
  84316. };
  84317. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84318. /**
  84319. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84320. */
  84321. set: function (count) {
  84322. this._instanceDataStorage.overridenInstanceCount = count;
  84323. },
  84324. enumerable: true,
  84325. configurable: true
  84326. });
  84327. // Methods
  84328. /** @hidden */
  84329. Mesh.prototype._preActivate = function () {
  84330. var sceneRenderId = this.getScene().getRenderId();
  84331. if (this._preActivateId === sceneRenderId) {
  84332. return this;
  84333. }
  84334. this._preActivateId = sceneRenderId;
  84335. this._instanceDataStorage.visibleInstances = null;
  84336. return this;
  84337. };
  84338. /** @hidden */
  84339. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84340. if (this._instanceDataStorage.visibleInstances) {
  84341. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84342. }
  84343. return this;
  84344. };
  84345. /** @hidden */
  84346. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84347. if (!this._instanceDataStorage.visibleInstances) {
  84348. this._instanceDataStorage.visibleInstances = {
  84349. defaultRenderId: renderId,
  84350. selfDefaultRenderId: this._renderId
  84351. };
  84352. }
  84353. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84354. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84355. }
  84356. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84357. return this;
  84358. };
  84359. /**
  84360. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84361. * This means the mesh underlying bounding box and sphere are recomputed.
  84362. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84363. * @returns the current mesh
  84364. */
  84365. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84366. if (applySkeleton === void 0) { applySkeleton = false; }
  84367. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84368. return this;
  84369. }
  84370. var bias = this.geometry ? this.geometry.boundingBias : null;
  84371. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84372. return this;
  84373. };
  84374. /** @hidden */
  84375. Mesh.prototype._createGlobalSubMesh = function (force) {
  84376. var totalVertices = this.getTotalVertices();
  84377. if (!totalVertices || !this.getIndices()) {
  84378. return null;
  84379. }
  84380. // Check if we need to recreate the submeshes
  84381. if (this.subMeshes && this.subMeshes.length > 0) {
  84382. var ib = this.getIndices();
  84383. if (!ib) {
  84384. return null;
  84385. }
  84386. var totalIndices = ib.length;
  84387. var needToRecreate = false;
  84388. if (force) {
  84389. needToRecreate = true;
  84390. }
  84391. else {
  84392. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84393. var submesh = _a[_i];
  84394. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84395. needToRecreate = true;
  84396. break;
  84397. }
  84398. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84399. needToRecreate = true;
  84400. break;
  84401. }
  84402. }
  84403. }
  84404. if (!needToRecreate) {
  84405. return this.subMeshes[0];
  84406. }
  84407. }
  84408. this.releaseSubMeshes();
  84409. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  84410. };
  84411. /**
  84412. * This function will subdivide the mesh into multiple submeshes
  84413. * @param count defines the expected number of submeshes
  84414. */
  84415. Mesh.prototype.subdivide = function (count) {
  84416. if (count < 1) {
  84417. return;
  84418. }
  84419. var totalIndices = this.getTotalIndices();
  84420. var subdivisionSize = (totalIndices / count) | 0;
  84421. var offset = 0;
  84422. // Ensure that subdivisionSize is a multiple of 3
  84423. while (subdivisionSize % 3 !== 0) {
  84424. subdivisionSize++;
  84425. }
  84426. this.releaseSubMeshes();
  84427. for (var index = 0; index < count; index++) {
  84428. if (offset >= totalIndices) {
  84429. break;
  84430. }
  84431. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  84432. offset += subdivisionSize;
  84433. }
  84434. this.synchronizeInstances();
  84435. };
  84436. /**
  84437. * Copy a FloatArray into a specific associated vertex buffer
  84438. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84439. * - VertexBuffer.PositionKind
  84440. * - VertexBuffer.UVKind
  84441. * - VertexBuffer.UV2Kind
  84442. * - VertexBuffer.UV3Kind
  84443. * - VertexBuffer.UV4Kind
  84444. * - VertexBuffer.UV5Kind
  84445. * - VertexBuffer.UV6Kind
  84446. * - VertexBuffer.ColorKind
  84447. * - VertexBuffer.MatricesIndicesKind
  84448. * - VertexBuffer.MatricesIndicesExtraKind
  84449. * - VertexBuffer.MatricesWeightsKind
  84450. * - VertexBuffer.MatricesWeightsExtraKind
  84451. * @param data defines the data source
  84452. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84453. * @param stride defines the data stride size (can be null)
  84454. * @returns the current mesh
  84455. */
  84456. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84457. if (updatable === void 0) { updatable = false; }
  84458. if (!this._geometry) {
  84459. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84460. vertexData.set(data, kind);
  84461. var scene = this.getScene();
  84462. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84463. }
  84464. else {
  84465. this._geometry.setVerticesData(kind, data, updatable, stride);
  84466. }
  84467. return this;
  84468. };
  84469. /**
  84470. * Flags an associated vertex buffer as updatable
  84471. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  84472. * - VertexBuffer.PositionKind
  84473. * - VertexBuffer.UVKind
  84474. * - VertexBuffer.UV2Kind
  84475. * - VertexBuffer.UV3Kind
  84476. * - VertexBuffer.UV4Kind
  84477. * - VertexBuffer.UV5Kind
  84478. * - VertexBuffer.UV6Kind
  84479. * - VertexBuffer.ColorKind
  84480. * - VertexBuffer.MatricesIndicesKind
  84481. * - VertexBuffer.MatricesIndicesExtraKind
  84482. * - VertexBuffer.MatricesWeightsKind
  84483. * - VertexBuffer.MatricesWeightsExtraKind
  84484. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84485. */
  84486. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  84487. if (updatable === void 0) { updatable = true; }
  84488. var vb = this.getVertexBuffer(kind);
  84489. if (!vb || vb.isUpdatable() === updatable) {
  84490. return;
  84491. }
  84492. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  84493. };
  84494. /**
  84495. * Sets the mesh global Vertex Buffer
  84496. * @param buffer defines the buffer to use
  84497. * @returns the current mesh
  84498. */
  84499. Mesh.prototype.setVerticesBuffer = function (buffer) {
  84500. if (!this._geometry) {
  84501. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  84502. }
  84503. this._geometry.setVerticesBuffer(buffer);
  84504. return this;
  84505. };
  84506. /**
  84507. * Update a specific associated vertex buffer
  84508. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84509. * - VertexBuffer.PositionKind
  84510. * - VertexBuffer.UVKind
  84511. * - VertexBuffer.UV2Kind
  84512. * - VertexBuffer.UV3Kind
  84513. * - VertexBuffer.UV4Kind
  84514. * - VertexBuffer.UV5Kind
  84515. * - VertexBuffer.UV6Kind
  84516. * - VertexBuffer.ColorKind
  84517. * - VertexBuffer.MatricesIndicesKind
  84518. * - VertexBuffer.MatricesIndicesExtraKind
  84519. * - VertexBuffer.MatricesWeightsKind
  84520. * - VertexBuffer.MatricesWeightsExtraKind
  84521. * @param data defines the data source
  84522. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84523. * @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)
  84524. * @returns the current mesh
  84525. */
  84526. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84527. if (!this._geometry) {
  84528. return this;
  84529. }
  84530. if (!makeItUnique) {
  84531. this._geometry.updateVerticesData(kind, data, updateExtends);
  84532. }
  84533. else {
  84534. this.makeGeometryUnique();
  84535. this.updateVerticesData(kind, data, updateExtends, false);
  84536. }
  84537. return this;
  84538. };
  84539. /**
  84540. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  84541. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  84542. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  84543. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  84544. * @returns the current mesh
  84545. */
  84546. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  84547. if (computeNormals === void 0) { computeNormals = true; }
  84548. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84549. if (!positions) {
  84550. return this;
  84551. }
  84552. positionFunction(positions);
  84553. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  84554. if (computeNormals) {
  84555. var indices = this.getIndices();
  84556. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  84557. if (!normals) {
  84558. return this;
  84559. }
  84560. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  84561. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  84562. }
  84563. return this;
  84564. };
  84565. /**
  84566. * Creates a un-shared specific occurence of the geometry for the mesh.
  84567. * @returns the current mesh
  84568. */
  84569. Mesh.prototype.makeGeometryUnique = function () {
  84570. if (!this._geometry) {
  84571. return this;
  84572. }
  84573. var oldGeometry = this._geometry;
  84574. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  84575. oldGeometry.releaseForMesh(this, true);
  84576. geometry.applyToMesh(this);
  84577. return this;
  84578. };
  84579. /**
  84580. * Set the index buffer of this mesh
  84581. * @param indices defines the source data
  84582. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  84583. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  84584. * @returns the current mesh
  84585. */
  84586. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  84587. if (totalVertices === void 0) { totalVertices = null; }
  84588. if (updatable === void 0) { updatable = false; }
  84589. if (!this._geometry) {
  84590. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84591. vertexData.indices = indices;
  84592. var scene = this.getScene();
  84593. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84594. }
  84595. else {
  84596. this._geometry.setIndices(indices, totalVertices, updatable);
  84597. }
  84598. return this;
  84599. };
  84600. /**
  84601. * Update the current index buffer
  84602. * @param indices defines the source data
  84603. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84604. * @returns the current mesh
  84605. */
  84606. Mesh.prototype.updateIndices = function (indices, offset) {
  84607. if (!this._geometry) {
  84608. return this;
  84609. }
  84610. this._geometry.updateIndices(indices, offset);
  84611. return this;
  84612. };
  84613. /**
  84614. * Invert the geometry to move from a right handed system to a left handed one.
  84615. * @returns the current mesh
  84616. */
  84617. Mesh.prototype.toLeftHanded = function () {
  84618. if (!this._geometry) {
  84619. return this;
  84620. }
  84621. this._geometry.toLeftHanded();
  84622. return this;
  84623. };
  84624. /** @hidden */
  84625. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  84626. if (!this._geometry) {
  84627. return this;
  84628. }
  84629. var engine = this.getScene().getEngine();
  84630. // Wireframe
  84631. var indexToBind;
  84632. if (this._unIndexed) {
  84633. indexToBind = null;
  84634. }
  84635. else {
  84636. switch (fillMode) {
  84637. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  84638. indexToBind = null;
  84639. break;
  84640. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  84641. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  84642. break;
  84643. default:
  84644. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  84645. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  84646. break;
  84647. }
  84648. }
  84649. // VBOs
  84650. this._geometry._bind(effect, indexToBind);
  84651. return this;
  84652. };
  84653. /** @hidden */
  84654. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  84655. if (alternate === void 0) { alternate = false; }
  84656. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84657. return this;
  84658. }
  84659. if (this._onBeforeDrawObservable) {
  84660. this._onBeforeDrawObservable.notifyObservers(this);
  84661. }
  84662. var scene = this.getScene();
  84663. var engine = scene.getEngine();
  84664. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  84665. // or triangles as points
  84666. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  84667. }
  84668. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  84669. // Triangles as wireframe
  84670. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  84671. }
  84672. else {
  84673. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84674. }
  84675. if (scene._isAlternateRenderingEnabled && !alternate) {
  84676. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  84677. if (!effect || !scene.activeCamera) {
  84678. return this;
  84679. }
  84680. scene._switchToAlternateCameraConfiguration(true);
  84681. this._effectiveMaterial.bindView(effect);
  84682. this._effectiveMaterial.bindViewProjection(effect);
  84683. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  84684. this._draw(subMesh, fillMode, instancesCount, true);
  84685. engine.setViewport(scene.activeCamera.viewport);
  84686. scene._switchToAlternateCameraConfiguration(false);
  84687. this._effectiveMaterial.bindView(effect);
  84688. this._effectiveMaterial.bindViewProjection(effect);
  84689. }
  84690. return this;
  84691. };
  84692. /**
  84693. * Registers for this mesh a javascript function called just before the rendering process
  84694. * @param func defines the function to call before rendering this mesh
  84695. * @returns the current mesh
  84696. */
  84697. Mesh.prototype.registerBeforeRender = function (func) {
  84698. this.onBeforeRenderObservable.add(func);
  84699. return this;
  84700. };
  84701. /**
  84702. * Disposes a previously registered javascript function called before the rendering
  84703. * @param func defines the function to remove
  84704. * @returns the current mesh
  84705. */
  84706. Mesh.prototype.unregisterBeforeRender = function (func) {
  84707. this.onBeforeRenderObservable.removeCallback(func);
  84708. return this;
  84709. };
  84710. /**
  84711. * Registers for this mesh a javascript function called just after the rendering is complete
  84712. * @param func defines the function to call after rendering this mesh
  84713. * @returns the current mesh
  84714. */
  84715. Mesh.prototype.registerAfterRender = function (func) {
  84716. this.onAfterRenderObservable.add(func);
  84717. return this;
  84718. };
  84719. /**
  84720. * Disposes a previously registered javascript function called after the rendering.
  84721. * @param func defines the function to remove
  84722. * @returns the current mesh
  84723. */
  84724. Mesh.prototype.unregisterAfterRender = function (func) {
  84725. this.onAfterRenderObservable.removeCallback(func);
  84726. return this;
  84727. };
  84728. /** @hidden */
  84729. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  84730. var scene = this.getScene();
  84731. var batchCache = this._instanceDataStorage.batchCache;
  84732. batchCache.mustReturn = false;
  84733. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  84734. batchCache.visibleInstances[subMeshId] = null;
  84735. if (this._instanceDataStorage.visibleInstances) {
  84736. var visibleInstances = this._instanceDataStorage.visibleInstances;
  84737. var currentRenderId = scene.getRenderId();
  84738. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  84739. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  84740. var selfRenderId = this._renderId;
  84741. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  84742. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  84743. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  84744. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  84745. }
  84746. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  84747. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  84748. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  84749. batchCache.mustReturn = true;
  84750. return batchCache;
  84751. }
  84752. if (currentRenderId !== selfRenderId) {
  84753. batchCache.renderSelf[subMeshId] = false;
  84754. }
  84755. }
  84756. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  84757. }
  84758. return batchCache;
  84759. };
  84760. /** @hidden */
  84761. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  84762. var visibleInstances = batch.visibleInstances[subMesh._id];
  84763. if (!visibleInstances) {
  84764. return this;
  84765. }
  84766. var matricesCount = visibleInstances.length + 1;
  84767. var bufferSize = matricesCount * 16 * 4;
  84768. var instanceStorage = this._instanceDataStorage;
  84769. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  84770. var instancesBuffer = instanceStorage.instancesBuffer;
  84771. while (instanceStorage.instancesBufferSize < bufferSize) {
  84772. instanceStorage.instancesBufferSize *= 2;
  84773. }
  84774. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84775. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  84776. }
  84777. var offset = 0;
  84778. var instancesCount = 0;
  84779. var world = this.getWorldMatrix();
  84780. if (batch.renderSelf[subMesh._id]) {
  84781. world.copyToArray(instanceStorage.instancesData, offset);
  84782. offset += 16;
  84783. instancesCount++;
  84784. }
  84785. if (visibleInstances) {
  84786. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  84787. var instance = visibleInstances[instanceIndex];
  84788. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  84789. offset += 16;
  84790. instancesCount++;
  84791. }
  84792. }
  84793. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84794. if (instancesBuffer) {
  84795. instancesBuffer.dispose();
  84796. }
  84797. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  84798. instanceStorage.instancesBuffer = instancesBuffer;
  84799. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  84800. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  84801. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  84802. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  84803. }
  84804. else {
  84805. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  84806. }
  84807. this._bind(subMesh, effect, fillMode);
  84808. this._draw(subMesh, fillMode, instancesCount);
  84809. engine.unbindInstanceAttributes();
  84810. return this;
  84811. };
  84812. /** @hidden */
  84813. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  84814. var scene = this.getScene();
  84815. var engine = scene.getEngine();
  84816. if (hardwareInstancedRendering) {
  84817. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  84818. }
  84819. else {
  84820. if (batch.renderSelf[subMesh._id]) {
  84821. // Draw
  84822. if (onBeforeDraw) {
  84823. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  84824. }
  84825. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  84826. }
  84827. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  84828. if (visibleInstancesForSubMesh) {
  84829. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  84830. var instance = visibleInstancesForSubMesh[instanceIndex];
  84831. // World
  84832. var world = instance.getWorldMatrix();
  84833. if (onBeforeDraw) {
  84834. onBeforeDraw(true, world, effectiveMaterial);
  84835. }
  84836. // Draw
  84837. this._draw(subMesh, fillMode);
  84838. }
  84839. }
  84840. }
  84841. return this;
  84842. };
  84843. /**
  84844. * 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
  84845. * @param subMesh defines the subMesh to render
  84846. * @param enableAlphaMode defines if alpha mode can be changed
  84847. * @returns the current mesh
  84848. */
  84849. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  84850. if (this._checkOcclusionQuery()) {
  84851. return this;
  84852. }
  84853. var scene = this.getScene();
  84854. // Managing instances
  84855. var batch = this._getInstancesRenderList(subMesh._id);
  84856. if (batch.mustReturn) {
  84857. return this;
  84858. }
  84859. // Checking geometry state
  84860. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84861. return this;
  84862. }
  84863. if (this._onBeforeRenderObservable) {
  84864. this._onBeforeRenderObservable.notifyObservers(this);
  84865. }
  84866. var engine = scene.getEngine();
  84867. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  84868. // Material
  84869. var material = subMesh.getMaterial();
  84870. if (!material) {
  84871. return this;
  84872. }
  84873. this._effectiveMaterial = material;
  84874. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84875. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84876. return this;
  84877. }
  84878. }
  84879. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84880. return this;
  84881. }
  84882. // Alpha mode
  84883. if (enableAlphaMode) {
  84884. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  84885. }
  84886. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  84887. var step = _a[_i];
  84888. step.action(this, subMesh, batch);
  84889. }
  84890. var effect;
  84891. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84892. effect = subMesh.effect;
  84893. }
  84894. else {
  84895. effect = this._effectiveMaterial.getEffect();
  84896. }
  84897. if (!effect) {
  84898. return this;
  84899. }
  84900. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  84901. var sideOrientation = this.overrideMaterialSideOrientation;
  84902. if (sideOrientation == null) {
  84903. sideOrientation = this._effectiveMaterial.sideOrientation;
  84904. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  84905. sideOrientation = (sideOrientation === _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].ClockWiseSideOrientation ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].CounterClockWiseSideOrientation : _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].ClockWiseSideOrientation);
  84906. }
  84907. }
  84908. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  84909. if (this._effectiveMaterial.forceDepthWrite) {
  84910. engine.setDepthWrite(true);
  84911. }
  84912. // Bind
  84913. var fillMode = scene.forcePointsCloud ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode : (scene.forceWireframe ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode : this._effectiveMaterial.fillMode);
  84914. if (this._onBeforeBindObservable) {
  84915. this._onBeforeBindObservable.notifyObservers(this);
  84916. }
  84917. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  84918. this._bind(subMesh, effect, fillMode);
  84919. }
  84920. var world = effectiveMesh.getWorldMatrix();
  84921. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84922. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  84923. }
  84924. else {
  84925. this._effectiveMaterial.bind(world, this);
  84926. }
  84927. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  84928. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  84929. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  84930. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  84931. }
  84932. // Draw
  84933. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  84934. // Unbind
  84935. this._effectiveMaterial.unbind();
  84936. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  84937. var step = _c[_b];
  84938. step.action(this, subMesh, batch);
  84939. }
  84940. if (this._onAfterRenderObservable) {
  84941. this._onAfterRenderObservable.notifyObservers(this);
  84942. }
  84943. return this;
  84944. };
  84945. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  84946. if (isInstance && effectiveMaterial) {
  84947. effectiveMaterial.bindOnlyWorldMatrix(world);
  84948. }
  84949. };
  84950. /**
  84951. * Renormalize the mesh and patch it up if there are no weights
  84952. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  84953. * However in the case of zero weights then we set just a single influence to 1.
  84954. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  84955. */
  84956. Mesh.prototype.cleanMatrixWeights = function () {
  84957. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  84958. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  84959. this.normalizeSkinWeightsAndExtra();
  84960. }
  84961. else {
  84962. this.normalizeSkinFourWeights();
  84963. }
  84964. }
  84965. };
  84966. // faster 4 weight version.
  84967. Mesh.prototype.normalizeSkinFourWeights = function () {
  84968. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  84969. var numWeights = matricesWeights.length;
  84970. for (var a = 0; a < numWeights; a += 4) {
  84971. // accumulate weights
  84972. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  84973. // check for invalid weight and just set it to 1.
  84974. if (t === 0) {
  84975. matricesWeights[a] = 1;
  84976. }
  84977. else {
  84978. // renormalize so everything adds to 1 use reciprical
  84979. var recip = 1 / t;
  84980. matricesWeights[a] *= recip;
  84981. matricesWeights[a + 1] *= recip;
  84982. matricesWeights[a + 2] *= recip;
  84983. matricesWeights[a + 3] *= recip;
  84984. }
  84985. }
  84986. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  84987. };
  84988. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  84989. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  84990. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  84991. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  84992. var numWeights = matricesWeights.length;
  84993. for (var a = 0; a < numWeights; a += 4) {
  84994. // accumulate weights
  84995. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  84996. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  84997. // check for invalid weight and just set it to 1.
  84998. if (t === 0) {
  84999. matricesWeights[a] = 1;
  85000. }
  85001. else {
  85002. // renormalize so everything adds to 1 use reciprical
  85003. var recip = 1 / t;
  85004. matricesWeights[a] *= recip;
  85005. matricesWeights[a + 1] *= recip;
  85006. matricesWeights[a + 2] *= recip;
  85007. matricesWeights[a + 3] *= recip;
  85008. // same goes for extras
  85009. matricesWeightsExtra[a] *= recip;
  85010. matricesWeightsExtra[a + 1] *= recip;
  85011. matricesWeightsExtra[a + 2] *= recip;
  85012. matricesWeightsExtra[a + 3] *= recip;
  85013. }
  85014. }
  85015. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85016. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  85017. };
  85018. /**
  85019. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  85020. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  85021. * the user know there was an issue with importing the mesh
  85022. * @returns a validation object with skinned, valid and report string
  85023. */
  85024. Mesh.prototype.validateSkinning = function () {
  85025. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85026. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85027. if (matricesWeights === null || this.skeleton == null) {
  85028. return { skinned: false, valid: true, report: "not skinned" };
  85029. }
  85030. var numWeights = matricesWeights.length;
  85031. var numberNotSorted = 0;
  85032. var missingWeights = 0;
  85033. var maxUsedWeights = 0;
  85034. var numberNotNormalized = 0;
  85035. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  85036. var usedWeightCounts = new Array();
  85037. for (var a = 0; a <= numInfluences; a++) {
  85038. usedWeightCounts[a] = 0;
  85039. }
  85040. var toleranceEpsilon = 0.001;
  85041. for (var a = 0; a < numWeights; a += 4) {
  85042. var lastWeight = matricesWeights[a];
  85043. var t = lastWeight;
  85044. var usedWeights = t === 0 ? 0 : 1;
  85045. for (var b = 1; b < numInfluences; b++) {
  85046. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  85047. if (d > lastWeight) {
  85048. numberNotSorted++;
  85049. }
  85050. if (d !== 0) {
  85051. usedWeights++;
  85052. }
  85053. t += d;
  85054. lastWeight = d;
  85055. }
  85056. // count the buffer weights usage
  85057. usedWeightCounts[usedWeights]++;
  85058. // max influences
  85059. if (usedWeights > maxUsedWeights) {
  85060. maxUsedWeights = usedWeights;
  85061. }
  85062. // check for invalid weight and just set it to 1.
  85063. if (t === 0) {
  85064. missingWeights++;
  85065. }
  85066. else {
  85067. // renormalize so everything adds to 1 use reciprical
  85068. var recip = 1 / t;
  85069. var tolerance = 0;
  85070. for (b = 0; b < numInfluences; b++) {
  85071. if (b < 4) {
  85072. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  85073. }
  85074. else {
  85075. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  85076. }
  85077. }
  85078. // arbitary epsilon value for dicdating not normalized
  85079. if (tolerance > toleranceEpsilon) {
  85080. numberNotNormalized++;
  85081. }
  85082. }
  85083. }
  85084. // validate bone indices are in range of the skeleton
  85085. var numBones = this.skeleton.bones.length;
  85086. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85087. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  85088. var numBadBoneIndices = 0;
  85089. for (var a = 0; a < numWeights; a++) {
  85090. for (var b = 0; b < numInfluences; b++) {
  85091. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  85092. if (index >= numBones || index < 0) {
  85093. numBadBoneIndices++;
  85094. }
  85095. }
  85096. }
  85097. // log mesh stats
  85098. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  85099. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  85100. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  85101. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  85102. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  85103. };
  85104. /** @hidden */
  85105. Mesh.prototype._checkDelayState = function () {
  85106. var scene = this.getScene();
  85107. if (this._geometry) {
  85108. this._geometry.load(scene);
  85109. }
  85110. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  85111. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_LOADING;
  85112. this._queueLoad(scene);
  85113. }
  85114. return this;
  85115. };
  85116. Mesh.prototype._queueLoad = function (scene) {
  85117. var _this = this;
  85118. scene._addPendingData(this);
  85119. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  85120. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  85121. if (data instanceof ArrayBuffer) {
  85122. _this._delayLoadingFunction(data, _this);
  85123. }
  85124. else {
  85125. _this._delayLoadingFunction(JSON.parse(data), _this);
  85126. }
  85127. _this.instances.forEach(function (instance) {
  85128. instance._syncSubMeshes();
  85129. });
  85130. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_LOADED;
  85131. scene._removePendingData(_this);
  85132. }, function () { }, scene.offlineProvider, getBinaryData);
  85133. return this;
  85134. };
  85135. /**
  85136. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  85137. * A mesh is in the frustum if its bounding box intersects the frustum
  85138. * @param frustumPlanes defines the frustum to test
  85139. * @returns true if the mesh is in the frustum planes
  85140. */
  85141. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  85142. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_LOADING) {
  85143. return false;
  85144. }
  85145. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  85146. return false;
  85147. }
  85148. this._checkDelayState();
  85149. return true;
  85150. };
  85151. /**
  85152. * Sets the mesh material by the material or multiMaterial `id` property
  85153. * @param id is a string identifying the material or the multiMaterial
  85154. * @returns the current mesh
  85155. */
  85156. Mesh.prototype.setMaterialByID = function (id) {
  85157. var materials = this.getScene().materials;
  85158. var index;
  85159. for (index = materials.length - 1; index > -1; index--) {
  85160. if (materials[index].id === id) {
  85161. this.material = materials[index];
  85162. return this;
  85163. }
  85164. }
  85165. // Multi
  85166. var multiMaterials = this.getScene().multiMaterials;
  85167. for (index = multiMaterials.length - 1; index > -1; index--) {
  85168. if (multiMaterials[index].id === id) {
  85169. this.material = multiMaterials[index];
  85170. return this;
  85171. }
  85172. }
  85173. return this;
  85174. };
  85175. /**
  85176. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  85177. * @returns an array of IAnimatable
  85178. */
  85179. Mesh.prototype.getAnimatables = function () {
  85180. var results = new Array();
  85181. if (this.material) {
  85182. results.push(this.material);
  85183. }
  85184. if (this.skeleton) {
  85185. results.push(this.skeleton);
  85186. }
  85187. return results;
  85188. };
  85189. /**
  85190. * Modifies the mesh geometry according to the passed transformation matrix.
  85191. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85192. * The mesh normals are modified using the same transformation.
  85193. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85194. * @param transform defines the transform matrix to use
  85195. * @see http://doc.babylonjs.com/resources/baking_transformations
  85196. * @returns the current mesh
  85197. */
  85198. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85199. // Position
  85200. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85201. return this;
  85202. }
  85203. var submeshes = this.subMeshes.splice(0);
  85204. this._resetPointsArrayCache();
  85205. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85206. var temp = new Array();
  85207. var index;
  85208. for (index = 0; index < data.length; index += 3) {
  85209. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85210. }
  85211. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85212. // Normals
  85213. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85214. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85215. temp = [];
  85216. for (index = 0; index < data.length; index += 3) {
  85217. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85218. }
  85219. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85220. }
  85221. // flip faces?
  85222. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85223. this.flipFaces();
  85224. }
  85225. // Restore submeshes
  85226. this.releaseSubMeshes();
  85227. this.subMeshes = submeshes;
  85228. return this;
  85229. };
  85230. /**
  85231. * Modifies the mesh geometry according to its own current World Matrix.
  85232. * The mesh World Matrix is then reset.
  85233. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85234. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85235. * @see http://doc.babylonjs.com/resources/baking_transformations
  85236. * @returns the current mesh
  85237. */
  85238. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85239. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85240. this.scaling.copyFromFloats(1, 1, 1);
  85241. this.position.copyFromFloats(0, 0, 0);
  85242. this.rotation.copyFromFloats(0, 0, 0);
  85243. //only if quaternion is already set
  85244. if (this.rotationQuaternion) {
  85245. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85246. }
  85247. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85248. return this;
  85249. };
  85250. Object.defineProperty(Mesh.prototype, "_positions", {
  85251. // Cache
  85252. /** @hidden */
  85253. get: function () {
  85254. if (this._geometry) {
  85255. return this._geometry._positions;
  85256. }
  85257. return null;
  85258. },
  85259. enumerable: true,
  85260. configurable: true
  85261. });
  85262. /** @hidden */
  85263. Mesh.prototype._resetPointsArrayCache = function () {
  85264. if (this._geometry) {
  85265. this._geometry._resetPointsArrayCache();
  85266. }
  85267. return this;
  85268. };
  85269. /** @hidden */
  85270. Mesh.prototype._generatePointsArray = function () {
  85271. if (this._geometry) {
  85272. return this._geometry._generatePointsArray();
  85273. }
  85274. return false;
  85275. };
  85276. /**
  85277. * Returns a new Mesh object generated from the current mesh properties.
  85278. * This method must not get confused with createInstance()
  85279. * @param name is a string, the name given to the new mesh
  85280. * @param newParent can be any Node object (default `null`)
  85281. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85282. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85283. * @returns a new mesh
  85284. */
  85285. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85286. if (name === void 0) { name = ""; }
  85287. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85288. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85289. };
  85290. /**
  85291. * Releases resources associated with this mesh.
  85292. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85293. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85294. */
  85295. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85296. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85297. this.morphTargetManager = null;
  85298. if (this._geometry) {
  85299. this._geometry.releaseForMesh(this, true);
  85300. }
  85301. if (this._onBeforeDrawObservable) {
  85302. this._onBeforeDrawObservable.clear();
  85303. }
  85304. if (this._onBeforeBindObservable) {
  85305. this._onBeforeBindObservable.clear();
  85306. }
  85307. if (this._onBeforeRenderObservable) {
  85308. this._onBeforeRenderObservable.clear();
  85309. }
  85310. if (this._onAfterRenderObservable) {
  85311. this._onAfterRenderObservable.clear();
  85312. }
  85313. // Sources
  85314. if (this._scene.useClonedMeshhMap) {
  85315. if (this.meshMap) {
  85316. for (var uniqueId in this.meshMap) {
  85317. var mesh = this.meshMap[uniqueId];
  85318. if (mesh) {
  85319. mesh._source = null;
  85320. this.meshMap[uniqueId] = undefined;
  85321. }
  85322. }
  85323. }
  85324. if (this._source && this._source.meshMap) {
  85325. this._source.meshMap[this.uniqueId] = undefined;
  85326. }
  85327. }
  85328. else {
  85329. var meshes = this.getScene().meshes;
  85330. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85331. var abstractMesh = meshes_1[_i];
  85332. var mesh = abstractMesh;
  85333. if (mesh._source && mesh._source === this) {
  85334. mesh._source = null;
  85335. }
  85336. }
  85337. }
  85338. this._source = null;
  85339. // Instances
  85340. if (this._instanceDataStorage.instancesBuffer) {
  85341. this._instanceDataStorage.instancesBuffer.dispose();
  85342. this._instanceDataStorage.instancesBuffer = null;
  85343. }
  85344. while (this.instances.length) {
  85345. this.instances[0].dispose();
  85346. }
  85347. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85348. };
  85349. /**
  85350. * Modifies the mesh geometry according to a displacement map.
  85351. * 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.
  85352. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85353. * @param url is a string, the URL from the image file is to be downloaded.
  85354. * @param minHeight is the lower limit of the displacement.
  85355. * @param maxHeight is the upper limit of the displacement.
  85356. * @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.
  85357. * @param uvOffset is an optional vector2 used to offset UV.
  85358. * @param uvScale is an optional vector2 used to scale UV.
  85359. * @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.
  85360. * @returns the Mesh.
  85361. */
  85362. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85363. var _this = this;
  85364. if (forceUpdate === void 0) { forceUpdate = false; }
  85365. var scene = this.getScene();
  85366. var onload = function (img) {
  85367. // Getting height map data
  85368. var canvas = document.createElement("canvas");
  85369. var context = canvas.getContext("2d");
  85370. var heightMapWidth = img.width;
  85371. var heightMapHeight = img.height;
  85372. canvas.width = heightMapWidth;
  85373. canvas.height = heightMapHeight;
  85374. context.drawImage(img, 0, 0);
  85375. // Create VertexData from map data
  85376. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85377. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85378. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85379. //execute success callback, if set
  85380. if (onSuccess) {
  85381. onSuccess(_this);
  85382. }
  85383. };
  85384. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85385. return this;
  85386. };
  85387. /**
  85388. * Modifies the mesh geometry according to a displacementMap buffer.
  85389. * 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.
  85390. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85391. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85392. * @param heightMapWidth is the width of the buffer image.
  85393. * @param heightMapHeight is the height of the buffer image.
  85394. * @param minHeight is the lower limit of the displacement.
  85395. * @param maxHeight is the upper limit of the displacement.
  85396. * @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.
  85397. * @param uvOffset is an optional vector2 used to offset UV.
  85398. * @param uvScale is an optional vector2 used to scale UV.
  85399. * @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.
  85400. * @returns the Mesh.
  85401. */
  85402. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  85403. if (forceUpdate === void 0) { forceUpdate = false; }
  85404. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  85405. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  85406. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  85407. _Misc_logger__WEBPACK_IMPORTED_MODULE_17__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  85408. return this;
  85409. }
  85410. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  85411. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85412. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85413. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85414. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85415. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85416. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85417. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  85418. for (var index = 0; index < positions.length; index += 3) {
  85419. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  85420. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  85421. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  85422. // Compute height
  85423. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  85424. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  85425. var pos = (u + v * heightMapWidth) * 4;
  85426. var r = buffer[pos] / 255.0;
  85427. var g = buffer[pos + 1] / 255.0;
  85428. var b = buffer[pos + 2] / 255.0;
  85429. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  85430. normal.normalize();
  85431. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  85432. position = position.add(normal);
  85433. position.toArray(positions, index);
  85434. }
  85435. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  85436. if (forceUpdate) {
  85437. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85438. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85439. }
  85440. else {
  85441. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85442. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85443. }
  85444. return this;
  85445. };
  85446. /**
  85447. * Modify the mesh to get a flat shading rendering.
  85448. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  85449. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  85450. * @returns current mesh
  85451. */
  85452. Mesh.prototype.convertToFlatShadedMesh = function () {
  85453. var kinds = this.getVerticesDataKinds();
  85454. var vbs = {};
  85455. var data = {};
  85456. var newdata = {};
  85457. var updatableNormals = false;
  85458. var kindIndex;
  85459. var kind;
  85460. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85461. kind = kinds[kindIndex];
  85462. var vertexBuffer = this.getVertexBuffer(kind);
  85463. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  85464. updatableNormals = vertexBuffer.isUpdatable();
  85465. kinds.splice(kindIndex, 1);
  85466. kindIndex--;
  85467. continue;
  85468. }
  85469. vbs[kind] = vertexBuffer;
  85470. data[kind] = vbs[kind].getData();
  85471. newdata[kind] = [];
  85472. }
  85473. // Save previous submeshes
  85474. var previousSubmeshes = this.subMeshes.slice(0);
  85475. var indices = this.getIndices();
  85476. var totalIndices = this.getTotalIndices();
  85477. // Generating unique vertices per face
  85478. var index;
  85479. for (index = 0; index < totalIndices; index++) {
  85480. var vertexIndex = indices[index];
  85481. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85482. kind = kinds[kindIndex];
  85483. var stride = vbs[kind].getStrideSize();
  85484. for (var offset = 0; offset < stride; offset++) {
  85485. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85486. }
  85487. }
  85488. }
  85489. // Updating faces & normal
  85490. var normals = [];
  85491. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  85492. for (index = 0; index < totalIndices; index += 3) {
  85493. indices[index] = index;
  85494. indices[index + 1] = index + 1;
  85495. indices[index + 2] = index + 2;
  85496. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  85497. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  85498. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  85499. var p1p2 = p1.subtract(p2);
  85500. var p3p2 = p3.subtract(p2);
  85501. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  85502. // Store same normals for every vertex
  85503. for (var localIndex = 0; localIndex < 3; localIndex++) {
  85504. normals.push(normal.x);
  85505. normals.push(normal.y);
  85506. normals.push(normal.z);
  85507. }
  85508. }
  85509. this.setIndices(indices);
  85510. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  85511. // Updating vertex buffers
  85512. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85513. kind = kinds[kindIndex];
  85514. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85515. }
  85516. // Updating submeshes
  85517. this.releaseSubMeshes();
  85518. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85519. var previousOne = previousSubmeshes[submeshIndex];
  85520. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85521. }
  85522. this.synchronizeInstances();
  85523. return this;
  85524. };
  85525. /**
  85526. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  85527. * In other words, more vertices, no more indices and a single bigger VBO.
  85528. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  85529. * @returns current mesh
  85530. */
  85531. Mesh.prototype.convertToUnIndexedMesh = function () {
  85532. var kinds = this.getVerticesDataKinds();
  85533. var vbs = {};
  85534. var data = {};
  85535. var newdata = {};
  85536. var kindIndex;
  85537. var kind;
  85538. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85539. kind = kinds[kindIndex];
  85540. var vertexBuffer = this.getVertexBuffer(kind);
  85541. vbs[kind] = vertexBuffer;
  85542. data[kind] = vbs[kind].getData();
  85543. newdata[kind] = [];
  85544. }
  85545. // Save previous submeshes
  85546. var previousSubmeshes = this.subMeshes.slice(0);
  85547. var indices = this.getIndices();
  85548. var totalIndices = this.getTotalIndices();
  85549. // Generating unique vertices per face
  85550. var index;
  85551. for (index = 0; index < totalIndices; index++) {
  85552. var vertexIndex = indices[index];
  85553. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85554. kind = kinds[kindIndex];
  85555. var stride = vbs[kind].getStrideSize();
  85556. for (var offset = 0; offset < stride; offset++) {
  85557. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85558. }
  85559. }
  85560. }
  85561. // Updating indices
  85562. for (index = 0; index < totalIndices; index += 3) {
  85563. indices[index] = index;
  85564. indices[index + 1] = index + 1;
  85565. indices[index + 2] = index + 2;
  85566. }
  85567. this.setIndices(indices);
  85568. // Updating vertex buffers
  85569. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85570. kind = kinds[kindIndex];
  85571. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85572. }
  85573. // Updating submeshes
  85574. this.releaseSubMeshes();
  85575. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85576. var previousOne = previousSubmeshes[submeshIndex];
  85577. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85578. }
  85579. this._unIndexed = true;
  85580. this.synchronizeInstances();
  85581. return this;
  85582. };
  85583. /**
  85584. * Inverses facet orientations.
  85585. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  85586. * @param flipNormals will also inverts the normals
  85587. * @returns current mesh
  85588. */
  85589. Mesh.prototype.flipFaces = function (flipNormals) {
  85590. if (flipNormals === void 0) { flipNormals = false; }
  85591. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  85592. var i;
  85593. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  85594. for (i = 0; i < vertex_data.normals.length; i++) {
  85595. vertex_data.normals[i] *= -1;
  85596. }
  85597. }
  85598. if (vertex_data.indices) {
  85599. var temp;
  85600. for (i = 0; i < vertex_data.indices.length; i += 3) {
  85601. // reassign indices
  85602. temp = vertex_data.indices[i + 1];
  85603. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  85604. vertex_data.indices[i + 2] = temp;
  85605. }
  85606. }
  85607. vertex_data.applyToMesh(this);
  85608. return this;
  85609. };
  85610. // Instances
  85611. /** @hidden */
  85612. Mesh._instancedMeshFactory = function (name, mesh) {
  85613. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("InstancedMesh");
  85614. };
  85615. /** @hidden */
  85616. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  85617. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("PhysicsImpostor");
  85618. };
  85619. /**
  85620. * Creates a new InstancedMesh object from the mesh model.
  85621. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85622. * @param name defines the name of the new instance
  85623. * @returns a new InstancedMesh
  85624. */
  85625. Mesh.prototype.createInstance = function (name) {
  85626. return Mesh._instancedMeshFactory(name, this);
  85627. };
  85628. /**
  85629. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  85630. * After this call, all the mesh instances have the same submeshes than the current mesh.
  85631. * @returns the current mesh
  85632. */
  85633. Mesh.prototype.synchronizeInstances = function () {
  85634. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  85635. var instance = this.instances[instanceIndex];
  85636. instance._syncSubMeshes();
  85637. }
  85638. return this;
  85639. };
  85640. /**
  85641. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  85642. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  85643. * This should be used together with the simplification to avoid disappearing triangles.
  85644. * @param successCallback an optional success callback to be called after the optimization finished.
  85645. * @returns the current mesh
  85646. */
  85647. Mesh.prototype.optimizeIndices = function (successCallback) {
  85648. var _this = this;
  85649. var indices = this.getIndices();
  85650. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85651. if (!positions || !indices) {
  85652. return this;
  85653. }
  85654. var vectorPositions = new Array();
  85655. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  85656. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  85657. }
  85658. var dupes = new Array();
  85659. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  85660. var realPos = vectorPositions.length - 1 - iteration;
  85661. var testedPosition = vectorPositions[realPos];
  85662. for (var j = 0; j < realPos; ++j) {
  85663. var againstPosition = vectorPositions[j];
  85664. if (testedPosition.equals(againstPosition)) {
  85665. dupes[realPos] = j;
  85666. break;
  85667. }
  85668. }
  85669. }, function () {
  85670. for (var i = 0; i < indices.length; ++i) {
  85671. indices[i] = dupes[indices[i]] || indices[i];
  85672. }
  85673. //indices are now reordered
  85674. var originalSubMeshes = _this.subMeshes.slice(0);
  85675. _this.setIndices(indices);
  85676. _this.subMeshes = originalSubMeshes;
  85677. if (successCallback) {
  85678. successCallback(_this);
  85679. }
  85680. });
  85681. return this;
  85682. };
  85683. /**
  85684. * Serialize current mesh
  85685. * @param serializationObject defines the object which will receive the serialization data
  85686. */
  85687. Mesh.prototype.serialize = function (serializationObject) {
  85688. serializationObject.name = this.name;
  85689. serializationObject.id = this.id;
  85690. serializationObject.type = this.getClassName();
  85691. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  85692. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  85693. }
  85694. serializationObject.position = this.position.asArray();
  85695. if (this.rotationQuaternion) {
  85696. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  85697. }
  85698. else if (this.rotation) {
  85699. serializationObject.rotation = this.rotation.asArray();
  85700. }
  85701. serializationObject.scaling = this.scaling.asArray();
  85702. if (this._postMultiplyPivotMatrix) {
  85703. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  85704. }
  85705. else {
  85706. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  85707. }
  85708. serializationObject.isEnabled = this.isEnabled(false);
  85709. serializationObject.isVisible = this.isVisible;
  85710. serializationObject.infiniteDistance = this.infiniteDistance;
  85711. serializationObject.pickable = this.isPickable;
  85712. serializationObject.receiveShadows = this.receiveShadows;
  85713. serializationObject.billboardMode = this.billboardMode;
  85714. serializationObject.visibility = this.visibility;
  85715. serializationObject.checkCollisions = this.checkCollisions;
  85716. serializationObject.isBlocker = this.isBlocker;
  85717. // Parent
  85718. if (this.parent) {
  85719. serializationObject.parentId = this.parent.id;
  85720. }
  85721. // Geometry
  85722. serializationObject.isUnIndexed = this.isUnIndexed;
  85723. var geometry = this._geometry;
  85724. if (geometry) {
  85725. var geometryId = geometry.id;
  85726. serializationObject.geometryId = geometryId;
  85727. // SubMeshes
  85728. serializationObject.subMeshes = [];
  85729. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  85730. var subMesh = this.subMeshes[subIndex];
  85731. serializationObject.subMeshes.push({
  85732. materialIndex: subMesh.materialIndex,
  85733. verticesStart: subMesh.verticesStart,
  85734. verticesCount: subMesh.verticesCount,
  85735. indexStart: subMesh.indexStart,
  85736. indexCount: subMesh.indexCount
  85737. });
  85738. }
  85739. }
  85740. // Material
  85741. if (this.material) {
  85742. serializationObject.materialId = this.material.id;
  85743. }
  85744. else {
  85745. this.material = null;
  85746. }
  85747. // Morph targets
  85748. if (this.morphTargetManager) {
  85749. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  85750. }
  85751. // Skeleton
  85752. if (this.skeleton) {
  85753. serializationObject.skeletonId = this.skeleton.id;
  85754. }
  85755. // Physics
  85756. //TODO implement correct serialization for physics impostors.
  85757. var impostor = this.getPhysicsImpostor();
  85758. if (impostor) {
  85759. serializationObject.physicsMass = impostor.getParam("mass");
  85760. serializationObject.physicsFriction = impostor.getParam("friction");
  85761. serializationObject.physicsRestitution = impostor.getParam("mass");
  85762. serializationObject.physicsImpostor = impostor.type;
  85763. }
  85764. // Metadata
  85765. if (this.metadata) {
  85766. serializationObject.metadata = this.metadata;
  85767. }
  85768. // Instances
  85769. serializationObject.instances = [];
  85770. for (var index = 0; index < this.instances.length; index++) {
  85771. var instance = this.instances[index];
  85772. if (instance.doNotSerialize) {
  85773. continue;
  85774. }
  85775. var serializationInstance = {
  85776. name: instance.name,
  85777. id: instance.id,
  85778. position: instance.position.asArray(),
  85779. scaling: instance.scaling.asArray()
  85780. };
  85781. if (instance.parent) {
  85782. serializationInstance.parentId = instance.parent.id;
  85783. }
  85784. if (instance.rotationQuaternion) {
  85785. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  85786. }
  85787. else if (instance.rotation) {
  85788. serializationInstance.rotation = instance.rotation.asArray();
  85789. }
  85790. serializationObject.instances.push(serializationInstance);
  85791. // Animations
  85792. _Misc_decorators__WEBPACK_IMPORTED_MODULE_16__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  85793. serializationInstance.ranges = instance.serializeAnimationRanges();
  85794. }
  85795. //
  85796. // Animations
  85797. _Misc_decorators__WEBPACK_IMPORTED_MODULE_16__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  85798. serializationObject.ranges = this.serializeAnimationRanges();
  85799. // Layer mask
  85800. serializationObject.layerMask = this.layerMask;
  85801. // Alpha
  85802. serializationObject.alphaIndex = this.alphaIndex;
  85803. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  85804. // Overlay
  85805. serializationObject.overlayAlpha = this.overlayAlpha;
  85806. serializationObject.overlayColor = this.overlayColor.asArray();
  85807. serializationObject.renderOverlay = this.renderOverlay;
  85808. // Fog
  85809. serializationObject.applyFog = this.applyFog;
  85810. // Action Manager
  85811. if (this.actionManager) {
  85812. serializationObject.actions = this.actionManager.serialize(this.name);
  85813. }
  85814. };
  85815. /** @hidden */
  85816. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  85817. if (!this.geometry) {
  85818. return;
  85819. }
  85820. this._markSubMeshesAsAttributesDirty();
  85821. var morphTargetManager = this._morphTargetManager;
  85822. if (morphTargetManager && morphTargetManager.vertexCount) {
  85823. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  85824. _Misc_logger__WEBPACK_IMPORTED_MODULE_17__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  85825. this.morphTargetManager = null;
  85826. return;
  85827. }
  85828. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  85829. var morphTarget = morphTargetManager.getActiveTarget(index);
  85830. var positions = morphTarget.getPositions();
  85831. if (!positions) {
  85832. _Misc_logger__WEBPACK_IMPORTED_MODULE_17__["Logger"].Error("Invalid morph target. Target must have positions.");
  85833. return;
  85834. }
  85835. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  85836. var normals = morphTarget.getNormals();
  85837. if (normals) {
  85838. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  85839. }
  85840. var tangents = morphTarget.getTangents();
  85841. if (tangents) {
  85842. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  85843. }
  85844. }
  85845. }
  85846. else {
  85847. var index = 0;
  85848. // Positions
  85849. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  85850. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  85851. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  85852. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  85853. }
  85854. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  85855. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  85856. }
  85857. index++;
  85858. }
  85859. }
  85860. };
  85861. /**
  85862. * Returns a new Mesh object parsed from the source provided.
  85863. * @param parsedMesh is the source
  85864. * @param scene defines the hosting scene
  85865. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  85866. * @returns a new Mesh
  85867. */
  85868. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  85869. var mesh;
  85870. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  85871. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  85872. }
  85873. else {
  85874. mesh = new Mesh(parsedMesh.name, scene);
  85875. }
  85876. mesh.id = parsedMesh.id;
  85877. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  85878. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  85879. }
  85880. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  85881. if (parsedMesh.metadata !== undefined) {
  85882. mesh.metadata = parsedMesh.metadata;
  85883. }
  85884. if (parsedMesh.rotationQuaternion) {
  85885. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  85886. }
  85887. else if (parsedMesh.rotation) {
  85888. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  85889. }
  85890. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  85891. if (parsedMesh.localMatrix) {
  85892. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  85893. }
  85894. else if (parsedMesh.pivotMatrix) {
  85895. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  85896. }
  85897. mesh.setEnabled(parsedMesh.isEnabled);
  85898. mesh.isVisible = parsedMesh.isVisible;
  85899. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  85900. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  85901. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  85902. if (parsedMesh.applyFog !== undefined) {
  85903. mesh.applyFog = parsedMesh.applyFog;
  85904. }
  85905. if (parsedMesh.pickable !== undefined) {
  85906. mesh.isPickable = parsedMesh.pickable;
  85907. }
  85908. if (parsedMesh.alphaIndex !== undefined) {
  85909. mesh.alphaIndex = parsedMesh.alphaIndex;
  85910. }
  85911. mesh.receiveShadows = parsedMesh.receiveShadows;
  85912. mesh.billboardMode = parsedMesh.billboardMode;
  85913. if (parsedMesh.visibility !== undefined) {
  85914. mesh.visibility = parsedMesh.visibility;
  85915. }
  85916. mesh.checkCollisions = parsedMesh.checkCollisions;
  85917. if (parsedMesh.isBlocker !== undefined) {
  85918. mesh.isBlocker = parsedMesh.isBlocker;
  85919. }
  85920. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  85921. // freezeWorldMatrix
  85922. if (parsedMesh.freezeWorldMatrix) {
  85923. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  85924. }
  85925. // Parent
  85926. if (parsedMesh.parentId) {
  85927. mesh._waitingParentId = parsedMesh.parentId;
  85928. }
  85929. // Actions
  85930. if (parsedMesh.actions !== undefined) {
  85931. mesh._waitingActions = parsedMesh.actions;
  85932. }
  85933. // Overlay
  85934. if (parsedMesh.overlayAlpha !== undefined) {
  85935. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  85936. }
  85937. if (parsedMesh.overlayColor !== undefined) {
  85938. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  85939. }
  85940. if (parsedMesh.renderOverlay !== undefined) {
  85941. mesh.renderOverlay = parsedMesh.renderOverlay;
  85942. }
  85943. // Geometry
  85944. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  85945. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  85946. if (parsedMesh.delayLoadingFile) {
  85947. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].DELAYLOADSTATE_NOTLOADED;
  85948. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  85949. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMaximum));
  85950. if (parsedMesh._binaryInfo) {
  85951. mesh._binaryInfo = parsedMesh._binaryInfo;
  85952. }
  85953. mesh._delayInfo = [];
  85954. if (parsedMesh.hasUVs) {
  85955. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85956. }
  85957. if (parsedMesh.hasUVs2) {
  85958. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  85959. }
  85960. if (parsedMesh.hasUVs3) {
  85961. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  85962. }
  85963. if (parsedMesh.hasUVs4) {
  85964. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  85965. }
  85966. if (parsedMesh.hasUVs5) {
  85967. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  85968. }
  85969. if (parsedMesh.hasUVs6) {
  85970. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  85971. }
  85972. if (parsedMesh.hasColors) {
  85973. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  85974. }
  85975. if (parsedMesh.hasMatricesIndices) {
  85976. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85977. }
  85978. if (parsedMesh.hasMatricesWeights) {
  85979. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85980. }
  85981. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  85982. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_14__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  85983. mesh._checkDelayState();
  85984. }
  85985. }
  85986. else {
  85987. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  85988. }
  85989. // Material
  85990. if (parsedMesh.materialId) {
  85991. mesh.setMaterialByID(parsedMesh.materialId);
  85992. }
  85993. else {
  85994. mesh.material = null;
  85995. }
  85996. // Morph targets
  85997. if (parsedMesh.morphTargetManagerId > -1) {
  85998. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  85999. }
  86000. // Skeleton
  86001. if (parsedMesh.skeletonId > -1) {
  86002. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  86003. if (parsedMesh.numBoneInfluencers) {
  86004. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  86005. }
  86006. }
  86007. // Animations
  86008. if (parsedMesh.animations) {
  86009. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  86010. var parsedAnimation = parsedMesh.animations[animationIndex];
  86011. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_18__["_TypeStore"].GetClass("BABYLON.Animation");
  86012. if (internalClass) {
  86013. mesh.animations.push(internalClass.Parse(parsedAnimation));
  86014. }
  86015. }
  86016. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  86017. }
  86018. if (parsedMesh.autoAnimate) {
  86019. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  86020. }
  86021. // Layer Mask
  86022. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  86023. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  86024. }
  86025. else {
  86026. mesh.layerMask = 0x0FFFFFFF;
  86027. }
  86028. // Physics
  86029. if (parsedMesh.physicsImpostor) {
  86030. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  86031. }
  86032. // Instances
  86033. if (parsedMesh.instances) {
  86034. for (var index = 0; index < parsedMesh.instances.length; index++) {
  86035. var parsedInstance = parsedMesh.instances[index];
  86036. var instance = mesh.createInstance(parsedInstance.name);
  86037. if (parsedInstance.id) {
  86038. instance.id = parsedInstance.id;
  86039. }
  86040. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86041. if (parsedInstance.tags) {
  86042. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  86043. }
  86044. else {
  86045. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  86046. }
  86047. }
  86048. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  86049. if (parsedInstance.parentId) {
  86050. instance._waitingParentId = parsedInstance.parentId;
  86051. }
  86052. if (parsedInstance.rotationQuaternion) {
  86053. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  86054. }
  86055. else if (parsedInstance.rotation) {
  86056. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  86057. }
  86058. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  86059. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  86060. instance.checkCollisions = parsedInstance.checkCollisions;
  86061. }
  86062. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  86063. instance.isPickable = parsedInstance.pickable;
  86064. }
  86065. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  86066. instance.showBoundingBox = parsedInstance.showBoundingBox;
  86067. }
  86068. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86069. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  86070. }
  86071. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86072. instance.alphaIndex = parsedInstance.alphaIndex;
  86073. }
  86074. // Physics
  86075. if (parsedInstance.physicsImpostor) {
  86076. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  86077. }
  86078. // Animation
  86079. if (parsedInstance.animations) {
  86080. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  86081. parsedAnimation = parsedInstance.animations[animationIndex];
  86082. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_18__["_TypeStore"].GetClass("BABYLON.Animation");
  86083. if (internalClass) {
  86084. instance.animations.push(internalClass.Parse(parsedAnimation));
  86085. }
  86086. }
  86087. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  86088. if (parsedInstance.autoAnimate) {
  86089. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  86090. }
  86091. }
  86092. }
  86093. }
  86094. return mesh;
  86095. };
  86096. /**
  86097. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  86098. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86099. * @param name defines the name of the mesh to create
  86100. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  86101. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  86102. * @param closePath creates a seam between the first and the last points of each path of the path array
  86103. * @param offset is taken in account only if the `pathArray` is containing a single path
  86104. * @param scene defines the hosting scene
  86105. * @param updatable defines if the mesh must be flagged as updatable
  86106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86107. * @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)
  86108. * @returns a new Mesh
  86109. */
  86110. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86111. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86112. };
  86113. /**
  86114. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  86115. * @param name defines the name of the mesh to create
  86116. * @param radius sets the radius size (float) of the polygon (default 0.5)
  86117. * @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
  86118. * @param scene defines the hosting scene
  86119. * @param updatable defines if the mesh must be flagged as updatable
  86120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86121. * @returns a new Mesh
  86122. */
  86123. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86124. if (scene === void 0) { scene = null; }
  86125. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86126. };
  86127. /**
  86128. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  86129. * @param name defines the name of the mesh to create
  86130. * @param size sets the size (float) of each box side (default 1)
  86131. * @param scene defines the hosting scene
  86132. * @param updatable defines if the mesh must be flagged as updatable
  86133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86134. * @returns a new Mesh
  86135. */
  86136. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86137. if (scene === void 0) { scene = null; }
  86138. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86139. };
  86140. /**
  86141. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  86142. * @param name defines the name of the mesh to create
  86143. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  86144. * @param diameter sets the diameter size (float) of the sphere (default 1)
  86145. * @param scene defines the hosting scene
  86146. * @param updatable defines if the mesh must be flagged as updatable
  86147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86148. * @returns a new Mesh
  86149. */
  86150. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86151. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86152. };
  86153. /**
  86154. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  86155. * @param name defines the name of the mesh to create
  86156. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  86157. * @param diameterTop set the top cap diameter (floats, default 1)
  86158. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  86159. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  86160. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  86161. * @param scene defines the hosting scene
  86162. * @param updatable defines if the mesh must be flagged as updatable
  86163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86164. * @returns a new Mesh
  86165. */
  86166. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86167. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86168. };
  86169. // Torus (Code from SharpDX.org)
  86170. /**
  86171. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  86172. * @param name defines the name of the mesh to create
  86173. * @param diameter sets the diameter size (float) of the torus (default 1)
  86174. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  86175. * @param tessellation sets the number of torus sides (postive integer, default 16)
  86176. * @param scene defines the hosting scene
  86177. * @param updatable defines if the mesh must be flagged as updatable
  86178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86179. * @returns a new Mesh
  86180. */
  86181. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86182. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86183. };
  86184. /**
  86185. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86186. * @param name defines the name of the mesh to create
  86187. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86188. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86189. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86190. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86191. * @param p the number of windings on X axis (positive integers, default 2)
  86192. * @param q the number of windings on Y axis (positive integers, default 3)
  86193. * @param scene defines the hosting scene
  86194. * @param updatable defines if the mesh must be flagged as updatable
  86195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86196. * @returns a new Mesh
  86197. */
  86198. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86199. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86200. };
  86201. /**
  86202. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86203. * @param name defines the name of the mesh to create
  86204. * @param points is an array successive Vector3
  86205. * @param scene defines the hosting scene
  86206. * @param updatable defines if the mesh must be flagged as updatable
  86207. * @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).
  86208. * @returns a new Mesh
  86209. */
  86210. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86211. if (scene === void 0) { scene = null; }
  86212. if (updatable === void 0) { updatable = false; }
  86213. if (instance === void 0) { instance = null; }
  86214. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86215. };
  86216. /**
  86217. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86218. * @param name defines the name of the mesh to create
  86219. * @param points is an array successive Vector3
  86220. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86221. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86222. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86223. * @param scene defines the hosting scene
  86224. * @param updatable defines if the mesh must be flagged as updatable
  86225. * @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)
  86226. * @returns a new Mesh
  86227. */
  86228. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86229. if (scene === void 0) { scene = null; }
  86230. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86231. };
  86232. /**
  86233. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86234. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86235. * 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.
  86236. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86237. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86238. * Remember you can only change the shape positions, not their number when updating a polygon.
  86239. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86240. * @param name defines the name of the mesh to create
  86241. * @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
  86242. * @param scene defines the hosting scene
  86243. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86244. * @param updatable defines if the mesh must be flagged as updatable
  86245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86246. * @param earcutInjection can be used to inject your own earcut reference
  86247. * @returns a new Mesh
  86248. */
  86249. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86250. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86251. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86252. };
  86253. /**
  86254. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86255. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86256. * @param name defines the name of the mesh to create
  86257. * @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
  86258. * @param depth defines the height of extrusion
  86259. * @param scene defines the hosting scene
  86260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86261. * @param updatable defines if the mesh must be flagged as updatable
  86262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86263. * @param earcutInjection can be used to inject your own earcut reference
  86264. * @returns a new Mesh
  86265. */
  86266. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86267. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86268. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86269. };
  86270. /**
  86271. * Creates an extruded shape mesh.
  86272. * 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
  86273. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86274. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86275. * @param name defines the name of the mesh to create
  86276. * @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
  86277. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86278. * @param scale is the value to scale the shape
  86279. * @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
  86280. * @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
  86281. * @param scene defines the hosting scene
  86282. * @param updatable defines if the mesh must be flagged as updatable
  86283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86284. * @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)
  86285. * @returns a new Mesh
  86286. */
  86287. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86288. if (scene === void 0) { scene = null; }
  86289. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86290. };
  86291. /**
  86292. * Creates an custom extruded shape mesh.
  86293. * The custom extrusion is a parametric shape.
  86294. * It has no predefined shape. Its final shape will depend on the input parameters.
  86295. * Please consider using the same method from the MeshBuilder class instead
  86296. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86297. * @param name defines the name of the mesh to create
  86298. * @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
  86299. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86300. * @param scaleFunction is a custom Javascript function called on each path point
  86301. * @param rotationFunction is a custom Javascript function called on each path point
  86302. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86303. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86304. * @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
  86305. * @param scene defines the hosting scene
  86306. * @param updatable defines if the mesh must be flagged as updatable
  86307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86308. * @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)
  86309. * @returns a new Mesh
  86310. */
  86311. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86312. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86313. };
  86314. /**
  86315. * Creates lathe mesh.
  86316. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86317. * Please consider using the same method from the MeshBuilder class instead
  86318. * @param name defines the name of the mesh to create
  86319. * @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
  86320. * @param radius is the radius value of the lathe
  86321. * @param tessellation is the side number of the lathe.
  86322. * @param scene defines the hosting scene
  86323. * @param updatable defines if the mesh must be flagged as updatable
  86324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86325. * @returns a new Mesh
  86326. */
  86327. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86328. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86329. };
  86330. /**
  86331. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86332. * @param name defines the name of the mesh to create
  86333. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86334. * @param scene defines the hosting scene
  86335. * @param updatable defines if the mesh must be flagged as updatable
  86336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86337. * @returns a new Mesh
  86338. */
  86339. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86340. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86341. };
  86342. /**
  86343. * Creates a ground mesh.
  86344. * Please consider using the same method from the MeshBuilder class instead
  86345. * @param name defines the name of the mesh to create
  86346. * @param width set the width of the ground
  86347. * @param height set the height of the ground
  86348. * @param subdivisions sets the number of subdivisions per side
  86349. * @param scene defines the hosting scene
  86350. * @param updatable defines if the mesh must be flagged as updatable
  86351. * @returns a new Mesh
  86352. */
  86353. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86354. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86355. };
  86356. /**
  86357. * Creates a tiled ground mesh.
  86358. * Please consider using the same method from the MeshBuilder class instead
  86359. * @param name defines the name of the mesh to create
  86360. * @param xmin set the ground minimum X coordinate
  86361. * @param zmin set the ground minimum Y coordinate
  86362. * @param xmax set the ground maximum X coordinate
  86363. * @param zmax set the ground maximum Z coordinate
  86364. * @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
  86365. * @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
  86366. * @param scene defines the hosting scene
  86367. * @param updatable defines if the mesh must be flagged as updatable
  86368. * @returns a new Mesh
  86369. */
  86370. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86371. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86372. };
  86373. /**
  86374. * Creates a ground mesh from a height map.
  86375. * Please consider using the same method from the MeshBuilder class instead
  86376. * @see http://doc.babylonjs.com/babylon101/height_map
  86377. * @param name defines the name of the mesh to create
  86378. * @param url sets the URL of the height map image resource
  86379. * @param width set the ground width size
  86380. * @param height set the ground height size
  86381. * @param subdivisions sets the number of subdivision per side
  86382. * @param minHeight is the minimum altitude on the ground
  86383. * @param maxHeight is the maximum altitude on the ground
  86384. * @param scene defines the hosting scene
  86385. * @param updatable defines if the mesh must be flagged as updatable
  86386. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86387. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86388. * @returns a new Mesh
  86389. */
  86390. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86391. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86392. };
  86393. /**
  86394. * Creates a tube mesh.
  86395. * The tube is a parametric shape.
  86396. * It has no predefined shape. Its final shape will depend on the input parameters.
  86397. * Please consider using the same method from the MeshBuilder class instead
  86398. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86399. * @param name defines the name of the mesh to create
  86400. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  86401. * @param radius sets the tube radius size
  86402. * @param tessellation is the number of sides on the tubular surface
  86403. * @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
  86404. * @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
  86405. * @param scene defines the hosting scene
  86406. * @param updatable defines if the mesh must be flagged as updatable
  86407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86408. * @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)
  86409. * @returns a new Mesh
  86410. */
  86411. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86412. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86413. };
  86414. /**
  86415. * Creates a polyhedron mesh.
  86416. * Please consider using the same method from the MeshBuilder class instead.
  86417. * * 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
  86418. * * The parameter `size` (positive float, default 1) sets the polygon size
  86419. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  86420. * * 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`
  86421. * * 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
  86422. * * 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)`)
  86423. * * 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
  86424. * * 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
  86425. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86426. * * 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
  86427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86428. * @param name defines the name of the mesh to create
  86429. * @param options defines the options used to create the mesh
  86430. * @param scene defines the hosting scene
  86431. * @returns a new Mesh
  86432. */
  86433. Mesh.CreatePolyhedron = function (name, options, scene) {
  86434. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86435. };
  86436. /**
  86437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86439. * * 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`)
  86440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86441. * * 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
  86442. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86443. * * 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
  86444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86445. * @param name defines the name of the mesh
  86446. * @param options defines the options used to create the mesh
  86447. * @param scene defines the hosting scene
  86448. * @returns a new Mesh
  86449. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86450. */
  86451. Mesh.CreateIcoSphere = function (name, options, scene) {
  86452. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86453. };
  86454. /**
  86455. * Creates a decal mesh.
  86456. * Please consider using the same method from the MeshBuilder class instead.
  86457. * A decal is a mesh usually applied as a model onto the surface of another mesh
  86458. * @param name defines the name of the mesh
  86459. * @param sourceMesh defines the mesh receiving the decal
  86460. * @param position sets the position of the decal in world coordinates
  86461. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  86462. * @param size sets the decal scaling
  86463. * @param angle sets the angle to rotate the decal
  86464. * @returns a new Mesh
  86465. */
  86466. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86467. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("MeshBuilder");
  86468. };
  86469. // Skeletons
  86470. /**
  86471. * Prepare internal position array for software CPU skinning
  86472. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  86473. */
  86474. Mesh.prototype.setPositionsForCPUSkinning = function () {
  86475. if (!this._sourcePositions) {
  86476. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86477. if (!source) {
  86478. return this._sourcePositions;
  86479. }
  86480. this._sourcePositions = new Float32Array(source);
  86481. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86482. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  86483. }
  86484. }
  86485. return this._sourcePositions;
  86486. };
  86487. /**
  86488. * Prepare internal normal array for software CPU skinning
  86489. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  86490. */
  86491. Mesh.prototype.setNormalsForCPUSkinning = function () {
  86492. if (!this._sourceNormals) {
  86493. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86494. if (!source) {
  86495. return this._sourceNormals;
  86496. }
  86497. this._sourceNormals = new Float32Array(source);
  86498. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86499. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  86500. }
  86501. }
  86502. return this._sourceNormals;
  86503. };
  86504. /**
  86505. * Updates the vertex buffer by applying transformation from the bones
  86506. * @param skeleton defines the skeleton to apply to current mesh
  86507. * @returns the current mesh
  86508. */
  86509. Mesh.prototype.applySkeleton = function (skeleton) {
  86510. if (!this.geometry) {
  86511. return this;
  86512. }
  86513. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  86514. return this;
  86515. }
  86516. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  86517. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86518. return this;
  86519. }
  86520. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86521. return this;
  86522. }
  86523. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  86524. return this;
  86525. }
  86526. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86527. return this;
  86528. }
  86529. if (!this._sourcePositions) {
  86530. var submeshes = this.subMeshes.slice();
  86531. this.setPositionsForCPUSkinning();
  86532. this.subMeshes = submeshes;
  86533. }
  86534. if (!this._sourceNormals) {
  86535. this.setNormalsForCPUSkinning();
  86536. }
  86537. // positionsData checks for not being Float32Array will only pass at most once
  86538. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86539. if (!positionsData) {
  86540. return this;
  86541. }
  86542. if (!(positionsData instanceof Float32Array)) {
  86543. positionsData = new Float32Array(positionsData);
  86544. }
  86545. // normalsData checks for not being Float32Array will only pass at most once
  86546. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86547. if (!normalsData) {
  86548. return this;
  86549. }
  86550. if (!(normalsData instanceof Float32Array)) {
  86551. normalsData = new Float32Array(normalsData);
  86552. }
  86553. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86554. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86555. if (!matricesWeightsData || !matricesIndicesData) {
  86556. return this;
  86557. }
  86558. var needExtras = this.numBoneInfluencers > 4;
  86559. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  86560. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  86561. var skeletonMatrices = skeleton.getTransformMatrices(this);
  86562. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86563. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86564. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86565. var matWeightIdx = 0;
  86566. var inf;
  86567. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  86568. var weight;
  86569. for (inf = 0; inf < 4; inf++) {
  86570. weight = matricesWeightsData[matWeightIdx + inf];
  86571. if (weight > 0) {
  86572. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86573. finalMatrix.addToSelf(tempMatrix);
  86574. }
  86575. }
  86576. if (needExtras) {
  86577. for (inf = 0; inf < 4; inf++) {
  86578. weight = matricesWeightsExtraData[matWeightIdx + inf];
  86579. if (weight > 0) {
  86580. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86581. finalMatrix.addToSelf(tempMatrix);
  86582. }
  86583. }
  86584. }
  86585. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  86586. tempVector3.toArray(positionsData, index);
  86587. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  86588. tempVector3.toArray(normalsData, index);
  86589. finalMatrix.reset();
  86590. }
  86591. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  86592. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  86593. return this;
  86594. };
  86595. // Tools
  86596. /**
  86597. * 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
  86598. * @param meshes defines the list of meshes to scan
  86599. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  86600. */
  86601. Mesh.MinMax = function (meshes) {
  86602. var minVector = null;
  86603. var maxVector = null;
  86604. meshes.forEach(function (mesh) {
  86605. var boundingInfo = mesh.getBoundingInfo();
  86606. var boundingBox = boundingInfo.boundingBox;
  86607. if (!minVector || !maxVector) {
  86608. minVector = boundingBox.minimumWorld;
  86609. maxVector = boundingBox.maximumWorld;
  86610. }
  86611. else {
  86612. minVector.minimizeInPlace(boundingBox.minimumWorld);
  86613. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  86614. }
  86615. });
  86616. if (!minVector || !maxVector) {
  86617. return {
  86618. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  86619. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  86620. };
  86621. }
  86622. return {
  86623. min: minVector,
  86624. max: maxVector
  86625. };
  86626. };
  86627. /**
  86628. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  86629. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  86630. * @returns a vector3
  86631. */
  86632. Mesh.Center = function (meshesOrMinMaxVector) {
  86633. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  86634. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  86635. };
  86636. /**
  86637. * Merge the array of meshes into a single mesh for performance reasons.
  86638. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  86639. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  86640. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  86641. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  86642. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  86643. * @returns a new mesh
  86644. */
  86645. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes) {
  86646. if (disposeSource === void 0) { disposeSource = true; }
  86647. var index;
  86648. if (!allow32BitsIndices) {
  86649. var totalVertices = 0;
  86650. // Counting vertices
  86651. for (index = 0; index < meshes.length; index++) {
  86652. if (meshes[index]) {
  86653. totalVertices += meshes[index].getTotalVertices();
  86654. if (totalVertices > 65536) {
  86655. _Misc_logger__WEBPACK_IMPORTED_MODULE_17__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  86656. return null;
  86657. }
  86658. }
  86659. }
  86660. }
  86661. // Merge
  86662. var vertexData = null;
  86663. var otherVertexData;
  86664. var indiceArray = new Array();
  86665. var source = null;
  86666. for (index = 0; index < meshes.length; index++) {
  86667. if (meshes[index]) {
  86668. var wm = meshes[index].computeWorldMatrix(true);
  86669. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(meshes[index], true, true);
  86670. otherVertexData.transform(wm);
  86671. if (vertexData) {
  86672. vertexData.merge(otherVertexData, allow32BitsIndices);
  86673. }
  86674. else {
  86675. vertexData = otherVertexData;
  86676. source = meshes[index];
  86677. }
  86678. if (subdivideWithSubMeshes) {
  86679. indiceArray.push(meshes[index].getTotalIndices());
  86680. }
  86681. }
  86682. }
  86683. source = source;
  86684. if (!meshSubclass) {
  86685. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  86686. }
  86687. vertexData.applyToMesh(meshSubclass);
  86688. // Setting properties
  86689. meshSubclass.material = source.material;
  86690. meshSubclass.checkCollisions = source.checkCollisions;
  86691. // Cleaning
  86692. if (disposeSource) {
  86693. for (index = 0; index < meshes.length; index++) {
  86694. if (meshes[index]) {
  86695. meshes[index].dispose();
  86696. }
  86697. }
  86698. }
  86699. // Subdivide
  86700. if (subdivideWithSubMeshes) {
  86701. //-- removal of global submesh
  86702. meshSubclass.releaseSubMeshes();
  86703. index = 0;
  86704. var offset = 0;
  86705. //-- apply subdivision according to index table
  86706. while (index < indiceArray.length) {
  86707. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  86708. offset += indiceArray[index];
  86709. index++;
  86710. }
  86711. }
  86712. return meshSubclass;
  86713. };
  86714. /** @hidden */
  86715. Mesh.prototype.addInstance = function (instance) {
  86716. instance._indexInSourceMeshInstanceArray = this.instances.length;
  86717. this.instances.push(instance);
  86718. };
  86719. /** @hidden */
  86720. Mesh.prototype.removeInstance = function (instance) {
  86721. // Remove from mesh
  86722. var index = instance._indexInSourceMeshInstanceArray;
  86723. if (index != -1) {
  86724. if (index !== this.instances.length - 1) {
  86725. var last = this.instances[this.instances.length - 1];
  86726. this.instances[index] = last;
  86727. last._indexInSourceMeshInstanceArray = index;
  86728. }
  86729. instance._indexInSourceMeshInstanceArray = -1;
  86730. this.instances.pop();
  86731. }
  86732. };
  86733. // Consts
  86734. /**
  86735. * Mesh side orientation : usually the external or front surface
  86736. */
  86737. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  86738. /**
  86739. * Mesh side orientation : usually the internal or back surface
  86740. */
  86741. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  86742. /**
  86743. * Mesh side orientation : both internal and external or front and back surfaces
  86744. */
  86745. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  86746. /**
  86747. * Mesh side orientation : by default, `FRONTSIDE`
  86748. */
  86749. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  86750. /**
  86751. * Mesh cap setting : no cap
  86752. */
  86753. Mesh.NO_CAP = 0;
  86754. /**
  86755. * Mesh cap setting : one cap at the beginning of the mesh
  86756. */
  86757. Mesh.CAP_START = 1;
  86758. /**
  86759. * Mesh cap setting : one cap at the end of the mesh
  86760. */
  86761. Mesh.CAP_END = 2;
  86762. /**
  86763. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86764. */
  86765. Mesh.CAP_ALL = 3;
  86766. // Statics
  86767. /** @hidden */
  86768. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  86769. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_19__["_DevTools"].WarnImport("GroundMesh");
  86770. };
  86771. return Mesh;
  86772. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  86773. /***/ }),
  86774. /***/ "./Meshes/mesh.vertexData.ts":
  86775. /*!***********************************!*\
  86776. !*** ./Meshes/mesh.vertexData.ts ***!
  86777. \***********************************/
  86778. /*! exports provided: VertexData */
  86779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86780. "use strict";
  86781. __webpack_require__.r(__webpack_exports__);
  86782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  86783. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86784. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86785. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86786. /**
  86787. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86788. */
  86789. var VertexData = /** @class */ (function () {
  86790. function VertexData() {
  86791. }
  86792. /**
  86793. * Uses the passed data array to set the set the values for the specified kind of data
  86794. * @param data a linear array of floating numbers
  86795. * @param kind the type of data that is being set, eg positions, colors etc
  86796. */
  86797. VertexData.prototype.set = function (data, kind) {
  86798. switch (kind) {
  86799. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  86800. this.positions = data;
  86801. break;
  86802. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  86803. this.normals = data;
  86804. break;
  86805. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  86806. this.tangents = data;
  86807. break;
  86808. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  86809. this.uvs = data;
  86810. break;
  86811. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  86812. this.uvs2 = data;
  86813. break;
  86814. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  86815. this.uvs3 = data;
  86816. break;
  86817. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  86818. this.uvs4 = data;
  86819. break;
  86820. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  86821. this.uvs5 = data;
  86822. break;
  86823. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  86824. this.uvs6 = data;
  86825. break;
  86826. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  86827. this.colors = data;
  86828. break;
  86829. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  86830. this.matricesIndices = data;
  86831. break;
  86832. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  86833. this.matricesWeights = data;
  86834. break;
  86835. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  86836. this.matricesIndicesExtra = data;
  86837. break;
  86838. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  86839. this.matricesWeightsExtra = data;
  86840. break;
  86841. }
  86842. };
  86843. /**
  86844. * Associates the vertexData to the passed Mesh.
  86845. * Sets it as updatable or not (default `false`)
  86846. * @param mesh the mesh the vertexData is applied to
  86847. * @param updatable when used and having the value true allows new data to update the vertexData
  86848. * @returns the VertexData
  86849. */
  86850. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  86851. this._applyTo(mesh, updatable);
  86852. return this;
  86853. };
  86854. /**
  86855. * Associates the vertexData to the passed Geometry.
  86856. * Sets it as updatable or not (default `false`)
  86857. * @param geometry the geometry the vertexData is applied to
  86858. * @param updatable when used and having the value true allows new data to update the vertexData
  86859. * @returns VertexData
  86860. */
  86861. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  86862. this._applyTo(geometry, updatable);
  86863. return this;
  86864. };
  86865. /**
  86866. * Updates the associated mesh
  86867. * @param mesh the mesh to be updated
  86868. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86869. * @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
  86870. * @returns VertexData
  86871. */
  86872. VertexData.prototype.updateMesh = function (mesh) {
  86873. this._update(mesh);
  86874. return this;
  86875. };
  86876. /**
  86877. * Updates the associated geometry
  86878. * @param geometry the geometry to be updated
  86879. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86880. * @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
  86881. * @returns VertexData.
  86882. */
  86883. VertexData.prototype.updateGeometry = function (geometry) {
  86884. this._update(geometry);
  86885. return this;
  86886. };
  86887. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  86888. if (updatable === void 0) { updatable = false; }
  86889. if (this.positions) {
  86890. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  86891. }
  86892. if (this.normals) {
  86893. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  86894. }
  86895. if (this.tangents) {
  86896. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  86897. }
  86898. if (this.uvs) {
  86899. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  86900. }
  86901. if (this.uvs2) {
  86902. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  86903. }
  86904. if (this.uvs3) {
  86905. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  86906. }
  86907. if (this.uvs4) {
  86908. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  86909. }
  86910. if (this.uvs5) {
  86911. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  86912. }
  86913. if (this.uvs6) {
  86914. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  86915. }
  86916. if (this.colors) {
  86917. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  86918. }
  86919. if (this.matricesIndices) {
  86920. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  86921. }
  86922. if (this.matricesWeights) {
  86923. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  86924. }
  86925. if (this.matricesIndicesExtra) {
  86926. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  86927. }
  86928. if (this.matricesWeightsExtra) {
  86929. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  86930. }
  86931. if (this.indices) {
  86932. meshOrGeometry.setIndices(this.indices, null, updatable);
  86933. }
  86934. else {
  86935. meshOrGeometry.setIndices([], null);
  86936. }
  86937. return this;
  86938. };
  86939. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  86940. if (this.positions) {
  86941. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  86942. }
  86943. if (this.normals) {
  86944. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  86945. }
  86946. if (this.tangents) {
  86947. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  86948. }
  86949. if (this.uvs) {
  86950. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  86951. }
  86952. if (this.uvs2) {
  86953. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  86954. }
  86955. if (this.uvs3) {
  86956. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  86957. }
  86958. if (this.uvs4) {
  86959. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  86960. }
  86961. if (this.uvs5) {
  86962. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  86963. }
  86964. if (this.uvs6) {
  86965. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  86966. }
  86967. if (this.colors) {
  86968. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  86969. }
  86970. if (this.matricesIndices) {
  86971. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  86972. }
  86973. if (this.matricesWeights) {
  86974. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  86975. }
  86976. if (this.matricesIndicesExtra) {
  86977. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  86978. }
  86979. if (this.matricesWeightsExtra) {
  86980. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  86981. }
  86982. if (this.indices) {
  86983. meshOrGeometry.setIndices(this.indices, null);
  86984. }
  86985. return this;
  86986. };
  86987. /**
  86988. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86989. * @param matrix the transforming matrix
  86990. * @returns the VertexData
  86991. */
  86992. VertexData.prototype.transform = function (matrix) {
  86993. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  86994. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  86995. var index;
  86996. if (this.positions) {
  86997. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  86998. for (index = 0; index < this.positions.length; index += 3) {
  86999. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  87000. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  87001. this.positions[index] = transformed.x;
  87002. this.positions[index + 1] = transformed.y;
  87003. this.positions[index + 2] = transformed.z;
  87004. }
  87005. }
  87006. if (this.normals) {
  87007. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87008. for (index = 0; index < this.normals.length; index += 3) {
  87009. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  87010. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  87011. this.normals[index] = transformed.x;
  87012. this.normals[index + 1] = transformed.y;
  87013. this.normals[index + 2] = transformed.z;
  87014. }
  87015. }
  87016. if (this.tangents) {
  87017. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87018. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87019. for (index = 0; index < this.tangents.length; index += 4) {
  87020. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  87021. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  87022. this.tangents[index] = tangentTransformed.x;
  87023. this.tangents[index + 1] = tangentTransformed.y;
  87024. this.tangents[index + 2] = tangentTransformed.z;
  87025. this.tangents[index + 3] = tangentTransformed.w;
  87026. }
  87027. }
  87028. if (flip && this.indices) {
  87029. for (index = 0; index < this.indices.length; index += 3) {
  87030. var tmp = this.indices[index + 1];
  87031. this.indices[index + 1] = this.indices[index + 2];
  87032. this.indices[index + 2] = tmp;
  87033. }
  87034. }
  87035. return this;
  87036. };
  87037. /**
  87038. * Merges the passed VertexData into the current one
  87039. * @param other the VertexData to be merged into the current one
  87040. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87041. * @returns the modified VertexData
  87042. */
  87043. VertexData.prototype.merge = function (other, use32BitsIndices) {
  87044. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  87045. this._validate();
  87046. other._validate();
  87047. if (!this.normals !== !other.normals ||
  87048. !this.tangents !== !other.tangents ||
  87049. !this.uvs !== !other.uvs ||
  87050. !this.uvs2 !== !other.uvs2 ||
  87051. !this.uvs3 !== !other.uvs3 ||
  87052. !this.uvs4 !== !other.uvs4 ||
  87053. !this.uvs5 !== !other.uvs5 ||
  87054. !this.uvs6 !== !other.uvs6 ||
  87055. !this.colors !== !other.colors ||
  87056. !this.matricesIndices !== !other.matricesIndices ||
  87057. !this.matricesWeights !== !other.matricesWeights ||
  87058. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  87059. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  87060. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  87061. }
  87062. if (other.indices) {
  87063. if (!this.indices) {
  87064. this.indices = [];
  87065. }
  87066. var offset = this.positions ? this.positions.length / 3 : 0;
  87067. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  87068. if (isSrcTypedArray) {
  87069. var len = this.indices.length + other.indices.length;
  87070. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  87071. temp.set(this.indices);
  87072. var decal = this.indices.length;
  87073. for (var index = 0; index < other.indices.length; index++) {
  87074. temp[decal + index] = other.indices[index] + offset;
  87075. }
  87076. this.indices = temp;
  87077. }
  87078. else {
  87079. for (var index = 0; index < other.indices.length; index++) {
  87080. this.indices.push(other.indices[index] + offset);
  87081. }
  87082. }
  87083. }
  87084. this.positions = this._mergeElement(this.positions, other.positions);
  87085. this.normals = this._mergeElement(this.normals, other.normals);
  87086. this.tangents = this._mergeElement(this.tangents, other.tangents);
  87087. this.uvs = this._mergeElement(this.uvs, other.uvs);
  87088. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  87089. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  87090. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  87091. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  87092. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  87093. this.colors = this._mergeElement(this.colors, other.colors);
  87094. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  87095. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  87096. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  87097. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  87098. return this;
  87099. };
  87100. VertexData.prototype._mergeElement = function (source, other) {
  87101. if (!source) {
  87102. return other;
  87103. }
  87104. if (!other) {
  87105. return source;
  87106. }
  87107. var len = other.length + source.length;
  87108. var isSrcTypedArray = source instanceof Float32Array;
  87109. var isOthTypedArray = other instanceof Float32Array;
  87110. // use non-loop method when the source is Float32Array
  87111. if (isSrcTypedArray) {
  87112. var ret32 = new Float32Array(len);
  87113. ret32.set(source);
  87114. ret32.set(other, source.length);
  87115. return ret32;
  87116. // source is number[], when other is also use concat
  87117. }
  87118. else if (!isOthTypedArray) {
  87119. return source.concat(other);
  87120. // source is a number[], but other is a Float32Array, loop required
  87121. }
  87122. else {
  87123. var ret = source.slice(0); // copy source to a separate array
  87124. for (var i = 0, len = other.length; i < len; i++) {
  87125. ret.push(other[i]);
  87126. }
  87127. return ret;
  87128. }
  87129. };
  87130. VertexData.prototype._validate = function () {
  87131. if (!this.positions) {
  87132. throw new Error("Positions are required");
  87133. }
  87134. var getElementCount = function (kind, values) {
  87135. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  87136. if ((values.length % stride) !== 0) {
  87137. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  87138. }
  87139. return values.length / stride;
  87140. };
  87141. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  87142. var validateElementCount = function (kind, values) {
  87143. var elementCount = getElementCount(kind, values);
  87144. if (elementCount !== positionsElementCount) {
  87145. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  87146. }
  87147. };
  87148. if (this.normals) {
  87149. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  87150. }
  87151. if (this.tangents) {
  87152. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  87153. }
  87154. if (this.uvs) {
  87155. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  87156. }
  87157. if (this.uvs2) {
  87158. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  87159. }
  87160. if (this.uvs3) {
  87161. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  87162. }
  87163. if (this.uvs4) {
  87164. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  87165. }
  87166. if (this.uvs5) {
  87167. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  87168. }
  87169. if (this.uvs6) {
  87170. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  87171. }
  87172. if (this.colors) {
  87173. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  87174. }
  87175. if (this.matricesIndices) {
  87176. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  87177. }
  87178. if (this.matricesWeights) {
  87179. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87180. }
  87181. if (this.matricesIndicesExtra) {
  87182. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87183. }
  87184. if (this.matricesWeightsExtra) {
  87185. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87186. }
  87187. };
  87188. /**
  87189. * Serializes the VertexData
  87190. * @returns a serialized object
  87191. */
  87192. VertexData.prototype.serialize = function () {
  87193. var serializationObject = this.serialize();
  87194. if (this.positions) {
  87195. serializationObject.positions = this.positions;
  87196. }
  87197. if (this.normals) {
  87198. serializationObject.normals = this.normals;
  87199. }
  87200. if (this.tangents) {
  87201. serializationObject.tangents = this.tangents;
  87202. }
  87203. if (this.uvs) {
  87204. serializationObject.uvs = this.uvs;
  87205. }
  87206. if (this.uvs2) {
  87207. serializationObject.uvs2 = this.uvs2;
  87208. }
  87209. if (this.uvs3) {
  87210. serializationObject.uvs3 = this.uvs3;
  87211. }
  87212. if (this.uvs4) {
  87213. serializationObject.uvs4 = this.uvs4;
  87214. }
  87215. if (this.uvs5) {
  87216. serializationObject.uvs5 = this.uvs5;
  87217. }
  87218. if (this.uvs6) {
  87219. serializationObject.uvs6 = this.uvs6;
  87220. }
  87221. if (this.colors) {
  87222. serializationObject.colors = this.colors;
  87223. }
  87224. if (this.matricesIndices) {
  87225. serializationObject.matricesIndices = this.matricesIndices;
  87226. serializationObject.matricesIndices._isExpanded = true;
  87227. }
  87228. if (this.matricesWeights) {
  87229. serializationObject.matricesWeights = this.matricesWeights;
  87230. }
  87231. if (this.matricesIndicesExtra) {
  87232. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87233. serializationObject.matricesIndicesExtra._isExpanded = true;
  87234. }
  87235. if (this.matricesWeightsExtra) {
  87236. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87237. }
  87238. serializationObject.indices = this.indices;
  87239. return serializationObject;
  87240. };
  87241. // Statics
  87242. /**
  87243. * Extracts the vertexData from a mesh
  87244. * @param mesh the mesh from which to extract the VertexData
  87245. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87246. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87247. * @returns the object VertexData associated to the passed mesh
  87248. */
  87249. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87250. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87251. };
  87252. /**
  87253. * Extracts the vertexData from the geometry
  87254. * @param geometry the geometry from which to extract the VertexData
  87255. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87256. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87257. * @returns the object VertexData associated to the passed mesh
  87258. */
  87259. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87260. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87261. };
  87262. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87263. var result = new VertexData();
  87264. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87265. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87266. }
  87267. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87268. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87269. }
  87270. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87271. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87272. }
  87273. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87274. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87275. }
  87276. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87277. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87278. }
  87279. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87280. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87281. }
  87282. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87283. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87284. }
  87285. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87286. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87287. }
  87288. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87289. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87290. }
  87291. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87292. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87293. }
  87294. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87295. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87296. }
  87297. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87298. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87299. }
  87300. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87301. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87302. }
  87303. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87304. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87305. }
  87306. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87307. return result;
  87308. };
  87309. /**
  87310. * Creates the VertexData for a Ribbon
  87311. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87312. * * pathArray array of paths, each of which an array of successive Vector3
  87313. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87314. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87315. * * 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
  87316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87317. * * 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)
  87318. * * 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)
  87319. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87320. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87321. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87322. * @returns the VertexData of the ribbon
  87323. */
  87324. VertexData.CreateRibbon = function (options) {
  87325. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  87326. };
  87327. /**
  87328. * Creates the VertexData for a box
  87329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87330. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87331. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87332. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87333. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87334. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87335. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87337. * * 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)
  87338. * * 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)
  87339. * @returns the VertexData of the box
  87340. */
  87341. VertexData.CreateBox = function (options) {
  87342. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  87343. };
  87344. /**
  87345. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87346. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87347. * * segments sets the number of horizontal strips optional, default 32
  87348. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87349. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87350. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87351. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87352. * * 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
  87353. * * 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
  87354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87355. * * 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)
  87356. * * 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)
  87357. * @returns the VertexData of the ellipsoid
  87358. */
  87359. VertexData.CreateSphere = function (options) {
  87360. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  87361. };
  87362. /**
  87363. * Creates the VertexData for a cylinder, cone or prism
  87364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87365. * * height sets the height (y direction) of the cylinder, optional, default 2
  87366. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87367. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87368. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87369. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87370. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87371. * * 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
  87372. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87373. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87374. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87375. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87377. * * 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)
  87378. * * 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)
  87379. * @returns the VertexData of the cylinder, cone or prism
  87380. */
  87381. VertexData.CreateCylinder = function (options) {
  87382. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  87383. };
  87384. /**
  87385. * Creates the VertexData for a torus
  87386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87387. * * diameter the diameter of the torus, optional default 1
  87388. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87389. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87391. * * 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)
  87392. * * 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)
  87393. * @returns the VertexData of the torus
  87394. */
  87395. VertexData.CreateTorus = function (options) {
  87396. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  87397. };
  87398. /**
  87399. * Creates the VertexData of the LineSystem
  87400. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87401. * - lines an array of lines, each line being an array of successive Vector3
  87402. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87403. * @returns the VertexData of the LineSystem
  87404. */
  87405. VertexData.CreateLineSystem = function (options) {
  87406. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87407. };
  87408. /**
  87409. * Create the VertexData for a DashedLines
  87410. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87411. * - points an array successive Vector3
  87412. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87413. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87414. * - dashNb the intended total number of dashes, optional, default 200
  87415. * @returns the VertexData for the DashedLines
  87416. */
  87417. VertexData.CreateDashedLines = function (options) {
  87418. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87419. };
  87420. /**
  87421. * Creates the VertexData for a Ground
  87422. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87423. * - width the width (x direction) of the ground, optional, default 1
  87424. * - height the height (z direction) of the ground, optional, default 1
  87425. * - subdivisions the number of subdivisions per side, optional, default 1
  87426. * @returns the VertexData of the Ground
  87427. */
  87428. VertexData.CreateGround = function (options) {
  87429. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87430. };
  87431. /**
  87432. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87433. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87434. * * xmin the ground minimum X coordinate, optional, default -1
  87435. * * zmin the ground minimum Z coordinate, optional, default -1
  87436. * * xmax the ground maximum X coordinate, optional, default 1
  87437. * * zmax the ground maximum Z coordinate, optional, default 1
  87438. * * 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}
  87439. * * 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}
  87440. * @returns the VertexData of the TiledGround
  87441. */
  87442. VertexData.CreateTiledGround = function (options) {
  87443. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87444. };
  87445. /**
  87446. * Creates the VertexData of the Ground designed from a heightmap
  87447. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87448. * * width the width (x direction) of the ground
  87449. * * height the height (z direction) of the ground
  87450. * * subdivisions the number of subdivisions per side
  87451. * * minHeight the minimum altitude on the ground, optional, default 0
  87452. * * maxHeight the maximum altitude on the ground, optional default 1
  87453. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87454. * * buffer the array holding the image color data
  87455. * * bufferWidth the width of image
  87456. * * bufferHeight the height of image
  87457. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87458. * @returns the VertexData of the Ground designed from a heightmap
  87459. */
  87460. VertexData.CreateGroundFromHeightMap = function (options) {
  87461. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87462. };
  87463. /**
  87464. * Creates the VertexData for a Plane
  87465. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87466. * * size sets the width and height of the plane to the value of size, optional default 1
  87467. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87468. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87470. * * 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)
  87471. * * 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)
  87472. * @returns the VertexData of the box
  87473. */
  87474. VertexData.CreatePlane = function (options) {
  87475. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  87476. };
  87477. /**
  87478. * Creates the VertexData of the Disc or regular Polygon
  87479. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87480. * * radius the radius of the disc, optional default 0.5
  87481. * * tessellation the number of polygon sides, optional, default 64
  87482. * * 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
  87483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87484. * * 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)
  87485. * * 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)
  87486. * @returns the VertexData of the box
  87487. */
  87488. VertexData.CreateDisc = function (options) {
  87489. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  87490. };
  87491. /**
  87492. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87493. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87494. * @param polygon a mesh built from polygonTriangulation.build()
  87495. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87496. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87497. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87498. * @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)
  87499. * @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)
  87500. * @returns the VertexData of the Polygon
  87501. */
  87502. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  87503. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  87504. };
  87505. /**
  87506. * Creates the VertexData of the IcoSphere
  87507. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87508. * * radius the radius of the IcoSphere, optional default 1
  87509. * * radiusX allows stretching in the x direction, optional, default radius
  87510. * * radiusY allows stretching in the y direction, optional, default radius
  87511. * * radiusZ allows stretching in the z direction, optional, default radius
  87512. * * flat when true creates a flat shaded mesh, optional, default true
  87513. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87515. * * 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)
  87516. * * 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)
  87517. * @returns the VertexData of the IcoSphere
  87518. */
  87519. VertexData.CreateIcoSphere = function (options) {
  87520. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  87521. };
  87522. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  87523. /**
  87524. * Creates the VertexData for a Polyhedron
  87525. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87526. * * type provided types are:
  87527. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87528. * * 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)
  87529. * * size the size of the IcoSphere, optional default 1
  87530. * * sizeX allows stretching in the x direction, optional, default size
  87531. * * sizeY allows stretching in the y direction, optional, default size
  87532. * * sizeZ allows stretching in the z direction, optional, default size
  87533. * * 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
  87534. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87535. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87536. * * flat when true creates a flat shaded mesh, optional, default true
  87537. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87539. * * 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)
  87540. * * 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)
  87541. * @returns the VertexData of the Polyhedron
  87542. */
  87543. VertexData.CreatePolyhedron = function (options) {
  87544. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  87545. };
  87546. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  87547. /**
  87548. * Creates the VertexData for a TorusKnot
  87549. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87550. * * radius the radius of the torus knot, optional, default 2
  87551. * * tube the thickness of the tube, optional, default 0.5
  87552. * * radialSegments the number of sides on each tube segments, optional, default 32
  87553. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87554. * * p the number of windings around the z axis, optional, default 2
  87555. * * q the number of windings around the x axis, optional, default 3
  87556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87557. * * 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)
  87558. * * 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)
  87559. * @returns the VertexData of the Torus Knot
  87560. */
  87561. VertexData.CreateTorusKnot = function (options) {
  87562. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  87563. };
  87564. // Tools
  87565. /**
  87566. * Compute normals for given positions and indices
  87567. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87568. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87569. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87570. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87571. * * facetNormals : optional array of facet normals (vector3)
  87572. * * facetPositions : optional array of facet positions (vector3)
  87573. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87574. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87575. * * bInfo : optional bounding info, required for facetPartitioning computation
  87576. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87577. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87578. * * useRightHandedSystem: optional boolean to for right handed system computation
  87579. * * depthSort : optional boolean to enable the facet depth sort computation
  87580. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87581. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87582. */
  87583. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  87584. // temporary scalar variables
  87585. var index = 0; // facet index
  87586. var p1p2x = 0.0; // p1p2 vector x coordinate
  87587. var p1p2y = 0.0; // p1p2 vector y coordinate
  87588. var p1p2z = 0.0; // p1p2 vector z coordinate
  87589. var p3p2x = 0.0; // p3p2 vector x coordinate
  87590. var p3p2y = 0.0; // p3p2 vector y coordinate
  87591. var p3p2z = 0.0; // p3p2 vector z coordinate
  87592. var faceNormalx = 0.0; // facet normal x coordinate
  87593. var faceNormaly = 0.0; // facet normal y coordinate
  87594. var faceNormalz = 0.0; // facet normal z coordinate
  87595. var length = 0.0; // facet normal length before normalization
  87596. var v1x = 0; // vector1 x index in the positions array
  87597. var v1y = 0; // vector1 y index in the positions array
  87598. var v1z = 0; // vector1 z index in the positions array
  87599. var v2x = 0; // vector2 x index in the positions array
  87600. var v2y = 0; // vector2 y index in the positions array
  87601. var v2z = 0; // vector2 z index in the positions array
  87602. var v3x = 0; // vector3 x index in the positions array
  87603. var v3y = 0; // vector3 y index in the positions array
  87604. var v3z = 0; // vector3 z index in the positions array
  87605. var computeFacetNormals = false;
  87606. var computeFacetPositions = false;
  87607. var computeFacetPartitioning = false;
  87608. var computeDepthSort = false;
  87609. var faceNormalSign = 1;
  87610. var ratio = 0;
  87611. var distanceTo = null;
  87612. if (options) {
  87613. computeFacetNormals = (options.facetNormals) ? true : false;
  87614. computeFacetPositions = (options.facetPositions) ? true : false;
  87615. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  87616. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  87617. ratio = options.ratio || 0;
  87618. computeDepthSort = (options.depthSort) ? true : false;
  87619. distanceTo = (options.distanceTo);
  87620. if (computeDepthSort) {
  87621. if (distanceTo === undefined) {
  87622. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87623. }
  87624. var depthSortedFacets = options.depthSortedFacets;
  87625. }
  87626. }
  87627. // facetPartitioning reinit if needed
  87628. var xSubRatio = 0;
  87629. var ySubRatio = 0;
  87630. var zSubRatio = 0;
  87631. var subSq = 0;
  87632. if (computeFacetPartitioning && options && options.bbSize) {
  87633. var ox = 0; // X partitioning index for facet position
  87634. var oy = 0; // Y partinioning index for facet position
  87635. var oz = 0; // Z partinioning index for facet position
  87636. var b1x = 0; // X partitioning index for facet v1 vertex
  87637. var b1y = 0; // Y partitioning index for facet v1 vertex
  87638. var b1z = 0; // z partitioning index for facet v1 vertex
  87639. var b2x = 0; // X partitioning index for facet v2 vertex
  87640. var b2y = 0; // Y partitioning index for facet v2 vertex
  87641. var b2z = 0; // Z partitioning index for facet v2 vertex
  87642. var b3x = 0; // X partitioning index for facet v3 vertex
  87643. var b3y = 0; // Y partitioning index for facet v3 vertex
  87644. var b3z = 0; // Z partitioning index for facet v3 vertex
  87645. var block_idx_o = 0; // facet barycenter block index
  87646. var block_idx_v1 = 0; // v1 vertex block index
  87647. var block_idx_v2 = 0; // v2 vertex block index
  87648. var block_idx_v3 = 0; // v3 vertex block index
  87649. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  87650. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  87651. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  87652. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  87653. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  87654. subSq = options.subDiv.max * options.subDiv.max;
  87655. options.facetPartitioning.length = 0;
  87656. }
  87657. // reset the normals
  87658. for (index = 0; index < positions.length; index++) {
  87659. normals[index] = 0.0;
  87660. }
  87661. // Loop : 1 indice triplet = 1 facet
  87662. var nbFaces = (indices.length / 3) | 0;
  87663. for (index = 0; index < nbFaces; index++) {
  87664. // get the indexes of the coordinates of each vertex of the facet
  87665. v1x = indices[index * 3] * 3;
  87666. v1y = v1x + 1;
  87667. v1z = v1x + 2;
  87668. v2x = indices[index * 3 + 1] * 3;
  87669. v2y = v2x + 1;
  87670. v2z = v2x + 2;
  87671. v3x = indices[index * 3 + 2] * 3;
  87672. v3y = v3x + 1;
  87673. v3z = v3x + 2;
  87674. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  87675. p1p2y = positions[v1y] - positions[v2y];
  87676. p1p2z = positions[v1z] - positions[v2z];
  87677. p3p2x = positions[v3x] - positions[v2x];
  87678. p3p2y = positions[v3y] - positions[v2y];
  87679. p3p2z = positions[v3z] - positions[v2z];
  87680. // compute the face normal with the cross product
  87681. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  87682. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  87683. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  87684. // normalize this normal and store it in the array facetData
  87685. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87686. length = (length === 0) ? 1.0 : length;
  87687. faceNormalx /= length;
  87688. faceNormaly /= length;
  87689. faceNormalz /= length;
  87690. if (computeFacetNormals && options) {
  87691. options.facetNormals[index].x = faceNormalx;
  87692. options.facetNormals[index].y = faceNormaly;
  87693. options.facetNormals[index].z = faceNormalz;
  87694. }
  87695. if (computeFacetPositions && options) {
  87696. // compute and the facet barycenter coordinates in the array facetPositions
  87697. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  87698. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  87699. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  87700. }
  87701. if (computeFacetPartitioning && options) {
  87702. // store the facet indexes in arrays in the main facetPartitioning array :
  87703. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  87704. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  87705. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  87706. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  87707. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87708. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87709. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87710. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87711. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87712. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87713. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87714. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87715. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87716. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  87717. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  87718. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  87719. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  87720. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  87721. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  87722. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  87723. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  87724. // push each facet index in each block containing the vertex
  87725. options.facetPartitioning[block_idx_v1].push(index);
  87726. if (block_idx_v2 != block_idx_v1) {
  87727. options.facetPartitioning[block_idx_v2].push(index);
  87728. }
  87729. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  87730. options.facetPartitioning[block_idx_v3].push(index);
  87731. }
  87732. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  87733. options.facetPartitioning[block_idx_o].push(index);
  87734. }
  87735. }
  87736. if (computeDepthSort && options && options.facetPositions) {
  87737. var dsf = depthSortedFacets[index];
  87738. dsf.ind = index * 3;
  87739. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  87740. }
  87741. // compute the normals anyway
  87742. normals[v1x] += faceNormalx; // accumulate all the normals per face
  87743. normals[v1y] += faceNormaly;
  87744. normals[v1z] += faceNormalz;
  87745. normals[v2x] += faceNormalx;
  87746. normals[v2y] += faceNormaly;
  87747. normals[v2z] += faceNormalz;
  87748. normals[v3x] += faceNormalx;
  87749. normals[v3y] += faceNormaly;
  87750. normals[v3z] += faceNormalz;
  87751. }
  87752. // last normalization of each normal
  87753. for (index = 0; index < normals.length / 3; index++) {
  87754. faceNormalx = normals[index * 3];
  87755. faceNormaly = normals[index * 3 + 1];
  87756. faceNormalz = normals[index * 3 + 2];
  87757. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87758. length = (length === 0) ? 1.0 : length;
  87759. faceNormalx /= length;
  87760. faceNormaly /= length;
  87761. faceNormalz /= length;
  87762. normals[index * 3] = faceNormalx;
  87763. normals[index * 3 + 1] = faceNormaly;
  87764. normals[index * 3 + 2] = faceNormalz;
  87765. }
  87766. };
  87767. /** @hidden */
  87768. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  87769. var li = indices.length;
  87770. var ln = normals.length;
  87771. var i;
  87772. var n;
  87773. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  87774. switch (sideOrientation) {
  87775. case VertexData.FRONTSIDE:
  87776. // nothing changed
  87777. break;
  87778. case VertexData.BACKSIDE:
  87779. var tmp;
  87780. // indices
  87781. for (i = 0; i < li; i += 3) {
  87782. tmp = indices[i];
  87783. indices[i] = indices[i + 2];
  87784. indices[i + 2] = tmp;
  87785. }
  87786. // normals
  87787. for (n = 0; n < ln; n++) {
  87788. normals[n] = -normals[n];
  87789. }
  87790. break;
  87791. case VertexData.DOUBLESIDE:
  87792. // positions
  87793. var lp = positions.length;
  87794. var l = lp / 3;
  87795. for (var p = 0; p < lp; p++) {
  87796. positions[lp + p] = positions[p];
  87797. }
  87798. // indices
  87799. for (i = 0; i < li; i += 3) {
  87800. indices[i + li] = indices[i + 2] + l;
  87801. indices[i + 1 + li] = indices[i + 1] + l;
  87802. indices[i + 2 + li] = indices[i] + l;
  87803. }
  87804. // normals
  87805. for (n = 0; n < ln; n++) {
  87806. normals[ln + n] = -normals[n];
  87807. }
  87808. // uvs
  87809. var lu = uvs.length;
  87810. var u = 0;
  87811. for (u = 0; u < lu; u++) {
  87812. uvs[u + lu] = uvs[u];
  87813. }
  87814. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87815. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87816. u = 0;
  87817. for (i = 0; i < lu / 2; i++) {
  87818. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  87819. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  87820. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  87821. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  87822. u += 2;
  87823. }
  87824. break;
  87825. }
  87826. };
  87827. /**
  87828. * Applies VertexData created from the imported parameters to the geometry
  87829. * @param parsedVertexData the parsed data from an imported file
  87830. * @param geometry the geometry to apply the VertexData to
  87831. */
  87832. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  87833. var vertexData = new VertexData();
  87834. // positions
  87835. var positions = parsedVertexData.positions;
  87836. if (positions) {
  87837. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  87838. }
  87839. // normals
  87840. var normals = parsedVertexData.normals;
  87841. if (normals) {
  87842. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  87843. }
  87844. // tangents
  87845. var tangents = parsedVertexData.tangents;
  87846. if (tangents) {
  87847. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  87848. }
  87849. // uvs
  87850. var uvs = parsedVertexData.uvs;
  87851. if (uvs) {
  87852. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  87853. }
  87854. // uv2s
  87855. var uv2s = parsedVertexData.uv2s;
  87856. if (uv2s) {
  87857. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  87858. }
  87859. // uv3s
  87860. var uv3s = parsedVertexData.uv3s;
  87861. if (uv3s) {
  87862. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  87863. }
  87864. // uv4s
  87865. var uv4s = parsedVertexData.uv4s;
  87866. if (uv4s) {
  87867. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  87868. }
  87869. // uv5s
  87870. var uv5s = parsedVertexData.uv5s;
  87871. if (uv5s) {
  87872. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  87873. }
  87874. // uv6s
  87875. var uv6s = parsedVertexData.uv6s;
  87876. if (uv6s) {
  87877. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  87878. }
  87879. // colors
  87880. var colors = parsedVertexData.colors;
  87881. if (colors) {
  87882. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  87883. }
  87884. // matricesIndices
  87885. var matricesIndices = parsedVertexData.matricesIndices;
  87886. if (matricesIndices) {
  87887. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  87888. }
  87889. // matricesWeights
  87890. var matricesWeights = parsedVertexData.matricesWeights;
  87891. if (matricesWeights) {
  87892. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  87893. }
  87894. // indices
  87895. var indices = parsedVertexData.indices;
  87896. if (indices) {
  87897. vertexData.indices = indices;
  87898. }
  87899. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  87900. };
  87901. /**
  87902. * Mesh side orientation : usually the external or front surface
  87903. */
  87904. VertexData.FRONTSIDE = 0;
  87905. /**
  87906. * Mesh side orientation : usually the internal or back surface
  87907. */
  87908. VertexData.BACKSIDE = 1;
  87909. /**
  87910. * Mesh side orientation : both internal and external or front and back surfaces
  87911. */
  87912. VertexData.DOUBLESIDE = 2;
  87913. /**
  87914. * Mesh side orientation : by default, `FRONTSIDE`
  87915. */
  87916. VertexData.DEFAULTSIDE = 0;
  87917. return VertexData;
  87918. }());
  87919. /***/ }),
  87920. /***/ "./Meshes/meshBuilder.ts":
  87921. /*!*******************************!*\
  87922. !*** ./Meshes/meshBuilder.ts ***!
  87923. \*******************************/
  87924. /*! exports provided: MeshBuilder */
  87925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87926. "use strict";
  87927. __webpack_require__.r(__webpack_exports__);
  87928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  87929. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  87930. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  87931. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  87932. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  87933. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  87934. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  87935. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  87936. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  87937. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  87938. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  87939. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  87940. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  87941. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  87942. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  87943. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  87944. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  87945. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  87946. /**
  87947. * Class containing static functions to help procedurally build meshes
  87948. */
  87949. var MeshBuilder = /** @class */ (function () {
  87950. function MeshBuilder() {
  87951. }
  87952. /**
  87953. * Creates a box mesh
  87954. * * The parameter `size` sets the size (float) of each box side (default 1)
  87955. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  87956. * * 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)
  87957. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  87958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87959. * * 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
  87960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  87962. * @param name defines the name of the mesh
  87963. * @param options defines the options used to create the mesh
  87964. * @param scene defines the hosting scene
  87965. * @returns the box mesh
  87966. */
  87967. MeshBuilder.CreateBox = function (name, options, scene) {
  87968. if (scene === void 0) { scene = null; }
  87969. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  87970. };
  87971. /**
  87972. * Creates a sphere mesh
  87973. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  87974. * * 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`)
  87975. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  87976. * * 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
  87977. * * 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)
  87978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87979. * * 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
  87980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87981. * @param name defines the name of the mesh
  87982. * @param options defines the options used to create the mesh
  87983. * @param scene defines the hosting scene
  87984. * @returns the sphere mesh
  87985. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  87986. */
  87987. MeshBuilder.CreateSphere = function (name, options, scene) {
  87988. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  87989. };
  87990. /**
  87991. * Creates a plane polygonal mesh. By default, this is a disc
  87992. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  87993. * * 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
  87994. * * 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
  87995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87996. * * 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
  87997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87998. * @param name defines the name of the mesh
  87999. * @param options defines the options used to create the mesh
  88000. * @param scene defines the hosting scene
  88001. * @returns the plane polygonal mesh
  88002. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88003. */
  88004. MeshBuilder.CreateDisc = function (name, options, scene) {
  88005. if (scene === void 0) { scene = null; }
  88006. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  88007. };
  88008. /**
  88009. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88010. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88011. * * 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`)
  88012. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88013. * * 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
  88014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88015. * * 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
  88016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88017. * @param name defines the name of the mesh
  88018. * @param options defines the options used to create the mesh
  88019. * @param scene defines the hosting scene
  88020. * @returns the icosahedron mesh
  88021. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88022. */
  88023. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  88024. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  88025. };
  88026. /**
  88027. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88028. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  88029. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  88030. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  88031. * * 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
  88032. * * 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
  88033. * * 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
  88034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88035. * * 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
  88036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88037. * * 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
  88038. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  88039. * * 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
  88040. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  88041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88042. * @param name defines the name of the mesh
  88043. * @param options defines the options used to create the mesh
  88044. * @param scene defines the hosting scene
  88045. * @returns the ribbon mesh
  88046. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  88047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88048. */
  88049. MeshBuilder.CreateRibbon = function (name, options, scene) {
  88050. if (scene === void 0) { scene = null; }
  88051. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  88052. };
  88053. /**
  88054. * Creates a cylinder or a cone mesh
  88055. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88056. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88057. * * 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.
  88058. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88059. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88060. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88061. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88062. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88063. * * 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).
  88064. * * 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
  88065. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88066. * * 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
  88067. * * 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.
  88068. * * If `enclose` is false, a ring surface is one element.
  88069. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88070. * * 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
  88071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88072. * * 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
  88073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88074. * @param name defines the name of the mesh
  88075. * @param options defines the options used to create the mesh
  88076. * @param scene defines the hosting scene
  88077. * @returns the cylinder mesh
  88078. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88079. */
  88080. MeshBuilder.CreateCylinder = function (name, options, scene) {
  88081. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  88082. };
  88083. /**
  88084. * Creates a torus mesh
  88085. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  88086. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  88087. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  88088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88089. * * 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
  88090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88091. * @param name defines the name of the mesh
  88092. * @param options defines the options used to create the mesh
  88093. * @param scene defines the hosting scene
  88094. * @returns the torus mesh
  88095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  88096. */
  88097. MeshBuilder.CreateTorus = function (name, options, scene) {
  88098. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  88099. };
  88100. /**
  88101. * Creates a torus knot mesh
  88102. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  88103. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  88104. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  88105. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  88106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88107. * * 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
  88108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88109. * @param name defines the name of the mesh
  88110. * @param options defines the options used to create the mesh
  88111. * @param scene defines the hosting scene
  88112. * @returns the torus knot mesh
  88113. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  88114. */
  88115. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  88116. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  88117. };
  88118. /**
  88119. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  88120. * * 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
  88121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  88122. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  88123. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  88124. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  88125. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  88126. * * 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
  88127. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  88128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  88130. * @param name defines the name of the new line system
  88131. * @param options defines the options used to create the line system
  88132. * @param scene defines the hosting scene
  88133. * @returns a new line system mesh
  88134. */
  88135. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  88136. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  88137. };
  88138. /**
  88139. * Creates a line mesh
  88140. * 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
  88141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88142. * * The parameter `points` is an array successive Vector3
  88143. * * 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
  88144. * * The optional parameter `colors` is an array of successive Color4, one per line point
  88145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  88146. * * When updating an instance, remember that only point positions can change, not the number of points
  88147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  88149. * @param name defines the name of the new line system
  88150. * @param options defines the options used to create the line system
  88151. * @param scene defines the hosting scene
  88152. * @returns a new line mesh
  88153. */
  88154. MeshBuilder.CreateLines = function (name, options, scene) {
  88155. if (scene === void 0) { scene = null; }
  88156. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  88157. };
  88158. /**
  88159. * Creates a dashed line mesh
  88160. * * 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
  88161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88162. * * The parameter `points` is an array successive Vector3
  88163. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  88164. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  88165. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88166. * * 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
  88167. * * When updating an instance, remember that only point positions can change, not the number of points
  88168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88169. * @param name defines the name of the mesh
  88170. * @param options defines the options used to create the mesh
  88171. * @param scene defines the hosting scene
  88172. * @returns the dashed line mesh
  88173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  88174. */
  88175. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  88176. if (scene === void 0) { scene = null; }
  88177. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  88178. };
  88179. /**
  88180. * 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.
  88181. * * 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.
  88182. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88183. * * 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.
  88184. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88185. * * 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
  88186. * * 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
  88187. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88189. * * 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
  88190. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88192. * @param name defines the name of the mesh
  88193. * @param options defines the options used to create the mesh
  88194. * @param scene defines the hosting scene
  88195. * @returns the extruded shape mesh
  88196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88198. */
  88199. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88200. if (scene === void 0) { scene = null; }
  88201. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88202. };
  88203. /**
  88204. * Creates an custom extruded shape mesh.
  88205. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88206. * * 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.
  88207. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88208. * * 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
  88209. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88210. * * 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
  88211. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88212. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88213. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88214. * * 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
  88215. * * 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
  88216. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88218. * * 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
  88219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88221. * @param name defines the name of the mesh
  88222. * @param options defines the options used to create the mesh
  88223. * @param scene defines the hosting scene
  88224. * @returns the custom extruded shape mesh
  88225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88228. */
  88229. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88230. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88231. };
  88232. /**
  88233. * Creates lathe mesh.
  88234. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88235. * * 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
  88236. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88237. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88238. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88239. * * 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
  88240. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88241. * * 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
  88242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88243. * * 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
  88244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88246. * @param name defines the name of the mesh
  88247. * @param options defines the options used to create the mesh
  88248. * @param scene defines the hosting scene
  88249. * @returns the lathe mesh
  88250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88251. */
  88252. MeshBuilder.CreateLathe = function (name, options, scene) {
  88253. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88254. };
  88255. /**
  88256. * Creates a plane mesh
  88257. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88258. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88259. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88261. * * 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
  88262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88263. * @param name defines the name of the mesh
  88264. * @param options defines the options used to create the mesh
  88265. * @param scene defines the hosting scene
  88266. * @returns the plane mesh
  88267. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88268. */
  88269. MeshBuilder.CreatePlane = function (name, options, scene) {
  88270. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88271. };
  88272. /**
  88273. * Creates a ground mesh
  88274. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88275. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88277. * @param name defines the name of the mesh
  88278. * @param options defines the options used to create the mesh
  88279. * @param scene defines the hosting scene
  88280. * @returns the ground mesh
  88281. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88282. */
  88283. MeshBuilder.CreateGround = function (name, options, scene) {
  88284. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88285. };
  88286. /**
  88287. * Creates a tiled ground mesh
  88288. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88289. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88290. * * 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
  88291. * * 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
  88292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88293. * @param name defines the name of the mesh
  88294. * @param options defines the options used to create the mesh
  88295. * @param scene defines the hosting scene
  88296. * @returns the tiled ground mesh
  88297. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88298. */
  88299. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88300. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88301. };
  88302. /**
  88303. * Creates a ground mesh from a height map
  88304. * * The parameter `url` sets the URL of the height map image resource.
  88305. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88306. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88307. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88308. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88309. * * 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.
  88310. * * 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).
  88311. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88313. * @param name defines the name of the mesh
  88314. * @param url defines the url to the height map
  88315. * @param options defines the options used to create the mesh
  88316. * @param scene defines the hosting scene
  88317. * @returns the ground mesh
  88318. * @see https://doc.babylonjs.com/babylon101/height_map
  88319. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88320. */
  88321. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88322. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88323. };
  88324. /**
  88325. * Creates a polygon mesh
  88326. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88327. * * 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
  88328. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88330. * * 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)
  88331. * * Remember you can only change the shape positions, not their number when updating a polygon
  88332. * @param name defines the name of the mesh
  88333. * @param options defines the options used to create the mesh
  88334. * @param scene defines the hosting scene
  88335. * @param earcutInjection can be used to inject your own earcut reference
  88336. * @returns the polygon mesh
  88337. */
  88338. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88339. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88340. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88341. };
  88342. /**
  88343. * Creates an extruded polygon mesh, with depth in the Y direction.
  88344. * * 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)
  88345. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88346. * @param name defines the name of the mesh
  88347. * @param options defines the options used to create the mesh
  88348. * @param scene defines the hosting scene
  88349. * @param earcutInjection can be used to inject your own earcut reference
  88350. * @returns the polygon mesh
  88351. */
  88352. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  88353. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88354. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  88355. };
  88356. /**
  88357. * Creates a tube mesh.
  88358. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88359. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  88360. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  88361. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  88362. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  88363. * * 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)
  88364. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  88365. * * 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
  88366. * * 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
  88367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88368. * * 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
  88369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88371. * @param name defines the name of the mesh
  88372. * @param options defines the options used to create the mesh
  88373. * @param scene defines the hosting scene
  88374. * @returns the tube mesh
  88375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88376. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  88377. */
  88378. MeshBuilder.CreateTube = function (name, options, scene) {
  88379. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  88380. };
  88381. /**
  88382. * Creates a polyhedron mesh
  88383. * * 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
  88384. * * The parameter `size` (positive float, default 1) sets the polygon size
  88385. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88386. * * 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`
  88387. * * 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
  88388. * * 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)`)
  88389. * * 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
  88390. * * 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
  88391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88392. * * 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
  88393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88394. * @param name defines the name of the mesh
  88395. * @param options defines the options used to create the mesh
  88396. * @param scene defines the hosting scene
  88397. * @returns the polyhedron mesh
  88398. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  88399. */
  88400. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  88401. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  88402. };
  88403. /**
  88404. * Creates a decal mesh.
  88405. * 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
  88406. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88407. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88408. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88409. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88410. * @param name defines the name of the mesh
  88411. * @param sourceMesh defines the mesh where the decal must be applied
  88412. * @param options defines the options used to create the mesh
  88413. * @param scene defines the hosting scene
  88414. * @returns the decal mesh
  88415. * @see https://doc.babylonjs.com/how_to/decals
  88416. */
  88417. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  88418. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  88419. };
  88420. return MeshBuilder;
  88421. }());
  88422. /***/ }),
  88423. /***/ "./Meshes/meshSimplification.ts":
  88424. /*!**************************************!*\
  88425. !*** ./Meshes/meshSimplification.ts ***!
  88426. \**************************************/
  88427. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  88428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88429. "use strict";
  88430. __webpack_require__.r(__webpack_exports__);
  88431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  88432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  88433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  88434. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88435. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88436. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  88437. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88438. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88439. /**
  88440. * Class used to specify simplification options
  88441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88442. */
  88443. var SimplificationSettings = /** @class */ (function () {
  88444. /**
  88445. * Creates a SimplificationSettings
  88446. * @param quality expected quality
  88447. * @param distance distance when this optimized version should be used
  88448. * @param optimizeMesh already optimized mesh
  88449. */
  88450. function SimplificationSettings(
  88451. /** expected quality */
  88452. quality,
  88453. /** distance when this optimized version should be used */
  88454. distance,
  88455. /** already optimized mesh */
  88456. optimizeMesh) {
  88457. this.quality = quality;
  88458. this.distance = distance;
  88459. this.optimizeMesh = optimizeMesh;
  88460. }
  88461. return SimplificationSettings;
  88462. }());
  88463. /**
  88464. * Queue used to order the simplification tasks
  88465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88466. */
  88467. var SimplificationQueue = /** @class */ (function () {
  88468. /**
  88469. * Creates a new queue
  88470. */
  88471. function SimplificationQueue() {
  88472. this.running = false;
  88473. this._simplificationArray = [];
  88474. }
  88475. /**
  88476. * Adds a new simplification task
  88477. * @param task defines a task to add
  88478. */
  88479. SimplificationQueue.prototype.addTask = function (task) {
  88480. this._simplificationArray.push(task);
  88481. };
  88482. /**
  88483. * Execute next task
  88484. */
  88485. SimplificationQueue.prototype.executeNext = function () {
  88486. var task = this._simplificationArray.pop();
  88487. if (task) {
  88488. this.running = true;
  88489. this.runSimplification(task);
  88490. }
  88491. else {
  88492. this.running = false;
  88493. }
  88494. };
  88495. /**
  88496. * Execute a simplification task
  88497. * @param task defines the task to run
  88498. */
  88499. SimplificationQueue.prototype.runSimplification = function (task) {
  88500. var _this = this;
  88501. if (task.parallelProcessing) {
  88502. //parallel simplifier
  88503. task.settings.forEach(function (setting) {
  88504. var simplifier = _this.getSimplifier(task);
  88505. simplifier.simplify(setting, function (newMesh) {
  88506. task.mesh.addLODLevel(setting.distance, newMesh);
  88507. newMesh.isVisible = true;
  88508. //check if it is the last
  88509. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  88510. //all done, run the success callback.
  88511. task.successCallback();
  88512. }
  88513. _this.executeNext();
  88514. });
  88515. });
  88516. }
  88517. else {
  88518. //single simplifier.
  88519. var simplifier = this.getSimplifier(task);
  88520. var runDecimation = function (setting, callback) {
  88521. simplifier.simplify(setting, function (newMesh) {
  88522. task.mesh.addLODLevel(setting.distance, newMesh);
  88523. newMesh.isVisible = true;
  88524. //run the next quality level
  88525. callback();
  88526. });
  88527. };
  88528. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  88529. runDecimation(task.settings[loop.index], function () {
  88530. loop.executeNext();
  88531. });
  88532. }, function () {
  88533. //execution ended, run the success callback.
  88534. if (task.successCallback) {
  88535. task.successCallback();
  88536. }
  88537. _this.executeNext();
  88538. });
  88539. }
  88540. };
  88541. SimplificationQueue.prototype.getSimplifier = function (task) {
  88542. switch (task.simplificationType) {
  88543. case SimplificationType.QUADRATIC:
  88544. default:
  88545. return new QuadraticErrorSimplification(task.mesh);
  88546. }
  88547. };
  88548. return SimplificationQueue;
  88549. }());
  88550. /**
  88551. * The implemented types of simplification
  88552. * At the moment only Quadratic Error Decimation is implemented
  88553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88554. */
  88555. var SimplificationType;
  88556. (function (SimplificationType) {
  88557. /** Quadratic error decimation */
  88558. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  88559. })(SimplificationType || (SimplificationType = {}));
  88560. var DecimationTriangle = /** @class */ (function () {
  88561. function DecimationTriangle(vertices) {
  88562. this.vertices = vertices;
  88563. this.error = new Array(4);
  88564. this.deleted = false;
  88565. this.isDirty = false;
  88566. this.deletePending = false;
  88567. this.borderFactor = 0;
  88568. }
  88569. return DecimationTriangle;
  88570. }());
  88571. var DecimationVertex = /** @class */ (function () {
  88572. function DecimationVertex(position, id) {
  88573. this.position = position;
  88574. this.id = id;
  88575. this.isBorder = true;
  88576. this.q = new QuadraticMatrix();
  88577. this.triangleCount = 0;
  88578. this.triangleStart = 0;
  88579. this.originalOffsets = [];
  88580. }
  88581. DecimationVertex.prototype.updatePosition = function (newPosition) {
  88582. this.position.copyFrom(newPosition);
  88583. };
  88584. return DecimationVertex;
  88585. }());
  88586. var QuadraticMatrix = /** @class */ (function () {
  88587. function QuadraticMatrix(data) {
  88588. this.data = new Array(10);
  88589. for (var i = 0; i < 10; ++i) {
  88590. if (data && data[i]) {
  88591. this.data[i] = data[i];
  88592. }
  88593. else {
  88594. this.data[i] = 0;
  88595. }
  88596. }
  88597. }
  88598. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  88599. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  88600. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  88601. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  88602. return det;
  88603. };
  88604. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  88605. for (var i = 0; i < 10; ++i) {
  88606. this.data[i] += matrix.data[i];
  88607. }
  88608. };
  88609. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  88610. for (var i = 0; i < 10; ++i) {
  88611. this.data[i] += data[i];
  88612. }
  88613. };
  88614. QuadraticMatrix.prototype.add = function (matrix) {
  88615. var m = new QuadraticMatrix();
  88616. for (var i = 0; i < 10; ++i) {
  88617. m.data[i] = this.data[i] + matrix.data[i];
  88618. }
  88619. return m;
  88620. };
  88621. QuadraticMatrix.FromData = function (a, b, c, d) {
  88622. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  88623. };
  88624. //returning an array to avoid garbage collection
  88625. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  88626. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  88627. };
  88628. return QuadraticMatrix;
  88629. }());
  88630. var Reference = /** @class */ (function () {
  88631. function Reference(vertexId, triangleId) {
  88632. this.vertexId = vertexId;
  88633. this.triangleId = triangleId;
  88634. }
  88635. return Reference;
  88636. }());
  88637. /**
  88638. * An implementation of the Quadratic Error simplification algorithm.
  88639. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  88640. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  88641. * @author RaananW
  88642. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88643. */
  88644. var QuadraticErrorSimplification = /** @class */ (function () {
  88645. function QuadraticErrorSimplification(_mesh) {
  88646. this._mesh = _mesh;
  88647. this.syncIterations = 5000;
  88648. this.aggressiveness = 7;
  88649. this.decimationIterations = 100;
  88650. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  88651. }
  88652. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  88653. var _this = this;
  88654. this.initDecimatedMesh();
  88655. //iterating through the submeshes array, one after the other.
  88656. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  88657. _this.initWithMesh(loop.index, function () {
  88658. _this.runDecimation(settings, loop.index, function () {
  88659. loop.executeNext();
  88660. });
  88661. }, settings.optimizeMesh);
  88662. }, function () {
  88663. setTimeout(function () {
  88664. successCallback(_this._reconstructedMesh);
  88665. }, 0);
  88666. });
  88667. };
  88668. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  88669. var _this = this;
  88670. var targetCount = ~~(this.triangles.length * settings.quality);
  88671. var deletedTriangles = 0;
  88672. var triangleCount = this.triangles.length;
  88673. var iterationFunction = function (iteration, callback) {
  88674. setTimeout(function () {
  88675. if (iteration % 5 === 0) {
  88676. _this.updateMesh(iteration === 0);
  88677. }
  88678. for (var i = 0; i < _this.triangles.length; ++i) {
  88679. _this.triangles[i].isDirty = false;
  88680. }
  88681. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  88682. var trianglesIterator = function (i) {
  88683. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  88684. var t = _this.triangles[tIdx];
  88685. if (!t) {
  88686. return;
  88687. }
  88688. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  88689. return;
  88690. }
  88691. for (var j = 0; j < 3; ++j) {
  88692. if (t.error[j] < threshold) {
  88693. var deleted0 = [];
  88694. var deleted1 = [];
  88695. var v0 = t.vertices[j];
  88696. var v1 = t.vertices[(j + 1) % 3];
  88697. if (v0.isBorder || v1.isBorder) {
  88698. continue;
  88699. }
  88700. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88701. // var n = Vector3.Zero();
  88702. // var uv = Vector2.Zero();
  88703. // var color = new Color4(0, 0, 0, 1);
  88704. _this.calculateError(v0, v1, p);
  88705. var delTr = new Array();
  88706. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  88707. continue;
  88708. }
  88709. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  88710. continue;
  88711. }
  88712. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  88713. continue;
  88714. }
  88715. var uniqueArray = new Array();
  88716. delTr.forEach(function (deletedT) {
  88717. if (uniqueArray.indexOf(deletedT) === -1) {
  88718. deletedT.deletePending = true;
  88719. uniqueArray.push(deletedT);
  88720. }
  88721. });
  88722. if (uniqueArray.length % 2 !== 0) {
  88723. continue;
  88724. }
  88725. v0.q = v1.q.add(v0.q);
  88726. v0.updatePosition(p);
  88727. var tStart = _this.references.length;
  88728. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  88729. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  88730. var tCount = _this.references.length - tStart;
  88731. if (tCount <= v0.triangleCount) {
  88732. if (tCount) {
  88733. for (var c = 0; c < tCount; c++) {
  88734. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  88735. }
  88736. }
  88737. }
  88738. else {
  88739. v0.triangleStart = tStart;
  88740. }
  88741. v0.triangleCount = tCount;
  88742. break;
  88743. }
  88744. }
  88745. };
  88746. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  88747. }, 0);
  88748. };
  88749. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  88750. if (triangleCount - deletedTriangles <= targetCount) {
  88751. loop.breakLoop();
  88752. }
  88753. else {
  88754. iterationFunction(loop.index, function () {
  88755. loop.executeNext();
  88756. });
  88757. }
  88758. }, function () {
  88759. setTimeout(function () {
  88760. //reconstruct this part of the mesh
  88761. _this.reconstructMesh(submeshIndex);
  88762. successCallback();
  88763. }, 0);
  88764. });
  88765. };
  88766. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  88767. var _this = this;
  88768. this.vertices = [];
  88769. this.triangles = [];
  88770. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88771. var indices = this._mesh.getIndices();
  88772. var submesh = this._mesh.subMeshes[submeshIndex];
  88773. var findInVertices = function (positionToSearch) {
  88774. if (optimizeMesh) {
  88775. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  88776. if (_this.vertices[ii].position.equals(positionToSearch)) {
  88777. return _this.vertices[ii];
  88778. }
  88779. }
  88780. }
  88781. return null;
  88782. };
  88783. var vertexReferences = [];
  88784. var vertexInit = function (i) {
  88785. if (!positionData) {
  88786. return;
  88787. }
  88788. var offset = i + submesh.verticesStart;
  88789. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  88790. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  88791. vertex.originalOffsets.push(offset);
  88792. if (vertex.id === _this.vertices.length) {
  88793. _this.vertices.push(vertex);
  88794. }
  88795. vertexReferences.push(vertex.id);
  88796. };
  88797. //var totalVertices = mesh.getTotalVertices();
  88798. var totalVertices = submesh.verticesCount;
  88799. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88800. var indicesInit = function (i) {
  88801. if (!indices) {
  88802. return;
  88803. }
  88804. var offset = (submesh.indexStart / 3) + i;
  88805. var pos = (offset * 3);
  88806. var i0 = indices[pos + 0];
  88807. var i1 = indices[pos + 1];
  88808. var i2 = indices[pos + 2];
  88809. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88810. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88811. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88812. var triangle = new DecimationTriangle([v0, v1, v2]);
  88813. triangle.originalOffset = pos;
  88814. _this.triangles.push(triangle);
  88815. };
  88816. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88817. _this.init(callback);
  88818. });
  88819. });
  88820. };
  88821. QuadraticErrorSimplification.prototype.init = function (callback) {
  88822. var _this = this;
  88823. var triangleInit1 = function (i) {
  88824. var t = _this.triangles[i];
  88825. t.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(t.vertices[1].position.subtract(t.vertices[0].position), t.vertices[2].position.subtract(t.vertices[0].position)).normalize();
  88826. for (var j = 0; j < 3; j++) {
  88827. t.vertices[j].q.addArrayInPlace(QuadraticMatrix.DataFromNumbers(t.normal.x, t.normal.y, t.normal.z, -(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(t.normal, t.vertices[0].position))));
  88828. }
  88829. };
  88830. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  88831. var triangleInit2 = function (i) {
  88832. var t = _this.triangles[i];
  88833. for (var j = 0; j < 3; ++j) {
  88834. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  88835. }
  88836. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88837. };
  88838. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  88839. callback();
  88840. });
  88841. });
  88842. };
  88843. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  88844. var newTriangles = [];
  88845. var i;
  88846. for (i = 0; i < this.vertices.length; ++i) {
  88847. this.vertices[i].triangleCount = 0;
  88848. }
  88849. var t;
  88850. var j;
  88851. for (i = 0; i < this.triangles.length; ++i) {
  88852. if (!this.triangles[i].deleted) {
  88853. t = this.triangles[i];
  88854. for (j = 0; j < 3; ++j) {
  88855. t.vertices[j].triangleCount = 1;
  88856. }
  88857. newTriangles.push(t);
  88858. }
  88859. }
  88860. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  88861. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  88862. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  88863. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  88864. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88865. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88866. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88867. var vertexCount = 0;
  88868. for (i = 0; i < this.vertices.length; ++i) {
  88869. var vertex = this.vertices[i];
  88870. vertex.id = vertexCount;
  88871. if (vertex.triangleCount) {
  88872. vertex.originalOffsets.forEach(function (originalOffset) {
  88873. if (!normalData) {
  88874. return;
  88875. }
  88876. newPositionData.push(vertex.position.x);
  88877. newPositionData.push(vertex.position.y);
  88878. newPositionData.push(vertex.position.z);
  88879. newNormalData.push(normalData[originalOffset * 3]);
  88880. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  88881. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  88882. if (uvs && uvs.length) {
  88883. newUVsData.push(uvs[(originalOffset * 2)]);
  88884. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  88885. }
  88886. else if (colorsData && colorsData.length) {
  88887. newColorsData.push(colorsData[(originalOffset * 4)]);
  88888. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  88889. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  88890. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  88891. }
  88892. ++vertexCount;
  88893. });
  88894. }
  88895. }
  88896. var startingIndex = this._reconstructedMesh.getTotalIndices();
  88897. var startingVertex = this._reconstructedMesh.getTotalVertices();
  88898. var submeshesArray = this._reconstructedMesh.subMeshes;
  88899. this._reconstructedMesh.subMeshes = [];
  88900. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  88901. var originalIndices = this._mesh.getIndices();
  88902. for (i = 0; i < newTriangles.length; ++i) {
  88903. t = newTriangles[i]; //now get the new referencing point for each vertex
  88904. [0, 1, 2].forEach(function (idx) {
  88905. var id = originalIndices[t.originalOffset + idx];
  88906. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  88907. if (offset < 0) {
  88908. offset = 0;
  88909. }
  88910. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  88911. });
  88912. }
  88913. //overwriting the old vertex buffers and indices.
  88914. this._reconstructedMesh.setIndices(newIndicesArray);
  88915. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  88916. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  88917. if (newUVsData.length > 0) {
  88918. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  88919. }
  88920. if (newColorsData.length > 0) {
  88921. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  88922. }
  88923. //create submesh
  88924. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  88925. if (submeshIndex > 0) {
  88926. this._reconstructedMesh.subMeshes = [];
  88927. submeshesArray.forEach(function (submesh) {
  88928. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  88929. });
  88930. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  88931. }
  88932. };
  88933. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  88934. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  88935. this._reconstructedMesh.material = this._mesh.material;
  88936. this._reconstructedMesh.parent = this._mesh.parent;
  88937. this._reconstructedMesh.isVisible = false;
  88938. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  88939. };
  88940. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  88941. for (var i = 0; i < vertex1.triangleCount; ++i) {
  88942. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  88943. if (t.deleted) {
  88944. continue;
  88945. }
  88946. var s = this.references[vertex1.triangleStart + i].vertexId;
  88947. var v1 = t.vertices[(s + 1) % 3];
  88948. var v2 = t.vertices[(s + 2) % 3];
  88949. if ((v1 === vertex2 || v2 === vertex2)) {
  88950. deletedArray[i] = true;
  88951. delTr.push(t);
  88952. continue;
  88953. }
  88954. var d1 = v1.position.subtract(point);
  88955. d1 = d1.normalize();
  88956. var d2 = v2.position.subtract(point);
  88957. d2 = d2.normalize();
  88958. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  88959. return true;
  88960. }
  88961. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  88962. deletedArray[i] = false;
  88963. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  88964. return true;
  88965. }
  88966. }
  88967. return false;
  88968. };
  88969. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  88970. var newDeleted = deletedTriangles;
  88971. for (var i = 0; i < vertex.triangleCount; ++i) {
  88972. var ref = this.references[vertex.triangleStart + i];
  88973. var t = this.triangles[ref.triangleId];
  88974. if (t.deleted) {
  88975. continue;
  88976. }
  88977. if (deletedArray[i] && t.deletePending) {
  88978. t.deleted = true;
  88979. newDeleted++;
  88980. continue;
  88981. }
  88982. t.vertices[ref.vertexId] = origVertex;
  88983. t.isDirty = true;
  88984. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  88985. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  88986. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  88987. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88988. this.references.push(ref);
  88989. }
  88990. return newDeleted;
  88991. };
  88992. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  88993. for (var i = 0; i < this.vertices.length; ++i) {
  88994. var vCount = [];
  88995. var vId = [];
  88996. var v = this.vertices[i];
  88997. var j;
  88998. for (j = 0; j < v.triangleCount; ++j) {
  88999. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  89000. for (var ii = 0; ii < 3; ii++) {
  89001. var ofs = 0;
  89002. var vv = triangle.vertices[ii];
  89003. while (ofs < vCount.length) {
  89004. if (vId[ofs] === vv.id) {
  89005. break;
  89006. }
  89007. ++ofs;
  89008. }
  89009. if (ofs === vCount.length) {
  89010. vCount.push(1);
  89011. vId.push(vv.id);
  89012. }
  89013. else {
  89014. vCount[ofs]++;
  89015. }
  89016. }
  89017. }
  89018. for (j = 0; j < vCount.length; ++j) {
  89019. if (vCount[j] === 1) {
  89020. this.vertices[vId[j]].isBorder = true;
  89021. }
  89022. else {
  89023. this.vertices[vId[j]].isBorder = false;
  89024. }
  89025. }
  89026. }
  89027. };
  89028. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  89029. if (identifyBorders === void 0) { identifyBorders = false; }
  89030. var i;
  89031. if (!identifyBorders) {
  89032. var newTrianglesVector = [];
  89033. for (i = 0; i < this.triangles.length; ++i) {
  89034. if (!this.triangles[i].deleted) {
  89035. newTrianglesVector.push(this.triangles[i]);
  89036. }
  89037. }
  89038. this.triangles = newTrianglesVector;
  89039. }
  89040. for (i = 0; i < this.vertices.length; ++i) {
  89041. this.vertices[i].triangleCount = 0;
  89042. this.vertices[i].triangleStart = 0;
  89043. }
  89044. var t;
  89045. var j;
  89046. var v;
  89047. for (i = 0; i < this.triangles.length; ++i) {
  89048. t = this.triangles[i];
  89049. for (j = 0; j < 3; ++j) {
  89050. v = t.vertices[j];
  89051. v.triangleCount++;
  89052. }
  89053. }
  89054. var tStart = 0;
  89055. for (i = 0; i < this.vertices.length; ++i) {
  89056. this.vertices[i].triangleStart = tStart;
  89057. tStart += this.vertices[i].triangleCount;
  89058. this.vertices[i].triangleCount = 0;
  89059. }
  89060. var newReferences = new Array(this.triangles.length * 3);
  89061. for (i = 0; i < this.triangles.length; ++i) {
  89062. t = this.triangles[i];
  89063. for (j = 0; j < 3; ++j) {
  89064. v = t.vertices[j];
  89065. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  89066. v.triangleCount++;
  89067. }
  89068. }
  89069. this.references = newReferences;
  89070. if (identifyBorders) {
  89071. this.identifyBorder();
  89072. }
  89073. };
  89074. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  89075. var x = point.x;
  89076. var y = point.y;
  89077. var z = point.z;
  89078. 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
  89079. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  89080. };
  89081. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  89082. var q = vertex1.q.add(vertex2.q);
  89083. var border = vertex1.isBorder && vertex2.isBorder;
  89084. var error = 0;
  89085. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  89086. if (qDet !== 0 && !border) {
  89087. if (!pointResult) {
  89088. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89089. }
  89090. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  89091. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  89092. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  89093. error = this.vertexError(q, pointResult);
  89094. }
  89095. else {
  89096. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  89097. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  89098. var error1 = this.vertexError(q, vertex1.position);
  89099. var error2 = this.vertexError(q, vertex2.position);
  89100. var error3 = this.vertexError(q, p3);
  89101. error = Math.min(error1, error2, error3);
  89102. if (error === error1) {
  89103. if (pointResult) {
  89104. pointResult.copyFrom(vertex1.position);
  89105. }
  89106. }
  89107. else if (error === error2) {
  89108. if (pointResult) {
  89109. pointResult.copyFrom(vertex2.position);
  89110. }
  89111. }
  89112. else {
  89113. if (pointResult) {
  89114. pointResult.copyFrom(p3);
  89115. }
  89116. }
  89117. }
  89118. return error;
  89119. };
  89120. return QuadraticErrorSimplification;
  89121. }());
  89122. /***/ }),
  89123. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  89124. /*!****************************************************!*\
  89125. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  89126. \****************************************************/
  89127. /*! exports provided: SimplicationQueueSceneComponent */
  89128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89129. "use strict";
  89130. __webpack_require__.r(__webpack_exports__);
  89131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  89132. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  89133. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  89134. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  89135. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89136. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  89137. get: function () {
  89138. if (!this._simplificationQueue) {
  89139. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  89140. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  89141. if (!component) {
  89142. component = new SimplicationQueueSceneComponent(this);
  89143. this._addComponent(component);
  89144. }
  89145. }
  89146. return this._simplificationQueue;
  89147. },
  89148. set: function (value) {
  89149. this._simplificationQueue = value;
  89150. },
  89151. enumerable: true,
  89152. configurable: true
  89153. });
  89154. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  89155. if (parallelProcessing === void 0) { parallelProcessing = true; }
  89156. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  89157. this.getScene().simplificationQueue.addTask({
  89158. settings: settings,
  89159. parallelProcessing: parallelProcessing,
  89160. mesh: this,
  89161. simplificationType: simplificationType,
  89162. successCallback: successCallback
  89163. });
  89164. return this;
  89165. };
  89166. /**
  89167. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  89168. * created in a scene
  89169. */
  89170. var SimplicationQueueSceneComponent = /** @class */ (function () {
  89171. /**
  89172. * Creates a new instance of the component for the given scene
  89173. * @param scene Defines the scene to register the component in
  89174. */
  89175. function SimplicationQueueSceneComponent(scene) {
  89176. /**
  89177. * The component name helpfull to identify the component in the list of scene components.
  89178. */
  89179. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89180. this.scene = scene;
  89181. }
  89182. /**
  89183. * Registers the component in a given scene
  89184. */
  89185. SimplicationQueueSceneComponent.prototype.register = function () {
  89186. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89187. };
  89188. /**
  89189. * Rebuilds the elements related to this component in case of
  89190. * context lost for instance.
  89191. */
  89192. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89193. // Nothing to do for this component
  89194. };
  89195. /**
  89196. * Disposes the component and the associated ressources
  89197. */
  89198. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89199. // Nothing to do for this component
  89200. };
  89201. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89202. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89203. this.scene._simplificationQueue.executeNext();
  89204. }
  89205. };
  89206. return SimplicationQueueSceneComponent;
  89207. }());
  89208. /***/ }),
  89209. /***/ "./Meshes/polygonMesh.ts":
  89210. /*!*******************************!*\
  89211. !*** ./Meshes/polygonMesh.ts ***!
  89212. \*******************************/
  89213. /*! exports provided: Polygon, PolygonMeshBuilder */
  89214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89215. "use strict";
  89216. __webpack_require__.r(__webpack_exports__);
  89217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89219. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89220. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89222. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89223. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89224. /**
  89225. * Vector2 wth index property
  89226. */
  89227. var IndexedVector2 = /** @class */ (function (_super) {
  89228. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89229. function IndexedVector2(original,
  89230. /** Index of the vector2 */
  89231. index) {
  89232. var _this = _super.call(this, original.x, original.y) || this;
  89233. _this.index = index;
  89234. return _this;
  89235. }
  89236. return IndexedVector2;
  89237. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89238. /**
  89239. * Defines points to create a polygon
  89240. */
  89241. var PolygonPoints = /** @class */ (function () {
  89242. function PolygonPoints() {
  89243. this.elements = new Array();
  89244. }
  89245. PolygonPoints.prototype.add = function (originalPoints) {
  89246. var _this = this;
  89247. var result = new Array();
  89248. originalPoints.forEach(function (point) {
  89249. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89250. var newPoint = new IndexedVector2(point, _this.elements.length);
  89251. result.push(newPoint);
  89252. _this.elements.push(newPoint);
  89253. }
  89254. });
  89255. return result;
  89256. };
  89257. PolygonPoints.prototype.computeBounds = function () {
  89258. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89259. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89260. this.elements.forEach(function (point) {
  89261. // x
  89262. if (point.x < lmin.x) {
  89263. lmin.x = point.x;
  89264. }
  89265. else if (point.x > lmax.x) {
  89266. lmax.x = point.x;
  89267. }
  89268. // y
  89269. if (point.y < lmin.y) {
  89270. lmin.y = point.y;
  89271. }
  89272. else if (point.y > lmax.y) {
  89273. lmax.y = point.y;
  89274. }
  89275. });
  89276. return {
  89277. min: lmin,
  89278. max: lmax,
  89279. width: lmax.x - lmin.x,
  89280. height: lmax.y - lmin.y
  89281. };
  89282. };
  89283. return PolygonPoints;
  89284. }());
  89285. /**
  89286. * Polygon
  89287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89288. */
  89289. var Polygon = /** @class */ (function () {
  89290. function Polygon() {
  89291. }
  89292. /**
  89293. * Creates a rectangle
  89294. * @param xmin bottom X coord
  89295. * @param ymin bottom Y coord
  89296. * @param xmax top X coord
  89297. * @param ymax top Y coord
  89298. * @returns points that make the resulting rectation
  89299. */
  89300. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89301. return [
  89302. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89303. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89304. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89305. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89306. ];
  89307. };
  89308. /**
  89309. * Creates a circle
  89310. * @param radius radius of circle
  89311. * @param cx scale in x
  89312. * @param cy scale in y
  89313. * @param numberOfSides number of sides that make up the circle
  89314. * @returns points that make the resulting circle
  89315. */
  89316. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89317. if (cx === void 0) { cx = 0; }
  89318. if (cy === void 0) { cy = 0; }
  89319. if (numberOfSides === void 0) { numberOfSides = 32; }
  89320. var result = new Array();
  89321. var angle = 0;
  89322. var increment = (Math.PI * 2) / numberOfSides;
  89323. for (var i = 0; i < numberOfSides; i++) {
  89324. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89325. angle -= increment;
  89326. }
  89327. return result;
  89328. };
  89329. /**
  89330. * Creates a polygon from input string
  89331. * @param input Input polygon data
  89332. * @returns the parsed points
  89333. */
  89334. Polygon.Parse = function (input) {
  89335. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89336. var i, result = [];
  89337. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89338. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89339. }
  89340. return result;
  89341. };
  89342. /**
  89343. * Starts building a polygon from x and y coordinates
  89344. * @param x x coordinate
  89345. * @param y y coordinate
  89346. * @returns the started path2
  89347. */
  89348. Polygon.StartingAt = function (x, y) {
  89349. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  89350. };
  89351. return Polygon;
  89352. }());
  89353. /**
  89354. * Builds a polygon
  89355. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  89356. */
  89357. var PolygonMeshBuilder = /** @class */ (function () {
  89358. /**
  89359. * Creates a PolygonMeshBuilder
  89360. * @param name name of the builder
  89361. * @param contours Path of the polygon
  89362. * @param scene scene to add to
  89363. * @param earcutInjection can be used to inject your own earcut reference
  89364. */
  89365. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  89366. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89367. this._points = new PolygonPoints();
  89368. this._outlinepoints = new PolygonPoints();
  89369. this._holes = new Array();
  89370. this._epoints = new Array();
  89371. this._eholes = new Array();
  89372. this.bjsEarcut = earcutInjection;
  89373. this._name = name;
  89374. this._scene = scene;
  89375. var points;
  89376. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  89377. points = contours.getPoints();
  89378. }
  89379. else {
  89380. points = contours;
  89381. }
  89382. this._addToepoint(points);
  89383. this._points.add(points);
  89384. this._outlinepoints.add(points);
  89385. if (typeof this.bjsEarcut === 'undefined') {
  89386. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  89387. }
  89388. }
  89389. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  89390. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  89391. var p = points_1[_i];
  89392. this._epoints.push(p.x, p.y);
  89393. }
  89394. };
  89395. /**
  89396. * Adds a whole within the polygon
  89397. * @param hole Array of points defining the hole
  89398. * @returns this
  89399. */
  89400. PolygonMeshBuilder.prototype.addHole = function (hole) {
  89401. this._points.add(hole);
  89402. var holepoints = new PolygonPoints();
  89403. holepoints.add(hole);
  89404. this._holes.push(holepoints);
  89405. this._eholes.push(this._epoints.length / 2);
  89406. this._addToepoint(hole);
  89407. return this;
  89408. };
  89409. /**
  89410. * Creates the polygon
  89411. * @param updatable If the mesh should be updatable
  89412. * @param depth The depth of the mesh created
  89413. * @returns the created mesh
  89414. */
  89415. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  89416. var _this = this;
  89417. if (updatable === void 0) { updatable = false; }
  89418. if (depth === void 0) { depth = 0; }
  89419. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  89420. var normals = new Array();
  89421. var positions = new Array();
  89422. var uvs = new Array();
  89423. var bounds = this._points.computeBounds();
  89424. this._points.elements.forEach(function (p) {
  89425. normals.push(0, 1.0, 0);
  89426. positions.push(p.x, 0, p.y);
  89427. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  89428. });
  89429. var indices = new Array();
  89430. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  89431. for (var i = 0; i < res.length; i++) {
  89432. indices.push(res[i]);
  89433. }
  89434. if (depth > 0) {
  89435. var positionscount = (positions.length / 3); //get the current pointcount
  89436. this._points.elements.forEach(function (p) {
  89437. normals.push(0, -1.0, 0);
  89438. positions.push(p.x, -depth, p.y);
  89439. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  89440. });
  89441. var totalCount = indices.length;
  89442. for (var i = 0; i < totalCount; i += 3) {
  89443. var i0 = indices[i + 0];
  89444. var i1 = indices[i + 1];
  89445. var i2 = indices[i + 2];
  89446. indices.push(i2 + positionscount);
  89447. indices.push(i1 + positionscount);
  89448. indices.push(i0 + positionscount);
  89449. }
  89450. //Add the sides
  89451. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  89452. this._holes.forEach(function (hole) {
  89453. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  89454. });
  89455. }
  89456. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  89457. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  89458. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  89459. result.setIndices(indices);
  89460. return result;
  89461. };
  89462. /**
  89463. * Adds a side to the polygon
  89464. * @param positions points that make the polygon
  89465. * @param normals normals of the polygon
  89466. * @param uvs uvs of the polygon
  89467. * @param indices indices of the polygon
  89468. * @param bounds bounds of the polygon
  89469. * @param points points of the polygon
  89470. * @param depth depth of the polygon
  89471. * @param flip flip of the polygon
  89472. */
  89473. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  89474. var StartIndex = positions.length / 3;
  89475. var ulength = 0;
  89476. for (var i = 0; i < points.elements.length; i++) {
  89477. var p = points.elements[i];
  89478. var p1;
  89479. if ((i + 1) > points.elements.length - 1) {
  89480. p1 = points.elements[0];
  89481. }
  89482. else {
  89483. p1 = points.elements[i + 1];
  89484. }
  89485. positions.push(p.x, 0, p.y);
  89486. positions.push(p.x, -depth, p.y);
  89487. positions.push(p1.x, 0, p1.y);
  89488. positions.push(p1.x, -depth, p1.y);
  89489. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  89490. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  89491. var v3 = v2.subtract(v1);
  89492. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  89493. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  89494. vn = vn.normalize();
  89495. uvs.push(ulength / bounds.width, 0);
  89496. uvs.push(ulength / bounds.width, 1);
  89497. ulength += v3.length();
  89498. uvs.push((ulength / bounds.width), 0);
  89499. uvs.push((ulength / bounds.width), 1);
  89500. if (!flip) {
  89501. normals.push(-vn.x, -vn.y, -vn.z);
  89502. normals.push(-vn.x, -vn.y, -vn.z);
  89503. normals.push(-vn.x, -vn.y, -vn.z);
  89504. normals.push(-vn.x, -vn.y, -vn.z);
  89505. indices.push(StartIndex);
  89506. indices.push(StartIndex + 1);
  89507. indices.push(StartIndex + 2);
  89508. indices.push(StartIndex + 1);
  89509. indices.push(StartIndex + 3);
  89510. indices.push(StartIndex + 2);
  89511. }
  89512. else {
  89513. normals.push(vn.x, vn.y, vn.z);
  89514. normals.push(vn.x, vn.y, vn.z);
  89515. normals.push(vn.x, vn.y, vn.z);
  89516. normals.push(vn.x, vn.y, vn.z);
  89517. indices.push(StartIndex);
  89518. indices.push(StartIndex + 2);
  89519. indices.push(StartIndex + 1);
  89520. indices.push(StartIndex + 1);
  89521. indices.push(StartIndex + 2);
  89522. indices.push(StartIndex + 3);
  89523. }
  89524. StartIndex += 4;
  89525. }
  89526. };
  89527. return PolygonMeshBuilder;
  89528. }());
  89529. /***/ }),
  89530. /***/ "./Meshes/subMesh.ts":
  89531. /*!***************************!*\
  89532. !*** ./Meshes/subMesh.ts ***!
  89533. \***************************/
  89534. /*! exports provided: BaseSubMesh, SubMesh */
  89535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89536. "use strict";
  89537. __webpack_require__.r(__webpack_exports__);
  89538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  89539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  89540. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89541. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89542. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89543. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  89544. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89545. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89546. /**
  89547. * Base class for submeshes
  89548. */
  89549. var BaseSubMesh = /** @class */ (function () {
  89550. function BaseSubMesh() {
  89551. }
  89552. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  89553. /**
  89554. * Gets associated effect
  89555. */
  89556. get: function () {
  89557. return this._materialEffect;
  89558. },
  89559. enumerable: true,
  89560. configurable: true
  89561. });
  89562. /**
  89563. * Sets associated effect (effect used to render this submesh)
  89564. * @param effect defines the effect to associate with
  89565. * @param defines defines the set of defines used to compile this effect
  89566. */
  89567. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  89568. if (defines === void 0) { defines = null; }
  89569. if (this._materialEffect === effect) {
  89570. if (!effect) {
  89571. this._materialDefines = null;
  89572. }
  89573. return;
  89574. }
  89575. this._materialDefines = defines;
  89576. this._materialEffect = effect;
  89577. };
  89578. return BaseSubMesh;
  89579. }());
  89580. /**
  89581. * Defines a subdivision inside a mesh
  89582. */
  89583. var SubMesh = /** @class */ (function (_super) {
  89584. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  89585. /**
  89586. * Creates a new submesh
  89587. * @param materialIndex defines the material index to use
  89588. * @param verticesStart defines vertex index start
  89589. * @param verticesCount defines vertices count
  89590. * @param indexStart defines index start
  89591. * @param indexCount defines indices count
  89592. * @param mesh defines the parent mesh
  89593. * @param renderingMesh defines an optional rendering mesh
  89594. * @param createBoundingBox defines if bounding box should be created for this submesh
  89595. */
  89596. function SubMesh(
  89597. /** the material index to use */
  89598. materialIndex,
  89599. /** vertex index start */
  89600. verticesStart,
  89601. /** vertices count */
  89602. verticesCount,
  89603. /** index start */
  89604. indexStart,
  89605. /** indices count */
  89606. indexCount, mesh, renderingMesh, createBoundingBox) {
  89607. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89608. var _this = _super.call(this) || this;
  89609. _this.materialIndex = materialIndex;
  89610. _this.verticesStart = verticesStart;
  89611. _this.verticesCount = verticesCount;
  89612. _this.indexStart = indexStart;
  89613. _this.indexCount = indexCount;
  89614. /** @hidden */
  89615. _this._renderId = 0;
  89616. _this._mesh = mesh;
  89617. _this._renderingMesh = renderingMesh || mesh;
  89618. mesh.subMeshes.push(_this);
  89619. _this._trianglePlanes = [];
  89620. _this._id = mesh.subMeshes.length - 1;
  89621. if (createBoundingBox) {
  89622. _this.refreshBoundingInfo();
  89623. mesh.computeWorldMatrix(true);
  89624. }
  89625. return _this;
  89626. }
  89627. /**
  89628. * Add a new submesh to a mesh
  89629. * @param materialIndex defines the material index to use
  89630. * @param verticesStart defines vertex index start
  89631. * @param verticesCount defines vertices count
  89632. * @param indexStart defines index start
  89633. * @param indexCount defines indices count
  89634. * @param mesh defines the parent mesh
  89635. * @param renderingMesh defines an optional rendering mesh
  89636. * @param createBoundingBox defines if bounding box should be created for this submesh
  89637. * @returns the new submesh
  89638. */
  89639. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  89640. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89641. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  89642. };
  89643. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  89644. /**
  89645. * Returns true if this submesh covers the entire parent mesh
  89646. * @ignorenaming
  89647. */
  89648. get: function () {
  89649. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  89650. },
  89651. enumerable: true,
  89652. configurable: true
  89653. });
  89654. /**
  89655. * Returns the submesh BoudingInfo object
  89656. * @returns current bounding info (or mesh's one if the submesh is global)
  89657. */
  89658. SubMesh.prototype.getBoundingInfo = function () {
  89659. if (this.IsGlobal) {
  89660. return this._mesh.getBoundingInfo();
  89661. }
  89662. return this._boundingInfo;
  89663. };
  89664. /**
  89665. * Sets the submesh BoundingInfo
  89666. * @param boundingInfo defines the new bounding info to use
  89667. * @returns the SubMesh
  89668. */
  89669. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  89670. this._boundingInfo = boundingInfo;
  89671. return this;
  89672. };
  89673. /**
  89674. * Returns the mesh of the current submesh
  89675. * @return the parent mesh
  89676. */
  89677. SubMesh.prototype.getMesh = function () {
  89678. return this._mesh;
  89679. };
  89680. /**
  89681. * Returns the rendering mesh of the submesh
  89682. * @returns the rendering mesh (could be different from parent mesh)
  89683. */
  89684. SubMesh.prototype.getRenderingMesh = function () {
  89685. return this._renderingMesh;
  89686. };
  89687. /**
  89688. * Returns the submesh material
  89689. * @returns null or the current material
  89690. */
  89691. SubMesh.prototype.getMaterial = function () {
  89692. var rootMaterial = this._renderingMesh.material;
  89693. if (rootMaterial === null || rootMaterial === undefined) {
  89694. return this._mesh.getScene().defaultMaterial;
  89695. }
  89696. else if (rootMaterial.getSubMaterial) {
  89697. var multiMaterial = rootMaterial;
  89698. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  89699. if (this._currentMaterial !== effectiveMaterial) {
  89700. this._currentMaterial = effectiveMaterial;
  89701. this._materialDefines = null;
  89702. }
  89703. return effectiveMaterial;
  89704. }
  89705. return rootMaterial;
  89706. };
  89707. // Methods
  89708. /**
  89709. * Sets a new updated BoundingInfo object to the submesh
  89710. * @returns the SubMesh
  89711. */
  89712. SubMesh.prototype.refreshBoundingInfo = function () {
  89713. this._lastColliderWorldVertices = null;
  89714. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  89715. return this;
  89716. }
  89717. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  89718. if (!data) {
  89719. this._boundingInfo = this._mesh.getBoundingInfo();
  89720. return this;
  89721. }
  89722. var indices = this._renderingMesh.getIndices();
  89723. var extend;
  89724. //is this the only submesh?
  89725. if (this.indexStart === 0 && this.indexCount === indices.length) {
  89726. var boundingInfo = this._renderingMesh.getBoundingInfo();
  89727. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  89728. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  89729. }
  89730. else {
  89731. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  89732. }
  89733. if (this._boundingInfo) {
  89734. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  89735. }
  89736. else {
  89737. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  89738. }
  89739. return this;
  89740. };
  89741. /** @hidden */
  89742. SubMesh.prototype._checkCollision = function (collider) {
  89743. var boundingInfo = this.getBoundingInfo();
  89744. return boundingInfo._checkCollision(collider);
  89745. };
  89746. /**
  89747. * Updates the submesh BoundingInfo
  89748. * @param world defines the world matrix to use to update the bounding info
  89749. * @returns the submesh
  89750. */
  89751. SubMesh.prototype.updateBoundingInfo = function (world) {
  89752. var boundingInfo = this.getBoundingInfo();
  89753. if (!boundingInfo) {
  89754. this.refreshBoundingInfo();
  89755. boundingInfo = this.getBoundingInfo();
  89756. }
  89757. boundingInfo.update(world);
  89758. return this;
  89759. };
  89760. /**
  89761. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89762. * @param frustumPlanes defines the frustum planes
  89763. * @returns true if the submesh is intersecting with the frustum
  89764. */
  89765. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  89766. var boundingInfo = this.getBoundingInfo();
  89767. if (!boundingInfo) {
  89768. return false;
  89769. }
  89770. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  89771. };
  89772. /**
  89773. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89774. * @param frustumPlanes defines the frustum planes
  89775. * @returns true if the submesh is inside the frustum
  89776. */
  89777. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  89778. var boundingInfo = this.getBoundingInfo();
  89779. if (!boundingInfo) {
  89780. return false;
  89781. }
  89782. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  89783. };
  89784. /**
  89785. * Renders the submesh
  89786. * @param enableAlphaMode defines if alpha needs to be used
  89787. * @returns the submesh
  89788. */
  89789. SubMesh.prototype.render = function (enableAlphaMode) {
  89790. this._renderingMesh.render(this, enableAlphaMode);
  89791. return this;
  89792. };
  89793. /**
  89794. * @hidden
  89795. */
  89796. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  89797. if (!this._linesIndexBuffer) {
  89798. var linesIndices = [];
  89799. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89800. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89801. }
  89802. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89803. this._linesIndexCount = linesIndices.length;
  89804. }
  89805. return this._linesIndexBuffer;
  89806. };
  89807. /**
  89808. * Checks if the submesh intersects with a ray
  89809. * @param ray defines the ray to test
  89810. * @returns true is the passed ray intersects the submesh bounding box
  89811. */
  89812. SubMesh.prototype.canIntersects = function (ray) {
  89813. var boundingInfo = this.getBoundingInfo();
  89814. if (!boundingInfo) {
  89815. return false;
  89816. }
  89817. return ray.intersectsBox(boundingInfo.boundingBox);
  89818. };
  89819. /**
  89820. * Intersects current submesh with a ray
  89821. * @param ray defines the ray to test
  89822. * @param positions defines mesh's positions array
  89823. * @param indices defines mesh's indices array
  89824. * @param fastCheck defines if only bounding info should be used
  89825. * @returns intersection info or null if no intersection
  89826. */
  89827. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  89828. var material = this.getMaterial();
  89829. if (!material) {
  89830. return null;
  89831. }
  89832. switch (material.fillMode) {
  89833. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  89834. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  89835. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  89836. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  89837. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  89838. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  89839. return null;
  89840. }
  89841. // LineMesh first as it's also a Mesh...
  89842. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  89843. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  89844. }
  89845. return this._intersectTriangles(ray, positions, indices, fastCheck);
  89846. };
  89847. /** @hidden */
  89848. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  89849. var intersectInfo = null;
  89850. // Line test
  89851. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  89852. var p0 = positions[indices[index]];
  89853. var p1 = positions[indices[index + 1]];
  89854. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  89855. if (length < 0) {
  89856. continue;
  89857. }
  89858. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  89859. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  89860. intersectInfo.faceId = index / 2;
  89861. if (fastCheck) {
  89862. break;
  89863. }
  89864. }
  89865. }
  89866. return intersectInfo;
  89867. };
  89868. /** @hidden */
  89869. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  89870. var intersectInfo = null;
  89871. // Triangles test
  89872. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89873. var p0 = positions[indices[index]];
  89874. var p1 = positions[indices[index + 1]];
  89875. var p2 = positions[indices[index + 2]];
  89876. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  89877. if (currentIntersectInfo) {
  89878. if (currentIntersectInfo.distance < 0) {
  89879. continue;
  89880. }
  89881. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  89882. intersectInfo = currentIntersectInfo;
  89883. intersectInfo.faceId = index / 3;
  89884. if (fastCheck) {
  89885. break;
  89886. }
  89887. }
  89888. }
  89889. }
  89890. return intersectInfo;
  89891. };
  89892. /** @hidden */
  89893. SubMesh.prototype._rebuild = function () {
  89894. if (this._linesIndexBuffer) {
  89895. this._linesIndexBuffer = null;
  89896. }
  89897. };
  89898. // Clone
  89899. /**
  89900. * Creates a new submesh from the passed mesh
  89901. * @param newMesh defines the new hosting mesh
  89902. * @param newRenderingMesh defines an optional rendering mesh
  89903. * @returns the new submesh
  89904. */
  89905. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  89906. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  89907. if (!this.IsGlobal) {
  89908. var boundingInfo = this.getBoundingInfo();
  89909. if (!boundingInfo) {
  89910. return result;
  89911. }
  89912. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  89913. }
  89914. return result;
  89915. };
  89916. // Dispose
  89917. /**
  89918. * Release associated resources
  89919. */
  89920. SubMesh.prototype.dispose = function () {
  89921. if (this._linesIndexBuffer) {
  89922. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  89923. this._linesIndexBuffer = null;
  89924. }
  89925. // Remove from mesh
  89926. var index = this._mesh.subMeshes.indexOf(this);
  89927. this._mesh.subMeshes.splice(index, 1);
  89928. };
  89929. /**
  89930. * Gets the class name
  89931. * @returns the string "SubMesh".
  89932. */
  89933. SubMesh.prototype.getClassName = function () {
  89934. return "SubMesh";
  89935. };
  89936. // Statics
  89937. /**
  89938. * Creates a new submesh from indices data
  89939. * @param materialIndex the index of the main mesh material
  89940. * @param startIndex the index where to start the copy in the mesh indices array
  89941. * @param indexCount the number of indices to copy then from the startIndex
  89942. * @param mesh the main mesh to create the submesh from
  89943. * @param renderingMesh the optional rendering mesh
  89944. * @returns a new submesh
  89945. */
  89946. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  89947. var minVertexIndex = Number.MAX_VALUE;
  89948. var maxVertexIndex = -Number.MAX_VALUE;
  89949. var whatWillRender = (renderingMesh || mesh);
  89950. var indices = whatWillRender.getIndices();
  89951. for (var index = startIndex; index < startIndex + indexCount; index++) {
  89952. var vertexIndex = indices[index];
  89953. if (vertexIndex < minVertexIndex) {
  89954. minVertexIndex = vertexIndex;
  89955. }
  89956. if (vertexIndex > maxVertexIndex) {
  89957. maxVertexIndex = vertexIndex;
  89958. }
  89959. }
  89960. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  89961. };
  89962. return SubMesh;
  89963. }(BaseSubMesh));
  89964. /***/ }),
  89965. /***/ "./Meshes/transformNode.ts":
  89966. /*!*********************************!*\
  89967. !*** ./Meshes/transformNode.ts ***!
  89968. \*********************************/
  89969. /*! exports provided: TransformNode */
  89970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89971. "use strict";
  89972. __webpack_require__.r(__webpack_exports__);
  89973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  89974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89975. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  89976. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  89977. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89978. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  89979. /**
  89980. * 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.
  89981. * @see https://doc.babylonjs.com/how_to/transformnode
  89982. */
  89983. var TransformNode = /** @class */ (function (_super) {
  89984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  89985. function TransformNode(name, scene, isPure) {
  89986. if (scene === void 0) { scene = null; }
  89987. if (isPure === void 0) { isPure = true; }
  89988. var _this = _super.call(this, name, scene) || this;
  89989. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  89990. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  89991. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  89992. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  89993. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  89994. // Properties
  89995. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  89996. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  89997. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  89998. _this._isDirty = false;
  89999. /**
  90000. * Set the billboard mode. Default is 0.
  90001. *
  90002. * | Value | Type | Description |
  90003. * | --- | --- | --- |
  90004. * | 0 | BILLBOARDMODE_NONE | |
  90005. * | 1 | BILLBOARDMODE_X | |
  90006. * | 2 | BILLBOARDMODE_Y | |
  90007. * | 4 | BILLBOARDMODE_Z | |
  90008. * | 7 | BILLBOARDMODE_ALL | |
  90009. *
  90010. */
  90011. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  90012. /**
  90013. * 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
  90014. */
  90015. _this.scalingDeterminant = 1;
  90016. /**
  90017. * Sets the distance of the object to max, often used by skybox
  90018. */
  90019. _this.infiniteDistance = false;
  90020. /**
  90021. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  90022. * By default the system will update normals to compensate
  90023. */
  90024. _this.ignoreNonUniformScaling = false;
  90025. /** @hidden */
  90026. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  90027. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90028. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  90029. _this._postMultiplyPivotMatrix = false;
  90030. _this._isWorldMatrixFrozen = false;
  90031. /** @hidden */
  90032. _this._indexInSceneTransformNodesArray = -1;
  90033. /**
  90034. * An event triggered after the world matrix is updated
  90035. */
  90036. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  90037. _this._nonUniformScaling = false;
  90038. if (isPure) {
  90039. _this.getScene().addTransformNode(_this);
  90040. }
  90041. return _this;
  90042. }
  90043. /**
  90044. * Gets a string identifying the name of the class
  90045. * @returns "TransformNode" string
  90046. */
  90047. TransformNode.prototype.getClassName = function () {
  90048. return "TransformNode";
  90049. };
  90050. Object.defineProperty(TransformNode.prototype, "position", {
  90051. /**
  90052. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  90053. */
  90054. get: function () {
  90055. return this._position;
  90056. },
  90057. set: function (newPosition) {
  90058. this._position = newPosition;
  90059. this._isDirty = true;
  90060. },
  90061. enumerable: true,
  90062. configurable: true
  90063. });
  90064. Object.defineProperty(TransformNode.prototype, "rotation", {
  90065. /**
  90066. * 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)).
  90067. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  90068. */
  90069. get: function () {
  90070. return this._rotation;
  90071. },
  90072. set: function (newRotation) {
  90073. this._rotation = newRotation;
  90074. this._isDirty = true;
  90075. },
  90076. enumerable: true,
  90077. configurable: true
  90078. });
  90079. Object.defineProperty(TransformNode.prototype, "scaling", {
  90080. /**
  90081. * 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)).
  90082. */
  90083. get: function () {
  90084. return this._scaling;
  90085. },
  90086. set: function (newScaling) {
  90087. this._scaling = newScaling;
  90088. this._isDirty = true;
  90089. },
  90090. enumerable: true,
  90091. configurable: true
  90092. });
  90093. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  90094. /**
  90095. * 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).
  90096. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  90097. */
  90098. get: function () {
  90099. return this._rotationQuaternion;
  90100. },
  90101. set: function (quaternion) {
  90102. this._rotationQuaternion = quaternion;
  90103. //reset the rotation vector.
  90104. if (quaternion) {
  90105. this.rotation.setAll(0.0);
  90106. }
  90107. },
  90108. enumerable: true,
  90109. configurable: true
  90110. });
  90111. Object.defineProperty(TransformNode.prototype, "forward", {
  90112. /**
  90113. * The forward direction of that transform in world space.
  90114. */
  90115. get: function () {
  90116. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  90117. },
  90118. enumerable: true,
  90119. configurable: true
  90120. });
  90121. Object.defineProperty(TransformNode.prototype, "up", {
  90122. /**
  90123. * The up direction of that transform in world space.
  90124. */
  90125. get: function () {
  90126. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  90127. },
  90128. enumerable: true,
  90129. configurable: true
  90130. });
  90131. Object.defineProperty(TransformNode.prototype, "right", {
  90132. /**
  90133. * The right direction of that transform in world space.
  90134. */
  90135. get: function () {
  90136. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  90137. },
  90138. enumerable: true,
  90139. configurable: true
  90140. });
  90141. /**
  90142. * Copies the parameter passed Matrix into the mesh Pose matrix.
  90143. * @param matrix the matrix to copy the pose from
  90144. * @returns this TransformNode.
  90145. */
  90146. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  90147. this._poseMatrix.copyFrom(matrix);
  90148. return this;
  90149. };
  90150. /**
  90151. * Returns the mesh Pose matrix.
  90152. * @returns the pose matrix
  90153. */
  90154. TransformNode.prototype.getPoseMatrix = function () {
  90155. return this._poseMatrix;
  90156. };
  90157. /** @hidden */
  90158. TransformNode.prototype._isSynchronized = function () {
  90159. if (this._isDirty) {
  90160. return false;
  90161. }
  90162. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90163. return false;
  90164. }
  90165. if (this._cache.pivotMatrixUpdated) {
  90166. return false;
  90167. }
  90168. if (this.infiniteDistance) {
  90169. return false;
  90170. }
  90171. if (!this._cache.position.equals(this._position)) {
  90172. return false;
  90173. }
  90174. if (this._rotationQuaternion) {
  90175. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  90176. return false;
  90177. }
  90178. }
  90179. if (!this._cache.rotation.equals(this._rotation)) {
  90180. return false;
  90181. }
  90182. if (!this._cache.scaling.equals(this._scaling)) {
  90183. return false;
  90184. }
  90185. return true;
  90186. };
  90187. /** @hidden */
  90188. TransformNode.prototype._initCache = function () {
  90189. _super.prototype._initCache.call(this);
  90190. this._cache.localMatrixUpdated = false;
  90191. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90192. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90193. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90194. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  90195. this._cache.billboardMode = -1;
  90196. this._cache.infiniteDistance = false;
  90197. };
  90198. /**
  90199. * Flag the transform node as dirty (Forcing it to update everything)
  90200. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  90201. * @returns this transform node
  90202. */
  90203. TransformNode.prototype.markAsDirty = function (property) {
  90204. if (property === "rotation") {
  90205. this.rotationQuaternion = null;
  90206. }
  90207. this._currentRenderId = Number.MAX_VALUE;
  90208. this._isDirty = true;
  90209. return this;
  90210. };
  90211. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  90212. /**
  90213. * Returns the current mesh absolute position.
  90214. * Returns a Vector3.
  90215. */
  90216. get: function () {
  90217. return this._absolutePosition;
  90218. },
  90219. enumerable: true,
  90220. configurable: true
  90221. });
  90222. /**
  90223. * Sets a new matrix to apply before all other transformation
  90224. * @param matrix defines the transform matrix
  90225. * @returns the current TransformNode
  90226. */
  90227. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  90228. return this.setPivotMatrix(matrix, false);
  90229. };
  90230. /**
  90231. * Sets a new pivot matrix to the current node
  90232. * @param matrix defines the new pivot matrix to use
  90233. * @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
  90234. * @returns the current TransformNode
  90235. */
  90236. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  90237. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  90238. this._pivotMatrix.copyFrom(matrix);
  90239. this._cache.pivotMatrixUpdated = true;
  90240. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  90241. if (this._postMultiplyPivotMatrix) {
  90242. if (!this._pivotMatrixInverse) {
  90243. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  90244. }
  90245. else {
  90246. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  90247. }
  90248. }
  90249. return this;
  90250. };
  90251. /**
  90252. * Returns the mesh pivot matrix.
  90253. * Default : Identity.
  90254. * @returns the matrix
  90255. */
  90256. TransformNode.prototype.getPivotMatrix = function () {
  90257. return this._pivotMatrix;
  90258. };
  90259. /**
  90260. * Prevents the World matrix to be computed any longer.
  90261. * @returns the TransformNode.
  90262. */
  90263. TransformNode.prototype.freezeWorldMatrix = function () {
  90264. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  90265. this.computeWorldMatrix(true);
  90266. this._isWorldMatrixFrozen = true;
  90267. return this;
  90268. };
  90269. /**
  90270. * Allows back the World matrix computation.
  90271. * @returns the TransformNode.
  90272. */
  90273. TransformNode.prototype.unfreezeWorldMatrix = function () {
  90274. this._isWorldMatrixFrozen = false;
  90275. this.computeWorldMatrix(true);
  90276. return this;
  90277. };
  90278. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  90279. /**
  90280. * True if the World matrix has been frozen.
  90281. */
  90282. get: function () {
  90283. return this._isWorldMatrixFrozen;
  90284. },
  90285. enumerable: true,
  90286. configurable: true
  90287. });
  90288. /**
  90289. * Retuns the mesh absolute position in the World.
  90290. * @returns a Vector3.
  90291. */
  90292. TransformNode.prototype.getAbsolutePosition = function () {
  90293. this.computeWorldMatrix();
  90294. return this._absolutePosition;
  90295. };
  90296. /**
  90297. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  90298. * @param absolutePosition the absolute position to set
  90299. * @returns the TransformNode.
  90300. */
  90301. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  90302. if (!absolutePosition) {
  90303. return this;
  90304. }
  90305. var absolutePositionX;
  90306. var absolutePositionY;
  90307. var absolutePositionZ;
  90308. if (absolutePosition.x === undefined) {
  90309. if (arguments.length < 3) {
  90310. return this;
  90311. }
  90312. absolutePositionX = arguments[0];
  90313. absolutePositionY = arguments[1];
  90314. absolutePositionZ = arguments[2];
  90315. }
  90316. else {
  90317. absolutePositionX = absolutePosition.x;
  90318. absolutePositionY = absolutePosition.y;
  90319. absolutePositionZ = absolutePosition.z;
  90320. }
  90321. if (this.parent) {
  90322. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90323. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90324. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  90325. }
  90326. else {
  90327. this.position.x = absolutePositionX;
  90328. this.position.y = absolutePositionY;
  90329. this.position.z = absolutePositionZ;
  90330. }
  90331. return this;
  90332. };
  90333. /**
  90334. * Sets the mesh position in its local space.
  90335. * @param vector3 the position to set in localspace
  90336. * @returns the TransformNode.
  90337. */
  90338. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  90339. this.computeWorldMatrix();
  90340. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  90341. return this;
  90342. };
  90343. /**
  90344. * Returns the mesh position in the local space from the current World matrix values.
  90345. * @returns a new Vector3.
  90346. */
  90347. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  90348. this.computeWorldMatrix();
  90349. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90350. this._localMatrix.invertToRef(invLocalWorldMatrix);
  90351. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  90352. };
  90353. /**
  90354. * Translates the mesh along the passed Vector3 in its local space.
  90355. * @param vector3 the distance to translate in localspace
  90356. * @returns the TransformNode.
  90357. */
  90358. TransformNode.prototype.locallyTranslate = function (vector3) {
  90359. this.computeWorldMatrix(true);
  90360. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  90361. return this;
  90362. };
  90363. /**
  90364. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90365. * @param targetPoint the position (must be in same space as current mesh) to look at
  90366. * @param yawCor optional yaw (y-axis) correction in radians
  90367. * @param pitchCor optional pitch (x-axis) correction in radians
  90368. * @param rollCor optional roll (z-axis) correction in radians
  90369. * @param space the choosen space of the target
  90370. * @returns the TransformNode.
  90371. */
  90372. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  90373. if (yawCor === void 0) { yawCor = 0; }
  90374. if (pitchCor === void 0) { pitchCor = 0; }
  90375. if (rollCor === void 0) { rollCor = 0; }
  90376. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90377. var dv = TransformNode._lookAtVectorCache;
  90378. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  90379. targetPoint.subtractToRef(pos, dv);
  90380. this.setDirection(dv, yawCor, pitchCor, rollCor);
  90381. // Correct for parent's rotation offset
  90382. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  90383. if (this.rotationQuaternion) {
  90384. // Get local rotation matrix of the looking object
  90385. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90386. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  90387. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90388. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90389. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90390. parentRotationMatrix.invert();
  90391. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90392. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  90393. }
  90394. else {
  90395. // Get local rotation matrix of the looking object
  90396. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  90398. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90399. quaternionRotation.toRotationMatrix(rotationMatrix);
  90400. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90401. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90402. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90403. parentRotationMatrix.invert();
  90404. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90405. quaternionRotation.fromRotationMatrix(rotationMatrix);
  90406. quaternionRotation.toEulerAnglesToRef(this.rotation);
  90407. }
  90408. }
  90409. return this;
  90410. };
  90411. /**
  90412. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90413. * This Vector3 is expressed in the World space.
  90414. * @param localAxis axis to rotate
  90415. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90416. */
  90417. TransformNode.prototype.getDirection = function (localAxis) {
  90418. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90419. this.getDirectionToRef(localAxis, result);
  90420. return result;
  90421. };
  90422. /**
  90423. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90424. * localAxis is expressed in the mesh local space.
  90425. * result is computed in the Wordl space from the mesh World matrix.
  90426. * @param localAxis axis to rotate
  90427. * @param result the resulting transformnode
  90428. * @returns this TransformNode.
  90429. */
  90430. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  90431. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  90432. return this;
  90433. };
  90434. /**
  90435. * Sets this transform node rotation to the given local axis.
  90436. * @param localAxis the axis in local space
  90437. * @param yawCor optional yaw (y-axis) correction in radians
  90438. * @param pitchCor optional pitch (x-axis) correction in radians
  90439. * @param rollCor optional roll (z-axis) correction in radians
  90440. * @returns this TransformNode
  90441. */
  90442. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  90443. if (yawCor === void 0) { yawCor = 0; }
  90444. if (pitchCor === void 0) { pitchCor = 0; }
  90445. if (rollCor === void 0) { rollCor = 0; }
  90446. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  90447. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  90448. var pitch = -Math.atan2(localAxis.y, len);
  90449. if (this.rotationQuaternion) {
  90450. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  90451. }
  90452. else {
  90453. this.rotation.x = pitch + pitchCor;
  90454. this.rotation.y = yaw + yawCor;
  90455. this.rotation.z = rollCor;
  90456. }
  90457. return this;
  90458. };
  90459. /**
  90460. * Sets a new pivot point to the current node
  90461. * @param point defines the new pivot point to use
  90462. * @param space defines if the point is in world or local space (local by default)
  90463. * @returns the current TransformNode
  90464. */
  90465. TransformNode.prototype.setPivotPoint = function (point, space) {
  90466. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90467. if (this.getScene().getRenderId() == 0) {
  90468. this.computeWorldMatrix(true);
  90469. }
  90470. var wm = this.getWorldMatrix();
  90471. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  90472. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90473. wm.invertToRef(tmat);
  90474. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  90475. }
  90476. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  90477. };
  90478. /**
  90479. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90480. * @returns the pivot point
  90481. */
  90482. TransformNode.prototype.getPivotPoint = function () {
  90483. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90484. this.getPivotPointToRef(point);
  90485. return point;
  90486. };
  90487. /**
  90488. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90489. * @param result the vector3 to store the result
  90490. * @returns this TransformNode.
  90491. */
  90492. TransformNode.prototype.getPivotPointToRef = function (result) {
  90493. result.x = -this._pivotMatrix.m[12];
  90494. result.y = -this._pivotMatrix.m[13];
  90495. result.z = -this._pivotMatrix.m[14];
  90496. return this;
  90497. };
  90498. /**
  90499. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90500. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90501. */
  90502. TransformNode.prototype.getAbsolutePivotPoint = function () {
  90503. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90504. this.getAbsolutePivotPointToRef(point);
  90505. return point;
  90506. };
  90507. /**
  90508. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90509. * @param result vector3 to store the result
  90510. * @returns this TransformNode.
  90511. */
  90512. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  90513. result.x = this._pivotMatrix.m[12];
  90514. result.y = this._pivotMatrix.m[13];
  90515. result.z = this._pivotMatrix.m[14];
  90516. this.getPivotPointToRef(result);
  90517. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  90518. return this;
  90519. };
  90520. /**
  90521. * Defines the passed node as the parent of the current node.
  90522. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90523. * @param node the node ot set as the parent
  90524. * @returns this TransformNode.
  90525. */
  90526. TransformNode.prototype.setParent = function (node) {
  90527. if (!node && !this.parent) {
  90528. return this;
  90529. }
  90530. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90531. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90532. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90533. if (!node) {
  90534. if (this.parent && this.parent.computeWorldMatrix) {
  90535. this.parent.computeWorldMatrix(true);
  90536. }
  90537. this.computeWorldMatrix(true);
  90538. this.getWorldMatrix().decompose(scale, quatRotation, position);
  90539. }
  90540. else {
  90541. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90542. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90543. this.computeWorldMatrix(true);
  90544. node.computeWorldMatrix(true);
  90545. node.getWorldMatrix().invertToRef(invParentMatrix);
  90546. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  90547. diffMatrix.decompose(scale, quatRotation, position);
  90548. }
  90549. if (this.rotationQuaternion) {
  90550. this.rotationQuaternion.copyFrom(quatRotation);
  90551. }
  90552. else {
  90553. quatRotation.toEulerAnglesToRef(this.rotation);
  90554. }
  90555. this.scaling.copyFrom(scale);
  90556. this.position.copyFrom(position);
  90557. this.parent = node;
  90558. return this;
  90559. };
  90560. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  90561. /**
  90562. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90563. */
  90564. get: function () {
  90565. return this._nonUniformScaling;
  90566. },
  90567. enumerable: true,
  90568. configurable: true
  90569. });
  90570. /** @hidden */
  90571. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  90572. if (this._nonUniformScaling === value) {
  90573. return false;
  90574. }
  90575. this._nonUniformScaling = value;
  90576. return true;
  90577. };
  90578. /**
  90579. * Attach the current TransformNode to another TransformNode associated with a bone
  90580. * @param bone Bone affecting the TransformNode
  90581. * @param affectedTransformNode TransformNode associated with the bone
  90582. * @returns this object
  90583. */
  90584. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  90585. this._transformToBoneReferal = affectedTransformNode;
  90586. this.parent = bone;
  90587. if (bone.getWorldMatrix().determinant() < 0) {
  90588. this.scalingDeterminant *= -1;
  90589. }
  90590. return this;
  90591. };
  90592. /**
  90593. * Detach the transform node if its associated with a bone
  90594. * @returns this object
  90595. */
  90596. TransformNode.prototype.detachFromBone = function () {
  90597. if (!this.parent) {
  90598. return this;
  90599. }
  90600. if (this.parent.getWorldMatrix().determinant() < 0) {
  90601. this.scalingDeterminant *= -1;
  90602. }
  90603. this._transformToBoneReferal = null;
  90604. this.parent = null;
  90605. return this;
  90606. };
  90607. /**
  90608. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90609. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90610. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90611. * The passed axis is also normalized.
  90612. * @param axis the axis to rotate around
  90613. * @param amount the amount to rotate in radians
  90614. * @param space Space to rotate in (Default: local)
  90615. * @returns the TransformNode.
  90616. */
  90617. TransformNode.prototype.rotate = function (axis, amount, space) {
  90618. axis.normalize();
  90619. if (!this.rotationQuaternion) {
  90620. this.rotationQuaternion = this.rotation.toQuaternion();
  90621. this.rotation.setAll(0);
  90622. }
  90623. var rotationQuaternion;
  90624. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90625. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90626. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  90627. }
  90628. else {
  90629. if (this.parent) {
  90630. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90631. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90632. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  90633. }
  90634. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90635. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90636. }
  90637. return this;
  90638. };
  90639. /**
  90640. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90641. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90642. * The passed axis is also normalized. .
  90643. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90644. * @param point the point to rotate around
  90645. * @param axis the axis to rotate around
  90646. * @param amount the amount to rotate in radians
  90647. * @returns the TransformNode
  90648. */
  90649. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  90650. axis.normalize();
  90651. if (!this.rotationQuaternion) {
  90652. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  90653. this.rotation.setAll(0);
  90654. }
  90655. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90656. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90657. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  90658. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90659. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  90660. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  90661. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  90662. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  90663. point.subtractToRef(this.position, tmpVector);
  90664. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  90665. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  90666. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  90667. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  90668. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  90669. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  90670. this.position.addInPlace(finalTranslation);
  90671. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90672. return this;
  90673. };
  90674. /**
  90675. * Translates the mesh along the axis vector for the passed distance in the given space.
  90676. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90677. * @param axis the axis to translate in
  90678. * @param distance the distance to translate
  90679. * @param space Space to rotate in (Default: local)
  90680. * @returns the TransformNode.
  90681. */
  90682. TransformNode.prototype.translate = function (axis, distance, space) {
  90683. var displacementVector = axis.scale(distance);
  90684. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90685. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  90686. this.setPositionWithLocalVector(tempV3);
  90687. }
  90688. else {
  90689. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  90690. }
  90691. return this;
  90692. };
  90693. /**
  90694. * Adds a rotation step to the mesh current rotation.
  90695. * x, y, z are Euler angles expressed in radians.
  90696. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90697. * This means this rotation is made in the mesh local space only.
  90698. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90699. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90700. * ```javascript
  90701. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90702. * ```
  90703. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90704. * 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.
  90705. * @param x Rotation to add
  90706. * @param y Rotation to add
  90707. * @param z Rotation to add
  90708. * @returns the TransformNode.
  90709. */
  90710. TransformNode.prototype.addRotation = function (x, y, z) {
  90711. var rotationQuaternion;
  90712. if (this.rotationQuaternion) {
  90713. rotationQuaternion = this.rotationQuaternion;
  90714. }
  90715. else {
  90716. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  90717. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  90718. }
  90719. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90720. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  90721. rotationQuaternion.multiplyInPlace(accumulation);
  90722. if (!this.rotationQuaternion) {
  90723. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  90724. }
  90725. return this;
  90726. };
  90727. /**
  90728. * Computes the world matrix of the node
  90729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90730. * @returns the world matrix
  90731. */
  90732. TransformNode.prototype.computeWorldMatrix = function (force) {
  90733. if (this._isWorldMatrixFrozen) {
  90734. return this._worldMatrix;
  90735. }
  90736. if (!force && this.isSynchronized()) {
  90737. this._currentRenderId = this.getScene().getRenderId();
  90738. return this._worldMatrix;
  90739. }
  90740. this._updateCache();
  90741. this._cache.position.copyFrom(this.position);
  90742. this._cache.scaling.copyFrom(this.scaling);
  90743. this._cache.pivotMatrixUpdated = false;
  90744. this._cache.billboardMode = this.billboardMode;
  90745. this._cache.infiniteDistance = this.infiniteDistance;
  90746. this._currentRenderId = this.getScene().getRenderId();
  90747. this._childRenderId = this.getScene().getRenderId();
  90748. this._isDirty = false;
  90749. // Scaling
  90750. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  90751. // Rotation
  90752. //rotate, if quaternion is set and rotation was used
  90753. if (this.rotationQuaternion) {
  90754. var len = this.rotation.length();
  90755. if (len) {
  90756. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  90757. this.rotation.copyFromFloats(0, 0, 0);
  90758. }
  90759. }
  90760. if (this.rotationQuaternion) {
  90761. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90762. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  90763. }
  90764. else {
  90765. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90766. this._cache.rotation.copyFrom(this.rotation);
  90767. }
  90768. // Translation
  90769. var camera = this.getScene().activeCamera;
  90770. if (this.infiniteDistance && !this.parent && camera) {
  90771. var cameraWorldMatrix = camera.getWorldMatrix();
  90772. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  90773. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  90774. }
  90775. else {
  90776. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  90777. }
  90778. // Composing transformations
  90779. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  90780. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90781. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  90782. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  90783. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  90784. // Need to decompose each rotation here
  90785. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  90786. if (this.parent && this.parent.getWorldMatrix) {
  90787. if (this._transformToBoneReferal) {
  90788. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90789. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  90790. }
  90791. else {
  90792. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  90793. }
  90794. }
  90795. else {
  90796. currentPosition.copyFrom(this.position);
  90797. }
  90798. currentPosition.subtractInPlace(camera.globalPosition);
  90799. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90800. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90801. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90802. }
  90803. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90804. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90805. }
  90806. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90807. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90808. }
  90809. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90810. }
  90811. else {
  90812. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90813. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90814. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90815. }
  90816. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90817. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90818. }
  90819. // Post multiply inverse of pivotMatrix
  90820. if (this._postMultiplyPivotMatrix) {
  90821. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90822. }
  90823. // Local world
  90824. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  90825. // Parent
  90826. if (this.parent && this.parent.getWorldMatrix) {
  90827. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90828. if (this._transformToBoneReferal) {
  90829. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90830. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90831. }
  90832. else {
  90833. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  90834. }
  90835. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  90836. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  90837. this._worldMatrix.copyFrom(this._localMatrix);
  90838. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  90839. }
  90840. else {
  90841. if (this._transformToBoneReferal) {
  90842. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90843. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  90844. }
  90845. else {
  90846. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  90847. }
  90848. }
  90849. this._markSyncedWithParent();
  90850. }
  90851. else {
  90852. this._worldMatrix.copyFrom(this._localMatrix);
  90853. }
  90854. // Normal matrix
  90855. if (!this.ignoreNonUniformScaling) {
  90856. if (this.scaling.isNonUniform) {
  90857. this._updateNonUniformScalingState(true);
  90858. }
  90859. else if (this.parent && this.parent._nonUniformScaling) {
  90860. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  90861. }
  90862. else {
  90863. this._updateNonUniformScalingState(false);
  90864. }
  90865. }
  90866. else {
  90867. this._updateNonUniformScalingState(false);
  90868. }
  90869. this._afterComputeWorldMatrix();
  90870. // Absolute position
  90871. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  90872. // Callbacks
  90873. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  90874. if (!this._poseMatrix) {
  90875. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  90876. }
  90877. // Cache the determinant
  90878. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  90879. return this._worldMatrix;
  90880. };
  90881. TransformNode.prototype._afterComputeWorldMatrix = function () {
  90882. };
  90883. /**
  90884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90885. * @param func callback function to add
  90886. *
  90887. * @returns the TransformNode.
  90888. */
  90889. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  90890. this.onAfterWorldMatrixUpdateObservable.add(func);
  90891. return this;
  90892. };
  90893. /**
  90894. * Removes a registered callback function.
  90895. * @param func callback function to remove
  90896. * @returns the TransformNode.
  90897. */
  90898. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  90899. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  90900. return this;
  90901. };
  90902. /**
  90903. * Gets the position of the current mesh in camera space
  90904. * @param camera defines the camera to use
  90905. * @returns a position
  90906. */
  90907. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  90908. if (camera === void 0) { camera = null; }
  90909. if (!camera) {
  90910. camera = this.getScene().activeCamera;
  90911. }
  90912. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  90913. };
  90914. /**
  90915. * Returns the distance from the mesh to the active camera
  90916. * @param camera defines the camera to use
  90917. * @returns the distance
  90918. */
  90919. TransformNode.prototype.getDistanceToCamera = function (camera) {
  90920. if (camera === void 0) { camera = null; }
  90921. if (!camera) {
  90922. camera = this.getScene().activeCamera;
  90923. }
  90924. return this.absolutePosition.subtract(camera.position).length();
  90925. };
  90926. /**
  90927. * Clone the current transform node
  90928. * @param name Name of the new clone
  90929. * @param newParent New parent for the clone
  90930. * @param doNotCloneChildren Do not clone children hierarchy
  90931. * @returns the new transform node
  90932. */
  90933. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  90934. var _this = this;
  90935. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  90936. result.name = name;
  90937. result.id = name;
  90938. if (newParent) {
  90939. result.parent = newParent;
  90940. }
  90941. if (!doNotCloneChildren) {
  90942. // Children
  90943. var directDescendants = this.getDescendants(true);
  90944. for (var index = 0; index < directDescendants.length; index++) {
  90945. var child = directDescendants[index];
  90946. if (child.clone) {
  90947. child.clone(name + "." + child.name, result);
  90948. }
  90949. }
  90950. }
  90951. return result;
  90952. };
  90953. /**
  90954. * Serializes the objects information.
  90955. * @param currentSerializationObject defines the object to serialize in
  90956. * @returns the serialized object
  90957. */
  90958. TransformNode.prototype.serialize = function (currentSerializationObject) {
  90959. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  90960. serializationObject.type = this.getClassName();
  90961. // Parent
  90962. if (this.parent) {
  90963. serializationObject.parentId = this.parent.id;
  90964. }
  90965. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  90966. serializationObject.isEnabled = this.isEnabled();
  90967. // Parent
  90968. if (this.parent) {
  90969. serializationObject.parentId = this.parent.id;
  90970. }
  90971. return serializationObject;
  90972. };
  90973. // Statics
  90974. /**
  90975. * Returns a new TransformNode object parsed from the source provided.
  90976. * @param parsedTransformNode is the source.
  90977. * @param scene the scne the object belongs to
  90978. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90979. * @returns a new TransformNode object parsed from the source provided.
  90980. */
  90981. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  90982. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  90983. if (parsedTransformNode.localMatrix) {
  90984. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  90985. }
  90986. else if (parsedTransformNode.pivotMatrix) {
  90987. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  90988. }
  90989. transformNode.setEnabled(parsedTransformNode.isEnabled);
  90990. // Parent
  90991. if (parsedTransformNode.parentId) {
  90992. transformNode._waitingParentId = parsedTransformNode.parentId;
  90993. }
  90994. return transformNode;
  90995. };
  90996. /**
  90997. * Get all child-transformNodes of this node
  90998. * @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
  90999. * @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
  91000. * @returns an array of TransformNode
  91001. */
  91002. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  91003. var results = [];
  91004. this._getDescendants(results, directDescendantsOnly, function (node) {
  91005. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  91006. });
  91007. return results;
  91008. };
  91009. /**
  91010. * Releases resources associated with this transform node.
  91011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91013. */
  91014. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91015. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91016. // Animations
  91017. this.getScene().stopAnimation(this);
  91018. // Remove from scene
  91019. this.getScene().removeTransformNode(this);
  91020. this.onAfterWorldMatrixUpdateObservable.clear();
  91021. if (doNotRecurse) {
  91022. var transformNodes = this.getChildTransformNodes(true);
  91023. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  91024. var transformNode = transformNodes_1[_i];
  91025. transformNode.parent = null;
  91026. transformNode.computeWorldMatrix(true);
  91027. }
  91028. }
  91029. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91030. };
  91031. // Statics
  91032. /**
  91033. * Object will not rotate to face the camera
  91034. */
  91035. TransformNode.BILLBOARDMODE_NONE = 0;
  91036. /**
  91037. * Object will rotate to face the camera but only on the x axis
  91038. */
  91039. TransformNode.BILLBOARDMODE_X = 1;
  91040. /**
  91041. * Object will rotate to face the camera but only on the y axis
  91042. */
  91043. TransformNode.BILLBOARDMODE_Y = 2;
  91044. /**
  91045. * Object will rotate to face the camera but only on the z axis
  91046. */
  91047. TransformNode.BILLBOARDMODE_Z = 4;
  91048. /**
  91049. * Object will rotate to face the camera
  91050. */
  91051. TransformNode.BILLBOARDMODE_ALL = 7;
  91052. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  91053. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  91054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  91056. ], TransformNode.prototype, "_position", void 0);
  91057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  91059. ], TransformNode.prototype, "_rotation", void 0);
  91060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  91062. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  91063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  91065. ], TransformNode.prototype, "_scaling", void 0);
  91066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91068. ], TransformNode.prototype, "billboardMode", void 0);
  91069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91071. ], TransformNode.prototype, "scalingDeterminant", void 0);
  91072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91074. ], TransformNode.prototype, "infiniteDistance", void 0);
  91075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91077. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  91078. return TransformNode;
  91079. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  91080. /***/ }),
  91081. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  91082. /*!***************************************************************!*\
  91083. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  91084. \***************************************************************/
  91085. /*! exports provided: CubeMapToSphericalPolynomialTools */
  91086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91087. "use strict";
  91088. __webpack_require__.r(__webpack_exports__);
  91089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  91090. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91091. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91092. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91093. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91094. var FileFaceOrientation = /** @class */ (function () {
  91095. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  91096. this.name = name;
  91097. this.worldAxisForNormal = worldAxisForNormal;
  91098. this.worldAxisForFileX = worldAxisForFileX;
  91099. this.worldAxisForFileY = worldAxisForFileY;
  91100. }
  91101. return FileFaceOrientation;
  91102. }());
  91103. /**
  91104. * Helper class dealing with the extraction of spherical polynomial dataArray
  91105. * from a cube map.
  91106. */
  91107. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  91108. function CubeMapToSphericalPolynomialTools() {
  91109. }
  91110. /**
  91111. * Converts a texture to the according Spherical Polynomial data.
  91112. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91113. *
  91114. * @param texture The texture to extract the information from.
  91115. * @return The Spherical Polynomial data.
  91116. */
  91117. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  91118. if (!texture.isCube) {
  91119. // Only supports cube Textures currently.
  91120. return null;
  91121. }
  91122. var size = texture.getSize().width;
  91123. var right = texture.readPixels(0);
  91124. var left = texture.readPixels(1);
  91125. var up;
  91126. var down;
  91127. if (texture.isRenderTarget) {
  91128. up = texture.readPixels(3);
  91129. down = texture.readPixels(2);
  91130. }
  91131. else {
  91132. up = texture.readPixels(2);
  91133. down = texture.readPixels(3);
  91134. }
  91135. var front = texture.readPixels(4);
  91136. var back = texture.readPixels(5);
  91137. var gammaSpace = texture.gammaSpace;
  91138. // Always read as RGBA.
  91139. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  91140. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91141. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91142. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  91143. }
  91144. var cubeInfo = {
  91145. size: size,
  91146. right: right,
  91147. left: left,
  91148. up: up,
  91149. down: down,
  91150. front: front,
  91151. back: back,
  91152. format: format,
  91153. type: type,
  91154. gammaSpace: gammaSpace,
  91155. };
  91156. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  91157. };
  91158. /**
  91159. * Converts a cubemap to the according Spherical Polynomial data.
  91160. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91161. *
  91162. * @param cubeInfo The Cube map to extract the information from.
  91163. * @return The Spherical Polynomial data.
  91164. */
  91165. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  91166. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  91167. var totalSolidAngle = 0.0;
  91168. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  91169. var du = 2.0 / cubeInfo.size;
  91170. var dv = du;
  91171. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91172. var minUV = du * 0.5 - 1.0;
  91173. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91174. var fileFace = this.FileFaces[faceIndex];
  91175. var dataArray = cubeInfo[fileFace.name];
  91176. var v = minUV;
  91177. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  91178. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  91179. // Because SP is still linear, so summation is fine in that basis.
  91180. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  91181. for (var y = 0; y < cubeInfo.size; y++) {
  91182. var u = minUV;
  91183. for (var x = 0; x < cubeInfo.size; x++) {
  91184. // World direction (not normalised)
  91185. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  91186. worldDirection.normalize();
  91187. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  91188. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  91189. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  91190. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  91191. // Handle Integer types.
  91192. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91193. r /= 255;
  91194. g /= 255;
  91195. b /= 255;
  91196. }
  91197. // Handle Gamma space textures.
  91198. if (cubeInfo.gammaSpace) {
  91199. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91200. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91201. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91202. }
  91203. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  91204. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  91205. totalSolidAngle += deltaSolidAngle;
  91206. u += du;
  91207. }
  91208. v += dv;
  91209. }
  91210. }
  91211. // Solid angle for entire sphere is 4*pi
  91212. var sphereSolidAngle = 4.0 * Math.PI;
  91213. // Adjust the solid angle to allow for how many faces we processed.
  91214. var facesProcessed = 6.0;
  91215. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  91216. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  91217. // This is needed because the numerical integration over the cube uses a
  91218. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  91219. // and also to compensate for accumulative error due to float precision in the summation.
  91220. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  91221. sphericalHarmonics.scale(correctionFactor);
  91222. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  91223. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  91224. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  91225. };
  91226. CubeMapToSphericalPolynomialTools.FileFaces = [
  91227. new FileFaceOrientation("right", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  91228. new FileFaceOrientation("left", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  91229. new FileFaceOrientation("up", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1)),
  91230. new FileFaceOrientation("down", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1)),
  91231. new FileFaceOrientation("front", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  91232. new FileFaceOrientation("back", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)) // -Z bottom
  91233. ];
  91234. return CubeMapToSphericalPolynomialTools;
  91235. }());
  91236. /***/ }),
  91237. /***/ "./Misc/HighDynamicRange/hdr.ts":
  91238. /*!**************************************!*\
  91239. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  91240. \**************************************/
  91241. /*! exports provided: HDRTools */
  91242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91243. "use strict";
  91244. __webpack_require__.r(__webpack_exports__);
  91245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  91246. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91247. /**
  91248. * This groups tools to convert HDR texture to native colors array.
  91249. */
  91250. var HDRTools = /** @class */ (function () {
  91251. function HDRTools() {
  91252. }
  91253. HDRTools.Ldexp = function (mantissa, exponent) {
  91254. if (exponent > 1023) {
  91255. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  91256. }
  91257. if (exponent < -1074) {
  91258. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  91259. }
  91260. return mantissa * Math.pow(2, exponent);
  91261. };
  91262. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  91263. if (exponent > 0) { /*nonzero pixel*/
  91264. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  91265. float32array[index + 0] = red * exponent;
  91266. float32array[index + 1] = green * exponent;
  91267. float32array[index + 2] = blue * exponent;
  91268. }
  91269. else {
  91270. float32array[index + 0] = 0;
  91271. float32array[index + 1] = 0;
  91272. float32array[index + 2] = 0;
  91273. }
  91274. };
  91275. HDRTools.readStringLine = function (uint8array, startIndex) {
  91276. var line = "";
  91277. var character = "";
  91278. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  91279. character = String.fromCharCode(uint8array[i]);
  91280. if (character == "\n") {
  91281. break;
  91282. }
  91283. line += character;
  91284. }
  91285. return line;
  91286. };
  91287. /**
  91288. * Reads header information from an RGBE texture stored in a native array.
  91289. * More information on this format are available here:
  91290. * https://en.wikipedia.org/wiki/RGBE_image_format
  91291. *
  91292. * @param uint8array The binary file stored in native array.
  91293. * @return The header information.
  91294. */
  91295. HDRTools.RGBE_ReadHeader = function (uint8array) {
  91296. var height = 0;
  91297. var width = 0;
  91298. var line = this.readStringLine(uint8array, 0);
  91299. if (line[0] != '#' || line[1] != '?') {
  91300. throw "Bad HDR Format.";
  91301. }
  91302. var endOfHeader = false;
  91303. var findFormat = false;
  91304. var lineIndex = 0;
  91305. do {
  91306. lineIndex += (line.length + 1);
  91307. line = this.readStringLine(uint8array, lineIndex);
  91308. if (line == "FORMAT=32-bit_rle_rgbe") {
  91309. findFormat = true;
  91310. }
  91311. else if (line.length == 0) {
  91312. endOfHeader = true;
  91313. }
  91314. } while (!endOfHeader);
  91315. if (!findFormat) {
  91316. throw "HDR Bad header format, unsupported FORMAT";
  91317. }
  91318. lineIndex += (line.length + 1);
  91319. line = this.readStringLine(uint8array, lineIndex);
  91320. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  91321. var match = sizeRegexp.exec(line);
  91322. // TODO. Support +Y and -X if needed.
  91323. if (!match || match.length < 3) {
  91324. throw "HDR Bad header format, no size";
  91325. }
  91326. width = parseInt(match[2]);
  91327. height = parseInt(match[1]);
  91328. if (width < 8 || width > 0x7fff) {
  91329. throw "HDR Bad header format, unsupported size";
  91330. }
  91331. lineIndex += (line.length + 1);
  91332. return {
  91333. height: height,
  91334. width: width,
  91335. dataPosition: lineIndex
  91336. };
  91337. };
  91338. /**
  91339. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  91340. * This RGBE texture needs to store the information as a panorama.
  91341. *
  91342. * More information on this format are available here:
  91343. * https://en.wikipedia.org/wiki/RGBE_image_format
  91344. *
  91345. * @param buffer The binary file stored in an array buffer.
  91346. * @param size The expected size of the extracted cubemap.
  91347. * @return The Cube Map information.
  91348. */
  91349. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  91350. var uint8array = new Uint8Array(buffer);
  91351. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  91352. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91353. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  91354. return cubeMapData;
  91355. };
  91356. /**
  91357. * Returns the pixels data extracted from an RGBE texture.
  91358. * This pixels will be stored left to right up to down in the R G B order in one array.
  91359. *
  91360. * More information on this format are available here:
  91361. * https://en.wikipedia.org/wiki/RGBE_image_format
  91362. *
  91363. * @param uint8array The binary file stored in an array buffer.
  91364. * @param hdrInfo The header information of the file.
  91365. * @return The pixels data in RGB right to left up to down order.
  91366. */
  91367. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  91368. // Keep for multi format supports.
  91369. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91370. };
  91371. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  91372. var num_scanlines = hdrInfo.height;
  91373. var scanline_width = hdrInfo.width;
  91374. var a, b, c, d, count;
  91375. var dataIndex = hdrInfo.dataPosition;
  91376. var index = 0, endIndex = 0, i = 0;
  91377. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  91378. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  91379. // 3 channels of 4 bytes per pixel in float.
  91380. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  91381. var resultArray = new Float32Array(resultBuffer);
  91382. // read in each successive scanline
  91383. while (num_scanlines > 0) {
  91384. a = uint8array[dataIndex++];
  91385. b = uint8array[dataIndex++];
  91386. c = uint8array[dataIndex++];
  91387. d = uint8array[dataIndex++];
  91388. if (a != 2 || b != 2 || (c & 0x80)) {
  91389. // this file is not run length encoded
  91390. throw "HDR Bad header format, not RLE";
  91391. }
  91392. if (((c << 8) | d) != scanline_width) {
  91393. throw "HDR Bad header format, wrong scan line width";
  91394. }
  91395. index = 0;
  91396. // read each of the four channels for the scanline into the buffer
  91397. for (i = 0; i < 4; i++) {
  91398. endIndex = (i + 1) * scanline_width;
  91399. while (index < endIndex) {
  91400. a = uint8array[dataIndex++];
  91401. b = uint8array[dataIndex++];
  91402. if (a > 128) {
  91403. // a run of the same value
  91404. count = a - 128;
  91405. if ((count == 0) || (count > endIndex - index)) {
  91406. throw "HDR Bad Format, bad scanline data (run)";
  91407. }
  91408. while (count-- > 0) {
  91409. scanLineArray[index++] = b;
  91410. }
  91411. }
  91412. else {
  91413. // a non-run
  91414. count = a;
  91415. if ((count == 0) || (count > endIndex - index)) {
  91416. throw "HDR Bad Format, bad scanline data (non-run)";
  91417. }
  91418. scanLineArray[index++] = b;
  91419. if (--count > 0) {
  91420. for (var j = 0; j < count; j++) {
  91421. scanLineArray[index++] = uint8array[dataIndex++];
  91422. }
  91423. }
  91424. }
  91425. }
  91426. }
  91427. // now convert data from buffer into floats
  91428. for (i = 0; i < scanline_width; i++) {
  91429. a = scanLineArray[i];
  91430. b = scanLineArray[i + scanline_width];
  91431. c = scanLineArray[i + 2 * scanline_width];
  91432. d = scanLineArray[i + 3 * scanline_width];
  91433. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  91434. }
  91435. num_scanlines--;
  91436. }
  91437. return resultArray;
  91438. };
  91439. return HDRTools;
  91440. }());
  91441. /***/ }),
  91442. /***/ "./Misc/HighDynamicRange/index.ts":
  91443. /*!****************************************!*\
  91444. !*** ./Misc/HighDynamicRange/index.ts ***!
  91445. \****************************************/
  91446. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  91447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91448. "use strict";
  91449. __webpack_require__.r(__webpack_exports__);
  91450. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  91452. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  91453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  91454. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  91456. /***/ }),
  91457. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  91458. /*!****************************************************!*\
  91459. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  91460. \****************************************************/
  91461. /*! exports provided: PanoramaToCubeMapTools */
  91462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91463. "use strict";
  91464. __webpack_require__.r(__webpack_exports__);
  91465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  91466. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91467. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91468. /**
  91469. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91470. */
  91471. var PanoramaToCubeMapTools = /** @class */ (function () {
  91472. function PanoramaToCubeMapTools() {
  91473. }
  91474. /**
  91475. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91476. *
  91477. * @param float32Array The source data.
  91478. * @param inputWidth The width of the input panorama.
  91479. * @param inputHeight The height of the input panorama.
  91480. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91481. * @return The cubemap data
  91482. */
  91483. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  91484. if (!float32Array) {
  91485. throw "ConvertPanoramaToCubemap: input cannot be null";
  91486. }
  91487. if (float32Array.length != inputWidth * inputHeight * 3) {
  91488. throw "ConvertPanoramaToCubemap: input size is wrong";
  91489. }
  91490. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  91491. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  91492. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  91493. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  91494. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  91495. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  91496. return {
  91497. front: textureFront,
  91498. back: textureBack,
  91499. left: textureLeft,
  91500. right: textureRight,
  91501. up: textureUp,
  91502. down: textureDown,
  91503. size: size,
  91504. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  91505. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  91506. gammaSpace: false,
  91507. };
  91508. };
  91509. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  91510. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  91511. var textureArray = new Float32Array(buffer);
  91512. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  91513. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  91514. var dy = 1 / texSize;
  91515. var fy = 0;
  91516. for (var y = 0; y < texSize; y++) {
  91517. var xv1 = faceData[0];
  91518. var xv2 = faceData[2];
  91519. for (var x = 0; x < texSize; x++) {
  91520. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  91521. v.normalize();
  91522. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  91523. // 3 channels per pixels
  91524. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  91525. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  91526. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  91527. xv1 = xv1.add(rotDX1);
  91528. xv2 = xv2.add(rotDX2);
  91529. }
  91530. fy += dy;
  91531. }
  91532. return textureArray;
  91533. };
  91534. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  91535. var theta = Math.atan2(vDir.z, vDir.x);
  91536. var phi = Math.acos(vDir.y);
  91537. while (theta < -Math.PI) {
  91538. theta += 2 * Math.PI;
  91539. }
  91540. while (theta > Math.PI) {
  91541. theta -= 2 * Math.PI;
  91542. }
  91543. var dx = theta / Math.PI;
  91544. var dy = phi / Math.PI;
  91545. // recenter.
  91546. dx = dx * 0.5 + 0.5;
  91547. var px = Math.round(dx * inputWidth);
  91548. if (px < 0) {
  91549. px = 0;
  91550. }
  91551. else if (px >= inputWidth) {
  91552. px = inputWidth - 1;
  91553. }
  91554. var py = Math.round(dy * inputHeight);
  91555. if (py < 0) {
  91556. py = 0;
  91557. }
  91558. else if (py >= inputHeight) {
  91559. py = inputHeight - 1;
  91560. }
  91561. var inputY = (inputHeight - py - 1);
  91562. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  91563. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  91564. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  91565. return {
  91566. r: r,
  91567. g: g,
  91568. b: b
  91569. };
  91570. };
  91571. PanoramaToCubeMapTools.FACE_FRONT = [
  91572. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91573. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91574. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91575. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  91576. ];
  91577. PanoramaToCubeMapTools.FACE_BACK = [
  91578. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91579. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91580. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  91581. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  91582. ];
  91583. PanoramaToCubeMapTools.FACE_RIGHT = [
  91584. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91585. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91586. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91587. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91588. ];
  91589. PanoramaToCubeMapTools.FACE_LEFT = [
  91590. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91591. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91592. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91593. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  91594. ];
  91595. PanoramaToCubeMapTools.FACE_DOWN = [
  91596. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91597. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91598. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91599. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91600. ];
  91601. PanoramaToCubeMapTools.FACE_UP = [
  91602. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91603. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91604. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91605. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  91606. ];
  91607. return PanoramaToCubeMapTools;
  91608. }());
  91609. /***/ }),
  91610. /***/ "./Misc/andOrNotEvaluator.ts":
  91611. /*!***********************************!*\
  91612. !*** ./Misc/andOrNotEvaluator.ts ***!
  91613. \***********************************/
  91614. /*! exports provided: AndOrNotEvaluator */
  91615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91616. "use strict";
  91617. __webpack_require__.r(__webpack_exports__);
  91618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  91619. /**
  91620. * Class used to evalaute queries containing `and` and `or` operators
  91621. */
  91622. var AndOrNotEvaluator = /** @class */ (function () {
  91623. function AndOrNotEvaluator() {
  91624. }
  91625. /**
  91626. * Evaluate a query
  91627. * @param query defines the query to evaluate
  91628. * @param evaluateCallback defines the callback used to filter result
  91629. * @returns true if the query matches
  91630. */
  91631. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  91632. if (!query.match(/\([^\(\)]*\)/g)) {
  91633. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  91634. }
  91635. else {
  91636. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  91637. // remove parenthesis
  91638. r = r.slice(1, r.length - 1);
  91639. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  91640. });
  91641. }
  91642. if (query === "true") {
  91643. return true;
  91644. }
  91645. if (query === "false") {
  91646. return false;
  91647. }
  91648. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  91649. };
  91650. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  91651. evaluateCallback = evaluateCallback || (function (r) {
  91652. return r === "true" ? true : false;
  91653. });
  91654. var result;
  91655. var or = parenthesisContent.split("||");
  91656. for (var i in or) {
  91657. if (or.hasOwnProperty(i)) {
  91658. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  91659. var and = ori.split("&&");
  91660. if (and.length > 1) {
  91661. for (var j = 0; j < and.length; ++j) {
  91662. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  91663. if (andj !== "true" && andj !== "false") {
  91664. if (andj[0] === "!") {
  91665. result = !evaluateCallback(andj.substring(1));
  91666. }
  91667. else {
  91668. result = evaluateCallback(andj);
  91669. }
  91670. }
  91671. else {
  91672. result = andj === "true" ? true : false;
  91673. }
  91674. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  91675. ori = "false";
  91676. break;
  91677. }
  91678. }
  91679. }
  91680. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  91681. result = true;
  91682. break;
  91683. }
  91684. // result equals false (or undefined)
  91685. if (ori !== "true" && ori !== "false") {
  91686. if (ori[0] === "!") {
  91687. result = !evaluateCallback(ori.substring(1));
  91688. }
  91689. else {
  91690. result = evaluateCallback(ori);
  91691. }
  91692. }
  91693. else {
  91694. result = ori === "true" ? true : false;
  91695. }
  91696. }
  91697. }
  91698. // the whole parenthesis scope is replaced by 'true' or 'false'
  91699. return result ? "true" : "false";
  91700. };
  91701. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  91702. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  91703. // remove whitespaces
  91704. r = r.replace(/[\s]/g, function () { return ""; });
  91705. return r.length % 2 ? "!" : "";
  91706. });
  91707. booleanString = booleanString.trim();
  91708. if (booleanString === "!true") {
  91709. booleanString = "false";
  91710. }
  91711. else if (booleanString === "!false") {
  91712. booleanString = "true";
  91713. }
  91714. return booleanString;
  91715. };
  91716. return AndOrNotEvaluator;
  91717. }());
  91718. /***/ }),
  91719. /***/ "./Misc/arrayTools.ts":
  91720. /*!****************************!*\
  91721. !*** ./Misc/arrayTools.ts ***!
  91722. \****************************/
  91723. /*! exports provided: ArrayTools */
  91724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91725. "use strict";
  91726. __webpack_require__.r(__webpack_exports__);
  91727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  91728. /**
  91729. * Class containing a set of static utilities functions for arrays.
  91730. */
  91731. var ArrayTools = /** @class */ (function () {
  91732. function ArrayTools() {
  91733. }
  91734. /**
  91735. * Returns an array of the given size filled with element built from the given constructor and the paramters
  91736. * @param size the number of element to construct and put in the array
  91737. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  91738. * @returns a new array filled with new objects
  91739. */
  91740. ArrayTools.BuildArray = function (size, itemBuilder) {
  91741. var a = [];
  91742. for (var i = 0; i < size; ++i) {
  91743. a.push(itemBuilder());
  91744. }
  91745. return a;
  91746. };
  91747. return ArrayTools;
  91748. }());
  91749. /***/ }),
  91750. /***/ "./Misc/assetsManager.ts":
  91751. /*!*******************************!*\
  91752. !*** ./Misc/assetsManager.ts ***!
  91753. \*******************************/
  91754. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  91755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91756. "use strict";
  91757. __webpack_require__.r(__webpack_exports__);
  91758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  91759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  91760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  91761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  91762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  91763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  91764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  91765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  91766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  91767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  91768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  91769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91770. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  91771. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  91772. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  91773. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  91774. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  91775. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  91776. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91777. /**
  91778. * Defines the list of states available for a task inside a AssetsManager
  91779. */
  91780. var AssetTaskState;
  91781. (function (AssetTaskState) {
  91782. /**
  91783. * Initialization
  91784. */
  91785. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  91786. /**
  91787. * Running
  91788. */
  91789. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  91790. /**
  91791. * Done
  91792. */
  91793. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91794. /**
  91795. * Error
  91796. */
  91797. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91798. })(AssetTaskState || (AssetTaskState = {}));
  91799. /**
  91800. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91801. */
  91802. var AbstractAssetTask = /** @class */ (function () {
  91803. /**
  91804. * Creates a new AssetsManager
  91805. * @param name defines the name of the task
  91806. */
  91807. function AbstractAssetTask(
  91808. /**
  91809. * Task name
  91810. */ name) {
  91811. this.name = name;
  91812. this._isCompleted = false;
  91813. this._taskState = AssetTaskState.INIT;
  91814. }
  91815. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91816. /**
  91817. * Get if the task is completed
  91818. */
  91819. get: function () {
  91820. return this._isCompleted;
  91821. },
  91822. enumerable: true,
  91823. configurable: true
  91824. });
  91825. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  91826. /**
  91827. * Gets the current state of the task
  91828. */
  91829. get: function () {
  91830. return this._taskState;
  91831. },
  91832. enumerable: true,
  91833. configurable: true
  91834. });
  91835. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  91836. /**
  91837. * Gets the current error object (if task is in error)
  91838. */
  91839. get: function () {
  91840. return this._errorObject;
  91841. },
  91842. enumerable: true,
  91843. configurable: true
  91844. });
  91845. /**
  91846. * Internal only
  91847. * @hidden
  91848. */
  91849. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  91850. if (this._errorObject) {
  91851. return;
  91852. }
  91853. this._errorObject = {
  91854. message: message,
  91855. exception: exception
  91856. };
  91857. };
  91858. /**
  91859. * Execute the current task
  91860. * @param scene defines the scene where you want your assets to be loaded
  91861. * @param onSuccess is a callback called when the task is successfully executed
  91862. * @param onError is a callback called if an error occurs
  91863. */
  91864. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91865. var _this = this;
  91866. this._taskState = AssetTaskState.RUNNING;
  91867. this.runTask(scene, function () {
  91868. _this.onDoneCallback(onSuccess, onError);
  91869. }, function (msg, exception) {
  91870. _this.onErrorCallback(onError, msg, exception);
  91871. });
  91872. };
  91873. /**
  91874. * Execute the current task
  91875. * @param scene defines the scene where you want your assets to be loaded
  91876. * @param onSuccess is a callback called when the task is successfully executed
  91877. * @param onError is a callback called if an error occurs
  91878. */
  91879. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91880. throw new Error("runTask is not implemented");
  91881. };
  91882. /**
  91883. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  91884. * This can be used with failed tasks that have the reason for failure fixed.
  91885. */
  91886. AbstractAssetTask.prototype.reset = function () {
  91887. this._taskState = AssetTaskState.INIT;
  91888. };
  91889. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  91890. this._taskState = AssetTaskState.ERROR;
  91891. this._errorObject = {
  91892. message: message,
  91893. exception: exception
  91894. };
  91895. if (this.onError) {
  91896. this.onError(this, message, exception);
  91897. }
  91898. onError();
  91899. };
  91900. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  91901. try {
  91902. this._taskState = AssetTaskState.DONE;
  91903. this._isCompleted = true;
  91904. if (this.onSuccess) {
  91905. this.onSuccess(this);
  91906. }
  91907. onSuccess();
  91908. }
  91909. catch (e) {
  91910. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  91911. }
  91912. };
  91913. return AbstractAssetTask;
  91914. }());
  91915. /**
  91916. * Class used to share progress information about assets loading
  91917. */
  91918. var AssetsProgressEvent = /** @class */ (function () {
  91919. /**
  91920. * Creates a AssetsProgressEvent
  91921. * @param remainingCount defines the number of remaining tasks to process
  91922. * @param totalCount defines the total number of tasks
  91923. * @param task defines the task that was just processed
  91924. */
  91925. function AssetsProgressEvent(remainingCount, totalCount, task) {
  91926. this.remainingCount = remainingCount;
  91927. this.totalCount = totalCount;
  91928. this.task = task;
  91929. }
  91930. return AssetsProgressEvent;
  91931. }());
  91932. /**
  91933. * Define a task used by AssetsManager to load meshes
  91934. */
  91935. var MeshAssetTask = /** @class */ (function (_super) {
  91936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  91937. /**
  91938. * Creates a new MeshAssetTask
  91939. * @param name defines the name of the task
  91940. * @param meshesNames defines the list of mesh's names you want to load
  91941. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  91942. * @param sceneFilename defines the filename of the scene to load from
  91943. */
  91944. function MeshAssetTask(
  91945. /**
  91946. * Defines the name of the task
  91947. */
  91948. name,
  91949. /**
  91950. * Defines the list of mesh's names you want to load
  91951. */
  91952. meshesNames,
  91953. /**
  91954. * Defines the root url to use as a base to load your meshes and associated resources
  91955. */
  91956. rootUrl,
  91957. /**
  91958. * Defines the filename of the scene to load from
  91959. */
  91960. sceneFilename) {
  91961. var _this = _super.call(this, name) || this;
  91962. _this.name = name;
  91963. _this.meshesNames = meshesNames;
  91964. _this.rootUrl = rootUrl;
  91965. _this.sceneFilename = sceneFilename;
  91966. return _this;
  91967. }
  91968. /**
  91969. * Execute the current task
  91970. * @param scene defines the scene where you want your assets to be loaded
  91971. * @param onSuccess is a callback called when the task is successfully executed
  91972. * @param onError is a callback called if an error occurs
  91973. */
  91974. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91975. var _this = this;
  91976. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  91977. _this.loadedMeshes = meshes;
  91978. _this.loadedParticleSystems = particleSystems;
  91979. _this.loadedSkeletons = skeletons;
  91980. _this.loadedAnimationGroups = animationGroups;
  91981. onSuccess();
  91982. }, null, function (scene, message, exception) {
  91983. onError(message, exception);
  91984. });
  91985. };
  91986. return MeshAssetTask;
  91987. }(AbstractAssetTask));
  91988. /**
  91989. * Define a task used by AssetsManager to load text content
  91990. */
  91991. var TextFileAssetTask = /** @class */ (function (_super) {
  91992. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  91993. /**
  91994. * Creates a new TextFileAssetTask object
  91995. * @param name defines the name of the task
  91996. * @param url defines the location of the file to load
  91997. */
  91998. function TextFileAssetTask(
  91999. /**
  92000. * Defines the name of the task
  92001. */
  92002. name,
  92003. /**
  92004. * Defines the location of the file to load
  92005. */
  92006. url) {
  92007. var _this = _super.call(this, name) || this;
  92008. _this.name = name;
  92009. _this.url = url;
  92010. return _this;
  92011. }
  92012. /**
  92013. * Execute the current task
  92014. * @param scene defines the scene where you want your assets to be loaded
  92015. * @param onSuccess is a callback called when the task is successfully executed
  92016. * @param onError is a callback called if an error occurs
  92017. */
  92018. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92019. var _this = this;
  92020. scene._loadFile(this.url, function (data) {
  92021. _this.text = data;
  92022. onSuccess();
  92023. }, undefined, false, false, function (request, exception) {
  92024. if (request) {
  92025. onError(request.status + " " + request.statusText, exception);
  92026. }
  92027. });
  92028. };
  92029. return TextFileAssetTask;
  92030. }(AbstractAssetTask));
  92031. /**
  92032. * Define a task used by AssetsManager to load binary data
  92033. */
  92034. var BinaryFileAssetTask = /** @class */ (function (_super) {
  92035. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  92036. /**
  92037. * Creates a new BinaryFileAssetTask object
  92038. * @param name defines the name of the new task
  92039. * @param url defines the location of the file to load
  92040. */
  92041. function BinaryFileAssetTask(
  92042. /**
  92043. * Defines the name of the task
  92044. */
  92045. name,
  92046. /**
  92047. * Defines the location of the file to load
  92048. */
  92049. url) {
  92050. var _this = _super.call(this, name) || this;
  92051. _this.name = name;
  92052. _this.url = url;
  92053. return _this;
  92054. }
  92055. /**
  92056. * Execute the current task
  92057. * @param scene defines the scene where you want your assets to be loaded
  92058. * @param onSuccess is a callback called when the task is successfully executed
  92059. * @param onError is a callback called if an error occurs
  92060. */
  92061. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92062. var _this = this;
  92063. scene._loadFile(this.url, function (data) {
  92064. _this.data = data;
  92065. onSuccess();
  92066. }, undefined, true, true, function (request, exception) {
  92067. if (request) {
  92068. onError(request.status + " " + request.statusText, exception);
  92069. }
  92070. });
  92071. };
  92072. return BinaryFileAssetTask;
  92073. }(AbstractAssetTask));
  92074. /**
  92075. * Define a task used by AssetsManager to load images
  92076. */
  92077. var ImageAssetTask = /** @class */ (function (_super) {
  92078. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  92079. /**
  92080. * Creates a new ImageAssetTask
  92081. * @param name defines the name of the task
  92082. * @param url defines the location of the image to load
  92083. */
  92084. function ImageAssetTask(
  92085. /**
  92086. * Defines the name of the task
  92087. */
  92088. name,
  92089. /**
  92090. * Defines the location of the image to load
  92091. */
  92092. url) {
  92093. var _this = _super.call(this, name) || this;
  92094. _this.name = name;
  92095. _this.url = url;
  92096. return _this;
  92097. }
  92098. /**
  92099. * Execute the current task
  92100. * @param scene defines the scene where you want your assets to be loaded
  92101. * @param onSuccess is a callback called when the task is successfully executed
  92102. * @param onError is a callback called if an error occurs
  92103. */
  92104. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92105. var _this = this;
  92106. var img = new Image();
  92107. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  92108. img.onload = function () {
  92109. _this.image = img;
  92110. onSuccess();
  92111. };
  92112. img.onerror = function (err) {
  92113. onError("Error loading image", err);
  92114. };
  92115. img.src = this.url;
  92116. };
  92117. return ImageAssetTask;
  92118. }(AbstractAssetTask));
  92119. /**
  92120. * Define a task used by AssetsManager to load 2D textures
  92121. */
  92122. var TextureAssetTask = /** @class */ (function (_super) {
  92123. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  92124. /**
  92125. * Creates a new TextureAssetTask object
  92126. * @param name defines the name of the task
  92127. * @param url defines the location of the file to load
  92128. * @param noMipmap defines if mipmap should not be generated (default is false)
  92129. * @param invertY defines if texture must be inverted on Y axis (default is false)
  92130. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92131. */
  92132. function TextureAssetTask(
  92133. /**
  92134. * Defines the name of the task
  92135. */
  92136. name,
  92137. /**
  92138. * Defines the location of the file to load
  92139. */
  92140. url,
  92141. /**
  92142. * Defines if mipmap should not be generated (default is false)
  92143. */
  92144. noMipmap,
  92145. /**
  92146. * Defines if texture must be inverted on Y axis (default is false)
  92147. */
  92148. invertY,
  92149. /**
  92150. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92151. */
  92152. samplingMode) {
  92153. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92154. var _this = _super.call(this, name) || this;
  92155. _this.name = name;
  92156. _this.url = url;
  92157. _this.noMipmap = noMipmap;
  92158. _this.invertY = invertY;
  92159. _this.samplingMode = samplingMode;
  92160. return _this;
  92161. }
  92162. /**
  92163. * Execute the current task
  92164. * @param scene defines the scene where you want your assets to be loaded
  92165. * @param onSuccess is a callback called when the task is successfully executed
  92166. * @param onError is a callback called if an error occurs
  92167. */
  92168. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92169. var onload = function () {
  92170. onSuccess();
  92171. };
  92172. var onerror = function (message, exception) {
  92173. onError(message, exception);
  92174. };
  92175. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92176. };
  92177. return TextureAssetTask;
  92178. }(AbstractAssetTask));
  92179. /**
  92180. * Define a task used by AssetsManager to load cube textures
  92181. */
  92182. var CubeTextureAssetTask = /** @class */ (function (_super) {
  92183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  92184. /**
  92185. * Creates a new CubeTextureAssetTask
  92186. * @param name defines the name of the task
  92187. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92188. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92189. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92190. * @param files defines the explicit list of files (undefined by default)
  92191. */
  92192. function CubeTextureAssetTask(
  92193. /**
  92194. * Defines the name of the task
  92195. */
  92196. name,
  92197. /**
  92198. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92199. */
  92200. url,
  92201. /**
  92202. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92203. */
  92204. extensions,
  92205. /**
  92206. * Defines if mipmaps should not be generated (default is false)
  92207. */
  92208. noMipmap,
  92209. /**
  92210. * Defines the explicit list of files (undefined by default)
  92211. */
  92212. files) {
  92213. var _this = _super.call(this, name) || this;
  92214. _this.name = name;
  92215. _this.url = url;
  92216. _this.extensions = extensions;
  92217. _this.noMipmap = noMipmap;
  92218. _this.files = files;
  92219. return _this;
  92220. }
  92221. /**
  92222. * Execute the current task
  92223. * @param scene defines the scene where you want your assets to be loaded
  92224. * @param onSuccess is a callback called when the task is successfully executed
  92225. * @param onError is a callback called if an error occurs
  92226. */
  92227. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92228. var onload = function () {
  92229. onSuccess();
  92230. };
  92231. var onerror = function (message, exception) {
  92232. onError(message, exception);
  92233. };
  92234. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  92235. };
  92236. return CubeTextureAssetTask;
  92237. }(AbstractAssetTask));
  92238. /**
  92239. * Define a task used by AssetsManager to load HDR cube textures
  92240. */
  92241. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  92242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  92243. /**
  92244. * Creates a new HDRCubeTextureAssetTask object
  92245. * @param name defines the name of the task
  92246. * @param url defines the location of the file to load
  92247. * @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.
  92248. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92249. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92250. * @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)
  92251. * @param reserved Internal use only
  92252. */
  92253. function HDRCubeTextureAssetTask(
  92254. /**
  92255. * Defines the name of the task
  92256. */
  92257. name,
  92258. /**
  92259. * Defines the location of the file to load
  92260. */
  92261. url,
  92262. /**
  92263. * Defines the desired size (the more it increases the longer the generation will be)
  92264. */
  92265. size,
  92266. /**
  92267. * Defines if mipmaps should not be generated (default is false)
  92268. */
  92269. noMipmap,
  92270. /**
  92271. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92272. */
  92273. generateHarmonics,
  92274. /**
  92275. * 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)
  92276. */
  92277. gammaSpace,
  92278. /**
  92279. * Internal Use Only
  92280. */
  92281. reserved) {
  92282. if (noMipmap === void 0) { noMipmap = false; }
  92283. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92284. if (gammaSpace === void 0) { gammaSpace = false; }
  92285. if (reserved === void 0) { reserved = false; }
  92286. var _this = _super.call(this, name) || this;
  92287. _this.name = name;
  92288. _this.url = url;
  92289. _this.size = size;
  92290. _this.noMipmap = noMipmap;
  92291. _this.generateHarmonics = generateHarmonics;
  92292. _this.gammaSpace = gammaSpace;
  92293. _this.reserved = reserved;
  92294. return _this;
  92295. }
  92296. /**
  92297. * Execute the current task
  92298. * @param scene defines the scene where you want your assets to be loaded
  92299. * @param onSuccess is a callback called when the task is successfully executed
  92300. * @param onError is a callback called if an error occurs
  92301. */
  92302. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92303. var onload = function () {
  92304. onSuccess();
  92305. };
  92306. var onerror = function (message, exception) {
  92307. onError(message, exception);
  92308. };
  92309. 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);
  92310. };
  92311. return HDRCubeTextureAssetTask;
  92312. }(AbstractAssetTask));
  92313. /**
  92314. * This class can be used to easily import assets into a scene
  92315. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  92316. */
  92317. var AssetsManager = /** @class */ (function () {
  92318. /**
  92319. * Creates a new AssetsManager
  92320. * @param scene defines the scene to work on
  92321. */
  92322. function AssetsManager(scene) {
  92323. this._isLoading = false;
  92324. this._tasks = new Array();
  92325. this._waitingTasksCount = 0;
  92326. this._totalTasksCount = 0;
  92327. /**
  92328. * Observable called when all tasks are processed
  92329. */
  92330. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92331. /**
  92332. * Observable called when a task had an error
  92333. */
  92334. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92335. /**
  92336. * Observable called when a task is successful
  92337. */
  92338. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92339. /**
  92340. * Observable called when a task is done (whatever the result is)
  92341. */
  92342. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92343. /**
  92344. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  92345. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92346. */
  92347. this.useDefaultLoadingScreen = true;
  92348. this._scene = scene;
  92349. }
  92350. /**
  92351. * Add a MeshAssetTask to the list of active tasks
  92352. * @param taskName defines the name of the new task
  92353. * @param meshesNames defines the name of meshes to load
  92354. * @param rootUrl defines the root url to use to locate files
  92355. * @param sceneFilename defines the filename of the scene file
  92356. * @returns a new MeshAssetTask object
  92357. */
  92358. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  92359. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  92360. this._tasks.push(task);
  92361. return task;
  92362. };
  92363. /**
  92364. * Add a TextFileAssetTask to the list of active tasks
  92365. * @param taskName defines the name of the new task
  92366. * @param url defines the url of the file to load
  92367. * @returns a new TextFileAssetTask object
  92368. */
  92369. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  92370. var task = new TextFileAssetTask(taskName, url);
  92371. this._tasks.push(task);
  92372. return task;
  92373. };
  92374. /**
  92375. * Add a BinaryFileAssetTask to the list of active tasks
  92376. * @param taskName defines the name of the new task
  92377. * @param url defines the url of the file to load
  92378. * @returns a new BinaryFileAssetTask object
  92379. */
  92380. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  92381. var task = new BinaryFileAssetTask(taskName, url);
  92382. this._tasks.push(task);
  92383. return task;
  92384. };
  92385. /**
  92386. * Add a ImageAssetTask to the list of active tasks
  92387. * @param taskName defines the name of the new task
  92388. * @param url defines the url of the file to load
  92389. * @returns a new ImageAssetTask object
  92390. */
  92391. AssetsManager.prototype.addImageTask = function (taskName, url) {
  92392. var task = new ImageAssetTask(taskName, url);
  92393. this._tasks.push(task);
  92394. return task;
  92395. };
  92396. /**
  92397. * Add a TextureAssetTask to the list of active tasks
  92398. * @param taskName defines the name of the new task
  92399. * @param url defines the url of the file to load
  92400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92401. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  92402. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  92403. * @returns a new TextureAssetTask object
  92404. */
  92405. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  92406. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92407. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  92408. this._tasks.push(task);
  92409. return task;
  92410. };
  92411. /**
  92412. * Add a CubeTextureAssetTask to the list of active tasks
  92413. * @param taskName defines the name of the new task
  92414. * @param url defines the url of the file to load
  92415. * @param extensions defines the extension to use to load the cube map (can be null)
  92416. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92417. * @param files defines the list of files to load (can be null)
  92418. * @returns a new CubeTextureAssetTask object
  92419. */
  92420. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  92421. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  92422. this._tasks.push(task);
  92423. return task;
  92424. };
  92425. /**
  92426. *
  92427. * Add a HDRCubeTextureAssetTask to the list of active tasks
  92428. * @param taskName defines the name of the new task
  92429. * @param url defines the url of the file to load
  92430. * @param size defines the size you want for the cubemap (can be null)
  92431. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92432. * @param generateHarmonics defines if you want to automatically generate (true by default)
  92433. * @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)
  92434. * @param reserved Internal use only
  92435. * @returns a new HDRCubeTextureAssetTask object
  92436. */
  92437. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  92438. if (noMipmap === void 0) { noMipmap = false; }
  92439. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92440. if (gammaSpace === void 0) { gammaSpace = false; }
  92441. if (reserved === void 0) { reserved = false; }
  92442. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  92443. this._tasks.push(task);
  92444. return task;
  92445. };
  92446. /**
  92447. * Remove a task from the assets manager.
  92448. * @param task the task to remove
  92449. */
  92450. AssetsManager.prototype.removeTask = function (task) {
  92451. var index = this._tasks.indexOf(task);
  92452. if (index > -1) {
  92453. this._tasks.splice(index, 1);
  92454. }
  92455. };
  92456. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  92457. this._waitingTasksCount--;
  92458. try {
  92459. if (this.onProgress) {
  92460. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  92461. }
  92462. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  92463. }
  92464. catch (e) {
  92465. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  92466. console.log(e);
  92467. }
  92468. if (this._waitingTasksCount === 0) {
  92469. try {
  92470. if (this.onFinish) {
  92471. this.onFinish(this._tasks);
  92472. }
  92473. // Let's remove successfull tasks
  92474. var currentTasks = this._tasks.slice();
  92475. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  92476. var task = currentTasks_1[_i];
  92477. if (task.taskState === AssetTaskState.DONE) {
  92478. var index = this._tasks.indexOf(task);
  92479. if (index > -1) {
  92480. this._tasks.splice(index, 1);
  92481. }
  92482. }
  92483. }
  92484. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92485. }
  92486. catch (e) {
  92487. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  92488. console.log(e);
  92489. }
  92490. this._isLoading = false;
  92491. this._scene.getEngine().hideLoadingUI();
  92492. }
  92493. };
  92494. AssetsManager.prototype._runTask = function (task) {
  92495. var _this = this;
  92496. var done = function () {
  92497. try {
  92498. if (_this.onTaskSuccess) {
  92499. _this.onTaskSuccess(task);
  92500. }
  92501. _this.onTaskSuccessObservable.notifyObservers(task);
  92502. _this._decreaseWaitingTasksCount(task);
  92503. }
  92504. catch (e) {
  92505. error("Error executing task success callbacks", e);
  92506. }
  92507. };
  92508. var error = function (message, exception) {
  92509. task._setErrorObject(message, exception);
  92510. if (_this.onTaskError) {
  92511. _this.onTaskError(task);
  92512. }
  92513. _this.onTaskErrorObservable.notifyObservers(task);
  92514. _this._decreaseWaitingTasksCount(task);
  92515. };
  92516. task.run(this._scene, done, error);
  92517. };
  92518. /**
  92519. * Reset the AssetsManager and remove all tasks
  92520. * @return the current instance of the AssetsManager
  92521. */
  92522. AssetsManager.prototype.reset = function () {
  92523. this._isLoading = false;
  92524. this._tasks = new Array();
  92525. return this;
  92526. };
  92527. /**
  92528. * Start the loading process
  92529. * @return the current instance of the AssetsManager
  92530. */
  92531. AssetsManager.prototype.load = function () {
  92532. if (this._isLoading) {
  92533. return this;
  92534. }
  92535. this._isLoading = true;
  92536. this._waitingTasksCount = this._tasks.length;
  92537. this._totalTasksCount = this._tasks.length;
  92538. if (this._waitingTasksCount === 0) {
  92539. this._isLoading = false;
  92540. if (this.onFinish) {
  92541. this.onFinish(this._tasks);
  92542. }
  92543. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92544. return this;
  92545. }
  92546. if (this.useDefaultLoadingScreen) {
  92547. this._scene.getEngine().displayLoadingUI();
  92548. }
  92549. for (var index = 0; index < this._tasks.length; index++) {
  92550. var task = this._tasks[index];
  92551. if (task.taskState === AssetTaskState.INIT) {
  92552. this._runTask(task);
  92553. }
  92554. }
  92555. return this;
  92556. };
  92557. return AssetsManager;
  92558. }());
  92559. /***/ }),
  92560. /***/ "./Misc/dds.ts":
  92561. /*!*********************!*\
  92562. !*** ./Misc/dds.ts ***!
  92563. \*********************/
  92564. /*! exports provided: DDSTools */
  92565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92566. "use strict";
  92567. __webpack_require__.r(__webpack_exports__);
  92568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  92569. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92570. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92572. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92573. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92574. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92575. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92576. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92577. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  92578. // All values and structures referenced from:
  92579. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  92580. var DDS_MAGIC = 0x20534444;
  92581. var
  92582. //DDSD_CAPS = 0x1,
  92583. //DDSD_HEIGHT = 0x2,
  92584. //DDSD_WIDTH = 0x4,
  92585. //DDSD_PITCH = 0x8,
  92586. //DDSD_PIXELFORMAT = 0x1000,
  92587. DDSD_MIPMAPCOUNT = 0x20000;
  92588. //DDSD_LINEARSIZE = 0x80000,
  92589. //DDSD_DEPTH = 0x800000;
  92590. // var DDSCAPS_COMPLEX = 0x8,
  92591. // DDSCAPS_MIPMAP = 0x400000,
  92592. // DDSCAPS_TEXTURE = 0x1000;
  92593. var DDSCAPS2_CUBEMAP = 0x200;
  92594. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  92595. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  92596. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  92597. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  92598. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  92599. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  92600. // DDSCAPS2_VOLUME = 0x200000;
  92601. var
  92602. //DDPF_ALPHAPIXELS = 0x1,
  92603. //DDPF_ALPHA = 0x2,
  92604. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  92605. //DDPF_YUV = 0x200,
  92606. DDPF_LUMINANCE = 0x20000;
  92607. function FourCCToInt32(value) {
  92608. return value.charCodeAt(0) +
  92609. (value.charCodeAt(1) << 8) +
  92610. (value.charCodeAt(2) << 16) +
  92611. (value.charCodeAt(3) << 24);
  92612. }
  92613. function Int32ToFourCC(value) {
  92614. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  92615. }
  92616. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  92617. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  92618. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  92619. var FOURCC_DX10 = FourCCToInt32("DX10");
  92620. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  92621. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  92622. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  92623. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  92624. var headerLengthInt = 31; // The header length in 32 bit ints
  92625. // Offsets into the header array
  92626. var off_magic = 0;
  92627. var off_size = 1;
  92628. var off_flags = 2;
  92629. var off_height = 3;
  92630. var off_width = 4;
  92631. var off_mipmapCount = 7;
  92632. var off_pfFlags = 20;
  92633. var off_pfFourCC = 21;
  92634. var off_RGBbpp = 22;
  92635. var off_RMask = 23;
  92636. var off_GMask = 24;
  92637. var off_BMask = 25;
  92638. var off_AMask = 26;
  92639. // var off_caps1 = 27;
  92640. var off_caps2 = 28;
  92641. // var off_caps3 = 29;
  92642. // var off_caps4 = 30;
  92643. var off_dxgiFormat = 32;
  92644. /**
  92645. * Class used to provide DDS decompression tools
  92646. */
  92647. var DDSTools = /** @class */ (function () {
  92648. function DDSTools() {
  92649. }
  92650. /**
  92651. * Gets DDS information from an array buffer
  92652. * @param arrayBuffer defines the array buffer to read data from
  92653. * @returns the DDS information
  92654. */
  92655. DDSTools.GetDDSInfo = function (arrayBuffer) {
  92656. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92657. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  92658. var mipmapCount = 1;
  92659. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  92660. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92661. }
  92662. var fourCC = header[off_pfFourCC];
  92663. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  92664. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92665. switch (fourCC) {
  92666. case FOURCC_D3DFMT_R16G16B16A16F:
  92667. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92668. break;
  92669. case FOURCC_D3DFMT_R32G32B32A32F:
  92670. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92671. break;
  92672. case FOURCC_DX10:
  92673. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  92674. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92675. break;
  92676. }
  92677. }
  92678. return {
  92679. width: header[off_width],
  92680. height: header[off_height],
  92681. mipmapCount: mipmapCount,
  92682. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  92683. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  92684. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  92685. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  92686. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  92687. dxgiFormat: dxgiFormat,
  92688. textureType: textureType
  92689. };
  92690. };
  92691. DDSTools._ToHalfFloat = function (value) {
  92692. if (!DDSTools._FloatView) {
  92693. DDSTools._FloatView = new Float32Array(1);
  92694. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  92695. }
  92696. DDSTools._FloatView[0] = value;
  92697. var x = DDSTools._Int32View[0];
  92698. var bits = (x >> 16) & 0x8000; /* Get the sign */
  92699. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  92700. var e = (x >> 23) & 0xff; /* Using int is faster here */
  92701. /* If zero, or denormal, or exponent underflows too much for a denormal
  92702. * half, return signed zero. */
  92703. if (e < 103) {
  92704. return bits;
  92705. }
  92706. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  92707. if (e > 142) {
  92708. bits |= 0x7c00;
  92709. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  92710. * not Inf, so make sure we set one mantissa bit too. */
  92711. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  92712. return bits;
  92713. }
  92714. /* If exponent underflows but not too much, return a denormal */
  92715. if (e < 113) {
  92716. m |= 0x0800;
  92717. /* Extra rounding may overflow and set mantissa to 0 and exponent
  92718. * to 1, which is OK. */
  92719. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  92720. return bits;
  92721. }
  92722. bits |= ((e - 112) << 10) | (m >> 1);
  92723. bits += m & 1;
  92724. return bits;
  92725. };
  92726. DDSTools._FromHalfFloat = function (value) {
  92727. var s = (value & 0x8000) >> 15;
  92728. var e = (value & 0x7C00) >> 10;
  92729. var f = value & 0x03FF;
  92730. if (e === 0) {
  92731. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  92732. }
  92733. else if (e == 0x1F) {
  92734. return f ? NaN : ((s ? -1 : 1) * Infinity);
  92735. }
  92736. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  92737. };
  92738. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92739. var destArray = new Float32Array(dataLength);
  92740. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92741. var index = 0;
  92742. for (var y = 0; y < height; y++) {
  92743. for (var x = 0; x < width; x++) {
  92744. var srcPos = (x + y * width) * 4;
  92745. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  92746. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  92747. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  92748. if (DDSTools.StoreLODInAlphaChannel) {
  92749. destArray[index + 3] = lod;
  92750. }
  92751. else {
  92752. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  92753. }
  92754. index += 4;
  92755. }
  92756. }
  92757. return destArray;
  92758. };
  92759. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92760. if (DDSTools.StoreLODInAlphaChannel) {
  92761. var destArray = new Uint16Array(dataLength);
  92762. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92763. var index = 0;
  92764. for (var y = 0; y < height; y++) {
  92765. for (var x = 0; x < width; x++) {
  92766. var srcPos = (x + y * width) * 4;
  92767. destArray[index] = srcData[srcPos];
  92768. destArray[index + 1] = srcData[srcPos + 1];
  92769. destArray[index + 2] = srcData[srcPos + 2];
  92770. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  92771. index += 4;
  92772. }
  92773. }
  92774. return destArray;
  92775. }
  92776. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  92777. };
  92778. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92779. if (DDSTools.StoreLODInAlphaChannel) {
  92780. var destArray = new Float32Array(dataLength);
  92781. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92782. var index = 0;
  92783. for (var y = 0; y < height; y++) {
  92784. for (var x = 0; x < width; x++) {
  92785. var srcPos = (x + y * width) * 4;
  92786. destArray[index] = srcData[srcPos];
  92787. destArray[index + 1] = srcData[srcPos + 1];
  92788. destArray[index + 2] = srcData[srcPos + 2];
  92789. destArray[index + 3] = lod;
  92790. index += 4;
  92791. }
  92792. }
  92793. return destArray;
  92794. }
  92795. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92796. };
  92797. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92798. var destArray = new Uint8Array(dataLength);
  92799. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92800. var index = 0;
  92801. for (var y = 0; y < height; y++) {
  92802. for (var x = 0; x < width; x++) {
  92803. var srcPos = (x + y * width) * 4;
  92804. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92805. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92806. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92807. if (DDSTools.StoreLODInAlphaChannel) {
  92808. destArray[index + 3] = lod;
  92809. }
  92810. else {
  92811. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92812. }
  92813. index += 4;
  92814. }
  92815. }
  92816. return destArray;
  92817. };
  92818. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92819. var destArray = new Uint8Array(dataLength);
  92820. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92821. var index = 0;
  92822. for (var y = 0; y < height; y++) {
  92823. for (var x = 0; x < width; x++) {
  92824. var srcPos = (x + y * width) * 4;
  92825. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  92826. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  92827. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  92828. if (DDSTools.StoreLODInAlphaChannel) {
  92829. destArray[index + 3] = lod;
  92830. }
  92831. else {
  92832. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  92833. }
  92834. index += 4;
  92835. }
  92836. }
  92837. return destArray;
  92838. };
  92839. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  92840. var byteArray = new Uint8Array(dataLength);
  92841. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92842. var index = 0;
  92843. for (var y = 0; y < height; y++) {
  92844. for (var x = 0; x < width; x++) {
  92845. var srcPos = (x + y * width) * 4;
  92846. byteArray[index] = srcData[srcPos + rOffset];
  92847. byteArray[index + 1] = srcData[srcPos + gOffset];
  92848. byteArray[index + 2] = srcData[srcPos + bOffset];
  92849. byteArray[index + 3] = srcData[srcPos + aOffset];
  92850. index += 4;
  92851. }
  92852. }
  92853. return byteArray;
  92854. };
  92855. DDSTools._ExtractLongWordOrder = function (value) {
  92856. if (value === 0 || value === 255 || value === -16777216) {
  92857. return 0;
  92858. }
  92859. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  92860. };
  92861. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  92862. var byteArray = new Uint8Array(dataLength);
  92863. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92864. var index = 0;
  92865. for (var y = 0; y < height; y++) {
  92866. for (var x = 0; x < width; x++) {
  92867. var srcPos = (x + y * width) * 3;
  92868. byteArray[index] = srcData[srcPos + rOffset];
  92869. byteArray[index + 1] = srcData[srcPos + gOffset];
  92870. byteArray[index + 2] = srcData[srcPos + bOffset];
  92871. index += 3;
  92872. }
  92873. }
  92874. return byteArray;
  92875. };
  92876. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  92877. var byteArray = new Uint8Array(dataLength);
  92878. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92879. var index = 0;
  92880. for (var y = 0; y < height; y++) {
  92881. for (var x = 0; x < width; x++) {
  92882. var srcPos = (x + y * width);
  92883. byteArray[index] = srcData[srcPos];
  92884. index++;
  92885. }
  92886. }
  92887. return byteArray;
  92888. };
  92889. /**
  92890. * Uploads DDS Levels to a Babylon Texture
  92891. * @hidden
  92892. */
  92893. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  92894. if (lodIndex === void 0) { lodIndex = -1; }
  92895. var sphericalPolynomialFaces = null;
  92896. if (info.sphericalPolynomial) {
  92897. sphericalPolynomialFaces = new Array();
  92898. }
  92899. var ext = engine.getCaps().s3tc;
  92900. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92901. var fourCC, width, height, dataLength = 0, dataOffset;
  92902. var byteArray, mipmapCount, mip;
  92903. var internalCompressedFormat = 0;
  92904. var blockBytes = 1;
  92905. if (header[off_magic] !== DDS_MAGIC) {
  92906. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  92907. return;
  92908. }
  92909. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  92910. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  92911. return;
  92912. }
  92913. if (info.isCompressed && !ext) {
  92914. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  92915. return;
  92916. }
  92917. var bpp = header[off_RGBbpp];
  92918. dataOffset = header[off_size] + 4;
  92919. var computeFormats = false;
  92920. if (info.isFourCC) {
  92921. fourCC = header[off_pfFourCC];
  92922. switch (fourCC) {
  92923. case FOURCC_DXT1:
  92924. blockBytes = 8;
  92925. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  92926. break;
  92927. case FOURCC_DXT3:
  92928. blockBytes = 16;
  92929. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  92930. break;
  92931. case FOURCC_DXT5:
  92932. blockBytes = 16;
  92933. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  92934. break;
  92935. case FOURCC_D3DFMT_R16G16B16A16F:
  92936. computeFormats = true;
  92937. break;
  92938. case FOURCC_D3DFMT_R32G32B32A32F:
  92939. computeFormats = true;
  92940. break;
  92941. case FOURCC_DX10:
  92942. // There is an additionnal header so dataOffset need to be changed
  92943. dataOffset += 5 * 4; // 5 uints
  92944. var supported = false;
  92945. switch (info.dxgiFormat) {
  92946. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  92947. computeFormats = true;
  92948. supported = true;
  92949. break;
  92950. case DXGI_FORMAT_B8G8R8X8_UNORM:
  92951. info.isRGB = true;
  92952. info.isFourCC = false;
  92953. bpp = 32;
  92954. supported = true;
  92955. break;
  92956. }
  92957. if (supported) {
  92958. break;
  92959. }
  92960. default:
  92961. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  92962. return;
  92963. }
  92964. }
  92965. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  92966. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  92967. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  92968. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  92969. if (computeFormats) {
  92970. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  92971. }
  92972. mipmapCount = 1;
  92973. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  92974. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92975. }
  92976. for (var face = 0; face < faces; face++) {
  92977. width = header[off_width];
  92978. height = header[off_height];
  92979. for (mip = 0; mip < mipmapCount; ++mip) {
  92980. if (lodIndex === -1 || lodIndex === mip) {
  92981. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  92982. var i = (lodIndex === -1) ? mip : 0;
  92983. if (!info.isCompressed && info.isFourCC) {
  92984. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92985. dataLength = width * height * 4;
  92986. var floatArray = null;
  92987. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  92988. if (bpp === 128) {
  92989. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92990. if (sphericalPolynomialFaces && i == 0) {
  92991. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92992. }
  92993. }
  92994. else if (bpp === 64) {
  92995. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92996. if (sphericalPolynomialFaces && i == 0) {
  92997. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92998. }
  92999. }
  93000. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93001. }
  93002. else {
  93003. if (bpp === 128) {
  93004. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93005. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93006. if (sphericalPolynomialFaces && i == 0) {
  93007. sphericalPolynomialFaces.push(floatArray);
  93008. }
  93009. }
  93010. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  93011. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93012. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93013. if (sphericalPolynomialFaces && i == 0) {
  93014. sphericalPolynomialFaces.push(floatArray);
  93015. }
  93016. }
  93017. else { // 64
  93018. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93019. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93020. if (sphericalPolynomialFaces && i == 0) {
  93021. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93022. }
  93023. }
  93024. }
  93025. if (floatArray) {
  93026. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  93027. }
  93028. }
  93029. else if (info.isRGB) {
  93030. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93031. if (bpp === 24) {
  93032. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  93033. dataLength = width * height * 3;
  93034. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  93035. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93036. }
  93037. else { // 32
  93038. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93039. dataLength = width * height * 4;
  93040. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  93041. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93042. }
  93043. }
  93044. else if (info.isLuminance) {
  93045. var unpackAlignment = engine._getUnpackAlignement();
  93046. var unpaddedRowSize = width;
  93047. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  93048. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  93049. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  93050. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  93051. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93052. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93053. }
  93054. else {
  93055. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  93056. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  93057. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93058. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  93059. }
  93060. }
  93061. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  93062. width *= 0.5;
  93063. height *= 0.5;
  93064. width = Math.max(1.0, width);
  93065. height = Math.max(1.0, height);
  93066. }
  93067. if (currentFace !== undefined) {
  93068. // Loading a single face
  93069. break;
  93070. }
  93071. }
  93072. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  93073. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  93074. size: header[off_width],
  93075. right: sphericalPolynomialFaces[0],
  93076. left: sphericalPolynomialFaces[1],
  93077. up: sphericalPolynomialFaces[2],
  93078. down: sphericalPolynomialFaces[3],
  93079. front: sphericalPolynomialFaces[4],
  93080. back: sphericalPolynomialFaces[5],
  93081. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  93082. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  93083. gammaSpace: false,
  93084. });
  93085. }
  93086. else {
  93087. info.sphericalPolynomial = undefined;
  93088. }
  93089. };
  93090. /**
  93091. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  93092. */
  93093. DDSTools.StoreLODInAlphaChannel = false;
  93094. return DDSTools;
  93095. }());
  93096. /**
  93097. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  93098. * @param rootUrl defines the url where the file to load is located
  93099. * @param scene defines the current scene
  93100. * @param lodScale defines scale to apply to the mip map selection
  93101. * @param lodOffset defines offset to apply to the mip map selection
  93102. * @param onLoad defines an optional callback raised when the texture is loaded
  93103. * @param onError defines an optional callback raised if there is an issue to load the texture
  93104. * @param format defines the format of the data
  93105. * @param forcedExtension defines the extension to use to pick the right loader
  93106. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  93107. * @returns the cube texture as an InternalTexture
  93108. */
  93109. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  93110. var _this = this;
  93111. if (onLoad === void 0) { onLoad = null; }
  93112. if (onError === void 0) { onError = null; }
  93113. if (forcedExtension === void 0) { forcedExtension = null; }
  93114. if (createPolynomials === void 0) { createPolynomials = true; }
  93115. var callback = function (loadData) {
  93116. if (!loadData) {
  93117. if (onLoad) {
  93118. onLoad(null);
  93119. }
  93120. return;
  93121. }
  93122. var texture = loadData.texture;
  93123. if (!createPolynomials) {
  93124. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  93125. }
  93126. else if (loadData.info.sphericalPolynomial) {
  93127. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  93128. }
  93129. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  93130. if (_this.getCaps().textureLOD) {
  93131. // Do not add extra process if texture lod is supported.
  93132. if (onLoad) {
  93133. onLoad(texture);
  93134. }
  93135. return;
  93136. }
  93137. var mipSlices = 3;
  93138. var gl = _this._gl;
  93139. var width = loadData.width;
  93140. if (!width) {
  93141. return;
  93142. }
  93143. var textures = [];
  93144. for (var i = 0; i < mipSlices; i++) {
  93145. //compute LOD from even spacing in smoothness (matching shader calculation)
  93146. var smoothness = i / (mipSlices - 1);
  93147. var roughness = 1 - smoothness;
  93148. var minLODIndex = lodOffset; // roughness = 0
  93149. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  93150. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93151. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93152. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93153. glTextureFromLod.type = texture.type;
  93154. glTextureFromLod.format = texture.format;
  93155. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  93156. glTextureFromLod.height = glTextureFromLod.width;
  93157. glTextureFromLod.isCube = true;
  93158. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  93159. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  93160. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  93161. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  93162. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  93163. if (loadData.isDDS) {
  93164. var info = loadData.info;
  93165. var data = loadData.data;
  93166. _this._unpackFlipY(info.isCompressed);
  93167. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  93168. }
  93169. else {
  93170. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  93171. }
  93172. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93173. // Wrap in a base texture for easy binding.
  93174. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93175. lodTexture.isCube = true;
  93176. lodTexture._texture = glTextureFromLod;
  93177. glTextureFromLod.isReady = true;
  93178. textures.push(lodTexture);
  93179. }
  93180. texture._lodTextureHigh = textures[2];
  93181. texture._lodTextureMid = textures[1];
  93182. texture._lodTextureLow = textures[0];
  93183. if (onLoad) {
  93184. onLoad(texture);
  93185. }
  93186. };
  93187. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  93188. };
  93189. /***/ }),
  93190. /***/ "./Misc/decorators.ts":
  93191. /*!****************************!*\
  93192. !*** ./Misc/decorators.ts ***!
  93193. \****************************/
  93194. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  93195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93196. "use strict";
  93197. __webpack_require__.r(__webpack_exports__);
  93198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  93199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  93200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  93201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  93202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  93203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  93204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  93205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  93206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  93207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  93208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  93209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  93210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  93211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  93212. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  93213. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93214. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  93215. var __decoratorInitialStore = {};
  93216. var __mergedStore = {};
  93217. var _copySource = function (creationFunction, source, instanciate) {
  93218. var destination = creationFunction();
  93219. // Tags
  93220. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93221. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93222. }
  93223. var classStore = getMergedStore(destination);
  93224. // Properties
  93225. for (var property in classStore) {
  93226. var propertyDescriptor = classStore[property];
  93227. var sourceProperty = source[property];
  93228. var propertyType = propertyDescriptor.type;
  93229. if (sourceProperty !== undefined && sourceProperty !== null) {
  93230. switch (propertyType) {
  93231. case 0: // Value
  93232. case 6: // Mesh reference
  93233. case 11: // Camera reference
  93234. destination[property] = sourceProperty;
  93235. break;
  93236. case 1: // Texture
  93237. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  93238. break;
  93239. case 2: // Color3
  93240. case 3: // FresnelParameters
  93241. case 4: // Vector2
  93242. case 5: // Vector3
  93243. case 7: // Color Curves
  93244. case 10: // Quaternion
  93245. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  93246. break;
  93247. }
  93248. }
  93249. }
  93250. return destination;
  93251. };
  93252. function getDirectStore(target) {
  93253. var classKey = target.getClassName();
  93254. if (!__decoratorInitialStore[classKey]) {
  93255. __decoratorInitialStore[classKey] = {};
  93256. }
  93257. return __decoratorInitialStore[classKey];
  93258. }
  93259. /**
  93260. * Return the list of properties flagged as serializable
  93261. * @param target: host object
  93262. */
  93263. function getMergedStore(target) {
  93264. var classKey = target.getClassName();
  93265. if (__mergedStore[classKey]) {
  93266. return __mergedStore[classKey];
  93267. }
  93268. __mergedStore[classKey] = {};
  93269. var store = __mergedStore[classKey];
  93270. var currentTarget = target;
  93271. var currentKey = classKey;
  93272. while (currentKey) {
  93273. var initialStore = __decoratorInitialStore[currentKey];
  93274. for (var property in initialStore) {
  93275. store[property] = initialStore[property];
  93276. }
  93277. var parent_1 = void 0;
  93278. var done = false;
  93279. do {
  93280. parent_1 = Object.getPrototypeOf(currentTarget);
  93281. if (!parent_1.getClassName) {
  93282. done = true;
  93283. break;
  93284. }
  93285. if (parent_1.getClassName() !== currentKey) {
  93286. break;
  93287. }
  93288. currentTarget = parent_1;
  93289. } while (parent_1);
  93290. if (done) {
  93291. break;
  93292. }
  93293. currentKey = parent_1.getClassName();
  93294. currentTarget = parent_1;
  93295. }
  93296. return store;
  93297. }
  93298. function generateSerializableMember(type, sourceName) {
  93299. return function (target, propertyKey) {
  93300. var classStore = getDirectStore(target);
  93301. if (!classStore[propertyKey]) {
  93302. classStore[propertyKey] = { type: type, sourceName: sourceName };
  93303. }
  93304. };
  93305. }
  93306. function generateExpandMember(setCallback, targetKey) {
  93307. if (targetKey === void 0) { targetKey = null; }
  93308. return function (target, propertyKey) {
  93309. var key = targetKey || ("_" + propertyKey);
  93310. Object.defineProperty(target, propertyKey, {
  93311. get: function () {
  93312. return this[key];
  93313. },
  93314. set: function (value) {
  93315. if (this[key] === value) {
  93316. return;
  93317. }
  93318. this[key] = value;
  93319. target[setCallback].apply(this);
  93320. },
  93321. enumerable: true,
  93322. configurable: true
  93323. });
  93324. };
  93325. }
  93326. function expandToProperty(callback, targetKey) {
  93327. if (targetKey === void 0) { targetKey = null; }
  93328. return generateExpandMember(callback, targetKey);
  93329. }
  93330. function serialize(sourceName) {
  93331. return generateSerializableMember(0, sourceName); // value member
  93332. }
  93333. function serializeAsTexture(sourceName) {
  93334. return generateSerializableMember(1, sourceName); // texture member
  93335. }
  93336. function serializeAsColor3(sourceName) {
  93337. return generateSerializableMember(2, sourceName); // color3 member
  93338. }
  93339. function serializeAsFresnelParameters(sourceName) {
  93340. return generateSerializableMember(3, sourceName); // fresnel parameters member
  93341. }
  93342. function serializeAsVector2(sourceName) {
  93343. return generateSerializableMember(4, sourceName); // vector2 member
  93344. }
  93345. function serializeAsVector3(sourceName) {
  93346. return generateSerializableMember(5, sourceName); // vector3 member
  93347. }
  93348. function serializeAsMeshReference(sourceName) {
  93349. return generateSerializableMember(6, sourceName); // mesh reference member
  93350. }
  93351. function serializeAsColorCurves(sourceName) {
  93352. return generateSerializableMember(7, sourceName); // color curves
  93353. }
  93354. function serializeAsColor4(sourceName) {
  93355. return generateSerializableMember(8, sourceName); // color 4
  93356. }
  93357. function serializeAsImageProcessingConfiguration(sourceName) {
  93358. return generateSerializableMember(9, sourceName); // image processing
  93359. }
  93360. function serializeAsQuaternion(sourceName) {
  93361. return generateSerializableMember(10, sourceName); // quaternion member
  93362. }
  93363. /**
  93364. * Decorator used to define property that can be serialized as reference to a camera
  93365. * @param sourceName defines the name of the property to decorate
  93366. */
  93367. function serializeAsCameraReference(sourceName) {
  93368. return generateSerializableMember(11, sourceName); // camera reference member
  93369. }
  93370. /**
  93371. * Class used to help serialization objects
  93372. */
  93373. var SerializationHelper = /** @class */ (function () {
  93374. function SerializationHelper() {
  93375. }
  93376. /**
  93377. * Appends the serialized animations from the source animations
  93378. * @param source Source containing the animations
  93379. * @param destination Target to store the animations
  93380. */
  93381. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  93382. if (source.animations) {
  93383. destination.animations = [];
  93384. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  93385. var animation = source.animations[animationIndex];
  93386. destination.animations.push(animation.serialize());
  93387. }
  93388. }
  93389. };
  93390. /**
  93391. * Static function used to serialized a specific entity
  93392. * @param entity defines the entity to serialize
  93393. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93394. * @returns a JSON compatible object representing the serialization of the entity
  93395. */
  93396. SerializationHelper.Serialize = function (entity, serializationObject) {
  93397. if (!serializationObject) {
  93398. serializationObject = {};
  93399. }
  93400. // Tags
  93401. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93402. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  93403. }
  93404. var serializedProperties = getMergedStore(entity);
  93405. // Properties
  93406. for (var property in serializedProperties) {
  93407. var propertyDescriptor = serializedProperties[property];
  93408. var targetPropertyName = propertyDescriptor.sourceName || property;
  93409. var propertyType = propertyDescriptor.type;
  93410. var sourceProperty = entity[property];
  93411. if (sourceProperty !== undefined && sourceProperty !== null) {
  93412. switch (propertyType) {
  93413. case 0: // Value
  93414. serializationObject[targetPropertyName] = sourceProperty;
  93415. break;
  93416. case 1: // Texture
  93417. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93418. break;
  93419. case 2: // Color3
  93420. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93421. break;
  93422. case 3: // FresnelParameters
  93423. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93424. break;
  93425. case 4: // Vector2
  93426. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93427. break;
  93428. case 5: // Vector3
  93429. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93430. break;
  93431. case 6: // Mesh reference
  93432. serializationObject[targetPropertyName] = sourceProperty.id;
  93433. break;
  93434. case 7: // Color Curves
  93435. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93436. break;
  93437. case 8: // Color 4
  93438. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93439. break;
  93440. case 9: // Image Processing
  93441. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93442. break;
  93443. case 10: // Quaternion
  93444. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93445. break;
  93446. case 11: // Camera reference
  93447. serializationObject[targetPropertyName] = sourceProperty.id;
  93448. break;
  93449. }
  93450. }
  93451. }
  93452. return serializationObject;
  93453. };
  93454. /**
  93455. * Creates a new entity from a serialization data object
  93456. * @param creationFunction defines a function used to instanciated the new entity
  93457. * @param source defines the source serialization data
  93458. * @param scene defines the hosting scene
  93459. * @param rootUrl defines the root url for resources
  93460. * @returns a new entity
  93461. */
  93462. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  93463. if (rootUrl === void 0) { rootUrl = null; }
  93464. var destination = creationFunction();
  93465. if (!rootUrl) {
  93466. rootUrl = "";
  93467. }
  93468. // Tags
  93469. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93470. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93471. }
  93472. var classStore = getMergedStore(destination);
  93473. // Properties
  93474. for (var property in classStore) {
  93475. var propertyDescriptor = classStore[property];
  93476. var sourceProperty = source[propertyDescriptor.sourceName || property];
  93477. var propertyType = propertyDescriptor.type;
  93478. if (sourceProperty !== undefined && sourceProperty !== null) {
  93479. var dest = destination;
  93480. switch (propertyType) {
  93481. case 0: // Value
  93482. dest[property] = sourceProperty;
  93483. break;
  93484. case 1: // Texture
  93485. if (scene) {
  93486. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  93487. }
  93488. break;
  93489. case 2: // Color3
  93490. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  93491. break;
  93492. case 3: // FresnelParameters
  93493. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  93494. break;
  93495. case 4: // Vector2
  93496. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  93497. break;
  93498. case 5: // Vector3
  93499. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  93500. break;
  93501. case 6: // Mesh reference
  93502. if (scene) {
  93503. dest[property] = scene.getLastMeshByID(sourceProperty);
  93504. }
  93505. break;
  93506. case 7: // Color Curves
  93507. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  93508. break;
  93509. case 8: // Color 4
  93510. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  93511. break;
  93512. case 9: // Image Processing
  93513. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  93514. break;
  93515. case 10: // Quaternion
  93516. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  93517. break;
  93518. case 11: // Camera reference
  93519. if (scene) {
  93520. dest[property] = scene.getCameraByID(sourceProperty);
  93521. }
  93522. break;
  93523. }
  93524. }
  93525. }
  93526. return destination;
  93527. };
  93528. /**
  93529. * Clones an object
  93530. * @param creationFunction defines the function used to instanciate the new object
  93531. * @param source defines the source object
  93532. * @returns the cloned object
  93533. */
  93534. SerializationHelper.Clone = function (creationFunction, source) {
  93535. return _copySource(creationFunction, source, false);
  93536. };
  93537. /**
  93538. * Instanciates a new object based on a source one (some data will be shared between both object)
  93539. * @param creationFunction defines the function used to instanciate the new object
  93540. * @param source defines the source object
  93541. * @returns the new object
  93542. */
  93543. SerializationHelper.Instanciate = function (creationFunction, source) {
  93544. return _copySource(creationFunction, source, true);
  93545. };
  93546. /** hidden */
  93547. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  93548. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  93549. };
  93550. /** hidden */
  93551. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  93552. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  93553. };
  93554. /** hidden */
  93555. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  93556. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  93557. };
  93558. /** hidden */
  93559. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  93560. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  93561. };
  93562. return SerializationHelper;
  93563. }());
  93564. /***/ }),
  93565. /***/ "./Misc/deepCopier.ts":
  93566. /*!****************************!*\
  93567. !*** ./Misc/deepCopier.ts ***!
  93568. \****************************/
  93569. /*! exports provided: DeepCopier */
  93570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93571. "use strict";
  93572. __webpack_require__.r(__webpack_exports__);
  93573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  93574. var cloneValue = function (source, destinationObject) {
  93575. if (!source) {
  93576. return null;
  93577. }
  93578. if (source.getClassName && source.getClassName() === "Mesh") {
  93579. return null;
  93580. }
  93581. if (source.getClassName && source.getClassName() === "SubMesh") {
  93582. return source.clone(destinationObject);
  93583. }
  93584. else if (source.clone) {
  93585. return source.clone();
  93586. }
  93587. return null;
  93588. };
  93589. /**
  93590. * Class containing a set of static utilities functions for deep copy.
  93591. */
  93592. var DeepCopier = /** @class */ (function () {
  93593. function DeepCopier() {
  93594. }
  93595. /**
  93596. * Tries to copy an object by duplicating every property
  93597. * @param source defines the source object
  93598. * @param destination defines the target object
  93599. * @param doNotCopyList defines a list of properties to avoid
  93600. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93601. */
  93602. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  93603. for (var prop in source) {
  93604. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  93605. continue;
  93606. }
  93607. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  93608. continue;
  93609. }
  93610. var sourceValue = source[prop];
  93611. var typeOfSourceValue = typeof sourceValue;
  93612. if (typeOfSourceValue === "function") {
  93613. continue;
  93614. }
  93615. try {
  93616. if (typeOfSourceValue === "object") {
  93617. if (sourceValue instanceof Array) {
  93618. destination[prop] = [];
  93619. if (sourceValue.length > 0) {
  93620. if (typeof sourceValue[0] == "object") {
  93621. for (var index = 0; index < sourceValue.length; index++) {
  93622. var clonedValue = cloneValue(sourceValue[index], destination);
  93623. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  93624. destination[prop].push(clonedValue);
  93625. }
  93626. }
  93627. }
  93628. else {
  93629. destination[prop] = sourceValue.slice(0);
  93630. }
  93631. }
  93632. }
  93633. else {
  93634. destination[prop] = cloneValue(sourceValue, destination);
  93635. }
  93636. }
  93637. else {
  93638. destination[prop] = sourceValue;
  93639. }
  93640. }
  93641. catch (e) {
  93642. // Just ignore error (it could be because of a read-only property)
  93643. }
  93644. }
  93645. };
  93646. return DeepCopier;
  93647. }());
  93648. /***/ }),
  93649. /***/ "./Misc/deferred.ts":
  93650. /*!**************************!*\
  93651. !*** ./Misc/deferred.ts ***!
  93652. \**************************/
  93653. /*! exports provided: Deferred */
  93654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93655. "use strict";
  93656. __webpack_require__.r(__webpack_exports__);
  93657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  93658. /**
  93659. * Wrapper class for promise with external resolve and reject.
  93660. */
  93661. var Deferred = /** @class */ (function () {
  93662. /**
  93663. * Constructor for this deferred object.
  93664. */
  93665. function Deferred() {
  93666. var _this = this;
  93667. this.promise = new Promise(function (resolve, reject) {
  93668. _this._resolve = resolve;
  93669. _this._reject = reject;
  93670. });
  93671. }
  93672. Object.defineProperty(Deferred.prototype, "resolve", {
  93673. /**
  93674. * The resolve method of the promise associated with this deferred object.
  93675. */
  93676. get: function () {
  93677. return this._resolve;
  93678. },
  93679. enumerable: true,
  93680. configurable: true
  93681. });
  93682. Object.defineProperty(Deferred.prototype, "reject", {
  93683. /**
  93684. * The reject method of the promise associated with this deferred object.
  93685. */
  93686. get: function () {
  93687. return this._reject;
  93688. },
  93689. enumerable: true,
  93690. configurable: true
  93691. });
  93692. return Deferred;
  93693. }());
  93694. /***/ }),
  93695. /***/ "./Misc/devTools.ts":
  93696. /*!**************************!*\
  93697. !*** ./Misc/devTools.ts ***!
  93698. \**************************/
  93699. /*! exports provided: _DevTools */
  93700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93701. "use strict";
  93702. __webpack_require__.r(__webpack_exports__);
  93703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  93704. /** @hidden */
  93705. var _DevTools = /** @class */ (function () {
  93706. function _DevTools() {
  93707. }
  93708. _DevTools.WarnImport = function (name) {
  93709. return name + " needs to be imported before as it contains a side-effect required by your code.";
  93710. };
  93711. return _DevTools;
  93712. }());
  93713. /***/ }),
  93714. /***/ "./Misc/domManagement.ts":
  93715. /*!*******************************!*\
  93716. !*** ./Misc/domManagement.ts ***!
  93717. \*******************************/
  93718. /*! exports provided: DomManagement */
  93719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93720. "use strict";
  93721. __webpack_require__.r(__webpack_exports__);
  93722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  93723. /**
  93724. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  93725. * Babylon.js
  93726. */
  93727. var DomManagement = /** @class */ (function () {
  93728. function DomManagement() {
  93729. }
  93730. /**
  93731. * Checks if the window object exists
  93732. * @returns true if the window object exists
  93733. */
  93734. DomManagement.IsWindowObjectExist = function () {
  93735. return (typeof window) !== "undefined";
  93736. };
  93737. /**
  93738. * Extracts text content from a DOM element hierarchy
  93739. * @param element defines the root element
  93740. * @returns a string
  93741. */
  93742. DomManagement.GetDOMTextContent = function (element) {
  93743. var result = "";
  93744. var child = element.firstChild;
  93745. while (child) {
  93746. if (child.nodeType === 3) {
  93747. result += child.textContent;
  93748. }
  93749. child = (child.nextSibling);
  93750. }
  93751. return result;
  93752. };
  93753. return DomManagement;
  93754. }());
  93755. /***/ }),
  93756. /***/ "./Misc/environmentTextureTools.ts":
  93757. /*!*****************************************!*\
  93758. !*** ./Misc/environmentTextureTools.ts ***!
  93759. \*****************************************/
  93760. /*! exports provided: EnvironmentTextureTools */
  93761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93762. "use strict";
  93763. __webpack_require__.r(__webpack_exports__);
  93764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  93765. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93767. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93768. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93769. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93770. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93771. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93772. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93773. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  93774. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93775. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  93776. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  93777. /**
  93778. * Sets of helpers addressing the serialization and deserialization of environment texture
  93779. * stored in a BabylonJS env file.
  93780. * Those files are usually stored as .env files.
  93781. */
  93782. var EnvironmentTextureTools = /** @class */ (function () {
  93783. function EnvironmentTextureTools() {
  93784. }
  93785. /**
  93786. * Gets the environment info from an env file.
  93787. * @param data The array buffer containing the .env bytes.
  93788. * @returns the environment file info (the json header) if successfully parsed.
  93789. */
  93790. EnvironmentTextureTools.GetEnvInfo = function (data) {
  93791. var dataView = new DataView(data);
  93792. var pos = 0;
  93793. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93794. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  93795. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  93796. return null;
  93797. }
  93798. }
  93799. // Read json manifest - collect characters up to null terminator
  93800. var manifestString = '';
  93801. var charCode = 0x00;
  93802. while ((charCode = dataView.getUint8(pos++))) {
  93803. manifestString += String.fromCharCode(charCode);
  93804. }
  93805. var manifest = JSON.parse(manifestString);
  93806. if (manifest.specular) {
  93807. // Extend the header with the position of the payload.
  93808. manifest.specular.specularDataPosition = pos;
  93809. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  93810. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  93811. }
  93812. return manifest;
  93813. };
  93814. /**
  93815. * Creates an environment texture from a loaded cube texture.
  93816. * @param texture defines the cube texture to convert in env file
  93817. * @return a promise containing the environment data if succesfull.
  93818. */
  93819. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93820. var _this = this;
  93821. var internalTexture = texture.getInternalTexture();
  93822. if (!internalTexture) {
  93823. return Promise.reject("The cube texture is invalid.");
  93824. }
  93825. if (!texture._prefiltered) {
  93826. return Promise.reject("The cube texture is invalid (not prefiltered).");
  93827. }
  93828. var engine = internalTexture.getEngine();
  93829. if (engine && engine.premultipliedAlpha) {
  93830. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  93831. }
  93832. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93833. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  93834. }
  93835. var canvas = engine.getRenderingCanvas();
  93836. if (!canvas) {
  93837. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  93838. }
  93839. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93840. if (!engine.getCaps().textureFloatRender) {
  93841. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93842. if (!engine.getCaps().textureHalfFloatRender) {
  93843. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  93844. }
  93845. }
  93846. var cubeWidth = internalTexture.width;
  93847. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  93848. var specularTextures = {};
  93849. var promises = [];
  93850. // Read and collect all mipmaps data from the cube.
  93851. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  93852. mipmapsCount = Math.round(mipmapsCount);
  93853. var _loop_1 = function (i) {
  93854. var faceWidth = Math.pow(2, mipmapsCount - i);
  93855. var _loop_2 = function (face) {
  93856. var data = texture.readPixels(face, i);
  93857. // Creates a temp texture with the face data.
  93858. 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);
  93859. // And rgbdEncode them.
  93860. var promise = new Promise(function (resolve, reject) {
  93861. 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);
  93862. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93863. rgbdPostProcess.onApply = function (effect) {
  93864. effect._bindTexture("textureSampler", tempTexture);
  93865. };
  93866. // As the process needs to happen on the main canvas, keep track of the current size
  93867. var currentW = engine.getRenderWidth();
  93868. var currentH = engine.getRenderHeight();
  93869. // Set the desired size for the texture
  93870. engine.setSize(faceWidth, faceWidth);
  93871. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  93872. // Reading datas from WebGL
  93873. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  93874. var fileReader = new FileReader();
  93875. fileReader.onload = function (event) {
  93876. var arrayBuffer = event.target.result;
  93877. specularTextures[i * 6 + face] = arrayBuffer;
  93878. resolve();
  93879. };
  93880. fileReader.readAsArrayBuffer(blob);
  93881. });
  93882. // Reapply the previous canvas size
  93883. engine.setSize(currentW, currentH);
  93884. });
  93885. });
  93886. promises.push(promise);
  93887. };
  93888. // All faces of the cube.
  93889. for (var face = 0; face < 6; face++) {
  93890. _loop_2(face);
  93891. }
  93892. };
  93893. for (var i = 0; i <= mipmapsCount; i++) {
  93894. _loop_1(i);
  93895. }
  93896. // Once all the textures haves been collected as RGBD stored in PNGs
  93897. return Promise.all(promises).then(function () {
  93898. // We can delete the hosting scene keeping track of all the creation objects
  93899. hostingScene.dispose();
  93900. // Creates the json header for the env texture
  93901. var info = {
  93902. version: 1,
  93903. width: cubeWidth,
  93904. irradiance: _this._CreateEnvTextureIrradiance(texture),
  93905. specular: {
  93906. mipmaps: [],
  93907. lodGenerationScale: texture.lodGenerationScale
  93908. }
  93909. };
  93910. // Sets the specular image data information
  93911. var position = 0;
  93912. for (var i = 0; i <= mipmapsCount; i++) {
  93913. for (var face = 0; face < 6; face++) {
  93914. var byteLength = specularTextures[i * 6 + face].byteLength;
  93915. info.specular.mipmaps.push({
  93916. length: byteLength,
  93917. position: position
  93918. });
  93919. position += byteLength;
  93920. }
  93921. }
  93922. // Encode the JSON as an array buffer
  93923. var infoString = JSON.stringify(info);
  93924. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  93925. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  93926. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  93927. infoView[i] = infoString.charCodeAt(i);
  93928. }
  93929. // Ends up with a null terminator for easier parsing
  93930. infoView[infoString.length] = 0x00;
  93931. // Computes the final required size and creates the storage
  93932. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  93933. var finalBuffer = new ArrayBuffer(totalSize);
  93934. var finalBufferView = new Uint8Array(finalBuffer);
  93935. var dataView = new DataView(finalBuffer);
  93936. // Copy the magic bytes identifying the file in
  93937. var pos = 0;
  93938. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93939. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  93940. }
  93941. // Add the json info
  93942. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  93943. pos += infoBuffer.byteLength;
  93944. // Finally inserts the texture data
  93945. for (var i = 0; i <= mipmapsCount; i++) {
  93946. for (var face = 0; face < 6; face++) {
  93947. var dataBuffer = specularTextures[i * 6 + face];
  93948. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  93949. pos += dataBuffer.byteLength;
  93950. }
  93951. }
  93952. // Voila
  93953. return finalBuffer;
  93954. });
  93955. };
  93956. /**
  93957. * Creates a JSON representation of the spherical data.
  93958. * @param texture defines the texture containing the polynomials
  93959. * @return the JSON representation of the spherical info
  93960. */
  93961. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  93962. var polynmials = texture.sphericalPolynomial;
  93963. if (polynmials == null) {
  93964. return null;
  93965. }
  93966. return {
  93967. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  93968. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  93969. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  93970. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  93971. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  93972. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  93973. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  93974. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  93975. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  93976. };
  93977. };
  93978. /**
  93979. * Uploads the texture info contained in the env file to the GPU.
  93980. * @param texture defines the internal texture to upload to
  93981. * @param arrayBuffer defines the buffer cotaining the data to load
  93982. * @param info defines the texture info retrieved through the GetEnvInfo method
  93983. * @returns a promise
  93984. */
  93985. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  93986. if (info.version !== 1) {
  93987. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  93988. }
  93989. var specularInfo = info.specular;
  93990. if (!specularInfo) {
  93991. // Nothing else parsed so far
  93992. return Promise.resolve();
  93993. }
  93994. // Double checks the enclosed info
  93995. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  93996. mipmapsCount = Math.round(mipmapsCount) + 1;
  93997. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  93998. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  93999. }
  94000. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  94001. var imageData = new Array(mipmapsCount);
  94002. for (var i = 0; i < mipmapsCount; i++) {
  94003. imageData[i] = new Array(6);
  94004. for (var face = 0; face < 6; face++) {
  94005. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  94006. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  94007. }
  94008. }
  94009. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  94010. };
  94011. /**
  94012. * Uploads the levels of image data to the GPU.
  94013. * @param texture defines the internal texture to upload to
  94014. * @param imageData defines the array buffer views of image data [mipmap][face]
  94015. * @returns a promise
  94016. */
  94017. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  94018. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  94019. throw new Error("Texture size must be a power of two");
  94020. }
  94021. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  94022. // Gets everything ready.
  94023. var engine = texture.getEngine();
  94024. var expandTexture = false;
  94025. var generateNonLODTextures = false;
  94026. var rgbdPostProcess = null;
  94027. var cubeRtt = null;
  94028. var lodTextures = null;
  94029. var caps = engine.getCaps();
  94030. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  94031. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94032. texture.generateMipMaps = true;
  94033. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  94034. // Add extra process if texture lod is not supported
  94035. if (!caps.textureLOD) {
  94036. expandTexture = false;
  94037. generateNonLODTextures = true;
  94038. lodTextures = {};
  94039. }
  94040. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  94041. else if (engine.webGLVersion < 2) {
  94042. expandTexture = false;
  94043. }
  94044. // If half float available we can uncompress the texture
  94045. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  94046. expandTexture = true;
  94047. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94048. }
  94049. // If full float available we can uncompress the texture
  94050. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  94051. expandTexture = true;
  94052. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94053. }
  94054. // Expand the texture if possible
  94055. if (expandTexture) {
  94056. // Simply run through the decode PP
  94057. 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);
  94058. texture._isRGBD = false;
  94059. texture.invertY = false;
  94060. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  94061. generateDepthBuffer: false,
  94062. generateMipMaps: true,
  94063. generateStencilBuffer: false,
  94064. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  94065. type: texture.type,
  94066. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  94067. });
  94068. }
  94069. else {
  94070. texture._isRGBD = true;
  94071. texture.invertY = true;
  94072. // In case of missing support, applies the same patch than DDS files.
  94073. if (generateNonLODTextures) {
  94074. var mipSlices = 3;
  94075. var scale = texture._lodGenerationScale;
  94076. var offset = texture._lodGenerationOffset;
  94077. for (var i = 0; i < mipSlices; i++) {
  94078. //compute LOD from even spacing in smoothness (matching shader calculation)
  94079. var smoothness = i / (mipSlices - 1);
  94080. var roughness = 1 - smoothness;
  94081. var minLODIndex = offset; // roughness = 0
  94082. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  94083. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94084. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94085. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94086. glTextureFromLod.isCube = true;
  94087. glTextureFromLod.invertY = true;
  94088. glTextureFromLod.generateMipMaps = false;
  94089. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  94090. // Wrap in a base texture for easy binding.
  94091. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  94092. lodTexture.isCube = true;
  94093. lodTexture._texture = glTextureFromLod;
  94094. lodTextures[mipmapIndex] = lodTexture;
  94095. switch (i) {
  94096. case 0:
  94097. texture._lodTextureLow = lodTexture;
  94098. break;
  94099. case 1:
  94100. texture._lodTextureMid = lodTexture;
  94101. break;
  94102. case 2:
  94103. texture._lodTextureHigh = lodTexture;
  94104. break;
  94105. }
  94106. }
  94107. }
  94108. }
  94109. var promises = [];
  94110. var _loop_3 = function (i) {
  94111. var _loop_4 = function (face) {
  94112. // Constructs an image element from image data
  94113. var bytes = imageData[i][face];
  94114. var blob = new Blob([bytes], { type: 'image/png' });
  94115. var url = URL.createObjectURL(blob);
  94116. var image = new Image();
  94117. image.src = url;
  94118. // Enqueue promise to upload to the texture.
  94119. var promise = new Promise(function (resolve, reject) {
  94120. image.onload = function () {
  94121. if (expandTexture) {
  94122. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  94123. reject(message);
  94124. }, image);
  94125. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94126. // Uncompress the data to a RTT
  94127. rgbdPostProcess.onApply = function (effect) {
  94128. effect._bindTexture("textureSampler", tempTexture_1);
  94129. effect.setFloat2("scale", 1, 1);
  94130. };
  94131. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  94132. // Cleanup
  94133. engine.restoreDefaultFramebuffer();
  94134. tempTexture_1.dispose();
  94135. window.URL.revokeObjectURL(url);
  94136. resolve();
  94137. });
  94138. }
  94139. else {
  94140. engine._uploadImageToTexture(texture, image, face, i);
  94141. // Upload the face to the non lod texture support
  94142. if (generateNonLODTextures) {
  94143. var lodTexture = lodTextures[i];
  94144. if (lodTexture) {
  94145. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  94146. }
  94147. }
  94148. resolve();
  94149. }
  94150. };
  94151. image.onerror = function (error) {
  94152. reject(error);
  94153. };
  94154. });
  94155. promises.push(promise);
  94156. };
  94157. // All faces
  94158. for (var face = 0; face < 6; face++) {
  94159. _loop_4(face);
  94160. }
  94161. };
  94162. // All mipmaps up to provided number of images
  94163. for (var i = 0; i < imageData.length; i++) {
  94164. _loop_3(i);
  94165. }
  94166. // Fill remaining mipmaps with black textures.
  94167. if (imageData.length < mipmapsCount) {
  94168. var data = void 0;
  94169. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  94170. var dataLength = size * size * 4;
  94171. switch (texture.type) {
  94172. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  94173. data = new Uint8Array(dataLength);
  94174. break;
  94175. }
  94176. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  94177. data = new Uint16Array(dataLength);
  94178. break;
  94179. }
  94180. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  94181. data = new Float32Array(dataLength);
  94182. break;
  94183. }
  94184. }
  94185. for (var i = imageData.length; i < mipmapsCount; i++) {
  94186. for (var face = 0; face < 6; face++) {
  94187. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  94188. }
  94189. }
  94190. }
  94191. // Once all done, finishes the cleanup and return
  94192. return Promise.all(promises).then(function () {
  94193. // Release temp RTT.
  94194. if (cubeRtt) {
  94195. engine._releaseFramebufferObjects(cubeRtt);
  94196. cubeRtt._swapAndDie(texture);
  94197. }
  94198. // Release temp Post Process.
  94199. if (rgbdPostProcess) {
  94200. rgbdPostProcess.dispose();
  94201. }
  94202. // Flag internal texture as ready in case they are in use.
  94203. if (generateNonLODTextures) {
  94204. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  94205. texture._lodTextureHigh._texture.isReady = true;
  94206. }
  94207. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  94208. texture._lodTextureMid._texture.isReady = true;
  94209. }
  94210. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  94211. texture._lodTextureLow._texture.isReady = true;
  94212. }
  94213. }
  94214. });
  94215. };
  94216. /**
  94217. * Uploads spherical polynomials information to the texture.
  94218. * @param texture defines the texture we are trying to upload the information to
  94219. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  94220. */
  94221. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  94222. if (info.version !== 1) {
  94223. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  94224. }
  94225. var irradianceInfo = info.irradiance;
  94226. if (!irradianceInfo) {
  94227. return;
  94228. }
  94229. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  94230. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  94231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  94232. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  94233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  94234. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  94235. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  94236. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  94237. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  94238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  94239. texture._sphericalPolynomial = sp;
  94240. };
  94241. /** @hidden */
  94242. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  94243. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  94244. internalTexture._bufferViewArrayArray = data;
  94245. internalTexture._lodGenerationScale = lodScale;
  94246. internalTexture._lodGenerationOffset = lodOffset;
  94247. internalTexture._sphericalPolynomial = sphericalPolynomial;
  94248. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  94249. internalTexture.isReady = true;
  94250. });
  94251. };
  94252. /**
  94253. * Magic number identifying the env file.
  94254. */
  94255. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  94256. return EnvironmentTextureTools;
  94257. }());
  94258. // References the dependencies.
  94259. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  94260. /***/ }),
  94261. /***/ "./Misc/filesInput.ts":
  94262. /*!****************************!*\
  94263. !*** ./Misc/filesInput.ts ***!
  94264. \****************************/
  94265. /*! exports provided: FilesInput */
  94266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94267. "use strict";
  94268. __webpack_require__.r(__webpack_exports__);
  94269. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  94270. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94271. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94272. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94273. /**
  94274. * Class used to help managing file picking and drag'n'drop
  94275. */
  94276. var FilesInput = /** @class */ (function () {
  94277. /**
  94278. * Creates a new FilesInput
  94279. * @param engine defines the rendering engine
  94280. * @param scene defines the hosting scene
  94281. * @param sceneLoadedCallback callback called when scene is loaded
  94282. * @param progressCallback callback called to track progress
  94283. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  94284. * @param textureLoadingCallback callback called when a texture is loading
  94285. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  94286. * @param onReloadCallback callback called when a reload is requested
  94287. * @param errorCallback callback call if an error occurs
  94288. */
  94289. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  94290. /**
  94291. * Callback called when a file is processed
  94292. */
  94293. this.onProcessFileCallback = function () { return true; };
  94294. this._engine = engine;
  94295. this._currentScene = scene;
  94296. this._sceneLoadedCallback = sceneLoadedCallback;
  94297. this._progressCallback = progressCallback;
  94298. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  94299. this._textureLoadingCallback = textureLoadingCallback;
  94300. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  94301. this._onReloadCallback = onReloadCallback;
  94302. this._errorCallback = errorCallback;
  94303. }
  94304. Object.defineProperty(FilesInput, "FilesToLoad", {
  94305. /**
  94306. * List of files ready to be loaded
  94307. */
  94308. get: function () {
  94309. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  94310. },
  94311. enumerable: true,
  94312. configurable: true
  94313. });
  94314. /**
  94315. * Calls this function to listen to drag'n'drop events on a specific DOM element
  94316. * @param elementToMonitor defines the DOM element to track
  94317. */
  94318. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  94319. var _this = this;
  94320. if (elementToMonitor) {
  94321. this._elementToMonitor = elementToMonitor;
  94322. this._dragEnterHandler = function (e) { _this.drag(e); };
  94323. this._dragOverHandler = function (e) { _this.drag(e); };
  94324. this._dropHandler = function (e) { _this.drop(e); };
  94325. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  94326. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  94327. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  94328. }
  94329. };
  94330. /**
  94331. * Release all associated resources
  94332. */
  94333. FilesInput.prototype.dispose = function () {
  94334. if (!this._elementToMonitor) {
  94335. return;
  94336. }
  94337. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  94338. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  94339. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  94340. };
  94341. FilesInput.prototype.renderFunction = function () {
  94342. if (this._additionalRenderLoopLogicCallback) {
  94343. this._additionalRenderLoopLogicCallback();
  94344. }
  94345. if (this._currentScene) {
  94346. if (this._textureLoadingCallback) {
  94347. var remaining = this._currentScene.getWaitingItemsCount();
  94348. if (remaining > 0) {
  94349. this._textureLoadingCallback(remaining);
  94350. }
  94351. }
  94352. this._currentScene.render();
  94353. }
  94354. };
  94355. FilesInput.prototype.drag = function (e) {
  94356. e.stopPropagation();
  94357. e.preventDefault();
  94358. };
  94359. FilesInput.prototype.drop = function (eventDrop) {
  94360. eventDrop.stopPropagation();
  94361. eventDrop.preventDefault();
  94362. this.loadFiles(eventDrop);
  94363. };
  94364. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  94365. var _this = this;
  94366. var reader = folder.createReader();
  94367. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  94368. reader.readEntries(function (entries) {
  94369. remaining.count += entries.length;
  94370. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  94371. var entry = entries_1[_i];
  94372. if (entry.isFile) {
  94373. entry.file(function (file) {
  94374. file.correctName = relativePath + file.name;
  94375. files.push(file);
  94376. if (--remaining.count === 0) {
  94377. callback();
  94378. }
  94379. });
  94380. }
  94381. else if (entry.isDirectory) {
  94382. _this._traverseFolder(entry, files, remaining, callback);
  94383. }
  94384. }
  94385. if (--remaining.count) {
  94386. callback();
  94387. }
  94388. });
  94389. };
  94390. FilesInput.prototype._processFiles = function (files) {
  94391. for (var i = 0; i < files.length; i++) {
  94392. var name = files[i].correctName.toLowerCase();
  94393. var extension = name.split('.').pop();
  94394. if (!this.onProcessFileCallback(files[i], name, extension)) {
  94395. continue;
  94396. }
  94397. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  94398. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  94399. this._sceneFileToLoad = files[i];
  94400. }
  94401. FilesInput.FilesToLoad[name] = files[i];
  94402. }
  94403. };
  94404. /**
  94405. * Load files from a drop event
  94406. * @param event defines the drop event to use as source
  94407. */
  94408. FilesInput.prototype.loadFiles = function (event) {
  94409. var _this = this;
  94410. // Handling data transfer via drag'n'drop
  94411. if (event && event.dataTransfer && event.dataTransfer.files) {
  94412. this._filesToLoad = event.dataTransfer.files;
  94413. }
  94414. // Handling files from input files
  94415. if (event && event.target && event.target.files) {
  94416. this._filesToLoad = event.target.files;
  94417. }
  94418. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  94419. return;
  94420. }
  94421. if (this._startingProcessingFilesCallback) {
  94422. this._startingProcessingFilesCallback(this._filesToLoad);
  94423. }
  94424. if (this._filesToLoad && this._filesToLoad.length > 0) {
  94425. var files_1 = new Array();
  94426. var folders = [];
  94427. var items = event.dataTransfer ? event.dataTransfer.items : null;
  94428. for (var i = 0; i < this._filesToLoad.length; i++) {
  94429. var fileToLoad = this._filesToLoad[i];
  94430. var name_1 = fileToLoad.name.toLowerCase();
  94431. var entry = void 0;
  94432. fileToLoad.correctName = name_1;
  94433. if (items) {
  94434. var item = items[i];
  94435. if (item.getAsEntry) {
  94436. entry = item.getAsEntry();
  94437. }
  94438. else if (item.webkitGetAsEntry) {
  94439. entry = item.webkitGetAsEntry();
  94440. }
  94441. }
  94442. if (!entry) {
  94443. files_1.push(fileToLoad);
  94444. }
  94445. else {
  94446. if (entry.isDirectory) {
  94447. folders.push(entry);
  94448. }
  94449. else {
  94450. files_1.push(fileToLoad);
  94451. }
  94452. }
  94453. }
  94454. if (folders.length === 0) {
  94455. this._processFiles(files_1);
  94456. this._processReload();
  94457. }
  94458. else {
  94459. var remaining = { count: folders.length };
  94460. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  94461. var folder = folders_1[_i];
  94462. this._traverseFolder(folder, files_1, remaining, function () {
  94463. _this._processFiles(files_1);
  94464. if (remaining.count === 0) {
  94465. _this._processReload();
  94466. }
  94467. });
  94468. }
  94469. }
  94470. }
  94471. };
  94472. FilesInput.prototype._processReload = function () {
  94473. if (this._onReloadCallback) {
  94474. this._onReloadCallback(this._sceneFileToLoad);
  94475. }
  94476. else {
  94477. this.reload();
  94478. }
  94479. };
  94480. /**
  94481. * Reload the current scene from the loaded files
  94482. */
  94483. FilesInput.prototype.reload = function () {
  94484. var _this = this;
  94485. // If a scene file has been provided
  94486. if (this._sceneFileToLoad) {
  94487. if (this._currentScene) {
  94488. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  94489. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  94490. }
  94491. this._engine.stopRenderLoop();
  94492. }
  94493. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  94494. if (_this._progressCallback) {
  94495. _this._progressCallback(progress);
  94496. }
  94497. }).then(function (scene) {
  94498. if (_this._currentScene) {
  94499. _this._currentScene.dispose();
  94500. }
  94501. _this._currentScene = scene;
  94502. if (_this._sceneLoadedCallback) {
  94503. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  94504. }
  94505. // Wait for textures and shaders to be ready
  94506. _this._currentScene.executeWhenReady(function () {
  94507. _this._engine.runRenderLoop(function () {
  94508. _this.renderFunction();
  94509. });
  94510. });
  94511. }).catch(function (error) {
  94512. if (_this._errorCallback) {
  94513. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  94514. }
  94515. });
  94516. }
  94517. else {
  94518. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  94519. }
  94520. };
  94521. return FilesInput;
  94522. }());
  94523. /***/ }),
  94524. /***/ "./Misc/filesInputStore.ts":
  94525. /*!*********************************!*\
  94526. !*** ./Misc/filesInputStore.ts ***!
  94527. \*********************************/
  94528. /*! exports provided: FilesInputStore */
  94529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94530. "use strict";
  94531. __webpack_require__.r(__webpack_exports__);
  94532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  94533. /**
  94534. * Class used to help managing file picking and drag'n'drop
  94535. * File Storage
  94536. */
  94537. var FilesInputStore = /** @class */ (function () {
  94538. function FilesInputStore() {
  94539. }
  94540. /**
  94541. * List of files ready to be loaded
  94542. */
  94543. FilesInputStore.FilesToLoad = {};
  94544. return FilesInputStore;
  94545. }());
  94546. /***/ }),
  94547. /***/ "./Misc/index.ts":
  94548. /*!***********************!*\
  94549. !*** ./Misc/index.ts ***!
  94550. \***********************/
  94551. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  94552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94553. "use strict";
  94554. __webpack_require__.r(__webpack_exports__);
  94555. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  94556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  94557. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  94558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  94559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  94560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  94561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  94562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  94563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  94564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  94565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  94566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  94567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  94568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  94569. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  94570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  94571. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  94572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  94573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  94574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  94575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  94576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  94577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  94578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  94579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  94580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  94581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  94582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  94583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  94584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  94585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  94586. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  94587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  94588. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  94589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  94590. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  94591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  94592. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  94593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  94594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  94595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  94596. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  94597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  94598. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  94600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  94601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  94602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  94603. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  94604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  94605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  94606. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  94607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  94608. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  94609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  94610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  94611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  94612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  94613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  94614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  94615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  94616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  94617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  94618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  94619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  94620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  94621. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  94622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  94623. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  94624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  94625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  94626. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  94627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  94628. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  94629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  94630. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  94631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  94632. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  94633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  94634. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  94636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  94637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  94638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  94639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  94640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  94641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  94642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  94643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  94644. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  94645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  94646. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  94647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  94648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  94649. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  94650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  94651. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  94652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  94653. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  94654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  94655. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  94657. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  94658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  94659. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  94660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  94661. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  94663. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  94664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  94665. /* empty/unused harmony star reexport */
  94666. /***/ }),
  94667. /***/ "./Misc/khronosTextureContainer.ts":
  94668. /*!*****************************************!*\
  94669. !*** ./Misc/khronosTextureContainer.ts ***!
  94670. \*****************************************/
  94671. /*! exports provided: KhronosTextureContainer */
  94672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94673. "use strict";
  94674. __webpack_require__.r(__webpack_exports__);
  94675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  94676. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94677. /**
  94678. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94679. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94680. */
  94681. var KhronosTextureContainer = /** @class */ (function () {
  94682. /**
  94683. * Creates a new KhronosTextureContainer
  94684. * @param arrayBuffer contents of the KTX container file
  94685. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  94686. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  94687. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  94688. */
  94689. function KhronosTextureContainer(
  94690. /** contents of the KTX container file */
  94691. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  94692. this.arrayBuffer = arrayBuffer;
  94693. /**
  94694. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  94695. */
  94696. this.isInvalid = false;
  94697. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  94698. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  94699. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  94700. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  94701. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  94702. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  94703. this.isInvalid = true;
  94704. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  94705. return;
  94706. }
  94707. // load the reset of the header in native 32 bit uint
  94708. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  94709. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  94710. var endianness = headerDataView.getUint32(0, true);
  94711. var littleEndian = endianness === 0x04030201;
  94712. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  94713. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  94714. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  94715. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  94716. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  94717. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  94718. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  94719. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  94720. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  94721. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  94722. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  94723. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  94724. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  94725. if (this.glType !== 0) {
  94726. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  94727. return;
  94728. }
  94729. else {
  94730. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  94731. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  94732. }
  94733. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  94734. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  94735. return;
  94736. }
  94737. if (this.numberOfArrayElements !== 0) {
  94738. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  94739. return;
  94740. }
  94741. if (this.numberOfFaces !== facesExpected) {
  94742. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  94743. return;
  94744. }
  94745. // we now have a completely validated file, so could use existence of loadType as success
  94746. // would need to make this more elaborate & adjust checks above to support more than one load type
  94747. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  94748. }
  94749. /**
  94750. * Uploads KTX content to a Babylon Texture.
  94751. * It is assumed that the texture has already been created & is currently bound
  94752. * @hidden
  94753. */
  94754. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  94755. switch (this.loadType) {
  94756. case KhronosTextureContainer.COMPRESSED_2D:
  94757. this._upload2DCompressedLevels(texture, loadMipmaps);
  94758. break;
  94759. case KhronosTextureContainer.TEX_2D:
  94760. case KhronosTextureContainer.COMPRESSED_3D:
  94761. case KhronosTextureContainer.TEX_3D:
  94762. }
  94763. };
  94764. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  94765. // initialize width & height for level 1
  94766. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  94767. var width = this.pixelWidth;
  94768. var height = this.pixelHeight;
  94769. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  94770. for (var level = 0; level < mipmapCount; level++) {
  94771. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  94772. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  94773. for (var face = 0; face < this.numberOfFaces; face++) {
  94774. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  94775. var engine = texture.getEngine();
  94776. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  94777. dataOffset += imageSize; // add size of the image for the next face/mipmap
  94778. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  94779. }
  94780. width = Math.max(1.0, width * 0.5);
  94781. height = Math.max(1.0, height * 0.5);
  94782. }
  94783. };
  94784. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  94785. // load types
  94786. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  94787. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  94788. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  94789. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  94790. return KhronosTextureContainer;
  94791. }());
  94792. /***/ }),
  94793. /***/ "./Misc/logger.ts":
  94794. /*!************************!*\
  94795. !*** ./Misc/logger.ts ***!
  94796. \************************/
  94797. /*! exports provided: Logger */
  94798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94799. "use strict";
  94800. __webpack_require__.r(__webpack_exports__);
  94801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  94802. /**
  94803. * Logger used througouht the application to allow configuration of
  94804. * the log level required for the messages.
  94805. */
  94806. var Logger = /** @class */ (function () {
  94807. function Logger() {
  94808. }
  94809. Logger._AddLogEntry = function (entry) {
  94810. Logger._LogCache = entry + Logger._LogCache;
  94811. if (Logger.OnNewCacheEntry) {
  94812. Logger.OnNewCacheEntry(entry);
  94813. }
  94814. };
  94815. Logger._FormatMessage = function (message) {
  94816. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94817. var date = new Date();
  94818. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94819. };
  94820. Logger._LogDisabled = function (message) {
  94821. // nothing to do
  94822. };
  94823. Logger._LogEnabled = function (message) {
  94824. var formattedMessage = Logger._FormatMessage(message);
  94825. console.log("BJS - " + formattedMessage);
  94826. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  94827. Logger._AddLogEntry(entry);
  94828. };
  94829. Logger._WarnDisabled = function (message) {
  94830. // nothing to do
  94831. };
  94832. Logger._WarnEnabled = function (message) {
  94833. var formattedMessage = Logger._FormatMessage(message);
  94834. console.warn("BJS - " + formattedMessage);
  94835. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  94836. Logger._AddLogEntry(entry);
  94837. };
  94838. Logger._ErrorDisabled = function (message) {
  94839. // nothing to do
  94840. };
  94841. Logger._ErrorEnabled = function (message) {
  94842. Logger.errorsCount++;
  94843. var formattedMessage = Logger._FormatMessage(message);
  94844. console.error("BJS - " + formattedMessage);
  94845. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  94846. Logger._AddLogEntry(entry);
  94847. };
  94848. Object.defineProperty(Logger, "LogCache", {
  94849. /**
  94850. * Gets current log cache (list of logs)
  94851. */
  94852. get: function () {
  94853. return Logger._LogCache;
  94854. },
  94855. enumerable: true,
  94856. configurable: true
  94857. });
  94858. /**
  94859. * Clears the log cache
  94860. */
  94861. Logger.ClearLogCache = function () {
  94862. Logger._LogCache = "";
  94863. Logger.errorsCount = 0;
  94864. };
  94865. Object.defineProperty(Logger, "LogLevels", {
  94866. /**
  94867. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94868. */
  94869. set: function (level) {
  94870. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  94871. Logger.Log = Logger._LogEnabled;
  94872. }
  94873. else {
  94874. Logger.Log = Logger._LogDisabled;
  94875. }
  94876. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  94877. Logger.Warn = Logger._WarnEnabled;
  94878. }
  94879. else {
  94880. Logger.Warn = Logger._WarnDisabled;
  94881. }
  94882. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  94883. Logger.Error = Logger._ErrorEnabled;
  94884. }
  94885. else {
  94886. Logger.Error = Logger._ErrorDisabled;
  94887. }
  94888. },
  94889. enumerable: true,
  94890. configurable: true
  94891. });
  94892. /**
  94893. * No log
  94894. */
  94895. Logger.NoneLogLevel = 0;
  94896. /**
  94897. * Only message logs
  94898. */
  94899. Logger.MessageLogLevel = 1;
  94900. /**
  94901. * Only warning logs
  94902. */
  94903. Logger.WarningLogLevel = 2;
  94904. /**
  94905. * Only error logs
  94906. */
  94907. Logger.ErrorLogLevel = 4;
  94908. /**
  94909. * All logs
  94910. */
  94911. Logger.AllLogLevel = 7;
  94912. Logger._LogCache = "";
  94913. /**
  94914. * Gets a value indicating the number of loading errors
  94915. * @ignorenaming
  94916. */
  94917. Logger.errorsCount = 0;
  94918. /**
  94919. * Log a message to the console
  94920. */
  94921. Logger.Log = Logger._LogEnabled;
  94922. /**
  94923. * Write a warning message to the console
  94924. */
  94925. Logger.Warn = Logger._WarnEnabled;
  94926. /**
  94927. * Write an error message to the console
  94928. */
  94929. Logger.Error = Logger._ErrorEnabled;
  94930. return Logger;
  94931. }());
  94932. /***/ }),
  94933. /***/ "./Misc/observable.ts":
  94934. /*!****************************!*\
  94935. !*** ./Misc/observable.ts ***!
  94936. \****************************/
  94937. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  94938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94939. "use strict";
  94940. __webpack_require__.r(__webpack_exports__);
  94941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  94942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  94943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  94944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  94945. /**
  94946. * A class serves as a medium between the observable and its observers
  94947. */
  94948. var EventState = /** @class */ (function () {
  94949. /**
  94950. * Create a new EventState
  94951. * @param mask defines the mask associated with this state
  94952. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94953. * @param target defines the original target of the state
  94954. * @param currentTarget defines the current target of the state
  94955. */
  94956. function EventState(mask, skipNextObservers, target, currentTarget) {
  94957. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94958. this.initalize(mask, skipNextObservers, target, currentTarget);
  94959. }
  94960. /**
  94961. * Initialize the current event state
  94962. * @param mask defines the mask associated with this state
  94963. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94964. * @param target defines the original target of the state
  94965. * @param currentTarget defines the current target of the state
  94966. * @returns the current event state
  94967. */
  94968. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  94969. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94970. this.mask = mask;
  94971. this.skipNextObservers = skipNextObservers;
  94972. this.target = target;
  94973. this.currentTarget = currentTarget;
  94974. return this;
  94975. };
  94976. return EventState;
  94977. }());
  94978. /**
  94979. * Represent an Observer registered to a given Observable object.
  94980. */
  94981. var Observer = /** @class */ (function () {
  94982. /**
  94983. * Creates a new observer
  94984. * @param callback defines the callback to call when the observer is notified
  94985. * @param mask defines the mask of the observer (used to filter notifications)
  94986. * @param scope defines the current scope used to restore the JS context
  94987. */
  94988. function Observer(
  94989. /**
  94990. * Defines the callback to call when the observer is notified
  94991. */
  94992. callback,
  94993. /**
  94994. * Defines the mask of the observer (used to filter notifications)
  94995. */
  94996. mask,
  94997. /**
  94998. * Defines the current scope used to restore the JS context
  94999. */
  95000. scope) {
  95001. if (scope === void 0) { scope = null; }
  95002. this.callback = callback;
  95003. this.mask = mask;
  95004. this.scope = scope;
  95005. /** @hidden */
  95006. this._willBeUnregistered = false;
  95007. /**
  95008. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  95009. */
  95010. this.unregisterOnNextCall = false;
  95011. }
  95012. return Observer;
  95013. }());
  95014. /**
  95015. * Represent a list of observers registered to multiple Observables object.
  95016. */
  95017. var MultiObserver = /** @class */ (function () {
  95018. function MultiObserver() {
  95019. }
  95020. /**
  95021. * Release associated resources
  95022. */
  95023. MultiObserver.prototype.dispose = function () {
  95024. if (this._observers && this._observables) {
  95025. for (var index = 0; index < this._observers.length; index++) {
  95026. this._observables[index].remove(this._observers[index]);
  95027. }
  95028. }
  95029. this._observers = null;
  95030. this._observables = null;
  95031. };
  95032. /**
  95033. * Raise a callback when one of the observable will notify
  95034. * @param observables defines a list of observables to watch
  95035. * @param callback defines the callback to call on notification
  95036. * @param mask defines the mask used to filter notifications
  95037. * @param scope defines the current scope used to restore the JS context
  95038. * @returns the new MultiObserver
  95039. */
  95040. MultiObserver.Watch = function (observables, callback, mask, scope) {
  95041. if (mask === void 0) { mask = -1; }
  95042. if (scope === void 0) { scope = null; }
  95043. var result = new MultiObserver();
  95044. result._observers = new Array();
  95045. result._observables = observables;
  95046. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  95047. var observable = observables_1[_i];
  95048. var observer = observable.add(callback, mask, false, scope);
  95049. if (observer) {
  95050. result._observers.push(observer);
  95051. }
  95052. }
  95053. return result;
  95054. };
  95055. return MultiObserver;
  95056. }());
  95057. /**
  95058. * The Observable class is a simple implementation of the Observable pattern.
  95059. *
  95060. * 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.
  95061. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  95062. * 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).
  95063. * 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.
  95064. */
  95065. var Observable = /** @class */ (function () {
  95066. /**
  95067. * Creates a new observable
  95068. * @param onObserverAdded defines a callback to call when a new observer is added
  95069. */
  95070. function Observable(onObserverAdded) {
  95071. this._observers = new Array();
  95072. this._eventState = new EventState(0);
  95073. if (onObserverAdded) {
  95074. this._onObserverAdded = onObserverAdded;
  95075. }
  95076. }
  95077. /**
  95078. * Create a new Observer with the specified callback
  95079. * @param callback the callback that will be executed for that Observer
  95080. * @param mask the mask used to filter observers
  95081. * @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.
  95082. * @param scope optional scope for the callback to be called from
  95083. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  95084. * @returns the new observer created for the callback
  95085. */
  95086. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  95087. if (mask === void 0) { mask = -1; }
  95088. if (insertFirst === void 0) { insertFirst = false; }
  95089. if (scope === void 0) { scope = null; }
  95090. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  95091. if (!callback) {
  95092. return null;
  95093. }
  95094. var observer = new Observer(callback, mask, scope);
  95095. observer.unregisterOnNextCall = unregisterOnFirstCall;
  95096. if (insertFirst) {
  95097. this._observers.unshift(observer);
  95098. }
  95099. else {
  95100. this._observers.push(observer);
  95101. }
  95102. if (this._onObserverAdded) {
  95103. this._onObserverAdded(observer);
  95104. }
  95105. return observer;
  95106. };
  95107. /**
  95108. * Create a new Observer with the specified callback and unregisters after the next notification
  95109. * @param callback the callback that will be executed for that Observer
  95110. * @returns the new observer created for the callback
  95111. */
  95112. Observable.prototype.addOnce = function (callback) {
  95113. return this.add(callback, undefined, undefined, undefined, true);
  95114. };
  95115. /**
  95116. * Remove an Observer from the Observable object
  95117. * @param observer the instance of the Observer to remove
  95118. * @returns false if it doesn't belong to this Observable
  95119. */
  95120. Observable.prototype.remove = function (observer) {
  95121. if (!observer) {
  95122. return false;
  95123. }
  95124. var index = this._observers.indexOf(observer);
  95125. if (index !== -1) {
  95126. this._deferUnregister(observer);
  95127. return true;
  95128. }
  95129. return false;
  95130. };
  95131. /**
  95132. * Remove a callback from the Observable object
  95133. * @param callback the callback to remove
  95134. * @param scope optional scope. If used only the callbacks with this scope will be removed
  95135. * @returns false if it doesn't belong to this Observable
  95136. */
  95137. Observable.prototype.removeCallback = function (callback, scope) {
  95138. for (var index = 0; index < this._observers.length; index++) {
  95139. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  95140. this._deferUnregister(this._observers[index]);
  95141. return true;
  95142. }
  95143. }
  95144. return false;
  95145. };
  95146. Observable.prototype._deferUnregister = function (observer) {
  95147. var _this = this;
  95148. observer.unregisterOnNextCall = false;
  95149. observer._willBeUnregistered = true;
  95150. setTimeout(function () {
  95151. _this._remove(observer);
  95152. }, 0);
  95153. };
  95154. // This should only be called when not iterating over _observers to avoid callback skipping.
  95155. // Removes an observer from the _observer Array.
  95156. Observable.prototype._remove = function (observer) {
  95157. if (!observer) {
  95158. return false;
  95159. }
  95160. var index = this._observers.indexOf(observer);
  95161. if (index !== -1) {
  95162. this._observers.splice(index, 1);
  95163. return true;
  95164. }
  95165. return false;
  95166. };
  95167. /**
  95168. * Notify all Observers by calling their respective callback with the given data
  95169. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  95170. * @param eventData defines the data to send to all observers
  95171. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  95172. * @param target defines the original target of the state
  95173. * @param currentTarget defines the current target of the state
  95174. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  95175. */
  95176. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  95177. if (mask === void 0) { mask = -1; }
  95178. if (!this._observers.length) {
  95179. return true;
  95180. }
  95181. var state = this._eventState;
  95182. state.mask = mask;
  95183. state.target = target;
  95184. state.currentTarget = currentTarget;
  95185. state.skipNextObservers = false;
  95186. state.lastReturnValue = eventData;
  95187. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95188. var obs = _a[_i];
  95189. if (obs._willBeUnregistered) {
  95190. continue;
  95191. }
  95192. if (obs.mask & mask) {
  95193. if (obs.scope) {
  95194. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  95195. }
  95196. else {
  95197. state.lastReturnValue = obs.callback(eventData, state);
  95198. }
  95199. if (obs.unregisterOnNextCall) {
  95200. this._deferUnregister(obs);
  95201. }
  95202. }
  95203. if (state.skipNextObservers) {
  95204. return false;
  95205. }
  95206. }
  95207. return true;
  95208. };
  95209. /**
  95210. * Calling this will execute each callback, expecting it to be a promise or return a value.
  95211. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  95212. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  95213. * and it is crucial that all callbacks will be executed.
  95214. * The order of the callbacks is kept, callbacks are not executed parallel.
  95215. *
  95216. * @param eventData The data to be sent to each callback
  95217. * @param mask is used to filter observers defaults to -1
  95218. * @param target defines the callback target (see EventState)
  95219. * @param currentTarget defines he current object in the bubbling phase
  95220. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  95221. */
  95222. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  95223. var _this = this;
  95224. if (mask === void 0) { mask = -1; }
  95225. // create an empty promise
  95226. var p = Promise.resolve(eventData);
  95227. // no observers? return this promise.
  95228. if (!this._observers.length) {
  95229. return p;
  95230. }
  95231. var state = this._eventState;
  95232. state.mask = mask;
  95233. state.target = target;
  95234. state.currentTarget = currentTarget;
  95235. state.skipNextObservers = false;
  95236. // execute one callback after another (not using Promise.all, the order is important)
  95237. this._observers.forEach(function (obs) {
  95238. if (state.skipNextObservers) {
  95239. return;
  95240. }
  95241. if (obs._willBeUnregistered) {
  95242. return;
  95243. }
  95244. if (obs.mask & mask) {
  95245. if (obs.scope) {
  95246. p = p.then(function (lastReturnedValue) {
  95247. state.lastReturnValue = lastReturnedValue;
  95248. return obs.callback.apply(obs.scope, [eventData, state]);
  95249. });
  95250. }
  95251. else {
  95252. p = p.then(function (lastReturnedValue) {
  95253. state.lastReturnValue = lastReturnedValue;
  95254. return obs.callback(eventData, state);
  95255. });
  95256. }
  95257. if (obs.unregisterOnNextCall) {
  95258. _this._deferUnregister(obs);
  95259. }
  95260. }
  95261. });
  95262. // return the eventData
  95263. return p.then(function () { return eventData; });
  95264. };
  95265. /**
  95266. * Notify a specific observer
  95267. * @param observer defines the observer to notify
  95268. * @param eventData defines the data to be sent to each callback
  95269. * @param mask is used to filter observers defaults to -1
  95270. */
  95271. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  95272. if (mask === void 0) { mask = -1; }
  95273. var state = this._eventState;
  95274. state.mask = mask;
  95275. state.skipNextObservers = false;
  95276. observer.callback(eventData, state);
  95277. };
  95278. /**
  95279. * Gets a boolean indicating if the observable has at least one observer
  95280. * @returns true is the Observable has at least one Observer registered
  95281. */
  95282. Observable.prototype.hasObservers = function () {
  95283. return this._observers.length > 0;
  95284. };
  95285. /**
  95286. * Clear the list of observers
  95287. */
  95288. Observable.prototype.clear = function () {
  95289. this._observers = new Array();
  95290. this._onObserverAdded = null;
  95291. };
  95292. /**
  95293. * Clone the current observable
  95294. * @returns a new observable
  95295. */
  95296. Observable.prototype.clone = function () {
  95297. var result = new Observable();
  95298. result._observers = this._observers.slice(0);
  95299. return result;
  95300. };
  95301. /**
  95302. * Does this observable handles observer registered with a given mask
  95303. * @param mask defines the mask to be tested
  95304. * @return whether or not one observer registered with the given mask is handeled
  95305. **/
  95306. Observable.prototype.hasSpecificMask = function (mask) {
  95307. if (mask === void 0) { mask = -1; }
  95308. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95309. var obs = _a[_i];
  95310. if (obs.mask & mask || obs.mask === mask) {
  95311. return true;
  95312. }
  95313. }
  95314. return false;
  95315. };
  95316. return Observable;
  95317. }());
  95318. /***/ }),
  95319. /***/ "./Misc/performanceMonitor.ts":
  95320. /*!************************************!*\
  95321. !*** ./Misc/performanceMonitor.ts ***!
  95322. \************************************/
  95323. /*! exports provided: PerformanceMonitor, RollingAverage */
  95324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95325. "use strict";
  95326. __webpack_require__.r(__webpack_exports__);
  95327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  95328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  95329. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95330. /**
  95331. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95332. */
  95333. var PerformanceMonitor = /** @class */ (function () {
  95334. /**
  95335. * constructor
  95336. * @param frameSampleSize The number of samples required to saturate the sliding window
  95337. */
  95338. function PerformanceMonitor(frameSampleSize) {
  95339. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  95340. this._enabled = true;
  95341. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  95342. }
  95343. /**
  95344. * Samples current frame
  95345. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95346. */
  95347. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  95348. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  95349. if (!this._enabled) {
  95350. return;
  95351. }
  95352. if (this._lastFrameTimeMs != null) {
  95353. var dt = timeMs - this._lastFrameTimeMs;
  95354. this._rollingFrameTime.add(dt);
  95355. }
  95356. this._lastFrameTimeMs = timeMs;
  95357. };
  95358. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  95359. /**
  95360. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95361. */
  95362. get: function () {
  95363. return this._rollingFrameTime.average;
  95364. },
  95365. enumerable: true,
  95366. configurable: true
  95367. });
  95368. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  95369. /**
  95370. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95371. */
  95372. get: function () {
  95373. return this._rollingFrameTime.variance;
  95374. },
  95375. enumerable: true,
  95376. configurable: true
  95377. });
  95378. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  95379. /**
  95380. * Returns the frame time of the most recent frame
  95381. */
  95382. get: function () {
  95383. return this._rollingFrameTime.history(0);
  95384. },
  95385. enumerable: true,
  95386. configurable: true
  95387. });
  95388. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  95389. /**
  95390. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95391. */
  95392. get: function () {
  95393. return 1000.0 / this._rollingFrameTime.average;
  95394. },
  95395. enumerable: true,
  95396. configurable: true
  95397. });
  95398. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  95399. /**
  95400. * Returns the average framerate in frames per second using the most recent frame time
  95401. */
  95402. get: function () {
  95403. var history = this._rollingFrameTime.history(0);
  95404. if (history === 0) {
  95405. return 0;
  95406. }
  95407. return 1000.0 / history;
  95408. },
  95409. enumerable: true,
  95410. configurable: true
  95411. });
  95412. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  95413. /**
  95414. * Returns true if enough samples have been taken to completely fill the sliding window
  95415. */
  95416. get: function () {
  95417. return this._rollingFrameTime.isSaturated();
  95418. },
  95419. enumerable: true,
  95420. configurable: true
  95421. });
  95422. /**
  95423. * Enables contributions to the sliding window sample set
  95424. */
  95425. PerformanceMonitor.prototype.enable = function () {
  95426. this._enabled = true;
  95427. };
  95428. /**
  95429. * Disables contributions to the sliding window sample set
  95430. * Samples will not be interpolated over the disabled period
  95431. */
  95432. PerformanceMonitor.prototype.disable = function () {
  95433. this._enabled = false;
  95434. //clear last sample to avoid interpolating over the disabled period when next enabled
  95435. this._lastFrameTimeMs = null;
  95436. };
  95437. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  95438. /**
  95439. * Returns true if sampling is enabled
  95440. */
  95441. get: function () {
  95442. return this._enabled;
  95443. },
  95444. enumerable: true,
  95445. configurable: true
  95446. });
  95447. /**
  95448. * Resets performance monitor
  95449. */
  95450. PerformanceMonitor.prototype.reset = function () {
  95451. //clear last sample to avoid interpolating over the disabled period when next enabled
  95452. this._lastFrameTimeMs = null;
  95453. //wipe record
  95454. this._rollingFrameTime.reset();
  95455. };
  95456. return PerformanceMonitor;
  95457. }());
  95458. /**
  95459. * RollingAverage
  95460. *
  95461. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95462. */
  95463. var RollingAverage = /** @class */ (function () {
  95464. /**
  95465. * constructor
  95466. * @param length The number of samples required to saturate the sliding window
  95467. */
  95468. function RollingAverage(length) {
  95469. this._samples = new Array(length);
  95470. this.reset();
  95471. }
  95472. /**
  95473. * Adds a sample to the sample set
  95474. * @param v The sample value
  95475. */
  95476. RollingAverage.prototype.add = function (v) {
  95477. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  95478. var delta;
  95479. //we need to check if we've already wrapped round
  95480. if (this.isSaturated()) {
  95481. //remove bottom of stack from mean
  95482. var bottomValue = this._samples[this._pos];
  95483. delta = bottomValue - this.average;
  95484. this.average -= delta / (this._sampleCount - 1);
  95485. this._m2 -= delta * (bottomValue - this.average);
  95486. }
  95487. else {
  95488. this._sampleCount++;
  95489. }
  95490. //add new value to mean
  95491. delta = v - this.average;
  95492. this.average += delta / (this._sampleCount);
  95493. this._m2 += delta * (v - this.average);
  95494. //set the new variance
  95495. this.variance = this._m2 / (this._sampleCount - 1);
  95496. this._samples[this._pos] = v;
  95497. this._pos++;
  95498. this._pos %= this._samples.length; //positive wrap around
  95499. };
  95500. /**
  95501. * Returns previously added values or null if outside of history or outside the sliding window domain
  95502. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95503. * @return Value previously recorded with add() or null if outside of range
  95504. */
  95505. RollingAverage.prototype.history = function (i) {
  95506. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  95507. return 0;
  95508. }
  95509. var i0 = this._wrapPosition(this._pos - 1.0);
  95510. return this._samples[this._wrapPosition(i0 - i)];
  95511. };
  95512. /**
  95513. * Returns true if enough samples have been taken to completely fill the sliding window
  95514. * @return true if sample-set saturated
  95515. */
  95516. RollingAverage.prototype.isSaturated = function () {
  95517. return this._sampleCount >= this._samples.length;
  95518. };
  95519. /**
  95520. * Resets the rolling average (equivalent to 0 samples taken so far)
  95521. */
  95522. RollingAverage.prototype.reset = function () {
  95523. this.average = 0;
  95524. this.variance = 0;
  95525. this._sampleCount = 0;
  95526. this._pos = 0;
  95527. this._m2 = 0;
  95528. };
  95529. /**
  95530. * Wraps a value around the sample range boundaries
  95531. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95532. * @return Wrapped position in sample range
  95533. */
  95534. RollingAverage.prototype._wrapPosition = function (i) {
  95535. var max = this._samples.length;
  95536. return ((i % max) + max) % max;
  95537. };
  95538. return RollingAverage;
  95539. }());
  95540. /***/ }),
  95541. /***/ "./Misc/pivotTools.ts":
  95542. /*!****************************!*\
  95543. !*** ./Misc/pivotTools.ts ***!
  95544. \****************************/
  95545. /*! exports provided: PivotTools */
  95546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95547. "use strict";
  95548. __webpack_require__.r(__webpack_exports__);
  95549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  95550. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95551. /**
  95552. * Class containing a set of static utilities functions for managing Pivots
  95553. * @hidden
  95554. */
  95555. var PivotTools = /** @class */ (function () {
  95556. function PivotTools() {
  95557. }
  95558. /** @hidden */
  95559. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  95560. if (mesh && PivotTools._PivotCached === 0) {
  95561. // Save old pivot and set pivot to 0,0,0
  95562. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  95563. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  95564. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  95565. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  95566. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95567. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95568. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95569. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  95570. }
  95571. }
  95572. PivotTools._PivotCached++;
  95573. };
  95574. /** @hidden */
  95575. PivotTools._RestorePivotPoint = function (mesh) {
  95576. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  95577. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  95578. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95579. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95580. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95581. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  95582. }
  95583. this._PivotCached--;
  95584. };
  95585. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  95586. // store/remove pivot point should only be applied during their outermost calls
  95587. PivotTools._PivotCached = 0;
  95588. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95589. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95590. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95591. return PivotTools;
  95592. }());
  95593. /***/ }),
  95594. /***/ "./Misc/precisionDate.ts":
  95595. /*!*******************************!*\
  95596. !*** ./Misc/precisionDate.ts ***!
  95597. \*******************************/
  95598. /*! exports provided: PrecisionDate */
  95599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95600. "use strict";
  95601. __webpack_require__.r(__webpack_exports__);
  95602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  95603. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  95604. /**
  95605. * Class containing a set of static utilities functions for precision date
  95606. */
  95607. var PrecisionDate = /** @class */ (function () {
  95608. function PrecisionDate() {
  95609. }
  95610. Object.defineProperty(PrecisionDate, "Now", {
  95611. /**
  95612. * Gets either window.performance.now() if supported or Date.now() else
  95613. */
  95614. get: function () {
  95615. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  95616. return window.performance.now();
  95617. }
  95618. return Date.now();
  95619. },
  95620. enumerable: true,
  95621. configurable: true
  95622. });
  95623. return PrecisionDate;
  95624. }());
  95625. /***/ }),
  95626. /***/ "./Misc/promise.ts":
  95627. /*!*************************!*\
  95628. !*** ./Misc/promise.ts ***!
  95629. \*************************/
  95630. /*! exports provided: PromisePolyfill */
  95631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95632. "use strict";
  95633. __webpack_require__.r(__webpack_exports__);
  95634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  95635. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95636. var PromiseStates;
  95637. (function (PromiseStates) {
  95638. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  95639. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  95640. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  95641. })(PromiseStates || (PromiseStates = {}));
  95642. var FulFillmentAgregator = /** @class */ (function () {
  95643. function FulFillmentAgregator() {
  95644. this.count = 0;
  95645. this.target = 0;
  95646. this.results = [];
  95647. }
  95648. return FulFillmentAgregator;
  95649. }());
  95650. var InternalPromise = /** @class */ (function () {
  95651. function InternalPromise(resolver) {
  95652. var _this = this;
  95653. this._state = PromiseStates.Pending;
  95654. this._children = new Array();
  95655. this._rejectWasConsumed = false;
  95656. if (!resolver) {
  95657. return;
  95658. }
  95659. try {
  95660. resolver(function (value) {
  95661. _this._resolve(value);
  95662. }, function (reason) {
  95663. _this._reject(reason);
  95664. });
  95665. }
  95666. catch (e) {
  95667. this._reject(e);
  95668. }
  95669. }
  95670. Object.defineProperty(InternalPromise.prototype, "_result", {
  95671. get: function () {
  95672. return this._resultValue;
  95673. },
  95674. set: function (value) {
  95675. this._resultValue = value;
  95676. if (this._parent && this._parent._result === undefined) {
  95677. this._parent._result = value;
  95678. }
  95679. },
  95680. enumerable: true,
  95681. configurable: true
  95682. });
  95683. InternalPromise.prototype.catch = function (onRejected) {
  95684. return this.then(undefined, onRejected);
  95685. };
  95686. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  95687. var _this = this;
  95688. var newPromise = new InternalPromise();
  95689. newPromise._onFulfilled = onFulfilled;
  95690. newPromise._onRejected = onRejected;
  95691. // Composition
  95692. this._children.push(newPromise);
  95693. newPromise._parent = this;
  95694. if (this._state !== PromiseStates.Pending) {
  95695. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  95696. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  95697. var returnedValue = newPromise._resolve(_this._result);
  95698. if (returnedValue !== undefined && returnedValue !== null) {
  95699. if (returnedValue._state !== undefined) {
  95700. var returnedPromise = returnedValue;
  95701. newPromise._children.push(returnedPromise);
  95702. returnedPromise._parent = newPromise;
  95703. newPromise = returnedPromise;
  95704. }
  95705. else {
  95706. newPromise._result = returnedValue;
  95707. }
  95708. }
  95709. }
  95710. else {
  95711. newPromise._reject(_this._reason);
  95712. }
  95713. });
  95714. }
  95715. return newPromise;
  95716. };
  95717. InternalPromise.prototype._moveChildren = function (children) {
  95718. var _this = this;
  95719. var _a;
  95720. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  95721. this._children.forEach(function (child) {
  95722. child._parent = _this;
  95723. });
  95724. if (this._state === PromiseStates.Fulfilled) {
  95725. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  95726. var child = _b[_i];
  95727. child._resolve(this._result);
  95728. }
  95729. }
  95730. else if (this._state === PromiseStates.Rejected) {
  95731. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  95732. var child = _d[_c];
  95733. child._reject(this._reason);
  95734. }
  95735. }
  95736. };
  95737. InternalPromise.prototype._resolve = function (value) {
  95738. try {
  95739. this._state = PromiseStates.Fulfilled;
  95740. var returnedValue = null;
  95741. if (this._onFulfilled) {
  95742. returnedValue = this._onFulfilled(value);
  95743. }
  95744. if (returnedValue !== undefined && returnedValue !== null) {
  95745. if (returnedValue._state !== undefined) {
  95746. // Transmit children
  95747. var returnedPromise = returnedValue;
  95748. returnedPromise._parent = this;
  95749. returnedPromise._moveChildren(this._children);
  95750. value = returnedPromise._result;
  95751. }
  95752. else {
  95753. value = returnedValue;
  95754. }
  95755. }
  95756. this._result = value;
  95757. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95758. var child = _a[_i];
  95759. child._resolve(value);
  95760. }
  95761. this._children.length = 0;
  95762. delete this._onFulfilled;
  95763. delete this._onRejected;
  95764. }
  95765. catch (e) {
  95766. this._reject(e, true);
  95767. }
  95768. };
  95769. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  95770. if (onLocalThrow === void 0) { onLocalThrow = false; }
  95771. this._state = PromiseStates.Rejected;
  95772. this._reason = reason;
  95773. if (this._onRejected && !onLocalThrow) {
  95774. try {
  95775. this._onRejected(reason);
  95776. this._rejectWasConsumed = true;
  95777. }
  95778. catch (e) {
  95779. reason = e;
  95780. }
  95781. }
  95782. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95783. var child = _a[_i];
  95784. if (this._rejectWasConsumed) {
  95785. child._resolve(null);
  95786. }
  95787. else {
  95788. child._reject(reason);
  95789. }
  95790. }
  95791. this._children.length = 0;
  95792. delete this._onFulfilled;
  95793. delete this._onRejected;
  95794. };
  95795. InternalPromise.resolve = function (value) {
  95796. var newPromise = new InternalPromise();
  95797. newPromise._resolve(value);
  95798. return newPromise;
  95799. };
  95800. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  95801. promise.then(function (value) {
  95802. agregator.results[index] = value;
  95803. agregator.count++;
  95804. if (agregator.count === agregator.target) {
  95805. agregator.rootPromise._resolve(agregator.results);
  95806. }
  95807. return null;
  95808. }, function (reason) {
  95809. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  95810. agregator.rootPromise._reject(reason);
  95811. }
  95812. });
  95813. };
  95814. InternalPromise.all = function (promises) {
  95815. var newPromise = new InternalPromise();
  95816. var agregator = new FulFillmentAgregator();
  95817. agregator.target = promises.length;
  95818. agregator.rootPromise = newPromise;
  95819. if (promises.length) {
  95820. for (var index = 0; index < promises.length; index++) {
  95821. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95822. }
  95823. }
  95824. else {
  95825. newPromise._resolve([]);
  95826. }
  95827. return newPromise;
  95828. };
  95829. InternalPromise.race = function (promises) {
  95830. var newPromise = new InternalPromise();
  95831. if (promises.length) {
  95832. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  95833. var promise = promises_1[_i];
  95834. promise.then(function (value) {
  95835. if (newPromise) {
  95836. newPromise._resolve(value);
  95837. newPromise = null;
  95838. }
  95839. return null;
  95840. }, function (reason) {
  95841. if (newPromise) {
  95842. newPromise._reject(reason);
  95843. newPromise = null;
  95844. }
  95845. });
  95846. }
  95847. }
  95848. return newPromise;
  95849. };
  95850. return InternalPromise;
  95851. }());
  95852. /**
  95853. * Helper class that provides a small promise polyfill
  95854. */
  95855. var PromisePolyfill = /** @class */ (function () {
  95856. function PromisePolyfill() {
  95857. }
  95858. /**
  95859. * Static function used to check if the polyfill is required
  95860. * If this is the case then the function will inject the polyfill to window.Promise
  95861. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95862. */
  95863. PromisePolyfill.Apply = function (force) {
  95864. if (force === void 0) { force = false; }
  95865. if (force || typeof Promise === 'undefined') {
  95866. var root = window;
  95867. root.Promise = InternalPromise;
  95868. }
  95869. };
  95870. return PromisePolyfill;
  95871. }());
  95872. /***/ }),
  95873. /***/ "./Misc/sceneOptimizer.ts":
  95874. /*!********************************!*\
  95875. !*** ./Misc/sceneOptimizer.ts ***!
  95876. \********************************/
  95877. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  95878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95879. "use strict";
  95880. __webpack_require__.r(__webpack_exports__);
  95881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  95882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  95883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  95884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  95885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  95886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  95887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  95888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  95889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  95890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  95891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  95892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  95893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95894. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  95895. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95896. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  95897. /**
  95898. * Defines the root class used to create scene optimization to use with SceneOptimizer
  95899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95900. */
  95901. var SceneOptimization = /** @class */ (function () {
  95902. /**
  95903. * Creates the SceneOptimization object
  95904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95905. * @param desc defines the description associated with the optimization
  95906. */
  95907. function SceneOptimization(
  95908. /**
  95909. * Defines the priority of this optimization (0 by default which means first in the list)
  95910. */
  95911. priority) {
  95912. if (priority === void 0) { priority = 0; }
  95913. this.priority = priority;
  95914. }
  95915. /**
  95916. * Gets a string describing the action executed by the current optimization
  95917. * @returns description string
  95918. */
  95919. SceneOptimization.prototype.getDescription = function () {
  95920. return "";
  95921. };
  95922. /**
  95923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95924. * @param scene defines the current scene where to apply this optimization
  95925. * @param optimizer defines the current optimizer
  95926. * @returns true if everything that can be done was applied
  95927. */
  95928. SceneOptimization.prototype.apply = function (scene, optimizer) {
  95929. return true;
  95930. };
  95931. return SceneOptimization;
  95932. }());
  95933. /**
  95934. * Defines an optimization used to reduce the size of render target textures
  95935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95936. */
  95937. var TextureOptimization = /** @class */ (function (_super) {
  95938. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  95939. /**
  95940. * Creates the TextureOptimization object
  95941. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95942. * @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
  95943. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95944. */
  95945. function TextureOptimization(
  95946. /**
  95947. * Defines the priority of this optimization (0 by default which means first in the list)
  95948. */
  95949. priority,
  95950. /**
  95951. * 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
  95952. */
  95953. maximumSize,
  95954. /**
  95955. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95956. */
  95957. step) {
  95958. if (priority === void 0) { priority = 0; }
  95959. if (maximumSize === void 0) { maximumSize = 1024; }
  95960. if (step === void 0) { step = 0.5; }
  95961. var _this = _super.call(this, priority) || this;
  95962. _this.priority = priority;
  95963. _this.maximumSize = maximumSize;
  95964. _this.step = step;
  95965. return _this;
  95966. }
  95967. /**
  95968. * Gets a string describing the action executed by the current optimization
  95969. * @returns description string
  95970. */
  95971. TextureOptimization.prototype.getDescription = function () {
  95972. return "Reducing render target texture size to " + this.maximumSize;
  95973. };
  95974. /**
  95975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95976. * @param scene defines the current scene where to apply this optimization
  95977. * @param optimizer defines the current optimizer
  95978. * @returns true if everything that can be done was applied
  95979. */
  95980. TextureOptimization.prototype.apply = function (scene, optimizer) {
  95981. var allDone = true;
  95982. for (var index = 0; index < scene.textures.length; index++) {
  95983. var texture = scene.textures[index];
  95984. if (!texture.canRescale || texture.getContext) {
  95985. continue;
  95986. }
  95987. var currentSize = texture.getSize();
  95988. var maxDimension = Math.max(currentSize.width, currentSize.height);
  95989. if (maxDimension > this.maximumSize) {
  95990. texture.scale(this.step);
  95991. allDone = false;
  95992. }
  95993. }
  95994. return allDone;
  95995. };
  95996. return TextureOptimization;
  95997. }(SceneOptimization));
  95998. /**
  95999. * Defines an optimization used to increase or decrease the rendering resolution
  96000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96001. */
  96002. var HardwareScalingOptimization = /** @class */ (function (_super) {
  96003. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  96004. /**
  96005. * Creates the HardwareScalingOptimization object
  96006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96007. * @param maximumScale defines the maximum scale to use (2 by default)
  96008. * @param step defines the step to use between two passes (0.5 by default)
  96009. */
  96010. function HardwareScalingOptimization(
  96011. /**
  96012. * Defines the priority of this optimization (0 by default which means first in the list)
  96013. */
  96014. priority,
  96015. /**
  96016. * Defines the maximum scale to use (2 by default)
  96017. */
  96018. maximumScale,
  96019. /**
  96020. * Defines the step to use between two passes (0.5 by default)
  96021. */
  96022. step) {
  96023. if (priority === void 0) { priority = 0; }
  96024. if (maximumScale === void 0) { maximumScale = 2; }
  96025. if (step === void 0) { step = 0.25; }
  96026. var _this = _super.call(this, priority) || this;
  96027. _this.priority = priority;
  96028. _this.maximumScale = maximumScale;
  96029. _this.step = step;
  96030. _this._currentScale = -1;
  96031. _this._directionOffset = 1;
  96032. return _this;
  96033. }
  96034. /**
  96035. * Gets a string describing the action executed by the current optimization
  96036. * @return description string
  96037. */
  96038. HardwareScalingOptimization.prototype.getDescription = function () {
  96039. return "Setting hardware scaling level to " + this._currentScale;
  96040. };
  96041. /**
  96042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96043. * @param scene defines the current scene where to apply this optimization
  96044. * @param optimizer defines the current optimizer
  96045. * @returns true if everything that can be done was applied
  96046. */
  96047. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  96048. if (this._currentScale === -1) {
  96049. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  96050. if (this._currentScale > this.maximumScale) {
  96051. this._directionOffset = -1;
  96052. }
  96053. }
  96054. this._currentScale += this._directionOffset * this.step;
  96055. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  96056. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  96057. };
  96058. return HardwareScalingOptimization;
  96059. }(SceneOptimization));
  96060. /**
  96061. * Defines an optimization used to remove shadows
  96062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96063. */
  96064. var ShadowsOptimization = /** @class */ (function (_super) {
  96065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  96066. function ShadowsOptimization() {
  96067. return _super !== null && _super.apply(this, arguments) || this;
  96068. }
  96069. /**
  96070. * Gets a string describing the action executed by the current optimization
  96071. * @return description string
  96072. */
  96073. ShadowsOptimization.prototype.getDescription = function () {
  96074. return "Turning shadows on/off";
  96075. };
  96076. /**
  96077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96078. * @param scene defines the current scene where to apply this optimization
  96079. * @param optimizer defines the current optimizer
  96080. * @returns true if everything that can be done was applied
  96081. */
  96082. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  96083. scene.shadowsEnabled = optimizer.isInImprovementMode;
  96084. return true;
  96085. };
  96086. return ShadowsOptimization;
  96087. }(SceneOptimization));
  96088. /**
  96089. * Defines an optimization used to turn post-processes off
  96090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96091. */
  96092. var PostProcessesOptimization = /** @class */ (function (_super) {
  96093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  96094. function PostProcessesOptimization() {
  96095. return _super !== null && _super.apply(this, arguments) || this;
  96096. }
  96097. /**
  96098. * Gets a string describing the action executed by the current optimization
  96099. * @return description string
  96100. */
  96101. PostProcessesOptimization.prototype.getDescription = function () {
  96102. return "Turning post-processes on/off";
  96103. };
  96104. /**
  96105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96106. * @param scene defines the current scene where to apply this optimization
  96107. * @param optimizer defines the current optimizer
  96108. * @returns true if everything that can be done was applied
  96109. */
  96110. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  96111. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  96112. return true;
  96113. };
  96114. return PostProcessesOptimization;
  96115. }(SceneOptimization));
  96116. /**
  96117. * Defines an optimization used to turn lens flares off
  96118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96119. */
  96120. var LensFlaresOptimization = /** @class */ (function (_super) {
  96121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  96122. function LensFlaresOptimization() {
  96123. return _super !== null && _super.apply(this, arguments) || this;
  96124. }
  96125. /**
  96126. * Gets a string describing the action executed by the current optimization
  96127. * @return description string
  96128. */
  96129. LensFlaresOptimization.prototype.getDescription = function () {
  96130. return "Turning lens flares on/off";
  96131. };
  96132. /**
  96133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96134. * @param scene defines the current scene where to apply this optimization
  96135. * @param optimizer defines the current optimizer
  96136. * @returns true if everything that can be done was applied
  96137. */
  96138. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  96139. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  96140. return true;
  96141. };
  96142. return LensFlaresOptimization;
  96143. }(SceneOptimization));
  96144. /**
  96145. * Defines an optimization based on user defined callback.
  96146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96147. */
  96148. var CustomOptimization = /** @class */ (function (_super) {
  96149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  96150. function CustomOptimization() {
  96151. return _super !== null && _super.apply(this, arguments) || this;
  96152. }
  96153. /**
  96154. * Gets a string describing the action executed by the current optimization
  96155. * @returns description string
  96156. */
  96157. CustomOptimization.prototype.getDescription = function () {
  96158. if (this.onGetDescription) {
  96159. return this.onGetDescription();
  96160. }
  96161. return "Running user defined callback";
  96162. };
  96163. /**
  96164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96165. * @param scene defines the current scene where to apply this optimization
  96166. * @param optimizer defines the current optimizer
  96167. * @returns true if everything that can be done was applied
  96168. */
  96169. CustomOptimization.prototype.apply = function (scene, optimizer) {
  96170. if (this.onApply) {
  96171. return this.onApply(scene, optimizer);
  96172. }
  96173. return true;
  96174. };
  96175. return CustomOptimization;
  96176. }(SceneOptimization));
  96177. /**
  96178. * Defines an optimization used to turn particles off
  96179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96180. */
  96181. var ParticlesOptimization = /** @class */ (function (_super) {
  96182. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  96183. function ParticlesOptimization() {
  96184. return _super !== null && _super.apply(this, arguments) || this;
  96185. }
  96186. /**
  96187. * Gets a string describing the action executed by the current optimization
  96188. * @return description string
  96189. */
  96190. ParticlesOptimization.prototype.getDescription = function () {
  96191. return "Turning particles on/off";
  96192. };
  96193. /**
  96194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96195. * @param scene defines the current scene where to apply this optimization
  96196. * @param optimizer defines the current optimizer
  96197. * @returns true if everything that can be done was applied
  96198. */
  96199. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  96200. scene.particlesEnabled = optimizer.isInImprovementMode;
  96201. return true;
  96202. };
  96203. return ParticlesOptimization;
  96204. }(SceneOptimization));
  96205. /**
  96206. * Defines an optimization used to turn render targets off
  96207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96208. */
  96209. var RenderTargetsOptimization = /** @class */ (function (_super) {
  96210. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  96211. function RenderTargetsOptimization() {
  96212. return _super !== null && _super.apply(this, arguments) || this;
  96213. }
  96214. /**
  96215. * Gets a string describing the action executed by the current optimization
  96216. * @return description string
  96217. */
  96218. RenderTargetsOptimization.prototype.getDescription = function () {
  96219. return "Turning render targets off";
  96220. };
  96221. /**
  96222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96223. * @param scene defines the current scene where to apply this optimization
  96224. * @param optimizer defines the current optimizer
  96225. * @returns true if everything that can be done was applied
  96226. */
  96227. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  96228. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  96229. return true;
  96230. };
  96231. return RenderTargetsOptimization;
  96232. }(SceneOptimization));
  96233. /**
  96234. * Defines an optimization used to merge meshes with compatible materials
  96235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96236. */
  96237. var MergeMeshesOptimization = /** @class */ (function (_super) {
  96238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  96239. function MergeMeshesOptimization() {
  96240. var _this = _super !== null && _super.apply(this, arguments) || this;
  96241. _this._canBeMerged = function (abstractMesh) {
  96242. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  96243. return false;
  96244. }
  96245. var mesh = abstractMesh;
  96246. if (mesh.isDisposed()) {
  96247. return false;
  96248. }
  96249. if (!mesh.isVisible || !mesh.isEnabled()) {
  96250. return false;
  96251. }
  96252. if (mesh.instances.length > 0) {
  96253. return false;
  96254. }
  96255. if (mesh.skeleton || mesh.hasLODLevels) {
  96256. return false;
  96257. }
  96258. return true;
  96259. };
  96260. return _this;
  96261. }
  96262. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  96263. /**
  96264. * Gets or sets a boolean which defines if optimization octree has to be updated
  96265. */
  96266. get: function () {
  96267. return MergeMeshesOptimization._UpdateSelectionTree;
  96268. },
  96269. /**
  96270. * Gets or sets a boolean which defines if optimization octree has to be updated
  96271. */
  96272. set: function (value) {
  96273. MergeMeshesOptimization._UpdateSelectionTree = value;
  96274. },
  96275. enumerable: true,
  96276. configurable: true
  96277. });
  96278. /**
  96279. * Gets a string describing the action executed by the current optimization
  96280. * @return description string
  96281. */
  96282. MergeMeshesOptimization.prototype.getDescription = function () {
  96283. return "Merging similar meshes together";
  96284. };
  96285. /**
  96286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96287. * @param scene defines the current scene where to apply this optimization
  96288. * @param optimizer defines the current optimizer
  96289. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  96290. * @returns true if everything that can be done was applied
  96291. */
  96292. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  96293. var globalPool = scene.meshes.slice(0);
  96294. var globalLength = globalPool.length;
  96295. for (var index = 0; index < globalLength; index++) {
  96296. var currentPool = new Array();
  96297. var current = globalPool[index];
  96298. // Checks
  96299. if (!this._canBeMerged(current)) {
  96300. continue;
  96301. }
  96302. currentPool.push(current);
  96303. // Find compatible meshes
  96304. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  96305. var otherMesh = globalPool[subIndex];
  96306. if (!this._canBeMerged(otherMesh)) {
  96307. continue;
  96308. }
  96309. if (otherMesh.material !== current.material) {
  96310. continue;
  96311. }
  96312. if (otherMesh.checkCollisions !== current.checkCollisions) {
  96313. continue;
  96314. }
  96315. currentPool.push(otherMesh);
  96316. globalLength--;
  96317. globalPool.splice(subIndex, 1);
  96318. subIndex--;
  96319. }
  96320. if (currentPool.length < 2) {
  96321. continue;
  96322. }
  96323. // Merge meshes
  96324. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  96325. }
  96326. // Call the octree system optimization if it is defined.
  96327. var sceneAsAny = scene;
  96328. if (sceneAsAny.createOrUpdateSelectionOctree) {
  96329. if (updateSelectionTree != undefined) {
  96330. if (updateSelectionTree) {
  96331. sceneAsAny.createOrUpdateSelectionOctree();
  96332. }
  96333. }
  96334. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  96335. sceneAsAny.createOrUpdateSelectionOctree();
  96336. }
  96337. }
  96338. return true;
  96339. };
  96340. MergeMeshesOptimization._UpdateSelectionTree = false;
  96341. return MergeMeshesOptimization;
  96342. }(SceneOptimization));
  96343. /**
  96344. * Defines a list of options used by SceneOptimizer
  96345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96346. */
  96347. var SceneOptimizerOptions = /** @class */ (function () {
  96348. /**
  96349. * Creates a new list of options used by SceneOptimizer
  96350. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  96351. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  96352. */
  96353. function SceneOptimizerOptions(
  96354. /**
  96355. * Defines the target frame rate to reach (60 by default)
  96356. */
  96357. targetFrameRate,
  96358. /**
  96359. * Defines the interval between two checkes (2000ms by default)
  96360. */
  96361. trackerDuration) {
  96362. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  96363. if (trackerDuration === void 0) { trackerDuration = 2000; }
  96364. this.targetFrameRate = targetFrameRate;
  96365. this.trackerDuration = trackerDuration;
  96366. /**
  96367. * Gets the list of optimizations to apply
  96368. */
  96369. this.optimizations = new Array();
  96370. }
  96371. /**
  96372. * Add a new optimization
  96373. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  96374. * @returns the current SceneOptimizerOptions
  96375. */
  96376. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  96377. this.optimizations.push(optimization);
  96378. return this;
  96379. };
  96380. /**
  96381. * Add a new custom optimization
  96382. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  96383. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  96384. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96385. * @returns the current SceneOptimizerOptions
  96386. */
  96387. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  96388. if (priority === void 0) { priority = 0; }
  96389. var optimization = new CustomOptimization(priority);
  96390. optimization.onApply = onApply;
  96391. optimization.onGetDescription = onGetDescription;
  96392. this.optimizations.push(optimization);
  96393. return this;
  96394. };
  96395. /**
  96396. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  96397. * @param targetFrameRate defines the target frame rate (60 by default)
  96398. * @returns a SceneOptimizerOptions object
  96399. */
  96400. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  96401. var result = new SceneOptimizerOptions(targetFrameRate);
  96402. var priority = 0;
  96403. result.addOptimization(new MergeMeshesOptimization(priority));
  96404. result.addOptimization(new ShadowsOptimization(priority));
  96405. result.addOptimization(new LensFlaresOptimization(priority));
  96406. // Next priority
  96407. priority++;
  96408. result.addOptimization(new PostProcessesOptimization(priority));
  96409. result.addOptimization(new ParticlesOptimization(priority));
  96410. // Next priority
  96411. priority++;
  96412. result.addOptimization(new TextureOptimization(priority, 1024));
  96413. return result;
  96414. };
  96415. /**
  96416. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  96417. * @param targetFrameRate defines the target frame rate (60 by default)
  96418. * @returns a SceneOptimizerOptions object
  96419. */
  96420. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  96421. var result = new SceneOptimizerOptions(targetFrameRate);
  96422. var priority = 0;
  96423. result.addOptimization(new MergeMeshesOptimization(priority));
  96424. result.addOptimization(new ShadowsOptimization(priority));
  96425. result.addOptimization(new LensFlaresOptimization(priority));
  96426. // Next priority
  96427. priority++;
  96428. result.addOptimization(new PostProcessesOptimization(priority));
  96429. result.addOptimization(new ParticlesOptimization(priority));
  96430. // Next priority
  96431. priority++;
  96432. result.addOptimization(new TextureOptimization(priority, 512));
  96433. // Next priority
  96434. priority++;
  96435. result.addOptimization(new RenderTargetsOptimization(priority));
  96436. // Next priority
  96437. priority++;
  96438. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  96439. return result;
  96440. };
  96441. /**
  96442. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  96443. * @param targetFrameRate defines the target frame rate (60 by default)
  96444. * @returns a SceneOptimizerOptions object
  96445. */
  96446. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  96447. var result = new SceneOptimizerOptions(targetFrameRate);
  96448. var priority = 0;
  96449. result.addOptimization(new MergeMeshesOptimization(priority));
  96450. result.addOptimization(new ShadowsOptimization(priority));
  96451. result.addOptimization(new LensFlaresOptimization(priority));
  96452. // Next priority
  96453. priority++;
  96454. result.addOptimization(new PostProcessesOptimization(priority));
  96455. result.addOptimization(new ParticlesOptimization(priority));
  96456. // Next priority
  96457. priority++;
  96458. result.addOptimization(new TextureOptimization(priority, 256));
  96459. // Next priority
  96460. priority++;
  96461. result.addOptimization(new RenderTargetsOptimization(priority));
  96462. // Next priority
  96463. priority++;
  96464. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  96465. return result;
  96466. };
  96467. return SceneOptimizerOptions;
  96468. }());
  96469. /**
  96470. * Class used to run optimizations in order to reach a target frame rate
  96471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96472. */
  96473. var SceneOptimizer = /** @class */ (function () {
  96474. /**
  96475. * Creates a new SceneOptimizer
  96476. * @param scene defines the scene to work on
  96477. * @param options defines the options to use with the SceneOptimizer
  96478. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  96479. * @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)
  96480. */
  96481. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  96482. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  96483. if (improvementMode === void 0) { improvementMode = false; }
  96484. var _this = this;
  96485. this._isRunning = false;
  96486. this._currentPriorityLevel = 0;
  96487. this._targetFrameRate = 60;
  96488. this._trackerDuration = 2000;
  96489. this._currentFrameRate = 0;
  96490. this._improvementMode = false;
  96491. /**
  96492. * Defines an observable called when the optimizer reaches the target frame rate
  96493. */
  96494. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96495. /**
  96496. * Defines an observable called when the optimizer enables an optimization
  96497. */
  96498. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96499. /**
  96500. * Defines an observable called when the optimizer is not able to reach the target frame rate
  96501. */
  96502. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96503. if (!options) {
  96504. this._options = new SceneOptimizerOptions();
  96505. }
  96506. else {
  96507. this._options = options;
  96508. }
  96509. if (this._options.targetFrameRate) {
  96510. this._targetFrameRate = this._options.targetFrameRate;
  96511. }
  96512. if (this._options.trackerDuration) {
  96513. this._trackerDuration = this._options.trackerDuration;
  96514. }
  96515. if (autoGeneratePriorities) {
  96516. var priority = 0;
  96517. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  96518. var optim = _a[_i];
  96519. optim.priority = priority++;
  96520. }
  96521. }
  96522. this._improvementMode = improvementMode;
  96523. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  96524. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  96525. _this._sceneDisposeObserver = null;
  96526. _this.dispose();
  96527. });
  96528. }
  96529. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  96530. /**
  96531. * Gets a boolean indicating if the optimizer is in improvement mode
  96532. */
  96533. get: function () {
  96534. return this._improvementMode;
  96535. },
  96536. enumerable: true,
  96537. configurable: true
  96538. });
  96539. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  96540. /**
  96541. * Gets the current priority level (0 at start)
  96542. */
  96543. get: function () {
  96544. return this._currentPriorityLevel;
  96545. },
  96546. enumerable: true,
  96547. configurable: true
  96548. });
  96549. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  96550. /**
  96551. * Gets the current frame rate checked by the SceneOptimizer
  96552. */
  96553. get: function () {
  96554. return this._currentFrameRate;
  96555. },
  96556. enumerable: true,
  96557. configurable: true
  96558. });
  96559. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  96560. /**
  96561. * Gets or sets the current target frame rate (60 by default)
  96562. */
  96563. get: function () {
  96564. return this._targetFrameRate;
  96565. },
  96566. /**
  96567. * Gets or sets the current target frame rate (60 by default)
  96568. */
  96569. set: function (value) {
  96570. this._targetFrameRate = value;
  96571. },
  96572. enumerable: true,
  96573. configurable: true
  96574. });
  96575. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  96576. /**
  96577. * Gets or sets the current interval between two checks (every 2000ms by default)
  96578. */
  96579. get: function () {
  96580. return this._trackerDuration;
  96581. },
  96582. /**
  96583. * Gets or sets the current interval between two checks (every 2000ms by default)
  96584. */
  96585. set: function (value) {
  96586. this._trackerDuration = value;
  96587. },
  96588. enumerable: true,
  96589. configurable: true
  96590. });
  96591. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  96592. /**
  96593. * Gets the list of active optimizations
  96594. */
  96595. get: function () {
  96596. return this._options.optimizations;
  96597. },
  96598. enumerable: true,
  96599. configurable: true
  96600. });
  96601. /**
  96602. * Stops the current optimizer
  96603. */
  96604. SceneOptimizer.prototype.stop = function () {
  96605. this._isRunning = false;
  96606. };
  96607. /**
  96608. * Reset the optimizer to initial step (current priority level = 0)
  96609. */
  96610. SceneOptimizer.prototype.reset = function () {
  96611. this._currentPriorityLevel = 0;
  96612. };
  96613. /**
  96614. * Start the optimizer. By default it will try to reach a specific framerate
  96615. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  96616. */
  96617. SceneOptimizer.prototype.start = function () {
  96618. var _this = this;
  96619. if (this._isRunning) {
  96620. return;
  96621. }
  96622. this._isRunning = true;
  96623. // Let's wait for the scene to be ready before running our check
  96624. this._scene.executeWhenReady(function () {
  96625. setTimeout(function () {
  96626. _this._checkCurrentState();
  96627. }, _this._trackerDuration);
  96628. });
  96629. };
  96630. SceneOptimizer.prototype._checkCurrentState = function () {
  96631. var _this = this;
  96632. if (!this._isRunning) {
  96633. return;
  96634. }
  96635. var scene = this._scene;
  96636. var options = this._options;
  96637. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  96638. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  96639. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  96640. this._isRunning = false;
  96641. this.onSuccessObservable.notifyObservers(this);
  96642. return;
  96643. }
  96644. // Apply current level of optimizations
  96645. var allDone = true;
  96646. var noOptimizationApplied = true;
  96647. for (var index = 0; index < options.optimizations.length; index++) {
  96648. var optimization = options.optimizations[index];
  96649. if (optimization.priority === this._currentPriorityLevel) {
  96650. noOptimizationApplied = false;
  96651. allDone = allDone && optimization.apply(scene, this);
  96652. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  96653. }
  96654. }
  96655. // If no optimization was applied, this is a failure :(
  96656. if (noOptimizationApplied) {
  96657. this._isRunning = false;
  96658. this.onFailureObservable.notifyObservers(this);
  96659. return;
  96660. }
  96661. // If all optimizations were done, move to next level
  96662. if (allDone) {
  96663. this._currentPriorityLevel++;
  96664. }
  96665. // Let's the system running for a specific amount of time before checking FPS
  96666. scene.executeWhenReady(function () {
  96667. setTimeout(function () {
  96668. _this._checkCurrentState();
  96669. }, _this._trackerDuration);
  96670. });
  96671. };
  96672. /**
  96673. * Release all resources
  96674. */
  96675. SceneOptimizer.prototype.dispose = function () {
  96676. this.stop();
  96677. this.onSuccessObservable.clear();
  96678. this.onFailureObservable.clear();
  96679. this.onNewOptimizationAppliedObservable.clear();
  96680. if (this._sceneDisposeObserver) {
  96681. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  96682. }
  96683. };
  96684. /**
  96685. * Helper function to create a SceneOptimizer with one single line of code
  96686. * @param scene defines the scene to work on
  96687. * @param options defines the options to use with the SceneOptimizer
  96688. * @param onSuccess defines a callback to call on success
  96689. * @param onFailure defines a callback to call on failure
  96690. * @returns the new SceneOptimizer object
  96691. */
  96692. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  96693. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  96694. if (onSuccess) {
  96695. optimizer.onSuccessObservable.add(function () {
  96696. onSuccess();
  96697. });
  96698. }
  96699. if (onFailure) {
  96700. optimizer.onFailureObservable.add(function () {
  96701. onFailure();
  96702. });
  96703. }
  96704. optimizer.start();
  96705. return optimizer;
  96706. };
  96707. return SceneOptimizer;
  96708. }());
  96709. /***/ }),
  96710. /***/ "./Misc/sceneSerializer.ts":
  96711. /*!*********************************!*\
  96712. !*** ./Misc/sceneSerializer.ts ***!
  96713. \*********************************/
  96714. /*! exports provided: SceneSerializer */
  96715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96716. "use strict";
  96717. __webpack_require__.r(__webpack_exports__);
  96718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  96719. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96720. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96721. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  96722. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96723. var serializedGeometries = [];
  96724. var serializeGeometry = function (geometry, serializationGeometries) {
  96725. if (serializedGeometries[geometry.id]) {
  96726. return;
  96727. }
  96728. if (geometry.doNotSerialize) {
  96729. return;
  96730. }
  96731. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  96732. serializedGeometries[geometry.id] = true;
  96733. };
  96734. var serializeMesh = function (mesh, serializationScene) {
  96735. var serializationObject = {};
  96736. // Geometry
  96737. var geometry = mesh._geometry;
  96738. if (geometry) {
  96739. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  96740. // 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
  96741. serializeGeometry(geometry, serializationScene.geometries);
  96742. }
  96743. }
  96744. // Custom
  96745. if (mesh.serialize) {
  96746. mesh.serialize(serializationObject);
  96747. }
  96748. return serializationObject;
  96749. };
  96750. var finalizeSingleMesh = function (mesh, serializationObject) {
  96751. //only works if the mesh is already loaded
  96752. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96753. //serialize material
  96754. if (mesh.material) {
  96755. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  96756. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  96757. serializationObject.materials = serializationObject.materials || [];
  96758. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96759. serializationObject.multiMaterials.push(mesh.material.serialize());
  96760. var _loop_1 = function (submaterial) {
  96761. if (submaterial) {
  96762. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  96763. serializationObject.materials.push(submaterial.serialize());
  96764. }
  96765. }
  96766. };
  96767. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  96768. var submaterial = _a[_i];
  96769. _loop_1(submaterial);
  96770. }
  96771. }
  96772. }
  96773. else {
  96774. serializationObject.materials = serializationObject.materials || [];
  96775. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96776. serializationObject.materials.push(mesh.material.serialize());
  96777. }
  96778. }
  96779. }
  96780. //serialize geometry
  96781. var geometry = mesh._geometry;
  96782. if (geometry) {
  96783. if (!serializationObject.geometries) {
  96784. serializationObject.geometries = {};
  96785. serializationObject.geometries.boxes = [];
  96786. serializationObject.geometries.spheres = [];
  96787. serializationObject.geometries.cylinders = [];
  96788. serializationObject.geometries.toruses = [];
  96789. serializationObject.geometries.grounds = [];
  96790. serializationObject.geometries.planes = [];
  96791. serializationObject.geometries.torusKnots = [];
  96792. serializationObject.geometries.vertexData = [];
  96793. }
  96794. serializeGeometry(geometry, serializationObject.geometries);
  96795. }
  96796. // Skeletons
  96797. if (mesh.skeleton) {
  96798. serializationObject.skeletons = serializationObject.skeletons || [];
  96799. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96800. }
  96801. //serialize the actual mesh
  96802. serializationObject.meshes = serializationObject.meshes || [];
  96803. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96804. }
  96805. };
  96806. /**
  96807. * Class used to serialize a scene into a string
  96808. */
  96809. var SceneSerializer = /** @class */ (function () {
  96810. function SceneSerializer() {
  96811. }
  96812. /**
  96813. * Clear cache used by a previous serialization
  96814. */
  96815. SceneSerializer.ClearCache = function () {
  96816. serializedGeometries = [];
  96817. };
  96818. /**
  96819. * Serialize a scene into a JSON compatible object
  96820. * @param scene defines the scene to serialize
  96821. * @returns a JSON compatible object
  96822. */
  96823. SceneSerializer.Serialize = function (scene) {
  96824. var serializationObject = {};
  96825. SceneSerializer.ClearCache();
  96826. // Scene
  96827. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96828. serializationObject.autoClear = scene.autoClear;
  96829. serializationObject.clearColor = scene.clearColor.asArray();
  96830. serializationObject.ambientColor = scene.ambientColor.asArray();
  96831. serializationObject.gravity = scene.gravity.asArray();
  96832. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  96833. // Fog
  96834. if (scene.fogMode && scene.fogMode !== 0) {
  96835. serializationObject.fogMode = scene.fogMode;
  96836. serializationObject.fogColor = scene.fogColor.asArray();
  96837. serializationObject.fogStart = scene.fogStart;
  96838. serializationObject.fogEnd = scene.fogEnd;
  96839. serializationObject.fogDensity = scene.fogDensity;
  96840. }
  96841. //Physics
  96842. if (scene.isPhysicsEnabled()) {
  96843. var physicEngine = scene.getPhysicsEngine();
  96844. if (physicEngine) {
  96845. serializationObject.physicsEnabled = true;
  96846. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  96847. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  96848. }
  96849. }
  96850. // Metadata
  96851. if (scene.metadata) {
  96852. serializationObject.metadata = scene.metadata;
  96853. }
  96854. // Morph targets
  96855. serializationObject.morphTargetManagers = [];
  96856. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  96857. var abstractMesh = _a[_i];
  96858. var manager = abstractMesh.morphTargetManager;
  96859. if (manager) {
  96860. serializationObject.morphTargetManagers.push(manager.serialize());
  96861. }
  96862. }
  96863. // Lights
  96864. serializationObject.lights = [];
  96865. var index;
  96866. var light;
  96867. for (index = 0; index < scene.lights.length; index++) {
  96868. light = scene.lights[index];
  96869. if (!light.doNotSerialize) {
  96870. serializationObject.lights.push(light.serialize());
  96871. }
  96872. }
  96873. // Cameras
  96874. serializationObject.cameras = [];
  96875. for (index = 0; index < scene.cameras.length; index++) {
  96876. var camera = scene.cameras[index];
  96877. if (!camera.doNotSerialize) {
  96878. serializationObject.cameras.push(camera.serialize());
  96879. }
  96880. }
  96881. if (scene.activeCamera) {
  96882. serializationObject.activeCameraID = scene.activeCamera.id;
  96883. }
  96884. // Animations
  96885. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  96886. // Reflection probes
  96887. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  96888. serializationObject.reflectionProbes = [];
  96889. for (index = 0; index < scene.reflectionProbes.length; index++) {
  96890. var reflectionProbe = scene.reflectionProbes[index];
  96891. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  96892. }
  96893. }
  96894. // Materials
  96895. serializationObject.materials = [];
  96896. serializationObject.multiMaterials = [];
  96897. var material;
  96898. for (index = 0; index < scene.materials.length; index++) {
  96899. material = scene.materials[index];
  96900. if (!material.doNotSerialize) {
  96901. serializationObject.materials.push(material.serialize());
  96902. }
  96903. }
  96904. // MultiMaterials
  96905. serializationObject.multiMaterials = [];
  96906. for (index = 0; index < scene.multiMaterials.length; index++) {
  96907. var multiMaterial = scene.multiMaterials[index];
  96908. serializationObject.multiMaterials.push(multiMaterial.serialize());
  96909. }
  96910. // Environment texture
  96911. if (scene.environmentTexture) {
  96912. serializationObject.environmentTexture = scene.environmentTexture.name;
  96913. }
  96914. // Skeletons
  96915. serializationObject.skeletons = [];
  96916. for (index = 0; index < scene.skeletons.length; index++) {
  96917. var skeleton = scene.skeletons[index];
  96918. if (!skeleton.doNotSerialize) {
  96919. serializationObject.skeletons.push(skeleton.serialize());
  96920. }
  96921. }
  96922. // Transform nodes
  96923. serializationObject.transformNodes = [];
  96924. for (index = 0; index < scene.transformNodes.length; index++) {
  96925. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  96926. }
  96927. // Geometries
  96928. serializationObject.geometries = {};
  96929. serializationObject.geometries.boxes = [];
  96930. serializationObject.geometries.spheres = [];
  96931. serializationObject.geometries.cylinders = [];
  96932. serializationObject.geometries.toruses = [];
  96933. serializationObject.geometries.grounds = [];
  96934. serializationObject.geometries.planes = [];
  96935. serializationObject.geometries.torusKnots = [];
  96936. serializationObject.geometries.vertexData = [];
  96937. serializedGeometries = [];
  96938. var geometries = scene.getGeometries();
  96939. for (index = 0; index < geometries.length; index++) {
  96940. var geometry = geometries[index];
  96941. if (geometry.isReady()) {
  96942. serializeGeometry(geometry, serializationObject.geometries);
  96943. }
  96944. }
  96945. // Meshes
  96946. serializationObject.meshes = [];
  96947. for (index = 0; index < scene.meshes.length; index++) {
  96948. var abstractMesh = scene.meshes[index];
  96949. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  96950. var mesh = abstractMesh;
  96951. if (!mesh.doNotSerialize) {
  96952. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96953. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96954. }
  96955. }
  96956. }
  96957. }
  96958. // Particles Systems
  96959. serializationObject.particleSystems = [];
  96960. for (index = 0; index < scene.particleSystems.length; index++) {
  96961. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  96962. }
  96963. // Action Manager
  96964. if (scene.actionManager) {
  96965. serializationObject.actions = scene.actionManager.serialize("scene");
  96966. }
  96967. // Components
  96968. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  96969. var component = _c[_b];
  96970. component.serialize(serializationObject);
  96971. }
  96972. return serializationObject;
  96973. };
  96974. /**
  96975. * Serialize a mesh into a JSON compatible object
  96976. * @param toSerialize defines the mesh to serialize
  96977. * @param withParents defines if parents must be serialized as well
  96978. * @param withChildren defines if children must be serialized as well
  96979. * @returns a JSON compatible object
  96980. */
  96981. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  96982. if (withParents === void 0) { withParents = false; }
  96983. if (withChildren === void 0) { withChildren = false; }
  96984. var serializationObject = {};
  96985. SceneSerializer.ClearCache();
  96986. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  96987. if (withParents || withChildren) {
  96988. //deliberate for loop! not for each, appended should be processed as well.
  96989. for (var i = 0; i < toSerialize.length; ++i) {
  96990. if (withChildren) {
  96991. toSerialize[i].getDescendants().forEach(function (node) {
  96992. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  96993. toSerialize.push(node);
  96994. }
  96995. });
  96996. }
  96997. //make sure the array doesn't contain the object already
  96998. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  96999. toSerialize.push(toSerialize[i].parent);
  97000. }
  97001. }
  97002. }
  97003. toSerialize.forEach(function (mesh) {
  97004. finalizeSingleMesh(mesh, serializationObject);
  97005. });
  97006. return serializationObject;
  97007. };
  97008. return SceneSerializer;
  97009. }());
  97010. /***/ }),
  97011. /***/ "./Misc/screenshotTools.ts":
  97012. /*!*********************************!*\
  97013. !*** ./Misc/screenshotTools.ts ***!
  97014. \*********************************/
  97015. /*! exports provided: ScreenshotTools */
  97016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97017. "use strict";
  97018. __webpack_require__.r(__webpack_exports__);
  97019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  97020. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97021. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97022. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  97023. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97024. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97025. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97026. // Screenshots
  97027. var screenshotCanvas;
  97028. /**
  97029. * Class containing a set of static utilities functions for screenshots
  97030. */
  97031. var ScreenshotTools = /** @class */ (function () {
  97032. function ScreenshotTools() {
  97033. }
  97034. /**
  97035. * Captures a screenshot of the current rendering
  97036. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97037. * @param engine defines the rendering engine
  97038. * @param camera defines the source camera
  97039. * @param size This parameter can be set to a single number or to an object with the
  97040. * following (optional) properties: precision, width, height. If a single number is passed,
  97041. * it will be used for both width and height. If an object is passed, the screenshot size
  97042. * will be derived from the parameters. The precision property is a multiplier allowing
  97043. * rendering at a higher or lower resolution
  97044. * @param successCallback defines the callback receives a single parameter which contains the
  97045. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97046. * src parameter of an <img> to display it
  97047. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97048. * Check your browser for supported MIME types
  97049. */
  97050. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  97051. if (mimeType === void 0) { mimeType = "image/png"; }
  97052. var width;
  97053. var height;
  97054. // If a precision value is specified
  97055. if (size.precision) {
  97056. width = Math.round(engine.getRenderWidth() * size.precision);
  97057. height = Math.round(width / engine.getAspectRatio(camera));
  97058. }
  97059. else if (size.width && size.height) {
  97060. width = size.width;
  97061. height = size.height;
  97062. }
  97063. //If passing only width, computing height to keep display canvas ratio.
  97064. else if (size.width && !size.height) {
  97065. width = size.width;
  97066. height = Math.round(width / engine.getAspectRatio(camera));
  97067. }
  97068. //If passing only height, computing width to keep display canvas ratio.
  97069. else if (size.height && !size.width) {
  97070. height = size.height;
  97071. width = Math.round(height * engine.getAspectRatio(camera));
  97072. }
  97073. //Assuming here that "size" parameter is a number
  97074. else if (!isNaN(size)) {
  97075. height = size;
  97076. width = size;
  97077. }
  97078. else {
  97079. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97080. return;
  97081. }
  97082. if (!screenshotCanvas) {
  97083. screenshotCanvas = document.createElement('canvas');
  97084. }
  97085. screenshotCanvas.width = width;
  97086. screenshotCanvas.height = height;
  97087. var renderContext = screenshotCanvas.getContext("2d");
  97088. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  97089. var newWidth = width;
  97090. var newHeight = newWidth / ratio;
  97091. if (newHeight > height) {
  97092. newHeight = height;
  97093. newWidth = newHeight * ratio;
  97094. }
  97095. var offsetX = Math.max(0, width - newWidth) / 2;
  97096. var offsetY = Math.max(0, height - newHeight) / 2;
  97097. var renderingCanvas = engine.getRenderingCanvas();
  97098. if (renderContext && renderingCanvas) {
  97099. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  97100. }
  97101. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  97102. };
  97103. /**
  97104. * Generates an image screenshot from the specified camera.
  97105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97106. * @param engine The engine to use for rendering
  97107. * @param camera The camera to use for rendering
  97108. * @param size This parameter can be set to a single number or to an object with the
  97109. * following (optional) properties: precision, width, height. If a single number is passed,
  97110. * it will be used for both width and height. If an object is passed, the screenshot size
  97111. * will be derived from the parameters. The precision property is a multiplier allowing
  97112. * rendering at a higher or lower resolution
  97113. * @param successCallback The callback receives a single parameter which contains the
  97114. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97115. * src parameter of an <img> to display it
  97116. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97117. * Check your browser for supported MIME types
  97118. * @param samples Texture samples (default: 1)
  97119. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97120. * @param fileName A name for for the downloaded file.
  97121. */
  97122. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  97123. if (mimeType === void 0) { mimeType = "image/png"; }
  97124. if (samples === void 0) { samples = 1; }
  97125. if (antialiasing === void 0) { antialiasing = false; }
  97126. var width;
  97127. var height;
  97128. //If a precision value is specified
  97129. if (size.precision) {
  97130. width = Math.round(engine.getRenderWidth() * size.precision);
  97131. height = Math.round(width / engine.getAspectRatio(camera));
  97132. size = { width: width, height: height };
  97133. }
  97134. else if (size.width && size.height) {
  97135. width = size.width;
  97136. height = size.height;
  97137. }
  97138. //If passing only width, computing height to keep display canvas ratio.
  97139. else if (size.width && !size.height) {
  97140. width = size.width;
  97141. height = Math.round(width / engine.getAspectRatio(camera));
  97142. size = { width: width, height: height };
  97143. }
  97144. //If passing only height, computing width to keep display canvas ratio.
  97145. else if (size.height && !size.width) {
  97146. height = size.height;
  97147. width = Math.round(height * engine.getAspectRatio(camera));
  97148. size = { width: width, height: height };
  97149. }
  97150. //Assuming here that "size" parameter is a number
  97151. else if (!isNaN(size)) {
  97152. height = size;
  97153. width = size;
  97154. }
  97155. else {
  97156. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97157. return;
  97158. }
  97159. var scene = camera.getScene();
  97160. var previousCamera = null;
  97161. if (scene.activeCamera !== camera) {
  97162. previousCamera = scene.activeCamera;
  97163. scene.activeCamera = camera;
  97164. }
  97165. var renderCanvas = engine.getRenderingCanvas();
  97166. if (!renderCanvas) {
  97167. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  97168. return;
  97169. }
  97170. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  97171. engine.setSize(width, height);
  97172. scene.render();
  97173. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  97174. 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);
  97175. texture.renderList = null;
  97176. texture.samples = samples;
  97177. if (antialiasing) {
  97178. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  97179. }
  97180. texture.onAfterRenderObservable.add(function () {
  97181. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  97182. });
  97183. scene.incrementRenderId();
  97184. scene.resetCachedMaterial();
  97185. texture.render(true);
  97186. texture.dispose();
  97187. if (previousCamera) {
  97188. scene.activeCamera = previousCamera;
  97189. }
  97190. engine.setSize(originalSize.width, originalSize.height);
  97191. camera.getProjectionMatrix(true); // Force cache refresh;
  97192. };
  97193. return ScreenshotTools;
  97194. }());
  97195. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  97196. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  97197. /***/ }),
  97198. /***/ "./Misc/smartArray.ts":
  97199. /*!****************************!*\
  97200. !*** ./Misc/smartArray.ts ***!
  97201. \****************************/
  97202. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  97203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97204. "use strict";
  97205. __webpack_require__.r(__webpack_exports__);
  97206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  97207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  97208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97209. /**
  97210. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97211. */
  97212. var SmartArray = /** @class */ (function () {
  97213. /**
  97214. * Instantiates a Smart Array.
  97215. * @param capacity defines the default capacity of the array.
  97216. */
  97217. function SmartArray(capacity) {
  97218. /**
  97219. * The active length of the array.
  97220. */
  97221. this.length = 0;
  97222. this.data = new Array(capacity);
  97223. this._id = SmartArray._GlobalId++;
  97224. }
  97225. /**
  97226. * Pushes a value at the end of the active data.
  97227. * @param value defines the object to push in the array.
  97228. */
  97229. SmartArray.prototype.push = function (value) {
  97230. this.data[this.length++] = value;
  97231. if (this.length > this.data.length) {
  97232. this.data.length *= 2;
  97233. }
  97234. };
  97235. /**
  97236. * Iterates over the active data and apply the lambda to them.
  97237. * @param func defines the action to apply on each value.
  97238. */
  97239. SmartArray.prototype.forEach = function (func) {
  97240. for (var index = 0; index < this.length; index++) {
  97241. func(this.data[index]);
  97242. }
  97243. };
  97244. /**
  97245. * Sorts the full sets of data.
  97246. * @param compareFn defines the comparison function to apply.
  97247. */
  97248. SmartArray.prototype.sort = function (compareFn) {
  97249. this.data.sort(compareFn);
  97250. };
  97251. /**
  97252. * Resets the active data to an empty array.
  97253. */
  97254. SmartArray.prototype.reset = function () {
  97255. this.length = 0;
  97256. };
  97257. /**
  97258. * Releases all the data from the array as well as the array.
  97259. */
  97260. SmartArray.prototype.dispose = function () {
  97261. this.reset();
  97262. if (this.data) {
  97263. this.data.length = 0;
  97264. this.data = [];
  97265. }
  97266. };
  97267. /**
  97268. * Concats the active data with a given array.
  97269. * @param array defines the data to concatenate with.
  97270. */
  97271. SmartArray.prototype.concat = function (array) {
  97272. if (array.length === 0) {
  97273. return;
  97274. }
  97275. if (this.length + array.length > this.data.length) {
  97276. this.data.length = (this.length + array.length) * 2;
  97277. }
  97278. for (var index = 0; index < array.length; index++) {
  97279. this.data[this.length++] = (array.data || array)[index];
  97280. }
  97281. };
  97282. /**
  97283. * Returns the position of a value in the active data.
  97284. * @param value defines the value to find the index for
  97285. * @returns the index if found in the active data otherwise -1
  97286. */
  97287. SmartArray.prototype.indexOf = function (value) {
  97288. var position = this.data.indexOf(value);
  97289. if (position >= this.length) {
  97290. return -1;
  97291. }
  97292. return position;
  97293. };
  97294. /**
  97295. * Returns whether an element is part of the active data.
  97296. * @param value defines the value to look for
  97297. * @returns true if found in the active data otherwise false
  97298. */
  97299. SmartArray.prototype.contains = function (value) {
  97300. return this.indexOf(value) !== -1;
  97301. };
  97302. // Statics
  97303. SmartArray._GlobalId = 0;
  97304. return SmartArray;
  97305. }());
  97306. /**
  97307. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97308. * The data in this array can only be present once
  97309. */
  97310. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  97311. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  97312. function SmartArrayNoDuplicate() {
  97313. var _this = _super !== null && _super.apply(this, arguments) || this;
  97314. _this._duplicateId = 0;
  97315. return _this;
  97316. }
  97317. /**
  97318. * Pushes a value at the end of the active data.
  97319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  97320. * @param value defines the object to push in the array.
  97321. */
  97322. SmartArrayNoDuplicate.prototype.push = function (value) {
  97323. _super.prototype.push.call(this, value);
  97324. if (!value.__smartArrayFlags) {
  97325. value.__smartArrayFlags = {};
  97326. }
  97327. value.__smartArrayFlags[this._id] = this._duplicateId;
  97328. };
  97329. /**
  97330. * Pushes a value at the end of the active data.
  97331. * If the data is already present, it won t be added again
  97332. * @param value defines the object to push in the array.
  97333. * @returns true if added false if it was already present
  97334. */
  97335. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  97336. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  97337. return false;
  97338. }
  97339. this.push(value);
  97340. return true;
  97341. };
  97342. /**
  97343. * Resets the active data to an empty array.
  97344. */
  97345. SmartArrayNoDuplicate.prototype.reset = function () {
  97346. _super.prototype.reset.call(this);
  97347. this._duplicateId++;
  97348. };
  97349. /**
  97350. * Concats the active data with a given array.
  97351. * This ensures no dupplicate will be present in the result.
  97352. * @param array defines the data to concatenate with.
  97353. */
  97354. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  97355. if (array.length === 0) {
  97356. return;
  97357. }
  97358. if (this.length + array.length > this.data.length) {
  97359. this.data.length = (this.length + array.length) * 2;
  97360. }
  97361. for (var index = 0; index < array.length; index++) {
  97362. var item = (array.data || array)[index];
  97363. this.pushNoDuplicate(item);
  97364. }
  97365. };
  97366. return SmartArrayNoDuplicate;
  97367. }(SmartArray));
  97368. /***/ }),
  97369. /***/ "./Misc/stringDictionary.ts":
  97370. /*!**********************************!*\
  97371. !*** ./Misc/stringDictionary.ts ***!
  97372. \**********************************/
  97373. /*! exports provided: StringDictionary */
  97374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97375. "use strict";
  97376. __webpack_require__.r(__webpack_exports__);
  97377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  97378. /**
  97379. * This class implement a typical dictionary using a string as key and the generic type T as value.
  97380. * The underlying implementation relies on an associative array to ensure the best performances.
  97381. * The value can be anything including 'null' but except 'undefined'
  97382. */
  97383. var StringDictionary = /** @class */ (function () {
  97384. function StringDictionary() {
  97385. this._count = 0;
  97386. this._data = {};
  97387. }
  97388. /**
  97389. * This will clear this dictionary and copy the content from the 'source' one.
  97390. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  97391. * @param source the dictionary to take the content from and copy to this dictionary
  97392. */
  97393. StringDictionary.prototype.copyFrom = function (source) {
  97394. var _this = this;
  97395. this.clear();
  97396. source.forEach(function (t, v) { return _this.add(t, v); });
  97397. };
  97398. /**
  97399. * Get a value based from its key
  97400. * @param key the given key to get the matching value from
  97401. * @return the value if found, otherwise undefined is returned
  97402. */
  97403. StringDictionary.prototype.get = function (key) {
  97404. var val = this._data[key];
  97405. if (val !== undefined) {
  97406. return val;
  97407. }
  97408. return undefined;
  97409. };
  97410. /**
  97411. * Get a value from its key or add it if it doesn't exist.
  97412. * This method will ensure you that a given key/data will be present in the dictionary.
  97413. * @param key the given key to get the matching value from
  97414. * @param factory the factory that will create the value if the key is not present in the dictionary.
  97415. * The factory will only be invoked if there's no data for the given key.
  97416. * @return the value corresponding to the key.
  97417. */
  97418. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  97419. var val = this.get(key);
  97420. if (val !== undefined) {
  97421. return val;
  97422. }
  97423. val = factory(key);
  97424. if (val) {
  97425. this.add(key, val);
  97426. }
  97427. return val;
  97428. };
  97429. /**
  97430. * Get a value from its key if present in the dictionary otherwise add it
  97431. * @param key the key to get the value from
  97432. * @param val if there's no such key/value pair in the dictionary add it with this value
  97433. * @return the value corresponding to the key
  97434. */
  97435. StringDictionary.prototype.getOrAdd = function (key, val) {
  97436. var curVal = this.get(key);
  97437. if (curVal !== undefined) {
  97438. return curVal;
  97439. }
  97440. this.add(key, val);
  97441. return val;
  97442. };
  97443. /**
  97444. * Check if there's a given key in the dictionary
  97445. * @param key the key to check for
  97446. * @return true if the key is present, false otherwise
  97447. */
  97448. StringDictionary.prototype.contains = function (key) {
  97449. return this._data[key] !== undefined;
  97450. };
  97451. /**
  97452. * Add a new key and its corresponding value
  97453. * @param key the key to add
  97454. * @param value the value corresponding to the key
  97455. * @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
  97456. */
  97457. StringDictionary.prototype.add = function (key, value) {
  97458. if (this._data[key] !== undefined) {
  97459. return false;
  97460. }
  97461. this._data[key] = value;
  97462. ++this._count;
  97463. return true;
  97464. };
  97465. /**
  97466. * Update a specific value associated to a key
  97467. * @param key defines the key to use
  97468. * @param value defines the value to store
  97469. * @returns true if the value was updated (or false if the key was not found)
  97470. */
  97471. StringDictionary.prototype.set = function (key, value) {
  97472. if (this._data[key] === undefined) {
  97473. return false;
  97474. }
  97475. this._data[key] = value;
  97476. return true;
  97477. };
  97478. /**
  97479. * Get the element of the given key and remove it from the dictionary
  97480. * @param key defines the key to search
  97481. * @returns the value associated with the key or null if not found
  97482. */
  97483. StringDictionary.prototype.getAndRemove = function (key) {
  97484. var val = this.get(key);
  97485. if (val !== undefined) {
  97486. delete this._data[key];
  97487. --this._count;
  97488. return val;
  97489. }
  97490. return null;
  97491. };
  97492. /**
  97493. * Remove a key/value from the dictionary.
  97494. * @param key the key to remove
  97495. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  97496. */
  97497. StringDictionary.prototype.remove = function (key) {
  97498. if (this.contains(key)) {
  97499. delete this._data[key];
  97500. --this._count;
  97501. return true;
  97502. }
  97503. return false;
  97504. };
  97505. /**
  97506. * Clear the whole content of the dictionary
  97507. */
  97508. StringDictionary.prototype.clear = function () {
  97509. this._data = {};
  97510. this._count = 0;
  97511. };
  97512. Object.defineProperty(StringDictionary.prototype, "count", {
  97513. /**
  97514. * Gets the current count
  97515. */
  97516. get: function () {
  97517. return this._count;
  97518. },
  97519. enumerable: true,
  97520. configurable: true
  97521. });
  97522. /**
  97523. * Execute a callback on each key/val of the dictionary.
  97524. * Note that you can remove any element in this dictionary in the callback implementation
  97525. * @param callback the callback to execute on a given key/value pair
  97526. */
  97527. StringDictionary.prototype.forEach = function (callback) {
  97528. for (var cur in this._data) {
  97529. var val = this._data[cur];
  97530. callback(cur, val);
  97531. }
  97532. };
  97533. /**
  97534. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  97535. * If the callback returns null or undefined the method will iterate to the next key/value pair
  97536. * Note that you can remove any element in this dictionary in the callback implementation
  97537. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  97538. * @returns the first item
  97539. */
  97540. StringDictionary.prototype.first = function (callback) {
  97541. for (var cur in this._data) {
  97542. var val = this._data[cur];
  97543. var res = callback(cur, val);
  97544. if (res) {
  97545. return res;
  97546. }
  97547. }
  97548. return null;
  97549. };
  97550. return StringDictionary;
  97551. }());
  97552. /***/ }),
  97553. /***/ "./Misc/tags.ts":
  97554. /*!**********************!*\
  97555. !*** ./Misc/tags.ts ***!
  97556. \**********************/
  97557. /*! exports provided: Tags */
  97558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97559. "use strict";
  97560. __webpack_require__.r(__webpack_exports__);
  97561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  97562. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97563. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97564. /**
  97565. * Class used to store custom tags
  97566. */
  97567. var Tags = /** @class */ (function () {
  97568. function Tags() {
  97569. }
  97570. /**
  97571. * Adds support for tags on the given object
  97572. * @param obj defines the object to use
  97573. */
  97574. Tags.EnableFor = function (obj) {
  97575. obj._tags = obj._tags || {};
  97576. obj.hasTags = function () {
  97577. return Tags.HasTags(obj);
  97578. };
  97579. obj.addTags = function (tagsString) {
  97580. return Tags.AddTagsTo(obj, tagsString);
  97581. };
  97582. obj.removeTags = function (tagsString) {
  97583. return Tags.RemoveTagsFrom(obj, tagsString);
  97584. };
  97585. obj.matchesTagsQuery = function (tagsQuery) {
  97586. return Tags.MatchesQuery(obj, tagsQuery);
  97587. };
  97588. };
  97589. /**
  97590. * Removes tags support
  97591. * @param obj defines the object to use
  97592. */
  97593. Tags.DisableFor = function (obj) {
  97594. delete obj._tags;
  97595. delete obj.hasTags;
  97596. delete obj.addTags;
  97597. delete obj.removeTags;
  97598. delete obj.matchesTagsQuery;
  97599. };
  97600. /**
  97601. * Gets a boolean indicating if the given object has tags
  97602. * @param obj defines the object to use
  97603. * @returns a boolean
  97604. */
  97605. Tags.HasTags = function (obj) {
  97606. if (!obj._tags) {
  97607. return false;
  97608. }
  97609. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  97610. };
  97611. /**
  97612. * Gets the tags available on a given object
  97613. * @param obj defines the object to use
  97614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  97615. * @returns the tags
  97616. */
  97617. Tags.GetTags = function (obj, asString) {
  97618. if (asString === void 0) { asString = true; }
  97619. if (!obj._tags) {
  97620. return null;
  97621. }
  97622. if (asString) {
  97623. var tagsArray = [];
  97624. for (var tag in obj._tags) {
  97625. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  97626. tagsArray.push(tag);
  97627. }
  97628. }
  97629. return tagsArray.join(" ");
  97630. }
  97631. else {
  97632. return obj._tags;
  97633. }
  97634. };
  97635. /**
  97636. * Adds tags to an object
  97637. * @param obj defines the object to use
  97638. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  97639. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  97640. */
  97641. Tags.AddTagsTo = function (obj, tagsString) {
  97642. if (!tagsString) {
  97643. return;
  97644. }
  97645. if (typeof tagsString !== "string") {
  97646. return;
  97647. }
  97648. var tags = tagsString.split(" ");
  97649. tags.forEach(function (tag, index, array) {
  97650. Tags._AddTagTo(obj, tag);
  97651. });
  97652. };
  97653. /**
  97654. * @hidden
  97655. */
  97656. Tags._AddTagTo = function (obj, tag) {
  97657. tag = tag.trim();
  97658. if (tag === "" || tag === "true" || tag === "false") {
  97659. return;
  97660. }
  97661. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  97662. return;
  97663. }
  97664. Tags.EnableFor(obj);
  97665. obj._tags[tag] = true;
  97666. };
  97667. /**
  97668. * Removes specific tags from a specific object
  97669. * @param obj defines the object to use
  97670. * @param tagsString defines the tags to remove
  97671. */
  97672. Tags.RemoveTagsFrom = function (obj, tagsString) {
  97673. if (!Tags.HasTags(obj)) {
  97674. return;
  97675. }
  97676. var tags = tagsString.split(" ");
  97677. for (var t in tags) {
  97678. Tags._RemoveTagFrom(obj, tags[t]);
  97679. }
  97680. };
  97681. /**
  97682. * @hidden
  97683. */
  97684. Tags._RemoveTagFrom = function (obj, tag) {
  97685. delete obj._tags[tag];
  97686. };
  97687. /**
  97688. * Defines if tags hosted on an object match a given query
  97689. * @param obj defines the object to use
  97690. * @param tagsQuery defines the tag query
  97691. * @returns a boolean
  97692. */
  97693. Tags.MatchesQuery = function (obj, tagsQuery) {
  97694. if (tagsQuery === undefined) {
  97695. return true;
  97696. }
  97697. if (tagsQuery === "") {
  97698. return Tags.HasTags(obj);
  97699. }
  97700. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  97701. };
  97702. return Tags;
  97703. }());
  97704. /***/ }),
  97705. /***/ "./Misc/textureTools.ts":
  97706. /*!******************************!*\
  97707. !*** ./Misc/textureTools.ts ***!
  97708. \******************************/
  97709. /*! exports provided: TextureTools */
  97710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97711. "use strict";
  97712. __webpack_require__.r(__webpack_exports__);
  97713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  97714. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97715. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97716. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  97717. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97718. /**
  97719. * Class used to host texture specific utilities
  97720. */
  97721. var TextureTools = /** @class */ (function () {
  97722. function TextureTools() {
  97723. }
  97724. /**
  97725. * Uses the GPU to create a copy texture rescaled at a given size
  97726. * @param texture Texture to copy from
  97727. * @param width defines the desired width
  97728. * @param height defines the desired height
  97729. * @param useBilinearMode defines if bilinear mode has to be used
  97730. * @return the generated texture
  97731. */
  97732. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  97733. if (useBilinearMode === void 0) { useBilinearMode = true; }
  97734. var scene = texture.getScene();
  97735. var engine = scene.getEngine();
  97736. 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);
  97737. rtt.wrapU = texture.wrapU;
  97738. rtt.wrapV = texture.wrapV;
  97739. rtt.uOffset = texture.uOffset;
  97740. rtt.vOffset = texture.vOffset;
  97741. rtt.uScale = texture.uScale;
  97742. rtt.vScale = texture.vScale;
  97743. rtt.uAng = texture.uAng;
  97744. rtt.vAng = texture.vAng;
  97745. rtt.wAng = texture.wAng;
  97746. rtt.coordinatesIndex = texture.coordinatesIndex;
  97747. rtt.level = texture.level;
  97748. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  97749. rtt._texture.isReady = false;
  97750. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97751. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97752. 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);
  97753. passPostProcess.getEffect().executeWhenCompiled(function () {
  97754. passPostProcess.onApply = function (effect) {
  97755. effect.setTexture("textureSampler", texture);
  97756. };
  97757. var internalTexture = rtt.getInternalTexture();
  97758. if (internalTexture) {
  97759. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  97760. engine.unBindFramebuffer(internalTexture);
  97761. rtt.disposeFramebufferObjects();
  97762. passPostProcess.dispose();
  97763. internalTexture.isReady = true;
  97764. }
  97765. });
  97766. return rtt;
  97767. };
  97768. /**
  97769. * Gets an environment BRDF texture for a given scene
  97770. * @param scene defines the hosting scene
  97771. * @returns the environment BRDF texture
  97772. */
  97773. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97774. if (!scene._environmentBRDFTexture) {
  97775. 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);
  97776. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97777. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97778. scene._environmentBRDFTexture = texture;
  97779. }
  97780. return scene._environmentBRDFTexture;
  97781. };
  97782. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=";
  97783. return TextureTools;
  97784. }());
  97785. /***/ }),
  97786. /***/ "./Misc/tga.ts":
  97787. /*!*********************!*\
  97788. !*** ./Misc/tga.ts ***!
  97789. \*********************/
  97790. /*! exports provided: TGATools */
  97791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97792. "use strict";
  97793. __webpack_require__.r(__webpack_exports__);
  97794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97795. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97796. /**
  97797. * Based on jsTGALoader - Javascript loader for TGA file
  97798. * By Vincent Thibault
  97799. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97800. */
  97801. var TGATools = /** @class */ (function () {
  97802. function TGATools() {
  97803. }
  97804. /**
  97805. * Gets the header of a TGA file
  97806. * @param data defines the TGA data
  97807. * @returns the header
  97808. */
  97809. TGATools.GetTGAHeader = function (data) {
  97810. var offset = 0;
  97811. var header = {
  97812. id_length: data[offset++],
  97813. colormap_type: data[offset++],
  97814. image_type: data[offset++],
  97815. colormap_index: data[offset++] | data[offset++] << 8,
  97816. colormap_length: data[offset++] | data[offset++] << 8,
  97817. colormap_size: data[offset++],
  97818. origin: [
  97819. data[offset++] | data[offset++] << 8,
  97820. data[offset++] | data[offset++] << 8
  97821. ],
  97822. width: data[offset++] | data[offset++] << 8,
  97823. height: data[offset++] | data[offset++] << 8,
  97824. pixel_size: data[offset++],
  97825. flags: data[offset++]
  97826. };
  97827. return header;
  97828. };
  97829. /**
  97830. * Uploads TGA content to a Babylon Texture
  97831. * @hidden
  97832. */
  97833. TGATools.UploadContent = function (texture, data) {
  97834. // Not enough data to contain header ?
  97835. if (data.length < 19) {
  97836. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  97837. return;
  97838. }
  97839. // Read Header
  97840. var offset = 18;
  97841. var header = TGATools.GetTGAHeader(data);
  97842. // Assume it's a valid Targa file.
  97843. if (header.id_length + offset > data.length) {
  97844. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  97845. return;
  97846. }
  97847. // Skip not needed data
  97848. offset += header.id_length;
  97849. var use_rle = false;
  97850. var use_pal = false;
  97851. var use_grey = false;
  97852. // Get some informations.
  97853. switch (header.image_type) {
  97854. case TGATools._TYPE_RLE_INDEXED:
  97855. use_rle = true;
  97856. case TGATools._TYPE_INDEXED:
  97857. use_pal = true;
  97858. break;
  97859. case TGATools._TYPE_RLE_RGB:
  97860. use_rle = true;
  97861. case TGATools._TYPE_RGB:
  97862. // use_rgb = true;
  97863. break;
  97864. case TGATools._TYPE_RLE_GREY:
  97865. use_rle = true;
  97866. case TGATools._TYPE_GREY:
  97867. use_grey = true;
  97868. break;
  97869. }
  97870. var pixel_data;
  97871. // var numAlphaBits = header.flags & 0xf;
  97872. var pixel_size = header.pixel_size >> 3;
  97873. var pixel_total = header.width * header.height * pixel_size;
  97874. // Read palettes
  97875. var palettes;
  97876. if (use_pal) {
  97877. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  97878. }
  97879. // Read LRE
  97880. if (use_rle) {
  97881. pixel_data = new Uint8Array(pixel_total);
  97882. var c, count, i;
  97883. var localOffset = 0;
  97884. var pixels = new Uint8Array(pixel_size);
  97885. while (offset < pixel_total && localOffset < pixel_total) {
  97886. c = data[offset++];
  97887. count = (c & 0x7f) + 1;
  97888. // RLE pixels
  97889. if (c & 0x80) {
  97890. // Bind pixel tmp array
  97891. for (i = 0; i < pixel_size; ++i) {
  97892. pixels[i] = data[offset++];
  97893. }
  97894. // Copy pixel array
  97895. for (i = 0; i < count; ++i) {
  97896. pixel_data.set(pixels, localOffset + i * pixel_size);
  97897. }
  97898. localOffset += pixel_size * count;
  97899. }
  97900. // Raw pixels
  97901. else {
  97902. count *= pixel_size;
  97903. for (i = 0; i < count; ++i) {
  97904. pixel_data[localOffset + i] = data[offset++];
  97905. }
  97906. localOffset += count;
  97907. }
  97908. }
  97909. }
  97910. // RAW Pixels
  97911. else {
  97912. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  97913. }
  97914. // Load to texture
  97915. var x_start, y_start, x_step, y_step, y_end, x_end;
  97916. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  97917. default:
  97918. case TGATools._ORIGIN_UL:
  97919. x_start = 0;
  97920. x_step = 1;
  97921. x_end = header.width;
  97922. y_start = 0;
  97923. y_step = 1;
  97924. y_end = header.height;
  97925. break;
  97926. case TGATools._ORIGIN_BL:
  97927. x_start = 0;
  97928. x_step = 1;
  97929. x_end = header.width;
  97930. y_start = header.height - 1;
  97931. y_step = -1;
  97932. y_end = -1;
  97933. break;
  97934. case TGATools._ORIGIN_UR:
  97935. x_start = header.width - 1;
  97936. x_step = -1;
  97937. x_end = -1;
  97938. y_start = 0;
  97939. y_step = 1;
  97940. y_end = header.height;
  97941. break;
  97942. case TGATools._ORIGIN_BR:
  97943. x_start = header.width - 1;
  97944. x_step = -1;
  97945. x_end = -1;
  97946. y_start = header.height - 1;
  97947. y_step = -1;
  97948. y_end = -1;
  97949. break;
  97950. }
  97951. // Load the specify method
  97952. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  97953. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  97954. var engine = texture.getEngine();
  97955. engine._uploadDataToTextureDirectly(texture, imageData);
  97956. };
  97957. /** @hidden */
  97958. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97959. var image = pixel_data, colormap = palettes;
  97960. var width = header.width, height = header.height;
  97961. var color, i = 0, x, y;
  97962. var imageData = new Uint8Array(width * height * 4);
  97963. for (y = y_start; y !== y_end; y += y_step) {
  97964. for (x = x_start; x !== x_end; x += x_step, i++) {
  97965. color = image[i];
  97966. imageData[(x + width * y) * 4 + 3] = 255;
  97967. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  97968. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  97969. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  97970. }
  97971. }
  97972. return imageData;
  97973. };
  97974. /** @hidden */
  97975. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97976. var image = pixel_data;
  97977. var width = header.width, height = header.height;
  97978. var color, i = 0, x, y;
  97979. var imageData = new Uint8Array(width * height * 4);
  97980. for (y = y_start; y !== y_end; y += y_step) {
  97981. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97982. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  97983. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  97984. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  97985. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  97986. imageData[(x + width * y) * 4 + 0] = r;
  97987. imageData[(x + width * y) * 4 + 1] = g;
  97988. imageData[(x + width * y) * 4 + 2] = b;
  97989. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  97990. }
  97991. }
  97992. return imageData;
  97993. };
  97994. /** @hidden */
  97995. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97996. var image = pixel_data;
  97997. var width = header.width, height = header.height;
  97998. var i = 0, x, y;
  97999. var imageData = new Uint8Array(width * height * 4);
  98000. for (y = y_start; y !== y_end; y += y_step) {
  98001. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  98002. imageData[(x + width * y) * 4 + 3] = 255;
  98003. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98004. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98005. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98006. }
  98007. }
  98008. return imageData;
  98009. };
  98010. /** @hidden */
  98011. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98012. var image = pixel_data;
  98013. var width = header.width, height = header.height;
  98014. var i = 0, x, y;
  98015. var imageData = new Uint8Array(width * height * 4);
  98016. for (y = y_start; y !== y_end; y += y_step) {
  98017. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  98018. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98019. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98020. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98021. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  98022. }
  98023. }
  98024. return imageData;
  98025. };
  98026. /** @hidden */
  98027. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98028. var image = pixel_data;
  98029. var width = header.width, height = header.height;
  98030. var color, i = 0, x, y;
  98031. var imageData = new Uint8Array(width * height * 4);
  98032. for (y = y_start; y !== y_end; y += y_step) {
  98033. for (x = x_start; x !== x_end; x += x_step, i++) {
  98034. color = image[i];
  98035. imageData[(x + width * y) * 4 + 0] = color;
  98036. imageData[(x + width * y) * 4 + 1] = color;
  98037. imageData[(x + width * y) * 4 + 2] = color;
  98038. imageData[(x + width * y) * 4 + 3] = 255;
  98039. }
  98040. }
  98041. return imageData;
  98042. };
  98043. /** @hidden */
  98044. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98045. var image = pixel_data;
  98046. var width = header.width, height = header.height;
  98047. var i = 0, x, y;
  98048. var imageData = new Uint8Array(width * height * 4);
  98049. for (y = y_start; y !== y_end; y += y_step) {
  98050. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98051. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  98052. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  98053. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98054. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  98055. }
  98056. }
  98057. return imageData;
  98058. };
  98059. //private static _TYPE_NO_DATA = 0;
  98060. TGATools._TYPE_INDEXED = 1;
  98061. TGATools._TYPE_RGB = 2;
  98062. TGATools._TYPE_GREY = 3;
  98063. TGATools._TYPE_RLE_INDEXED = 9;
  98064. TGATools._TYPE_RLE_RGB = 10;
  98065. TGATools._TYPE_RLE_GREY = 11;
  98066. TGATools._ORIGIN_MASK = 0x30;
  98067. TGATools._ORIGIN_SHIFT = 0x04;
  98068. TGATools._ORIGIN_BL = 0x00;
  98069. TGATools._ORIGIN_BR = 0x01;
  98070. TGATools._ORIGIN_UL = 0x02;
  98071. TGATools._ORIGIN_UR = 0x03;
  98072. return TGATools;
  98073. }());
  98074. /***/ }),
  98075. /***/ "./Misc/tools.ts":
  98076. /*!***********************!*\
  98077. !*** ./Misc/tools.ts ***!
  98078. \***********************/
  98079. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  98080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98081. "use strict";
  98082. __webpack_require__.r(__webpack_exports__);
  98083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  98084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  98085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  98086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  98087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  98088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  98089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  98090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  98091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  98092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98093. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98094. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98095. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98096. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98097. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98098. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98099. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98100. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98101. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98102. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98103. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98104. /** Class used to store color4 gradient */
  98105. var ColorGradient = /** @class */ (function () {
  98106. function ColorGradient() {
  98107. }
  98108. /**
  98109. * Will get a color picked randomly between color1 and color2.
  98110. * If color2 is undefined then color1 will be used
  98111. * @param result defines the target Color4 to store the result in
  98112. */
  98113. ColorGradient.prototype.getColorToRef = function (result) {
  98114. if (!this.color2) {
  98115. result.copyFrom(this.color1);
  98116. return;
  98117. }
  98118. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  98119. };
  98120. return ColorGradient;
  98121. }());
  98122. /** Class used to store color 3 gradient */
  98123. var Color3Gradient = /** @class */ (function () {
  98124. function Color3Gradient() {
  98125. }
  98126. return Color3Gradient;
  98127. }());
  98128. /** Class used to store factor gradient */
  98129. var FactorGradient = /** @class */ (function () {
  98130. function FactorGradient() {
  98131. }
  98132. /**
  98133. * Will get a number picked randomly between factor1 and factor2.
  98134. * If factor2 is undefined then factor1 will be used
  98135. * @returns the picked number
  98136. */
  98137. FactorGradient.prototype.getFactor = function () {
  98138. if (this.factor2 === undefined) {
  98139. return this.factor1;
  98140. }
  98141. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  98142. };
  98143. return FactorGradient;
  98144. }());
  98145. /**
  98146. * @ignore
  98147. * Application error to support additional information when loading a file
  98148. */
  98149. var LoadFileError = /** @class */ (function (_super) {
  98150. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  98151. /**
  98152. * Creates a new LoadFileError
  98153. * @param message defines the message of the error
  98154. * @param request defines the optional XHR request
  98155. */
  98156. function LoadFileError(message,
  98157. /** defines the optional XHR request */
  98158. request) {
  98159. var _this = _super.call(this, message) || this;
  98160. _this.request = request;
  98161. _this.name = "LoadFileError";
  98162. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  98163. return _this;
  98164. }
  98165. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  98166. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  98167. // Polyfill for Object.setPrototypeOf if necessary.
  98168. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  98169. return LoadFileError;
  98170. }(Error));
  98171. /**
  98172. * Class used to define a retry strategy when error happens while loading assets
  98173. */
  98174. var RetryStrategy = /** @class */ (function () {
  98175. function RetryStrategy() {
  98176. }
  98177. /**
  98178. * Function used to defines an exponential back off strategy
  98179. * @param maxRetries defines the maximum number of retries (3 by default)
  98180. * @param baseInterval defines the interval between retries
  98181. * @returns the strategy function to use
  98182. */
  98183. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  98184. if (maxRetries === void 0) { maxRetries = 3; }
  98185. if (baseInterval === void 0) { baseInterval = 500; }
  98186. return function (url, request, retryIndex) {
  98187. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  98188. return -1;
  98189. }
  98190. return Math.pow(2, retryIndex) * baseInterval;
  98191. };
  98192. };
  98193. return RetryStrategy;
  98194. }());
  98195. // Screenshots
  98196. var screenshotCanvas;
  98197. /**
  98198. * Class containing a set of static utilities functions
  98199. */
  98200. var Tools = /** @class */ (function () {
  98201. function Tools() {
  98202. }
  98203. /**
  98204. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98205. * @param u defines the coordinate on X axis
  98206. * @param v defines the coordinate on Y axis
  98207. * @param width defines the width of the source data
  98208. * @param height defines the height of the source data
  98209. * @param pixels defines the source byte array
  98210. * @param color defines the output color
  98211. */
  98212. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  98213. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  98214. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  98215. var position = (wrappedU + wrappedV * width) * 4;
  98216. color.r = pixels[position] / 255;
  98217. color.g = pixels[position + 1] / 255;
  98218. color.b = pixels[position + 2] / 255;
  98219. color.a = pixels[position + 3] / 255;
  98220. };
  98221. /**
  98222. * Interpolates between a and b via alpha
  98223. * @param a The lower value (returned when alpha = 0)
  98224. * @param b The upper value (returned when alpha = 1)
  98225. * @param alpha The interpolation-factor
  98226. * @return The mixed value
  98227. */
  98228. Tools.Mix = function (a, b, alpha) {
  98229. return a * (1 - alpha) + b * alpha;
  98230. };
  98231. /**
  98232. * Tries to instantiate a new object from a given class name
  98233. * @param className defines the class name to instantiate
  98234. * @returns the new object or null if the system was not able to do the instantiation
  98235. */
  98236. Tools.Instantiate = function (className) {
  98237. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  98238. return Tools.RegisteredExternalClasses[className];
  98239. }
  98240. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  98241. if (internalClass) {
  98242. return internalClass;
  98243. }
  98244. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  98245. var arr = className.split(".");
  98246. var fn = (window || this);
  98247. for (var i = 0, len = arr.length; i < len; i++) {
  98248. fn = fn[arr[i]];
  98249. }
  98250. if (typeof fn !== "function") {
  98251. return null;
  98252. }
  98253. return fn;
  98254. };
  98255. /**
  98256. * Provides a slice function that will work even on IE
  98257. * @param data defines the array to slice
  98258. * @param start defines the start of the data (optional)
  98259. * @param end defines the end of the data (optional)
  98260. * @returns the new sliced array
  98261. */
  98262. Tools.Slice = function (data, start, end) {
  98263. if (data.slice) {
  98264. return data.slice(start, end);
  98265. }
  98266. return Array.prototype.slice.call(data, start, end);
  98267. };
  98268. /**
  98269. * Polyfill for setImmediate
  98270. * @param action defines the action to execute after the current execution block
  98271. */
  98272. Tools.SetImmediate = function (action) {
  98273. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  98274. window.setImmediate(action);
  98275. }
  98276. else {
  98277. setTimeout(action, 1);
  98278. }
  98279. };
  98280. /**
  98281. * Function indicating if a number is an exponent of 2
  98282. * @param value defines the value to test
  98283. * @returns true if the value is an exponent of 2
  98284. */
  98285. Tools.IsExponentOfTwo = function (value) {
  98286. var count = 1;
  98287. do {
  98288. count *= 2;
  98289. } while (count < value);
  98290. return count === value;
  98291. };
  98292. /**
  98293. * Returns the nearest 32-bit single precision float representation of a Number
  98294. * @param value A Number. If the parameter is of a different type, it will get converted
  98295. * to a number or to NaN if it cannot be converted
  98296. * @returns number
  98297. */
  98298. Tools.FloatRound = function (value) {
  98299. if (Math.fround) {
  98300. return Math.fround(value);
  98301. }
  98302. return (Tools._tmpFloatArray[0] = value);
  98303. };
  98304. /**
  98305. * Find the next highest power of two.
  98306. * @param x Number to start search from.
  98307. * @return Next highest power of two.
  98308. */
  98309. Tools.CeilingPOT = function (x) {
  98310. x--;
  98311. x |= x >> 1;
  98312. x |= x >> 2;
  98313. x |= x >> 4;
  98314. x |= x >> 8;
  98315. x |= x >> 16;
  98316. x++;
  98317. return x;
  98318. };
  98319. /**
  98320. * Find the next lowest power of two.
  98321. * @param x Number to start search from.
  98322. * @return Next lowest power of two.
  98323. */
  98324. Tools.FloorPOT = function (x) {
  98325. x = x | (x >> 1);
  98326. x = x | (x >> 2);
  98327. x = x | (x >> 4);
  98328. x = x | (x >> 8);
  98329. x = x | (x >> 16);
  98330. return x - (x >> 1);
  98331. };
  98332. /**
  98333. * Find the nearest power of two.
  98334. * @param x Number to start search from.
  98335. * @return Next nearest power of two.
  98336. */
  98337. Tools.NearestPOT = function (x) {
  98338. var c = Tools.CeilingPOT(x);
  98339. var f = Tools.FloorPOT(x);
  98340. return (c - x) > (x - f) ? f : c;
  98341. };
  98342. /**
  98343. * Get the closest exponent of two
  98344. * @param value defines the value to approximate
  98345. * @param max defines the maximum value to return
  98346. * @param mode defines how to define the closest value
  98347. * @returns closest exponent of two of the given value
  98348. */
  98349. Tools.GetExponentOfTwo = function (value, max, mode) {
  98350. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  98351. var pot;
  98352. switch (mode) {
  98353. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  98354. pot = Tools.FloorPOT(value);
  98355. break;
  98356. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  98357. pot = Tools.NearestPOT(value);
  98358. break;
  98359. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  98360. default:
  98361. pot = Tools.CeilingPOT(value);
  98362. break;
  98363. }
  98364. return Math.min(pot, max);
  98365. };
  98366. /**
  98367. * Extracts the filename from a path
  98368. * @param path defines the path to use
  98369. * @returns the filename
  98370. */
  98371. Tools.GetFilename = function (path) {
  98372. var index = path.lastIndexOf("/");
  98373. if (index < 0) {
  98374. return path;
  98375. }
  98376. return path.substring(index + 1);
  98377. };
  98378. /**
  98379. * Extracts the "folder" part of a path (everything before the filename).
  98380. * @param uri The URI to extract the info from
  98381. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98382. * @returns The "folder" part of the path
  98383. */
  98384. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  98385. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  98386. var index = uri.lastIndexOf("/");
  98387. if (index < 0) {
  98388. if (returnUnchangedIfNoSlash) {
  98389. return uri;
  98390. }
  98391. return "";
  98392. }
  98393. return uri.substring(0, index + 1);
  98394. };
  98395. /**
  98396. * Convert an angle in radians to degrees
  98397. * @param angle defines the angle to convert
  98398. * @returns the angle in degrees
  98399. */
  98400. Tools.ToDegrees = function (angle) {
  98401. return angle * 180 / Math.PI;
  98402. };
  98403. /**
  98404. * Convert an angle in degrees to radians
  98405. * @param angle defines the angle to convert
  98406. * @returns the angle in radians
  98407. */
  98408. Tools.ToRadians = function (angle) {
  98409. return angle * Math.PI / 180;
  98410. };
  98411. /**
  98412. * Encode a buffer to a base64 string
  98413. * @param buffer defines the buffer to encode
  98414. * @returns the encoded string
  98415. */
  98416. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  98417. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  98418. var output = "";
  98419. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  98420. var i = 0;
  98421. var bytes = new Uint8Array(buffer);
  98422. while (i < bytes.length) {
  98423. chr1 = bytes[i++];
  98424. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  98425. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  98426. enc1 = chr1 >> 2;
  98427. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  98428. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  98429. enc4 = chr3 & 63;
  98430. if (isNaN(chr2)) {
  98431. enc3 = enc4 = 64;
  98432. }
  98433. else if (isNaN(chr3)) {
  98434. enc4 = 64;
  98435. }
  98436. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  98437. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  98438. }
  98439. return "data:image/png;base64," + output;
  98440. };
  98441. /**
  98442. * Extracts minimum and maximum values from a list of indexed positions
  98443. * @param positions defines the positions to use
  98444. * @param indices defines the indices to the positions
  98445. * @param indexStart defines the start index
  98446. * @param indexCount defines the end index
  98447. * @param bias defines bias value to add to the result
  98448. * @return minimum and maximum values
  98449. */
  98450. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  98451. if (bias === void 0) { bias = null; }
  98452. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98453. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98454. for (var index = indexStart; index < indexStart + indexCount; index++) {
  98455. var offset = indices[index] * 3;
  98456. var x = positions[offset];
  98457. var y = positions[offset + 1];
  98458. var z = positions[offset + 2];
  98459. minimum.minimizeInPlaceFromFloats(x, y, z);
  98460. maximum.maximizeInPlaceFromFloats(x, y, z);
  98461. }
  98462. if (bias) {
  98463. minimum.x -= minimum.x * bias.x + bias.y;
  98464. minimum.y -= minimum.y * bias.x + bias.y;
  98465. minimum.z -= minimum.z * bias.x + bias.y;
  98466. maximum.x += maximum.x * bias.x + bias.y;
  98467. maximum.y += maximum.y * bias.x + bias.y;
  98468. maximum.z += maximum.z * bias.x + bias.y;
  98469. }
  98470. return {
  98471. minimum: minimum,
  98472. maximum: maximum
  98473. };
  98474. };
  98475. /**
  98476. * Extracts minimum and maximum values from a list of positions
  98477. * @param positions defines the positions to use
  98478. * @param start defines the start index in the positions array
  98479. * @param count defines the number of positions to handle
  98480. * @param bias defines bias value to add to the result
  98481. * @param stride defines the stride size to use (distance between two positions in the positions array)
  98482. * @return minimum and maximum values
  98483. */
  98484. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  98485. if (bias === void 0) { bias = null; }
  98486. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98487. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98488. if (!stride) {
  98489. stride = 3;
  98490. }
  98491. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  98492. var x = positions[offset];
  98493. var y = positions[offset + 1];
  98494. var z = positions[offset + 2];
  98495. minimum.minimizeInPlaceFromFloats(x, y, z);
  98496. maximum.maximizeInPlaceFromFloats(x, y, z);
  98497. }
  98498. if (bias) {
  98499. minimum.x -= minimum.x * bias.x + bias.y;
  98500. minimum.y -= minimum.y * bias.x + bias.y;
  98501. minimum.z -= minimum.z * bias.x + bias.y;
  98502. maximum.x += maximum.x * bias.x + bias.y;
  98503. maximum.y += maximum.y * bias.x + bias.y;
  98504. maximum.z += maximum.z * bias.x + bias.y;
  98505. }
  98506. return {
  98507. minimum: minimum,
  98508. maximum: maximum
  98509. };
  98510. };
  98511. /**
  98512. * Returns an array if obj is not an array
  98513. * @param obj defines the object to evaluate as an array
  98514. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98515. * @returns either obj directly if obj is an array or a new array containing obj
  98516. */
  98517. Tools.MakeArray = function (obj, allowsNullUndefined) {
  98518. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  98519. return null;
  98520. }
  98521. return Array.isArray(obj) ? obj : [obj];
  98522. };
  98523. /**
  98524. * Gets the pointer prefix to use
  98525. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98526. */
  98527. Tools.GetPointerPrefix = function () {
  98528. var eventPrefix = "pointer";
  98529. // Check if pointer events are supported
  98530. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  98531. eventPrefix = "mouse";
  98532. }
  98533. return eventPrefix;
  98534. };
  98535. /**
  98536. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98537. * @param func - the function to be called
  98538. * @param requester - the object that will request the next frame. Falls back to window.
  98539. * @returns frame number
  98540. */
  98541. Tools.QueueNewFrame = function (func, requester) {
  98542. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98543. return setTimeout(func, 16);
  98544. }
  98545. if (!requester) {
  98546. requester = window;
  98547. }
  98548. if (requester.requestAnimationFrame) {
  98549. return requester.requestAnimationFrame(func);
  98550. }
  98551. else if (requester.msRequestAnimationFrame) {
  98552. return requester.msRequestAnimationFrame(func);
  98553. }
  98554. else if (requester.webkitRequestAnimationFrame) {
  98555. return requester.webkitRequestAnimationFrame(func);
  98556. }
  98557. else if (requester.mozRequestAnimationFrame) {
  98558. return requester.mozRequestAnimationFrame(func);
  98559. }
  98560. else if (requester.oRequestAnimationFrame) {
  98561. return requester.oRequestAnimationFrame(func);
  98562. }
  98563. else {
  98564. return window.setTimeout(func, 16);
  98565. }
  98566. };
  98567. /**
  98568. * Ask the browser to promote the current element to fullscreen rendering mode
  98569. * @param element defines the DOM element to promote
  98570. */
  98571. Tools.RequestFullscreen = function (element) {
  98572. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  98573. if (!requestFunction) {
  98574. return;
  98575. }
  98576. requestFunction.call(element);
  98577. };
  98578. /**
  98579. * Asks the browser to exit fullscreen mode
  98580. */
  98581. Tools.ExitFullscreen = function () {
  98582. if (document.exitFullscreen) {
  98583. document.exitFullscreen();
  98584. }
  98585. else if (document.mozCancelFullScreen) {
  98586. document.mozCancelFullScreen();
  98587. }
  98588. else if (document.webkitCancelFullScreen) {
  98589. document.webkitCancelFullScreen();
  98590. }
  98591. else if (document.msCancelFullScreen) {
  98592. document.msCancelFullScreen();
  98593. }
  98594. };
  98595. /**
  98596. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98597. * @param url define the url we are trying
  98598. * @param element define the dom element where to configure the cors policy
  98599. */
  98600. Tools.SetCorsBehavior = function (url, element) {
  98601. if (url && url.indexOf("data:") === 0) {
  98602. return;
  98603. }
  98604. if (Tools.CorsBehavior) {
  98605. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  98606. element.crossOrigin = Tools.CorsBehavior;
  98607. }
  98608. else {
  98609. var result = Tools.CorsBehavior(url);
  98610. if (result) {
  98611. element.crossOrigin = result;
  98612. }
  98613. }
  98614. }
  98615. };
  98616. // External files
  98617. /**
  98618. * Removes unwanted characters from an url
  98619. * @param url defines the url to clean
  98620. * @returns the cleaned url
  98621. */
  98622. Tools.CleanUrl = function (url) {
  98623. url = url.replace(/#/mg, "%23");
  98624. return url;
  98625. };
  98626. /**
  98627. * Loads an image as an HTMLImageElement.
  98628. * @param input url string, ArrayBuffer, or Blob to load
  98629. * @param onLoad callback called when the image successfully loads
  98630. * @param onError callback called when the image fails to load
  98631. * @param offlineProvider offline provider for caching
  98632. * @returns the HTMLImageElement of the loaded image
  98633. */
  98634. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  98635. var url;
  98636. var usingObjectURL = false;
  98637. if (input instanceof ArrayBuffer) {
  98638. url = URL.createObjectURL(new Blob([input]));
  98639. usingObjectURL = true;
  98640. }
  98641. else if (input instanceof Blob) {
  98642. url = URL.createObjectURL(input);
  98643. usingObjectURL = true;
  98644. }
  98645. else {
  98646. url = Tools.CleanUrl(input);
  98647. url = Tools.PreprocessUrl(input);
  98648. }
  98649. var img = new Image();
  98650. Tools.SetCorsBehavior(url, img);
  98651. var loadHandler = function () {
  98652. if (usingObjectURL && img.src) {
  98653. URL.revokeObjectURL(img.src);
  98654. }
  98655. img.removeEventListener("load", loadHandler);
  98656. img.removeEventListener("error", errorHandler);
  98657. onLoad(img);
  98658. };
  98659. var errorHandler = function (err) {
  98660. if (usingObjectURL && img.src) {
  98661. URL.revokeObjectURL(img.src);
  98662. }
  98663. img.removeEventListener("load", loadHandler);
  98664. img.removeEventListener("error", errorHandler);
  98665. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  98666. if (onError) {
  98667. onError("Error while trying to load image: " + input, err);
  98668. }
  98669. };
  98670. img.addEventListener("load", loadHandler);
  98671. img.addEventListener("error", errorHandler);
  98672. var noOfflineSupport = function () {
  98673. img.src = url;
  98674. };
  98675. var loadFromOfflineSupport = function () {
  98676. if (offlineProvider) {
  98677. offlineProvider.loadImage(url, img);
  98678. }
  98679. };
  98680. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  98681. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  98682. }
  98683. else {
  98684. if (url.indexOf("file:") !== -1) {
  98685. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  98686. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  98687. try {
  98688. var blobURL;
  98689. try {
  98690. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98691. }
  98692. catch (ex) {
  98693. // Chrome doesn't support oneTimeOnly parameter
  98694. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98695. }
  98696. img.src = blobURL;
  98697. usingObjectURL = true;
  98698. }
  98699. catch (e) {
  98700. img.src = "";
  98701. }
  98702. return img;
  98703. }
  98704. }
  98705. noOfflineSupport();
  98706. }
  98707. return img;
  98708. };
  98709. /**
  98710. * Loads a file
  98711. * @param url url string, ArrayBuffer, or Blob to load
  98712. * @param onSuccess callback called when the file successfully loads
  98713. * @param onProgress callback called while file is loading (if the server supports this mode)
  98714. * @param offlineProvider defines the offline provider for caching
  98715. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98716. * @param onError callback called when the file fails to load
  98717. * @returns a file request object
  98718. */
  98719. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  98720. url = Tools.CleanUrl(url);
  98721. url = Tools.PreprocessUrl(url);
  98722. // If file and file input are set
  98723. if (url.indexOf("file:") !== -1) {
  98724. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  98725. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  98726. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  98727. }
  98728. }
  98729. var loadUrl = Tools.BaseUrl + url;
  98730. var aborted = false;
  98731. var fileRequest = {
  98732. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98733. abort: function () { return aborted = true; },
  98734. };
  98735. var requestFile = function () {
  98736. var request = new XMLHttpRequest();
  98737. var retryHandle = null;
  98738. fileRequest.abort = function () {
  98739. aborted = true;
  98740. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  98741. request.abort();
  98742. }
  98743. if (retryHandle !== null) {
  98744. clearTimeout(retryHandle);
  98745. retryHandle = null;
  98746. }
  98747. };
  98748. var retryLoop = function (retryIndex) {
  98749. request.open('GET', loadUrl, true);
  98750. if (useArrayBuffer) {
  98751. request.responseType = "arraybuffer";
  98752. }
  98753. if (onProgress) {
  98754. request.addEventListener("progress", onProgress);
  98755. }
  98756. var onLoadEnd = function () {
  98757. request.removeEventListener("loadend", onLoadEnd);
  98758. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98759. fileRequest.onCompleteObservable.clear();
  98760. };
  98761. request.addEventListener("loadend", onLoadEnd);
  98762. var onReadyStateChange = function () {
  98763. if (aborted) {
  98764. return;
  98765. }
  98766. // In case of undefined state in some browsers.
  98767. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  98768. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  98769. request.removeEventListener("readystatechange", onReadyStateChange);
  98770. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  98771. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  98772. return;
  98773. }
  98774. var retryStrategy = Tools.DefaultRetryStrategy;
  98775. if (retryStrategy) {
  98776. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  98777. if (waitTime !== -1) {
  98778. // Prevent the request from completing for retry.
  98779. request.removeEventListener("loadend", onLoadEnd);
  98780. request = new XMLHttpRequest();
  98781. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  98782. return;
  98783. }
  98784. }
  98785. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  98786. if (onError) {
  98787. onError(request, e);
  98788. }
  98789. else {
  98790. throw e;
  98791. }
  98792. }
  98793. };
  98794. request.addEventListener("readystatechange", onReadyStateChange);
  98795. if (Tools.UseCustomRequestHeaders) {
  98796. Tools.InjectCustomRequestHeaders(request);
  98797. }
  98798. request.send();
  98799. };
  98800. retryLoop(0);
  98801. };
  98802. // Caching all files
  98803. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98804. var noOfflineSupport_1 = function (request) {
  98805. if (request && request.status > 400) {
  98806. if (onError) {
  98807. onError(request);
  98808. }
  98809. }
  98810. else {
  98811. if (!aborted) {
  98812. requestFile();
  98813. }
  98814. }
  98815. };
  98816. var loadFromOfflineSupport = function () {
  98817. // TODO: database needs to support aborting and should return a IFileRequest
  98818. if (aborted) {
  98819. return;
  98820. }
  98821. if (offlineProvider) {
  98822. offlineProvider.loadFile(url, function (data) {
  98823. if (!aborted) {
  98824. onSuccess(data);
  98825. }
  98826. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98827. }, onProgress ? function (event) {
  98828. if (!aborted) {
  98829. onProgress(event);
  98830. }
  98831. } : undefined, noOfflineSupport_1, useArrayBuffer);
  98832. }
  98833. };
  98834. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  98835. }
  98836. else {
  98837. requestFile();
  98838. }
  98839. return fileRequest;
  98840. };
  98841. /**
  98842. * Load a script (identified by an url). When the url returns, the
  98843. * content of this file is added into a new script element, attached to the DOM (body element)
  98844. * @param scriptUrl defines the url of the script to laod
  98845. * @param onSuccess defines the callback called when the script is loaded
  98846. * @param onError defines the callback to call if an error occurs
  98847. */
  98848. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  98849. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98850. return;
  98851. }
  98852. var head = document.getElementsByTagName('head')[0];
  98853. var script = document.createElement('script');
  98854. script.type = 'text/javascript';
  98855. script.src = scriptUrl;
  98856. script.onload = function () {
  98857. if (onSuccess) {
  98858. onSuccess();
  98859. }
  98860. };
  98861. script.onerror = function (e) {
  98862. if (onError) {
  98863. onError("Unable to load script '" + scriptUrl + "'", e);
  98864. }
  98865. };
  98866. head.appendChild(script);
  98867. };
  98868. /**
  98869. * Loads a file from a blob
  98870. * @param fileToLoad defines the blob to use
  98871. * @param callback defines the callback to call when data is loaded
  98872. * @param progressCallback defines the callback to call during loading process
  98873. * @returns a file request object
  98874. */
  98875. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  98876. var reader = new FileReader();
  98877. var request = {
  98878. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98879. abort: function () { return reader.abort(); },
  98880. };
  98881. reader.onloadend = function (e) {
  98882. request.onCompleteObservable.notifyObservers(request);
  98883. };
  98884. reader.onload = function (e) {
  98885. //target doesn't have result from ts 1.3
  98886. callback(e.target['result']);
  98887. };
  98888. reader.onprogress = progressCallback;
  98889. reader.readAsDataURL(fileToLoad);
  98890. return request;
  98891. };
  98892. /**
  98893. * Loads a file
  98894. * @param fileToLoad defines the file to load
  98895. * @param callback defines the callback to call when data is loaded
  98896. * @param progressCallBack defines the callback to call during loading process
  98897. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98898. * @returns a file request object
  98899. */
  98900. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  98901. var reader = new FileReader();
  98902. var request = {
  98903. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98904. abort: function () { return reader.abort(); },
  98905. };
  98906. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  98907. reader.onerror = function (e) {
  98908. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  98909. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  98910. };
  98911. reader.onload = function (e) {
  98912. //target doesn't have result from ts 1.3
  98913. callback(e.target['result']);
  98914. };
  98915. if (progressCallBack) {
  98916. reader.onprogress = progressCallBack;
  98917. }
  98918. if (!useArrayBuffer) {
  98919. // Asynchronous read
  98920. reader.readAsText(fileToLoad);
  98921. }
  98922. else {
  98923. reader.readAsArrayBuffer(fileToLoad);
  98924. }
  98925. return request;
  98926. };
  98927. /**
  98928. * Creates a data url from a given string content
  98929. * @param content defines the content to convert
  98930. * @returns the new data url link
  98931. */
  98932. Tools.FileAsURL = function (content) {
  98933. var fileBlob = new Blob([content]);
  98934. var url = window.URL || window.webkitURL;
  98935. var link = url.createObjectURL(fileBlob);
  98936. return link;
  98937. };
  98938. /**
  98939. * Format the given number to a specific decimal format
  98940. * @param value defines the number to format
  98941. * @param decimals defines the number of decimals to use
  98942. * @returns the formatted string
  98943. */
  98944. Tools.Format = function (value, decimals) {
  98945. if (decimals === void 0) { decimals = 2; }
  98946. return value.toFixed(decimals);
  98947. };
  98948. /**
  98949. * Checks if a given vector is inside a specific range
  98950. * @param v defines the vector to test
  98951. * @param min defines the minimum range
  98952. * @param max defines the maximum range
  98953. */
  98954. Tools.CheckExtends = function (v, min, max) {
  98955. min.minimizeInPlace(v);
  98956. max.maximizeInPlace(v);
  98957. };
  98958. /**
  98959. * Tries to copy an object by duplicating every property
  98960. * @param source defines the source object
  98961. * @param destination defines the target object
  98962. * @param doNotCopyList defines a list of properties to avoid
  98963. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98964. */
  98965. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98966. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  98967. };
  98968. /**
  98969. * Gets a boolean indicating if the given object has no own property
  98970. * @param obj defines the object to test
  98971. * @returns true if object has no own property
  98972. */
  98973. Tools.IsEmpty = function (obj) {
  98974. for (var i in obj) {
  98975. if (obj.hasOwnProperty(i)) {
  98976. return false;
  98977. }
  98978. }
  98979. return true;
  98980. };
  98981. /**
  98982. * Function used to register events at window level
  98983. * @param events defines the events to register
  98984. */
  98985. Tools.RegisterTopRootEvents = function (events) {
  98986. for (var index = 0; index < events.length; index++) {
  98987. var event = events[index];
  98988. window.addEventListener(event.name, event.handler, false);
  98989. try {
  98990. if (window.parent) {
  98991. window.parent.addEventListener(event.name, event.handler, false);
  98992. }
  98993. }
  98994. catch (e) {
  98995. // Silently fails...
  98996. }
  98997. }
  98998. };
  98999. /**
  99000. * Function used to unregister events from window level
  99001. * @param events defines the events to unregister
  99002. */
  99003. Tools.UnregisterTopRootEvents = function (events) {
  99004. for (var index = 0; index < events.length; index++) {
  99005. var event = events[index];
  99006. window.removeEventListener(event.name, event.handler);
  99007. try {
  99008. if (window.parent) {
  99009. window.parent.removeEventListener(event.name, event.handler);
  99010. }
  99011. }
  99012. catch (e) {
  99013. // Silently fails...
  99014. }
  99015. }
  99016. };
  99017. /**
  99018. * Dumps the current bound framebuffer
  99019. * @param width defines the rendering width
  99020. * @param height defines the rendering height
  99021. * @param engine defines the hosting engine
  99022. * @param successCallback defines the callback triggered once the data are available
  99023. * @param mimeType defines the mime type of the result
  99024. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99025. */
  99026. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  99027. if (mimeType === void 0) { mimeType = "image/png"; }
  99028. // Read the contents of the framebuffer
  99029. var numberOfChannelsByLine = width * 4;
  99030. var halfHeight = height / 2;
  99031. //Reading datas from WebGL
  99032. var data = engine.readPixels(0, 0, width, height);
  99033. //To flip image on Y axis.
  99034. for (var i = 0; i < halfHeight; i++) {
  99035. for (var j = 0; j < numberOfChannelsByLine; j++) {
  99036. var currentCell = j + i * numberOfChannelsByLine;
  99037. var targetLine = height - i - 1;
  99038. var targetCell = j + targetLine * numberOfChannelsByLine;
  99039. var temp = data[currentCell];
  99040. data[currentCell] = data[targetCell];
  99041. data[targetCell] = temp;
  99042. }
  99043. }
  99044. // Create a 2D canvas to store the result
  99045. if (!screenshotCanvas) {
  99046. screenshotCanvas = document.createElement('canvas');
  99047. }
  99048. screenshotCanvas.width = width;
  99049. screenshotCanvas.height = height;
  99050. var context = screenshotCanvas.getContext('2d');
  99051. if (context) {
  99052. // Copy the pixels to a 2D canvas
  99053. var imageData = context.createImageData(width, height);
  99054. var castData = (imageData.data);
  99055. castData.set(data);
  99056. context.putImageData(imageData, 0, 0);
  99057. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  99058. }
  99059. };
  99060. /**
  99061. * Converts the canvas data to blob.
  99062. * This acts as a polyfill for browsers not supporting the to blob function.
  99063. * @param canvas Defines the canvas to extract the data from
  99064. * @param successCallback Defines the callback triggered once the data are available
  99065. * @param mimeType Defines the mime type of the result
  99066. */
  99067. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  99068. if (mimeType === void 0) { mimeType = "image/png"; }
  99069. // We need HTMLCanvasElement.toBlob for HD screenshots
  99070. if (!canvas.toBlob) {
  99071. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  99072. canvas.toBlob = function (callback, type, quality) {
  99073. var _this = this;
  99074. setTimeout(function () {
  99075. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  99076. for (var i = 0; i < len; i++) {
  99077. arr[i] = binStr.charCodeAt(i);
  99078. }
  99079. callback(new Blob([arr]));
  99080. });
  99081. };
  99082. }
  99083. canvas.toBlob(function (blob) {
  99084. successCallback(blob);
  99085. }, mimeType);
  99086. };
  99087. /**
  99088. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99089. * @param successCallback defines the callback triggered once the data are available
  99090. * @param mimeType defines the mime type of the result
  99091. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99092. */
  99093. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  99094. if (mimeType === void 0) { mimeType = "image/png"; }
  99095. if (successCallback) {
  99096. var base64Image = screenshotCanvas.toDataURL(mimeType);
  99097. successCallback(base64Image);
  99098. }
  99099. else {
  99100. this.ToBlob(screenshotCanvas, function (blob) {
  99101. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  99102. if (("download" in document.createElement("a"))) {
  99103. if (!fileName) {
  99104. var date = new Date();
  99105. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  99106. fileName = "screenshot_" + stringDate + ".png";
  99107. }
  99108. Tools.Download(blob, fileName);
  99109. }
  99110. else {
  99111. var url = URL.createObjectURL(blob);
  99112. var newWindow = window.open("");
  99113. if (!newWindow) {
  99114. return;
  99115. }
  99116. var img = newWindow.document.createElement("img");
  99117. img.onload = function () {
  99118. // no longer need to read the blob so it's revoked
  99119. URL.revokeObjectURL(url);
  99120. };
  99121. img.src = url;
  99122. newWindow.document.body.appendChild(img);
  99123. }
  99124. }, mimeType);
  99125. }
  99126. };
  99127. /**
  99128. * Downloads a blob in the browser
  99129. * @param blob defines the blob to download
  99130. * @param fileName defines the name of the downloaded file
  99131. */
  99132. Tools.Download = function (blob, fileName) {
  99133. if (navigator && navigator.msSaveBlob) {
  99134. navigator.msSaveBlob(blob, fileName);
  99135. return;
  99136. }
  99137. var url = window.URL.createObjectURL(blob);
  99138. var a = document.createElement("a");
  99139. document.body.appendChild(a);
  99140. a.style.display = "none";
  99141. a.href = url;
  99142. a.download = fileName;
  99143. a.addEventListener("click", function () {
  99144. if (a.parentElement) {
  99145. a.parentElement.removeChild(a);
  99146. }
  99147. });
  99148. a.click();
  99149. window.URL.revokeObjectURL(url);
  99150. };
  99151. /**
  99152. * Captures a screenshot of the current rendering
  99153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99154. * @param engine defines the rendering engine
  99155. * @param camera defines the source camera
  99156. * @param size This parameter can be set to a single number or to an object with the
  99157. * following (optional) properties: precision, width, height. If a single number is passed,
  99158. * it will be used for both width and height. If an object is passed, the screenshot size
  99159. * will be derived from the parameters. The precision property is a multiplier allowing
  99160. * rendering at a higher or lower resolution
  99161. * @param successCallback defines the callback receives a single parameter which contains the
  99162. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99163. * src parameter of an <img> to display it
  99164. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99165. * Check your browser for supported MIME types
  99166. */
  99167. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99168. if (mimeType === void 0) { mimeType = "image/png"; }
  99169. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99170. };
  99171. /**
  99172. * Generates an image screenshot from the specified camera.
  99173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99174. * @param engine The engine to use for rendering
  99175. * @param camera The camera to use for rendering
  99176. * @param size This parameter can be set to a single number or to an object with the
  99177. * following (optional) properties: precision, width, height. If a single number is passed,
  99178. * it will be used for both width and height. If an object is passed, the screenshot size
  99179. * will be derived from the parameters. The precision property is a multiplier allowing
  99180. * rendering at a higher or lower resolution
  99181. * @param successCallback The callback receives a single parameter which contains the
  99182. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99183. * src parameter of an <img> to display it
  99184. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99185. * Check your browser for supported MIME types
  99186. * @param samples Texture samples (default: 1)
  99187. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99188. * @param fileName A name for for the downloaded file.
  99189. */
  99190. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  99191. if (mimeType === void 0) { mimeType = "image/png"; }
  99192. if (samples === void 0) { samples = 1; }
  99193. if (antialiasing === void 0) { antialiasing = false; }
  99194. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99195. };
  99196. /**
  99197. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99198. * Be aware Math.random() could cause collisions, but:
  99199. * "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"
  99200. * @returns a pseudo random id
  99201. */
  99202. Tools.RandomId = function () {
  99203. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  99204. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  99205. return v.toString(16);
  99206. });
  99207. };
  99208. /**
  99209. * Test if the given uri is a base64 string
  99210. * @param uri The uri to test
  99211. * @return True if the uri is a base64 string or false otherwise
  99212. */
  99213. Tools.IsBase64 = function (uri) {
  99214. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  99215. };
  99216. /**
  99217. * Decode the given base64 uri.
  99218. * @param uri The uri to decode
  99219. * @return The decoded base64 data.
  99220. */
  99221. Tools.DecodeBase64 = function (uri) {
  99222. var decodedString = atob(uri.split(",")[1]);
  99223. var bufferLength = decodedString.length;
  99224. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  99225. for (var i = 0; i < bufferLength; i++) {
  99226. bufferView[i] = decodedString.charCodeAt(i);
  99227. }
  99228. return bufferView.buffer;
  99229. };
  99230. Object.defineProperty(Tools, "errorsCount", {
  99231. /**
  99232. * Gets a value indicating the number of loading errors
  99233. * @ignorenaming
  99234. */
  99235. get: function () {
  99236. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  99237. },
  99238. enumerable: true,
  99239. configurable: true
  99240. });
  99241. /**
  99242. * Log a message to the console
  99243. * @param message defines the message to log
  99244. */
  99245. Tools.Log = function (message) {
  99246. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  99247. };
  99248. /**
  99249. * Write a warning message to the console
  99250. * @param message defines the message to log
  99251. */
  99252. Tools.Warn = function (message) {
  99253. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  99254. };
  99255. /**
  99256. * Write an error message to the console
  99257. * @param message defines the message to log
  99258. */
  99259. Tools.Error = function (message) {
  99260. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  99261. };
  99262. Object.defineProperty(Tools, "LogCache", {
  99263. /**
  99264. * Gets current log cache (list of logs)
  99265. */
  99266. get: function () {
  99267. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  99268. },
  99269. enumerable: true,
  99270. configurable: true
  99271. });
  99272. /**
  99273. * Clears the log cache
  99274. */
  99275. Tools.ClearLogCache = function () {
  99276. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  99277. };
  99278. Object.defineProperty(Tools, "LogLevels", {
  99279. /**
  99280. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99281. */
  99282. set: function (level) {
  99283. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  99284. },
  99285. enumerable: true,
  99286. configurable: true
  99287. });
  99288. /**
  99289. * Checks if the loaded document was accessed via `file:`-Protocol.
  99290. * @returns boolean
  99291. */
  99292. Tools.IsFileURL = function () {
  99293. return location.protocol === "file:";
  99294. };
  99295. Object.defineProperty(Tools, "PerformanceLogLevel", {
  99296. /**
  99297. * Sets the current performance log level
  99298. */
  99299. set: function (level) {
  99300. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  99301. Tools.StartPerformanceCounter = Tools._StartUserMark;
  99302. Tools.EndPerformanceCounter = Tools._EndUserMark;
  99303. return;
  99304. }
  99305. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  99306. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  99307. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  99308. return;
  99309. }
  99310. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99311. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99312. },
  99313. enumerable: true,
  99314. configurable: true
  99315. });
  99316. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  99317. };
  99318. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  99319. };
  99320. Tools._StartUserMark = function (counterName, condition) {
  99321. if (condition === void 0) { condition = true; }
  99322. if (!Tools._performance) {
  99323. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99324. return;
  99325. }
  99326. Tools._performance = window.performance;
  99327. }
  99328. if (!condition || !Tools._performance.mark) {
  99329. return;
  99330. }
  99331. Tools._performance.mark(counterName + "-Begin");
  99332. };
  99333. Tools._EndUserMark = function (counterName, condition) {
  99334. if (condition === void 0) { condition = true; }
  99335. if (!condition || !Tools._performance.mark) {
  99336. return;
  99337. }
  99338. Tools._performance.mark(counterName + "-End");
  99339. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  99340. };
  99341. Tools._StartPerformanceConsole = function (counterName, condition) {
  99342. if (condition === void 0) { condition = true; }
  99343. if (!condition) {
  99344. return;
  99345. }
  99346. Tools._StartUserMark(counterName, condition);
  99347. if (console.time) {
  99348. console.time(counterName);
  99349. }
  99350. };
  99351. Tools._EndPerformanceConsole = function (counterName, condition) {
  99352. if (condition === void 0) { condition = true; }
  99353. if (!condition) {
  99354. return;
  99355. }
  99356. Tools._EndUserMark(counterName, condition);
  99357. if (console.time) {
  99358. console.timeEnd(counterName);
  99359. }
  99360. };
  99361. /**
  99362. * Injects the @see CustomRequestHeaders into the given request
  99363. * @param request the request that should be used for injection
  99364. */
  99365. Tools.InjectCustomRequestHeaders = function (request) {
  99366. for (var key in Tools.CustomRequestHeaders) {
  99367. var val = Tools.CustomRequestHeaders[key];
  99368. if (val) {
  99369. request.setRequestHeader(key, val);
  99370. }
  99371. }
  99372. };
  99373. Object.defineProperty(Tools, "Now", {
  99374. /**
  99375. * Gets either window.performance.now() if supported or Date.now() else
  99376. */
  99377. get: function () {
  99378. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99379. },
  99380. enumerable: true,
  99381. configurable: true
  99382. });
  99383. /**
  99384. * This method will return the name of the class used to create the instance of the given object.
  99385. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99386. * @param object the object to get the class name from
  99387. * @param isType defines if the object is actually a type
  99388. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99389. */
  99390. Tools.GetClassName = function (object, isType) {
  99391. if (isType === void 0) { isType = false; }
  99392. var name = null;
  99393. if (!isType && object.getClassName) {
  99394. name = object.getClassName();
  99395. }
  99396. else {
  99397. if (object instanceof Object) {
  99398. var classObj = isType ? object : Object.getPrototypeOf(object);
  99399. name = classObj.constructor["__bjsclassName__"];
  99400. }
  99401. if (!name) {
  99402. name = typeof object;
  99403. }
  99404. }
  99405. return name;
  99406. };
  99407. /**
  99408. * Gets the first element of an array satisfying a given predicate
  99409. * @param array defines the array to browse
  99410. * @param predicate defines the predicate to use
  99411. * @returns null if not found or the element
  99412. */
  99413. Tools.First = function (array, predicate) {
  99414. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  99415. var el = array_1[_i];
  99416. if (predicate(el)) {
  99417. return el;
  99418. }
  99419. }
  99420. return null;
  99421. };
  99422. /**
  99423. * This method will return the name of the full name of the class, including its owning module (if any).
  99424. * 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).
  99425. * @param object the object to get the class name from
  99426. * @param isType defines if the object is actually a type
  99427. * @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.
  99428. * @ignorenaming
  99429. */
  99430. Tools.getFullClassName = function (object, isType) {
  99431. if (isType === void 0) { isType = false; }
  99432. var className = null;
  99433. var moduleName = null;
  99434. if (!isType && object.getClassName) {
  99435. className = object.getClassName();
  99436. }
  99437. else {
  99438. if (object instanceof Object) {
  99439. var classObj = isType ? object : Object.getPrototypeOf(object);
  99440. className = classObj.constructor["__bjsclassName__"];
  99441. moduleName = classObj.constructor["__bjsmoduleName__"];
  99442. }
  99443. if (!className) {
  99444. className = typeof object;
  99445. }
  99446. }
  99447. if (!className) {
  99448. return null;
  99449. }
  99450. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  99451. };
  99452. /**
  99453. * Returns a promise that resolves after the given amount of time.
  99454. * @param delay Number of milliseconds to delay
  99455. * @returns Promise that resolves after the given amount of time
  99456. */
  99457. Tools.DelayAsync = function (delay) {
  99458. return new Promise(function (resolve) {
  99459. setTimeout(function () {
  99460. resolve();
  99461. }, delay);
  99462. });
  99463. };
  99464. /**
  99465. * Gets the current gradient from an array of IValueGradient
  99466. * @param ratio defines the current ratio to get
  99467. * @param gradients defines the array of IValueGradient
  99468. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99469. */
  99470. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  99471. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  99472. var currentGradient = gradients[gradientIndex];
  99473. var nextGradient = gradients[gradientIndex + 1];
  99474. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  99475. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  99476. updateFunc(currentGradient, nextGradient, scale);
  99477. return;
  99478. }
  99479. }
  99480. // Use last index if over
  99481. var lastIndex = gradients.length - 1;
  99482. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  99483. };
  99484. /**
  99485. * Gets or sets the base URL to use to load assets
  99486. */
  99487. Tools.BaseUrl = "";
  99488. /**
  99489. * Enable/Disable Custom HTTP Request Headers globally.
  99490. * default = false
  99491. * @see CustomRequestHeaders
  99492. */
  99493. Tools.UseCustomRequestHeaders = false;
  99494. /**
  99495. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99496. * i.e. when loading files, where the server/service expects an Authorization header.
  99497. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  99498. */
  99499. Tools.CustomRequestHeaders = {};
  99500. /**
  99501. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99502. */
  99503. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  99504. /**
  99505. * Default behaviour for cors in the application.
  99506. * It can be a string if the expected behavior is identical in the entire app.
  99507. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99508. */
  99509. Tools.CorsBehavior = "anonymous";
  99510. /**
  99511. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99512. * @ignorenaming
  99513. */
  99514. Tools.UseFallbackTexture = true;
  99515. /**
  99516. * Use this object to register external classes like custom textures or material
  99517. * to allow the laoders to instantiate them
  99518. */
  99519. Tools.RegisteredExternalClasses = {};
  99520. /**
  99521. * Texture content used if a texture cannot loaded
  99522. * @ignorenaming
  99523. */
  99524. Tools.fallbackTexture = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";
  99525. Tools._tmpFloatArray = new Float32Array(1);
  99526. /**
  99527. * Extracts text content from a DOM element hierarchy
  99528. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99529. */
  99530. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  99531. /**
  99532. * Gets or sets a function used to pre-process url before using them to load assets
  99533. */
  99534. Tools.PreprocessUrl = function (url) {
  99535. return url;
  99536. };
  99537. // Logs
  99538. /**
  99539. * No log
  99540. */
  99541. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  99542. /**
  99543. * Only message logs
  99544. */
  99545. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  99546. /**
  99547. * Only warning logs
  99548. */
  99549. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  99550. /**
  99551. * Only error logs
  99552. */
  99553. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  99554. /**
  99555. * All logs
  99556. */
  99557. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  99558. /**
  99559. * Checks if the window object exists
  99560. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99561. */
  99562. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  99563. // Performances
  99564. /**
  99565. * No performance log
  99566. */
  99567. Tools.PerformanceNoneLogLevel = 0;
  99568. /**
  99569. * Use user marks to log performance
  99570. */
  99571. Tools.PerformanceUserMarkLogLevel = 1;
  99572. /**
  99573. * Log performance to the console
  99574. */
  99575. Tools.PerformanceConsoleLogLevel = 2;
  99576. /**
  99577. * Starts a performance counter
  99578. */
  99579. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99580. /**
  99581. * Ends a specific performance coutner
  99582. */
  99583. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99584. return Tools;
  99585. }());
  99586. /**
  99587. * This class is used to track a performance counter which is number based.
  99588. * The user has access to many properties which give statistics of different nature.
  99589. *
  99590. * The implementer can track two kinds of Performance Counter: time and count.
  99591. * 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.
  99592. * 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.
  99593. */
  99594. var PerfCounter = /** @class */ (function () {
  99595. /**
  99596. * Creates a new counter
  99597. */
  99598. function PerfCounter() {
  99599. this._startMonitoringTime = 0;
  99600. this._min = 0;
  99601. this._max = 0;
  99602. this._average = 0;
  99603. this._lastSecAverage = 0;
  99604. this._current = 0;
  99605. this._totalValueCount = 0;
  99606. this._totalAccumulated = 0;
  99607. this._lastSecAccumulated = 0;
  99608. this._lastSecTime = 0;
  99609. this._lastSecValueCount = 0;
  99610. }
  99611. Object.defineProperty(PerfCounter.prototype, "min", {
  99612. /**
  99613. * Returns the smallest value ever
  99614. */
  99615. get: function () {
  99616. return this._min;
  99617. },
  99618. enumerable: true,
  99619. configurable: true
  99620. });
  99621. Object.defineProperty(PerfCounter.prototype, "max", {
  99622. /**
  99623. * Returns the biggest value ever
  99624. */
  99625. get: function () {
  99626. return this._max;
  99627. },
  99628. enumerable: true,
  99629. configurable: true
  99630. });
  99631. Object.defineProperty(PerfCounter.prototype, "average", {
  99632. /**
  99633. * Returns the average value since the performance counter is running
  99634. */
  99635. get: function () {
  99636. return this._average;
  99637. },
  99638. enumerable: true,
  99639. configurable: true
  99640. });
  99641. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  99642. /**
  99643. * Returns the average value of the last second the counter was monitored
  99644. */
  99645. get: function () {
  99646. return this._lastSecAverage;
  99647. },
  99648. enumerable: true,
  99649. configurable: true
  99650. });
  99651. Object.defineProperty(PerfCounter.prototype, "current", {
  99652. /**
  99653. * Returns the current value
  99654. */
  99655. get: function () {
  99656. return this._current;
  99657. },
  99658. enumerable: true,
  99659. configurable: true
  99660. });
  99661. Object.defineProperty(PerfCounter.prototype, "total", {
  99662. /**
  99663. * Gets the accumulated total
  99664. */
  99665. get: function () {
  99666. return this._totalAccumulated;
  99667. },
  99668. enumerable: true,
  99669. configurable: true
  99670. });
  99671. Object.defineProperty(PerfCounter.prototype, "count", {
  99672. /**
  99673. * Gets the total value count
  99674. */
  99675. get: function () {
  99676. return this._totalValueCount;
  99677. },
  99678. enumerable: true,
  99679. configurable: true
  99680. });
  99681. /**
  99682. * Call this method to start monitoring a new frame.
  99683. * 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.
  99684. */
  99685. PerfCounter.prototype.fetchNewFrame = function () {
  99686. this._totalValueCount++;
  99687. this._current = 0;
  99688. this._lastSecValueCount++;
  99689. };
  99690. /**
  99691. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99692. * @param newCount the count value to add to the monitored count
  99693. * @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.
  99694. */
  99695. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  99696. if (!PerfCounter.Enabled) {
  99697. return;
  99698. }
  99699. this._current += newCount;
  99700. if (fetchResult) {
  99701. this._fetchResult();
  99702. }
  99703. };
  99704. /**
  99705. * Start monitoring this performance counter
  99706. */
  99707. PerfCounter.prototype.beginMonitoring = function () {
  99708. if (!PerfCounter.Enabled) {
  99709. return;
  99710. }
  99711. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99712. };
  99713. /**
  99714. * Compute the time lapsed since the previous beginMonitoring() call.
  99715. * @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
  99716. */
  99717. PerfCounter.prototype.endMonitoring = function (newFrame) {
  99718. if (newFrame === void 0) { newFrame = true; }
  99719. if (!PerfCounter.Enabled) {
  99720. return;
  99721. }
  99722. if (newFrame) {
  99723. this.fetchNewFrame();
  99724. }
  99725. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99726. this._current = currentTime - this._startMonitoringTime;
  99727. if (newFrame) {
  99728. this._fetchResult();
  99729. }
  99730. };
  99731. PerfCounter.prototype._fetchResult = function () {
  99732. this._totalAccumulated += this._current;
  99733. this._lastSecAccumulated += this._current;
  99734. // Min/Max update
  99735. this._min = Math.min(this._min, this._current);
  99736. this._max = Math.max(this._max, this._current);
  99737. this._average = this._totalAccumulated / this._totalValueCount;
  99738. // Reset last sec?
  99739. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99740. if ((now - this._lastSecTime) > 1000) {
  99741. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  99742. this._lastSecTime = now;
  99743. this._lastSecAccumulated = 0;
  99744. this._lastSecValueCount = 0;
  99745. }
  99746. };
  99747. /**
  99748. * Gets or sets a global boolean to turn on and off all the counters
  99749. */
  99750. PerfCounter.Enabled = true;
  99751. return PerfCounter;
  99752. }());
  99753. /**
  99754. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99755. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99756. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99757. * @param name The name of the class, case should be preserved
  99758. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99759. */
  99760. function className(name, module) {
  99761. return function (target) {
  99762. target["__bjsclassName__"] = name;
  99763. target["__bjsmoduleName__"] = (module != null) ? module : null;
  99764. };
  99765. }
  99766. /**
  99767. * An implementation of a loop for asynchronous functions.
  99768. */
  99769. var AsyncLoop = /** @class */ (function () {
  99770. /**
  99771. * Constructor.
  99772. * @param iterations the number of iterations.
  99773. * @param func the function to run each iteration
  99774. * @param successCallback the callback that will be called upon succesful execution
  99775. * @param offset starting offset.
  99776. */
  99777. function AsyncLoop(
  99778. /**
  99779. * Defines the number of iterations for the loop
  99780. */
  99781. iterations, func, successCallback, offset) {
  99782. if (offset === void 0) { offset = 0; }
  99783. this.iterations = iterations;
  99784. this.index = offset - 1;
  99785. this._done = false;
  99786. this._fn = func;
  99787. this._successCallback = successCallback;
  99788. }
  99789. /**
  99790. * Execute the next iteration. Must be called after the last iteration was finished.
  99791. */
  99792. AsyncLoop.prototype.executeNext = function () {
  99793. if (!this._done) {
  99794. if (this.index + 1 < this.iterations) {
  99795. ++this.index;
  99796. this._fn(this);
  99797. }
  99798. else {
  99799. this.breakLoop();
  99800. }
  99801. }
  99802. };
  99803. /**
  99804. * Break the loop and run the success callback.
  99805. */
  99806. AsyncLoop.prototype.breakLoop = function () {
  99807. this._done = true;
  99808. this._successCallback();
  99809. };
  99810. /**
  99811. * Create and run an async loop.
  99812. * @param iterations the number of iterations.
  99813. * @param fn the function to run each iteration
  99814. * @param successCallback the callback that will be called upon succesful execution
  99815. * @param offset starting offset.
  99816. * @returns the created async loop object
  99817. */
  99818. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99819. if (offset === void 0) { offset = 0; }
  99820. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99821. loop.executeNext();
  99822. return loop;
  99823. };
  99824. /**
  99825. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99826. * @param iterations total number of iterations
  99827. * @param syncedIterations number of synchronous iterations in each async iteration.
  99828. * @param fn the function to call each iteration.
  99829. * @param callback a success call back that will be called when iterating stops.
  99830. * @param breakFunction a break condition (optional)
  99831. * @param timeout timeout settings for the setTimeout function. default - 0.
  99832. * @returns the created async loop object
  99833. */
  99834. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  99835. if (timeout === void 0) { timeout = 0; }
  99836. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  99837. if (breakFunction && breakFunction()) {
  99838. loop.breakLoop();
  99839. }
  99840. else {
  99841. setTimeout(function () {
  99842. for (var i = 0; i < syncedIterations; ++i) {
  99843. var iteration = (loop.index * syncedIterations) + i;
  99844. if (iteration >= iterations) {
  99845. break;
  99846. }
  99847. fn(iteration);
  99848. if (breakFunction && breakFunction()) {
  99849. loop.breakLoop();
  99850. break;
  99851. }
  99852. }
  99853. loop.executeNext();
  99854. }, timeout);
  99855. }
  99856. }, callback);
  99857. };
  99858. return AsyncLoop;
  99859. }());
  99860. /***/ }),
  99861. /***/ "./Misc/typeStore.ts":
  99862. /*!***************************!*\
  99863. !*** ./Misc/typeStore.ts ***!
  99864. \***************************/
  99865. /*! exports provided: _TypeStore */
  99866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99867. "use strict";
  99868. __webpack_require__.r(__webpack_exports__);
  99869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  99870. /** @hidden */
  99871. var _TypeStore = /** @class */ (function () {
  99872. function _TypeStore() {
  99873. }
  99874. /** @hidden */
  99875. _TypeStore.GetClass = function (fqdn) {
  99876. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  99877. return this.RegisteredTypes[fqdn];
  99878. }
  99879. return null;
  99880. };
  99881. /** @hidden */
  99882. _TypeStore.RegisteredTypes = {};
  99883. return _TypeStore;
  99884. }());
  99885. /***/ }),
  99886. /***/ "./Misc/videoRecorder.ts":
  99887. /*!*******************************!*\
  99888. !*** ./Misc/videoRecorder.ts ***!
  99889. \*******************************/
  99890. /*! exports provided: VideoRecorder */
  99891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99892. "use strict";
  99893. __webpack_require__.r(__webpack_exports__);
  99894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  99895. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99896. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99897. /**
  99898. * This can helps recording videos from BabylonJS.
  99899. * This is based on the available WebRTC functionalities of the browser.
  99900. *
  99901. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  99902. */
  99903. var VideoRecorder = /** @class */ (function () {
  99904. /**
  99905. * Create a new VideoCapture object which can help converting what you see in Babylon to
  99906. * a video file.
  99907. * @param engine Defines the BabylonJS Engine you wish to record
  99908. * @param options Defines options that can be used to customized the capture
  99909. */
  99910. function VideoRecorder(engine, options) {
  99911. if (options === void 0) { options = null; }
  99912. if (!VideoRecorder.IsSupported(engine)) {
  99913. throw "Your browser does not support recording so far.";
  99914. }
  99915. var canvas = engine.getRenderingCanvas();
  99916. if (!canvas) {
  99917. throw "The babylon engine must have a canvas to be recorded";
  99918. }
  99919. this._canvas = canvas;
  99920. this._canvas.isRecording = false;
  99921. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  99922. var stream = this._canvas.captureStream(this._options.fps);
  99923. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  99924. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  99925. this._mediaRecorder.onerror = this._handleError.bind(this);
  99926. this._mediaRecorder.onstop = this._handleStop.bind(this);
  99927. }
  99928. /**
  99929. * Returns wehther or not the VideoRecorder is available in your browser.
  99930. * @param engine Defines the Babylon Engine to check the support for
  99931. * @returns true if supported otherwise false
  99932. */
  99933. VideoRecorder.IsSupported = function (engine) {
  99934. var canvas = engine.getRenderingCanvas();
  99935. return (!!canvas && typeof canvas.captureStream === "function");
  99936. };
  99937. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  99938. /**
  99939. * True wether a recording is already in progress.
  99940. */
  99941. get: function () {
  99942. return !!this._canvas && this._canvas.isRecording;
  99943. },
  99944. enumerable: true,
  99945. configurable: true
  99946. });
  99947. /**
  99948. * Stops the current recording before the default capture timeout passed in the startRecording
  99949. * functions.
  99950. */
  99951. VideoRecorder.prototype.stopRecording = function () {
  99952. if (!this._canvas || !this._mediaRecorder) {
  99953. return;
  99954. }
  99955. if (!this.isRecording) {
  99956. return;
  99957. }
  99958. this._canvas.isRecording = false;
  99959. this._mediaRecorder.stop();
  99960. };
  99961. /**
  99962. * Starts recording the canvas for a max duration specified in parameters.
  99963. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  99964. * @param maxDuration Defines the maximum recording time in seconds.
  99965. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  99966. * @return a promise callback at the end of the recording with the video data in Blob.
  99967. */
  99968. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  99969. var _this = this;
  99970. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  99971. if (maxDuration === void 0) { maxDuration = 7; }
  99972. if (!this._canvas || !this._mediaRecorder) {
  99973. throw "Recorder has already been disposed";
  99974. }
  99975. if (this.isRecording) {
  99976. throw "Recording already in progress";
  99977. }
  99978. if (maxDuration > 0) {
  99979. setTimeout(function () {
  99980. _this.stopRecording();
  99981. }, maxDuration * 1000);
  99982. }
  99983. this._fileName = fileName;
  99984. this._recordedChunks = [];
  99985. this._resolve = null;
  99986. this._reject = null;
  99987. this._canvas.isRecording = true;
  99988. this._mediaRecorder.start(this._options.recordChunckSize);
  99989. return new Promise(function (resolve, reject) {
  99990. _this._resolve = resolve;
  99991. _this._reject = reject;
  99992. });
  99993. };
  99994. /**
  99995. * Releases internal resources used during the recording.
  99996. */
  99997. VideoRecorder.prototype.dispose = function () {
  99998. this._canvas = null;
  99999. this._mediaRecorder = null;
  100000. this._recordedChunks = [];
  100001. this._fileName = null;
  100002. this._resolve = null;
  100003. this._reject = null;
  100004. };
  100005. VideoRecorder.prototype._handleDataAvailable = function (event) {
  100006. if (event.data.size > 0) {
  100007. this._recordedChunks.push(event.data);
  100008. }
  100009. };
  100010. VideoRecorder.prototype._handleError = function (event) {
  100011. this.stopRecording();
  100012. if (this._reject) {
  100013. this._reject(event.error);
  100014. }
  100015. else {
  100016. throw new event.error();
  100017. }
  100018. };
  100019. VideoRecorder.prototype._handleStop = function () {
  100020. this.stopRecording();
  100021. var superBuffer = new Blob(this._recordedChunks);
  100022. if (this._resolve) {
  100023. this._resolve(superBuffer);
  100024. }
  100025. window.URL.createObjectURL(superBuffer);
  100026. if (this._fileName) {
  100027. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  100028. }
  100029. };
  100030. VideoRecorder._defaultOptions = {
  100031. mimeType: "video/webm",
  100032. fps: 25,
  100033. recordChunckSize: 3000
  100034. };
  100035. return VideoRecorder;
  100036. }());
  100037. /***/ }),
  100038. /***/ "./Misc/virtualJoystick.ts":
  100039. /*!*********************************!*\
  100040. !*** ./Misc/virtualJoystick.ts ***!
  100041. \*********************************/
  100042. /*! exports provided: JoystickAxis, VirtualJoystick */
  100043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100044. "use strict";
  100045. __webpack_require__.r(__webpack_exports__);
  100046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  100047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  100048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100049. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  100050. // Mainly based on these 2 articles :
  100051. // 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
  100052. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  100053. /**
  100054. * Defines the potential axis of a Joystick
  100055. */
  100056. var JoystickAxis;
  100057. (function (JoystickAxis) {
  100058. /** X axis */
  100059. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  100060. /** Y axis */
  100061. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  100062. /** Z axis */
  100063. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  100064. })(JoystickAxis || (JoystickAxis = {}));
  100065. /**
  100066. * Class used to define virtual joystick (used in touch mode)
  100067. */
  100068. var VirtualJoystick = /** @class */ (function () {
  100069. /**
  100070. * Creates a new virtual joystick
  100071. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100072. */
  100073. function VirtualJoystick(leftJoystick) {
  100074. var _this = this;
  100075. if (leftJoystick) {
  100076. this._leftJoystick = true;
  100077. }
  100078. else {
  100079. this._leftJoystick = false;
  100080. }
  100081. VirtualJoystick._globalJoystickIndex++;
  100082. // By default left & right arrow keys are moving the X
  100083. // and up & down keys are moving the Y
  100084. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100085. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100086. this.reverseLeftRight = false;
  100087. this.reverseUpDown = false;
  100088. // collections of pointers
  100089. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  100090. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  100091. this._joystickSensibility = 25;
  100092. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100093. this._onResize = function (evt) {
  100094. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100095. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100096. if (VirtualJoystick.Canvas) {
  100097. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  100098. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  100099. }
  100100. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  100101. };
  100102. // injecting a canvas element on top of the canvas 3D game
  100103. if (!VirtualJoystick.Canvas) {
  100104. window.addEventListener("resize", this._onResize, false);
  100105. VirtualJoystick.Canvas = document.createElement("canvas");
  100106. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100107. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100108. VirtualJoystick.Canvas.width = window.innerWidth;
  100109. VirtualJoystick.Canvas.height = window.innerHeight;
  100110. VirtualJoystick.Canvas.style.width = "100%";
  100111. VirtualJoystick.Canvas.style.height = "100%";
  100112. VirtualJoystick.Canvas.style.position = "absolute";
  100113. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  100114. VirtualJoystick.Canvas.style.top = "0px";
  100115. VirtualJoystick.Canvas.style.left = "0px";
  100116. VirtualJoystick.Canvas.style.zIndex = "5";
  100117. VirtualJoystick.Canvas.style.msTouchAction = "none";
  100118. // Support for jQuery PEP polyfill
  100119. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  100120. var context = VirtualJoystick.Canvas.getContext('2d');
  100121. if (!context) {
  100122. throw new Error("Unable to create canvas for virtual joystick");
  100123. }
  100124. VirtualJoystick.vjCanvasContext = context;
  100125. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  100126. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100127. document.body.appendChild(VirtualJoystick.Canvas);
  100128. }
  100129. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  100130. this.pressed = false;
  100131. // default joystick color
  100132. this._joystickColor = "cyan";
  100133. this._joystickPointerID = -1;
  100134. // current joystick position
  100135. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100136. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100137. // origin joystick position
  100138. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100139. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100140. this._onPointerDownHandlerRef = function (evt) {
  100141. _this._onPointerDown(evt);
  100142. };
  100143. this._onPointerMoveHandlerRef = function (evt) {
  100144. _this._onPointerMove(evt);
  100145. };
  100146. this._onPointerUpHandlerRef = function (evt) {
  100147. _this._onPointerUp(evt);
  100148. };
  100149. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  100150. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  100151. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  100152. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  100153. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  100154. evt.preventDefault(); // Disables system menu
  100155. }, false);
  100156. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100157. }
  100158. /**
  100159. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100160. * @param newJoystickSensibility defines the new sensibility
  100161. */
  100162. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  100163. this._joystickSensibility = newJoystickSensibility;
  100164. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100165. };
  100166. VirtualJoystick.prototype._onPointerDown = function (e) {
  100167. var positionOnScreenCondition;
  100168. e.preventDefault();
  100169. if (this._leftJoystick === true) {
  100170. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  100171. }
  100172. else {
  100173. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  100174. }
  100175. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  100176. // First contact will be dedicated to the virtual joystick
  100177. this._joystickPointerID = e.pointerId;
  100178. this._joystickPointerStartPos.x = e.clientX;
  100179. this._joystickPointerStartPos.y = e.clientY;
  100180. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  100181. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  100182. this._deltaJoystickVector.x = 0;
  100183. this._deltaJoystickVector.y = 0;
  100184. this.pressed = true;
  100185. this._touches.add(e.pointerId.toString(), e);
  100186. }
  100187. else {
  100188. // You can only trigger the action buttons with a joystick declared
  100189. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  100190. this._action();
  100191. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  100192. }
  100193. }
  100194. };
  100195. VirtualJoystick.prototype._onPointerMove = function (e) {
  100196. // If the current pointer is the one associated to the joystick (first touch contact)
  100197. if (this._joystickPointerID == e.pointerId) {
  100198. this._joystickPointerPos.x = e.clientX;
  100199. this._joystickPointerPos.y = e.clientY;
  100200. this._deltaJoystickVector = this._joystickPointerPos.clone();
  100201. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  100202. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  100203. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  100204. switch (this._axisTargetedByLeftAndRight) {
  100205. case JoystickAxis.X:
  100206. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  100207. break;
  100208. case JoystickAxis.Y:
  100209. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  100210. break;
  100211. case JoystickAxis.Z:
  100212. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  100213. break;
  100214. }
  100215. var directionUpDown = this.reverseUpDown ? 1 : -1;
  100216. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  100217. switch (this._axisTargetedByUpAndDown) {
  100218. case JoystickAxis.X:
  100219. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  100220. break;
  100221. case JoystickAxis.Y:
  100222. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  100223. break;
  100224. case JoystickAxis.Z:
  100225. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  100226. break;
  100227. }
  100228. }
  100229. else {
  100230. var data = this._touches.get(e.pointerId.toString());
  100231. if (data) {
  100232. data.x = e.clientX;
  100233. data.y = e.clientY;
  100234. }
  100235. }
  100236. };
  100237. VirtualJoystick.prototype._onPointerUp = function (e) {
  100238. if (this._joystickPointerID == e.pointerId) {
  100239. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  100240. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  100241. this._joystickPointerID = -1;
  100242. this.pressed = false;
  100243. }
  100244. else {
  100245. var touch = this._touches.get(e.pointerId.toString());
  100246. if (touch) {
  100247. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100248. }
  100249. }
  100250. this._deltaJoystickVector.x = 0;
  100251. this._deltaJoystickVector.y = 0;
  100252. this._touches.remove(e.pointerId.toString());
  100253. };
  100254. /**
  100255. * Change the color of the virtual joystick
  100256. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100257. */
  100258. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  100259. this._joystickColor = newColor;
  100260. };
  100261. /**
  100262. * Defines a callback to call when the joystick is touched
  100263. * @param action defines the callback
  100264. */
  100265. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  100266. this._action = action;
  100267. };
  100268. /**
  100269. * Defines which axis you'd like to control for left & right
  100270. * @param axis defines the axis to use
  100271. */
  100272. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  100273. switch (axis) {
  100274. case JoystickAxis.X:
  100275. case JoystickAxis.Y:
  100276. case JoystickAxis.Z:
  100277. this._axisTargetedByLeftAndRight = axis;
  100278. break;
  100279. default:
  100280. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100281. break;
  100282. }
  100283. };
  100284. /**
  100285. * Defines which axis you'd like to control for up & down
  100286. * @param axis defines the axis to use
  100287. */
  100288. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  100289. switch (axis) {
  100290. case JoystickAxis.X:
  100291. case JoystickAxis.Y:
  100292. case JoystickAxis.Z:
  100293. this._axisTargetedByUpAndDown = axis;
  100294. break;
  100295. default:
  100296. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100297. break;
  100298. }
  100299. };
  100300. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  100301. var _this = this;
  100302. if (this.pressed) {
  100303. this._touches.forEach(function (key, touch) {
  100304. if (touch.pointerId === _this._joystickPointerID) {
  100305. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  100306. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  100307. VirtualJoystick.vjCanvasContext.beginPath();
  100308. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100309. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100310. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  100311. VirtualJoystick.vjCanvasContext.stroke();
  100312. VirtualJoystick.vjCanvasContext.closePath();
  100313. VirtualJoystick.vjCanvasContext.beginPath();
  100314. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100315. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100316. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  100317. VirtualJoystick.vjCanvasContext.stroke();
  100318. VirtualJoystick.vjCanvasContext.closePath();
  100319. VirtualJoystick.vjCanvasContext.beginPath();
  100320. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100321. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  100322. VirtualJoystick.vjCanvasContext.stroke();
  100323. VirtualJoystick.vjCanvasContext.closePath();
  100324. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  100325. }
  100326. else {
  100327. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100328. VirtualJoystick.vjCanvasContext.beginPath();
  100329. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  100330. VirtualJoystick.vjCanvasContext.beginPath();
  100331. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  100332. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100333. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  100334. VirtualJoystick.vjCanvasContext.stroke();
  100335. VirtualJoystick.vjCanvasContext.closePath();
  100336. touch.prevX = touch.x;
  100337. touch.prevY = touch.y;
  100338. }
  100339. });
  100340. }
  100341. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100342. };
  100343. /**
  100344. * Release internal HTML canvas
  100345. */
  100346. VirtualJoystick.prototype.releaseCanvas = function () {
  100347. if (VirtualJoystick.Canvas) {
  100348. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  100349. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  100350. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  100351. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  100352. window.removeEventListener("resize", this._onResize);
  100353. document.body.removeChild(VirtualJoystick.Canvas);
  100354. VirtualJoystick.Canvas = null;
  100355. }
  100356. };
  100357. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  100358. VirtualJoystick._globalJoystickIndex = 0;
  100359. return VirtualJoystick;
  100360. }());
  100361. /***/ }),
  100362. /***/ "./Misc/workerPool.ts":
  100363. /*!****************************!*\
  100364. !*** ./Misc/workerPool.ts ***!
  100365. \****************************/
  100366. /*! exports provided: WorkerPool */
  100367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100368. "use strict";
  100369. __webpack_require__.r(__webpack_exports__);
  100370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  100371. /**
  100372. * Helper class to push actions to a pool of workers.
  100373. */
  100374. var WorkerPool = /** @class */ (function () {
  100375. /**
  100376. * Constructor
  100377. * @param workers Array of workers to use for actions
  100378. */
  100379. function WorkerPool(workers) {
  100380. this._pendingActions = new Array();
  100381. this._workerInfos = workers.map(function (worker) { return ({
  100382. worker: worker,
  100383. active: false
  100384. }); });
  100385. }
  100386. /**
  100387. * Terminates all workers and clears any pending actions.
  100388. */
  100389. WorkerPool.prototype.dispose = function () {
  100390. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100391. var workerInfo = _a[_i];
  100392. workerInfo.worker.terminate();
  100393. }
  100394. delete this._workerInfos;
  100395. delete this._pendingActions;
  100396. };
  100397. /**
  100398. * Pushes an action to the worker pool. If all the workers are active, the action will be
  100399. * pended until a worker has completed its action.
  100400. * @param action The action to perform. Call onComplete when the action is complete.
  100401. */
  100402. WorkerPool.prototype.push = function (action) {
  100403. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100404. var workerInfo = _a[_i];
  100405. if (!workerInfo.active) {
  100406. this._execute(workerInfo, action);
  100407. return;
  100408. }
  100409. }
  100410. this._pendingActions.push(action);
  100411. };
  100412. WorkerPool.prototype._execute = function (workerInfo, action) {
  100413. var _this = this;
  100414. workerInfo.active = true;
  100415. action(workerInfo.worker, function () {
  100416. workerInfo.active = false;
  100417. var nextAction = _this._pendingActions.shift();
  100418. if (nextAction) {
  100419. _this._execute(workerInfo, nextAction);
  100420. }
  100421. });
  100422. };
  100423. return WorkerPool;
  100424. }());
  100425. /***/ }),
  100426. /***/ "./Morph/index.ts":
  100427. /*!************************!*\
  100428. !*** ./Morph/index.ts ***!
  100429. \************************/
  100430. /*! exports provided: MorphTarget, MorphTargetManager */
  100431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100432. "use strict";
  100433. __webpack_require__.r(__webpack_exports__);
  100434. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  100436. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  100437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  100438. /***/ }),
  100439. /***/ "./Morph/morphTarget.ts":
  100440. /*!******************************!*\
  100441. !*** ./Morph/morphTarget.ts ***!
  100442. \******************************/
  100443. /*! exports provided: MorphTarget */
  100444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100445. "use strict";
  100446. __webpack_require__.r(__webpack_exports__);
  100447. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  100448. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100449. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  100450. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100451. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  100452. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  100453. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  100454. /**
  100455. * Defines a target to use with MorphTargetManager
  100456. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100457. */
  100458. var MorphTarget = /** @class */ (function () {
  100459. /**
  100460. * Creates a new MorphTarget
  100461. * @param name defines the name of the target
  100462. * @param influence defines the influence to use
  100463. * @param scene defines the scene the morphtarget belongs to
  100464. */
  100465. function MorphTarget(
  100466. /** defines the name of the target */
  100467. name, influence, scene) {
  100468. if (influence === void 0) { influence = 0; }
  100469. if (scene === void 0) { scene = null; }
  100470. this.name = name;
  100471. /**
  100472. * Gets or sets the list of animations
  100473. */
  100474. this.animations = new Array();
  100475. this._positions = null;
  100476. this._normals = null;
  100477. this._tangents = null;
  100478. /**
  100479. * Observable raised when the influence changes
  100480. */
  100481. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100482. /** @hidden */
  100483. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100484. this._animationPropertiesOverride = null;
  100485. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100486. this.influence = influence;
  100487. }
  100488. Object.defineProperty(MorphTarget.prototype, "influence", {
  100489. /**
  100490. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  100491. */
  100492. get: function () {
  100493. return this._influence;
  100494. },
  100495. set: function (influence) {
  100496. if (this._influence === influence) {
  100497. return;
  100498. }
  100499. var previous = this._influence;
  100500. this._influence = influence;
  100501. if (this.onInfluenceChanged.hasObservers) {
  100502. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  100503. }
  100504. },
  100505. enumerable: true,
  100506. configurable: true
  100507. });
  100508. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  100509. /**
  100510. * Gets or sets the animation properties override
  100511. */
  100512. get: function () {
  100513. if (!this._animationPropertiesOverride && this._scene) {
  100514. return this._scene.animationPropertiesOverride;
  100515. }
  100516. return this._animationPropertiesOverride;
  100517. },
  100518. set: function (value) {
  100519. this._animationPropertiesOverride = value;
  100520. },
  100521. enumerable: true,
  100522. configurable: true
  100523. });
  100524. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  100525. /**
  100526. * Gets a boolean defining if the target contains position data
  100527. */
  100528. get: function () {
  100529. return !!this._positions;
  100530. },
  100531. enumerable: true,
  100532. configurable: true
  100533. });
  100534. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  100535. /**
  100536. * Gets a boolean defining if the target contains normal data
  100537. */
  100538. get: function () {
  100539. return !!this._normals;
  100540. },
  100541. enumerable: true,
  100542. configurable: true
  100543. });
  100544. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  100545. /**
  100546. * Gets a boolean defining if the target contains tangent data
  100547. */
  100548. get: function () {
  100549. return !!this._tangents;
  100550. },
  100551. enumerable: true,
  100552. configurable: true
  100553. });
  100554. /**
  100555. * Affects position data to this target
  100556. * @param data defines the position data to use
  100557. */
  100558. MorphTarget.prototype.setPositions = function (data) {
  100559. var hadPositions = this.hasPositions;
  100560. this._positions = data;
  100561. if (hadPositions !== this.hasPositions) {
  100562. this._onDataLayoutChanged.notifyObservers(undefined);
  100563. }
  100564. };
  100565. /**
  100566. * Gets the position data stored in this target
  100567. * @returns a FloatArray containing the position data (or null if not present)
  100568. */
  100569. MorphTarget.prototype.getPositions = function () {
  100570. return this._positions;
  100571. };
  100572. /**
  100573. * Affects normal data to this target
  100574. * @param data defines the normal data to use
  100575. */
  100576. MorphTarget.prototype.setNormals = function (data) {
  100577. var hadNormals = this.hasNormals;
  100578. this._normals = data;
  100579. if (hadNormals !== this.hasNormals) {
  100580. this._onDataLayoutChanged.notifyObservers(undefined);
  100581. }
  100582. };
  100583. /**
  100584. * Gets the normal data stored in this target
  100585. * @returns a FloatArray containing the normal data (or null if not present)
  100586. */
  100587. MorphTarget.prototype.getNormals = function () {
  100588. return this._normals;
  100589. };
  100590. /**
  100591. * Affects tangent data to this target
  100592. * @param data defines the tangent data to use
  100593. */
  100594. MorphTarget.prototype.setTangents = function (data) {
  100595. var hadTangents = this.hasTangents;
  100596. this._tangents = data;
  100597. if (hadTangents !== this.hasTangents) {
  100598. this._onDataLayoutChanged.notifyObservers(undefined);
  100599. }
  100600. };
  100601. /**
  100602. * Gets the tangent data stored in this target
  100603. * @returns a FloatArray containing the tangent data (or null if not present)
  100604. */
  100605. MorphTarget.prototype.getTangents = function () {
  100606. return this._tangents;
  100607. };
  100608. /**
  100609. * Serializes the current target into a Serialization object
  100610. * @returns the serialized object
  100611. */
  100612. MorphTarget.prototype.serialize = function () {
  100613. var serializationObject = {};
  100614. serializationObject.name = this.name;
  100615. serializationObject.influence = this.influence;
  100616. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  100617. if (this.id != null) {
  100618. serializationObject.id = this.id;
  100619. }
  100620. if (this.hasNormals) {
  100621. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  100622. }
  100623. if (this.hasTangents) {
  100624. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  100625. }
  100626. // Animations
  100627. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100628. return serializationObject;
  100629. };
  100630. /**
  100631. * Returns the string "MorphTarget"
  100632. * @returns "MorphTarget"
  100633. */
  100634. MorphTarget.prototype.getClassName = function () {
  100635. return "MorphTarget";
  100636. };
  100637. // Statics
  100638. /**
  100639. * Creates a new target from serialized data
  100640. * @param serializationObject defines the serialized data to use
  100641. * @returns a new MorphTarget
  100642. */
  100643. MorphTarget.Parse = function (serializationObject) {
  100644. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  100645. result.setPositions(serializationObject.positions);
  100646. if (serializationObject.id != null) {
  100647. result.id = serializationObject.id;
  100648. }
  100649. if (serializationObject.normals) {
  100650. result.setNormals(serializationObject.normals);
  100651. }
  100652. if (serializationObject.tangents) {
  100653. result.setTangents(serializationObject.tangents);
  100654. }
  100655. // Animations
  100656. if (serializationObject.animations) {
  100657. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  100658. var parsedAnimation = serializationObject.animations[animationIndex];
  100659. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  100660. if (internalClass) {
  100661. result.animations.push(internalClass.Parse(parsedAnimation));
  100662. }
  100663. }
  100664. }
  100665. return result;
  100666. };
  100667. /**
  100668. * Creates a MorphTarget from mesh data
  100669. * @param mesh defines the source mesh
  100670. * @param name defines the name to use for the new target
  100671. * @param influence defines the influence to attach to the target
  100672. * @returns a new MorphTarget
  100673. */
  100674. MorphTarget.FromMesh = function (mesh, name, influence) {
  100675. if (!name) {
  100676. name = mesh.name;
  100677. }
  100678. var result = new MorphTarget(name, influence, mesh.getScene());
  100679. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  100680. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  100681. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  100682. }
  100683. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  100684. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  100685. }
  100686. return result;
  100687. };
  100688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  100689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  100690. ], MorphTarget.prototype, "id", void 0);
  100691. return MorphTarget;
  100692. }());
  100693. /***/ }),
  100694. /***/ "./Morph/morphTargetManager.ts":
  100695. /*!*************************************!*\
  100696. !*** ./Morph/morphTargetManager.ts ***!
  100697. \*************************************/
  100698. /*! exports provided: MorphTargetManager */
  100699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100700. "use strict";
  100701. __webpack_require__.r(__webpack_exports__);
  100702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  100703. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  100704. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100705. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100706. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100707. /**
  100708. * This class is used to deform meshes using morphing between different targets
  100709. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100710. */
  100711. var MorphTargetManager = /** @class */ (function () {
  100712. /**
  100713. * Creates a new MorphTargetManager
  100714. * @param scene defines the current scene
  100715. */
  100716. function MorphTargetManager(scene) {
  100717. if (scene === void 0) { scene = null; }
  100718. this._targets = new Array();
  100719. this._targetInfluenceChangedObservers = new Array();
  100720. this._targetDataLayoutChangedObservers = new Array();
  100721. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  100722. this._supportsNormals = false;
  100723. this._supportsTangents = false;
  100724. this._vertexCount = 0;
  100725. this._uniqueId = 0;
  100726. this._tempInfluences = new Array();
  100727. if (!scene) {
  100728. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100729. }
  100730. this._scene = scene;
  100731. if (this._scene) {
  100732. this._scene.morphTargetManagers.push(this);
  100733. this._uniqueId = this._scene.getUniqueId();
  100734. }
  100735. }
  100736. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  100737. /**
  100738. * Gets the unique ID of this manager
  100739. */
  100740. get: function () {
  100741. return this._uniqueId;
  100742. },
  100743. enumerable: true,
  100744. configurable: true
  100745. });
  100746. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  100747. /**
  100748. * Gets the number of vertices handled by this manager
  100749. */
  100750. get: function () {
  100751. return this._vertexCount;
  100752. },
  100753. enumerable: true,
  100754. configurable: true
  100755. });
  100756. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  100757. /**
  100758. * Gets a boolean indicating if this manager supports morphing of normals
  100759. */
  100760. get: function () {
  100761. return this._supportsNormals;
  100762. },
  100763. enumerable: true,
  100764. configurable: true
  100765. });
  100766. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  100767. /**
  100768. * Gets a boolean indicating if this manager supports morphing of tangents
  100769. */
  100770. get: function () {
  100771. return this._supportsTangents;
  100772. },
  100773. enumerable: true,
  100774. configurable: true
  100775. });
  100776. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  100777. /**
  100778. * Gets the number of targets stored in this manager
  100779. */
  100780. get: function () {
  100781. return this._targets.length;
  100782. },
  100783. enumerable: true,
  100784. configurable: true
  100785. });
  100786. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  100787. /**
  100788. * Gets the number of influencers (ie. the number of targets with influences > 0)
  100789. */
  100790. get: function () {
  100791. return this._activeTargets.length;
  100792. },
  100793. enumerable: true,
  100794. configurable: true
  100795. });
  100796. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100797. /**
  100798. * Gets the list of influences (one per target)
  100799. */
  100800. get: function () {
  100801. return this._influences;
  100802. },
  100803. enumerable: true,
  100804. configurable: true
  100805. });
  100806. /**
  100807. * Gets the active target at specified index. An active target is a target with an influence > 0
  100808. * @param index defines the index to check
  100809. * @returns the requested target
  100810. */
  100811. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100812. return this._activeTargets.data[index];
  100813. };
  100814. /**
  100815. * Gets the target at specified index
  100816. * @param index defines the index to check
  100817. * @returns the requested target
  100818. */
  100819. MorphTargetManager.prototype.getTarget = function (index) {
  100820. return this._targets[index];
  100821. };
  100822. /**
  100823. * Add a new target to this manager
  100824. * @param target defines the target to add
  100825. */
  100826. MorphTargetManager.prototype.addTarget = function (target) {
  100827. var _this = this;
  100828. this._targets.push(target);
  100829. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  100830. _this._syncActiveTargets(needUpdate);
  100831. }));
  100832. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  100833. _this._syncActiveTargets(true);
  100834. }));
  100835. this._syncActiveTargets(true);
  100836. };
  100837. /**
  100838. * Removes a target from the manager
  100839. * @param target defines the target to remove
  100840. */
  100841. MorphTargetManager.prototype.removeTarget = function (target) {
  100842. var index = this._targets.indexOf(target);
  100843. if (index >= 0) {
  100844. this._targets.splice(index, 1);
  100845. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  100846. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  100847. this._syncActiveTargets(true);
  100848. }
  100849. };
  100850. /**
  100851. * Serializes the current manager into a Serialization object
  100852. * @returns the serialized object
  100853. */
  100854. MorphTargetManager.prototype.serialize = function () {
  100855. var serializationObject = {};
  100856. serializationObject.id = this.uniqueId;
  100857. serializationObject.targets = [];
  100858. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100859. var target = _a[_i];
  100860. serializationObject.targets.push(target.serialize());
  100861. }
  100862. return serializationObject;
  100863. };
  100864. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  100865. var influenceCount = 0;
  100866. this._activeTargets.reset();
  100867. this._supportsNormals = true;
  100868. this._supportsTangents = true;
  100869. this._vertexCount = 0;
  100870. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100871. var target = _a[_i];
  100872. if (target.influence === 0) {
  100873. continue;
  100874. }
  100875. this._activeTargets.push(target);
  100876. this._tempInfluences[influenceCount++] = target.influence;
  100877. this._supportsNormals = this._supportsNormals && target.hasNormals;
  100878. this._supportsTangents = this._supportsTangents && target.hasTangents;
  100879. var positions = target.getPositions();
  100880. if (positions) {
  100881. var vertexCount = positions.length / 3;
  100882. if (this._vertexCount === 0) {
  100883. this._vertexCount = vertexCount;
  100884. }
  100885. else if (this._vertexCount !== vertexCount) {
  100886. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  100887. return;
  100888. }
  100889. }
  100890. }
  100891. if (!this._influences || this._influences.length !== influenceCount) {
  100892. this._influences = new Float32Array(influenceCount);
  100893. }
  100894. for (var index = 0; index < influenceCount; index++) {
  100895. this._influences[index] = this._tempInfluences[index];
  100896. }
  100897. if (needUpdate) {
  100898. this.synchronize();
  100899. }
  100900. };
  100901. /**
  100902. * Syncrhonize the targets with all the meshes using this morph target manager
  100903. */
  100904. MorphTargetManager.prototype.synchronize = function () {
  100905. if (!this._scene) {
  100906. return;
  100907. }
  100908. // Flag meshes as dirty to resync with the active targets
  100909. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  100910. var mesh = _a[_i];
  100911. if (mesh.morphTargetManager === this) {
  100912. mesh._syncGeometryWithMorphTargetManager();
  100913. }
  100914. }
  100915. };
  100916. // Statics
  100917. /**
  100918. * Creates a new MorphTargetManager from serialized data
  100919. * @param serializationObject defines the serialized data
  100920. * @param scene defines the hosting scene
  100921. * @returns the new MorphTargetManager
  100922. */
  100923. MorphTargetManager.Parse = function (serializationObject, scene) {
  100924. var result = new MorphTargetManager(scene);
  100925. result._uniqueId = serializationObject.id;
  100926. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  100927. var targetData = _a[_i];
  100928. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  100929. }
  100930. return result;
  100931. };
  100932. return MorphTargetManager;
  100933. }());
  100934. /***/ }),
  100935. /***/ "./Offline/database.ts":
  100936. /*!*****************************!*\
  100937. !*** ./Offline/database.ts ***!
  100938. \*****************************/
  100939. /*! exports provided: Database */
  100940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100941. "use strict";
  100942. __webpack_require__.r(__webpack_exports__);
  100943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  100944. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  100945. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100946. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  100947. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  100948. // Sets the default offline provider to Babylon.js
  100949. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  100950. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100951. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  100952. };
  100953. /**
  100954. * Class used to enable access to IndexedDB
  100955. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100956. */
  100957. var Database = /** @class */ (function () {
  100958. /**
  100959. * Creates a new Database
  100960. * @param urlToScene defines the url to load the scene
  100961. * @param callbackManifestChecked defines the callback to use when manifest is checked
  100962. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  100963. */
  100964. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  100965. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100966. var _this = this;
  100967. // Handling various flavors of prefixed version of IndexedDB
  100968. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  100969. this._callbackManifestChecked = callbackManifestChecked;
  100970. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  100971. this._db = null;
  100972. this._enableSceneOffline = false;
  100973. this._enableTexturesOffline = false;
  100974. this._manifestVersionFound = 0;
  100975. this._mustUpdateRessources = false;
  100976. this._hasReachedQuota = false;
  100977. if (!Database.IDBStorageEnabled) {
  100978. this._callbackManifestChecked(true);
  100979. }
  100980. else {
  100981. if (disableManifestCheck) {
  100982. this._enableSceneOffline = true;
  100983. this._enableTexturesOffline = true;
  100984. this._manifestVersionFound = 1;
  100985. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100986. _this._callbackManifestChecked(true);
  100987. });
  100988. }
  100989. else {
  100990. this._checkManifestFile();
  100991. }
  100992. }
  100993. }
  100994. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  100995. /**
  100996. * Gets a boolean indicating if scene must be saved in the database
  100997. */
  100998. get: function () {
  100999. return this._enableSceneOffline;
  101000. },
  101001. enumerable: true,
  101002. configurable: true
  101003. });
  101004. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  101005. /**
  101006. * Gets a boolean indicating if textures must be saved in the database
  101007. */
  101008. get: function () {
  101009. return this._enableTexturesOffline;
  101010. },
  101011. enumerable: true,
  101012. configurable: true
  101013. });
  101014. Database.prototype._checkManifestFile = function () {
  101015. var _this = this;
  101016. var noManifestFile = function () {
  101017. _this._enableSceneOffline = false;
  101018. _this._enableTexturesOffline = false;
  101019. _this._callbackManifestChecked(false);
  101020. };
  101021. var timeStampUsed = false;
  101022. var manifestURL = this._currentSceneUrl + ".manifest";
  101023. var xhr = new XMLHttpRequest();
  101024. if (navigator.onLine) {
  101025. // Adding a timestamp to by-pass browsers' cache
  101026. timeStampUsed = true;
  101027. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  101028. }
  101029. xhr.open("GET", manifestURL, true);
  101030. xhr.addEventListener("load", function () {
  101031. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  101032. try {
  101033. var manifestFile = JSON.parse(xhr.response);
  101034. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  101035. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  101036. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  101037. _this._manifestVersionFound = manifestFile.version;
  101038. }
  101039. if (_this._callbackManifestChecked) {
  101040. _this._callbackManifestChecked(true);
  101041. }
  101042. }
  101043. catch (ex) {
  101044. noManifestFile();
  101045. }
  101046. }
  101047. else {
  101048. noManifestFile();
  101049. }
  101050. }, false);
  101051. xhr.addEventListener("error", function () {
  101052. if (timeStampUsed) {
  101053. timeStampUsed = false;
  101054. // Let's retry without the timeStamp
  101055. // It could fail when coupled with HTML5 Offline API
  101056. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  101057. xhr.open("GET", retryManifestURL, true);
  101058. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101059. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101060. }
  101061. xhr.send();
  101062. }
  101063. else {
  101064. noManifestFile();
  101065. }
  101066. }, false);
  101067. try {
  101068. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101069. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101070. }
  101071. xhr.send();
  101072. }
  101073. catch (ex) {
  101074. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  101075. this._callbackManifestChecked(false);
  101076. }
  101077. };
  101078. /**
  101079. * Open the database and make it available
  101080. * @param successCallback defines the callback to call on success
  101081. * @param errorCallback defines the callback to call on error
  101082. */
  101083. Database.prototype.open = function (successCallback, errorCallback) {
  101084. var _this = this;
  101085. var handleError = function () {
  101086. _this._isSupported = false;
  101087. if (errorCallback) {
  101088. errorCallback();
  101089. }
  101090. };
  101091. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  101092. // Your browser doesn't support IndexedDB
  101093. this._isSupported = false;
  101094. if (errorCallback) {
  101095. errorCallback();
  101096. }
  101097. }
  101098. else {
  101099. // If the DB hasn't been opened or created yet
  101100. if (!this._db) {
  101101. this._hasReachedQuota = false;
  101102. this._isSupported = true;
  101103. var request = this._idbFactory.open("babylonjs", 1);
  101104. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  101105. request.onerror = function () {
  101106. handleError();
  101107. };
  101108. // executes when a version change transaction cannot complete due to other active transactions
  101109. request.onblocked = function () {
  101110. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  101111. handleError();
  101112. };
  101113. // DB has been opened successfully
  101114. request.onsuccess = function () {
  101115. _this._db = request.result;
  101116. successCallback();
  101117. };
  101118. // Initialization of the DB. Creating Scenes & Textures stores
  101119. request.onupgradeneeded = function (event) {
  101120. _this._db = (event.target).result;
  101121. if (_this._db) {
  101122. try {
  101123. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  101124. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  101125. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  101126. }
  101127. catch (ex) {
  101128. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  101129. handleError();
  101130. }
  101131. }
  101132. };
  101133. }
  101134. // DB has already been created and opened
  101135. else {
  101136. if (successCallback) {
  101137. successCallback();
  101138. }
  101139. }
  101140. }
  101141. };
  101142. /**
  101143. * Loads an image from the database
  101144. * @param url defines the url to load from
  101145. * @param image defines the target DOM image
  101146. */
  101147. Database.prototype.loadImage = function (url, image) {
  101148. var _this = this;
  101149. var completeURL = Database._ReturnFullUrlLocation(url);
  101150. var saveAndLoadImage = function () {
  101151. if (!_this._hasReachedQuota && _this._db !== null) {
  101152. // the texture is not yet in the DB, let's try to save it
  101153. _this._saveImageIntoDBAsync(completeURL, image);
  101154. }
  101155. // If the texture is not in the DB and we've reached the DB quota limit
  101156. // let's load it directly from the web
  101157. else {
  101158. image.src = url;
  101159. }
  101160. };
  101161. if (!this._mustUpdateRessources) {
  101162. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  101163. }
  101164. // First time we're download the images or update requested in the manifest file by a version change
  101165. else {
  101166. saveAndLoadImage();
  101167. }
  101168. };
  101169. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  101170. if (this._isSupported && this._db !== null) {
  101171. var texture;
  101172. var transaction = this._db.transaction(["textures"]);
  101173. transaction.onabort = function () {
  101174. image.src = url;
  101175. };
  101176. transaction.oncomplete = function () {
  101177. var blobTextureURL;
  101178. if (texture) {
  101179. var URL = window.URL || window.webkitURL;
  101180. blobTextureURL = URL.createObjectURL(texture.data);
  101181. image.onerror = function () {
  101182. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  101183. image.src = url;
  101184. };
  101185. image.src = blobTextureURL;
  101186. }
  101187. else {
  101188. notInDBCallback();
  101189. }
  101190. };
  101191. var getRequest = transaction.objectStore("textures").get(url);
  101192. getRequest.onsuccess = function (event) {
  101193. texture = (event.target).result;
  101194. };
  101195. getRequest.onerror = function () {
  101196. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  101197. image.src = url;
  101198. };
  101199. }
  101200. else {
  101201. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101202. image.src = url;
  101203. }
  101204. };
  101205. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  101206. var _this = this;
  101207. if (this._isSupported) {
  101208. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  101209. var generateBlobUrl = function () {
  101210. var blobTextureURL;
  101211. if (blob) {
  101212. var URL = window.URL || window.webkitURL;
  101213. try {
  101214. blobTextureURL = URL.createObjectURL(blob);
  101215. }
  101216. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  101217. catch (ex) {
  101218. blobTextureURL = URL.createObjectURL(blob);
  101219. }
  101220. }
  101221. if (blobTextureURL) {
  101222. image.src = blobTextureURL;
  101223. }
  101224. };
  101225. if (Database.IsUASupportingBlobStorage) { // Create XHR
  101226. var xhr = new XMLHttpRequest(), blob;
  101227. xhr.open("GET", url, true);
  101228. xhr.responseType = "blob";
  101229. xhr.addEventListener("load", function () {
  101230. if (xhr.status === 200 && _this._db) {
  101231. // Blob as response (XHR2)
  101232. blob = xhr.response;
  101233. var transaction = _this._db.transaction(["textures"], "readwrite");
  101234. // the transaction could abort because of a QuotaExceededError error
  101235. transaction.onabort = function (event) {
  101236. try {
  101237. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101238. var srcElement = (event.srcElement || event.target);
  101239. var error = srcElement.error;
  101240. if (error && error.name === "QuotaExceededError") {
  101241. _this._hasReachedQuota = true;
  101242. }
  101243. }
  101244. catch (ex) { }
  101245. generateBlobUrl();
  101246. };
  101247. transaction.oncomplete = function () {
  101248. generateBlobUrl();
  101249. };
  101250. var newTexture = { textureUrl: url, data: blob };
  101251. try {
  101252. // Put the blob into the dabase
  101253. var addRequest = transaction.objectStore("textures").put(newTexture);
  101254. addRequest.onsuccess = function () {
  101255. };
  101256. addRequest.onerror = function () {
  101257. generateBlobUrl();
  101258. };
  101259. }
  101260. catch (ex) {
  101261. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  101262. if (ex.code === 25) {
  101263. Database.IsUASupportingBlobStorage = false;
  101264. _this._enableTexturesOffline = false;
  101265. }
  101266. image.src = url;
  101267. }
  101268. }
  101269. else {
  101270. image.src = url;
  101271. }
  101272. }, false);
  101273. xhr.addEventListener("error", function () {
  101274. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  101275. image.src = url;
  101276. }, false);
  101277. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  101278. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101279. }
  101280. xhr.send();
  101281. }
  101282. else {
  101283. image.src = url;
  101284. }
  101285. }
  101286. else {
  101287. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101288. image.src = url;
  101289. }
  101290. };
  101291. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  101292. var _this = this;
  101293. var updateVersion = function () {
  101294. // the version is not yet in the DB or we need to update it
  101295. _this._saveVersionIntoDBAsync(url, versionLoaded);
  101296. };
  101297. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  101298. };
  101299. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  101300. var _this = this;
  101301. if (this._isSupported && this._db) {
  101302. var version;
  101303. try {
  101304. var transaction = this._db.transaction(["versions"]);
  101305. transaction.oncomplete = function () {
  101306. if (version) {
  101307. // If the version in the JSON file is different from the version in DB
  101308. if (_this._manifestVersionFound !== version.data) {
  101309. _this._mustUpdateRessources = true;
  101310. updateInDBCallback();
  101311. }
  101312. else {
  101313. callback(version.data);
  101314. }
  101315. }
  101316. // version was not found in DB
  101317. else {
  101318. _this._mustUpdateRessources = true;
  101319. updateInDBCallback();
  101320. }
  101321. };
  101322. transaction.onabort = function () {
  101323. callback(-1);
  101324. };
  101325. var getRequest = transaction.objectStore("versions").get(url);
  101326. getRequest.onsuccess = function (event) {
  101327. version = (event.target).result;
  101328. };
  101329. getRequest.onerror = function () {
  101330. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  101331. callback(-1);
  101332. };
  101333. }
  101334. catch (ex) {
  101335. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  101336. callback(-1);
  101337. }
  101338. }
  101339. else {
  101340. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101341. callback(-1);
  101342. }
  101343. };
  101344. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  101345. var _this = this;
  101346. if (this._isSupported && !this._hasReachedQuota && this._db) {
  101347. try {
  101348. // Open a transaction to the database
  101349. var transaction = this._db.transaction(["versions"], "readwrite");
  101350. // the transaction could abort because of a QuotaExceededError error
  101351. transaction.onabort = function (event) {
  101352. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101353. var error = event.srcElement['error'];
  101354. if (error && error.name === "QuotaExceededError") {
  101355. _this._hasReachedQuota = true;
  101356. }
  101357. }
  101358. catch (ex) { }
  101359. callback(-1);
  101360. };
  101361. transaction.oncomplete = function () {
  101362. callback(_this._manifestVersionFound);
  101363. };
  101364. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  101365. // Put the scene into the database
  101366. var addRequest = transaction.objectStore("versions").put(newVersion);
  101367. addRequest.onsuccess = function () {
  101368. };
  101369. addRequest.onerror = function () {
  101370. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  101371. };
  101372. }
  101373. catch (ex) {
  101374. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  101375. callback(-1);
  101376. }
  101377. }
  101378. else {
  101379. callback(-1);
  101380. }
  101381. };
  101382. /**
  101383. * Loads a file from database
  101384. * @param url defines the URL to load from
  101385. * @param sceneLoaded defines a callback to call on success
  101386. * @param progressCallBack defines a callback to call when progress changed
  101387. * @param errorCallback defines a callback to call on error
  101388. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  101389. */
  101390. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  101391. var _this = this;
  101392. var completeUrl = Database._ReturnFullUrlLocation(url);
  101393. var saveAndLoadFile = function () {
  101394. // the scene is not yet in the DB, let's try to save it
  101395. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101396. };
  101397. this._checkVersionFromDB(completeUrl, function (version) {
  101398. if (version !== -1) {
  101399. if (!_this._mustUpdateRessources) {
  101400. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  101401. }
  101402. else {
  101403. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101404. }
  101405. }
  101406. else {
  101407. if (errorCallback) {
  101408. errorCallback();
  101409. }
  101410. }
  101411. });
  101412. };
  101413. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  101414. if (this._isSupported && this._db) {
  101415. var targetStore;
  101416. if (url.indexOf(".babylon") !== -1) {
  101417. targetStore = "scenes";
  101418. }
  101419. else {
  101420. targetStore = "textures";
  101421. }
  101422. var file;
  101423. var transaction = this._db.transaction([targetStore]);
  101424. transaction.oncomplete = function () {
  101425. if (file) {
  101426. callback(file.data);
  101427. }
  101428. // file was not found in DB
  101429. else {
  101430. notInDBCallback();
  101431. }
  101432. };
  101433. transaction.onabort = function () {
  101434. notInDBCallback();
  101435. };
  101436. var getRequest = transaction.objectStore(targetStore).get(url);
  101437. getRequest.onsuccess = function (event) {
  101438. file = (event.target).result;
  101439. };
  101440. getRequest.onerror = function () {
  101441. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  101442. notInDBCallback();
  101443. };
  101444. }
  101445. else {
  101446. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101447. callback();
  101448. }
  101449. };
  101450. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  101451. var _this = this;
  101452. if (this._isSupported) {
  101453. var targetStore;
  101454. if (url.indexOf(".babylon") !== -1) {
  101455. targetStore = "scenes";
  101456. }
  101457. else {
  101458. targetStore = "textures";
  101459. }
  101460. // Create XHR
  101461. var xhr = new XMLHttpRequest();
  101462. var fileData;
  101463. xhr.open("GET", url + "?" + Date.now(), true);
  101464. if (useArrayBuffer) {
  101465. xhr.responseType = "arraybuffer";
  101466. }
  101467. if (progressCallback) {
  101468. xhr.onprogress = progressCallback;
  101469. }
  101470. xhr.addEventListener("load", function () {
  101471. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  101472. // Blob as response (XHR2)
  101473. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  101474. if (!_this._hasReachedQuota && _this._db) {
  101475. // Open a transaction to the database
  101476. var transaction = _this._db.transaction([targetStore], "readwrite");
  101477. // the transaction could abort because of a QuotaExceededError error
  101478. transaction.onabort = function (event) {
  101479. try {
  101480. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101481. var error = event.srcElement['error'];
  101482. if (error && error.name === "QuotaExceededError") {
  101483. _this._hasReachedQuota = true;
  101484. }
  101485. }
  101486. catch (ex) { }
  101487. callback(fileData);
  101488. };
  101489. transaction.oncomplete = function () {
  101490. callback(fileData);
  101491. };
  101492. var newFile;
  101493. if (targetStore === "scenes") {
  101494. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  101495. }
  101496. else {
  101497. newFile = { textureUrl: url, data: fileData };
  101498. }
  101499. try {
  101500. // Put the scene into the database
  101501. var addRequest = transaction.objectStore(targetStore).put(newFile);
  101502. addRequest.onsuccess = function () {
  101503. };
  101504. addRequest.onerror = function () {
  101505. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  101506. };
  101507. }
  101508. catch (ex) {
  101509. callback(fileData);
  101510. }
  101511. }
  101512. else {
  101513. callback(fileData);
  101514. }
  101515. }
  101516. else {
  101517. if (xhr.status >= 400 && errorCallback) {
  101518. errorCallback(xhr);
  101519. }
  101520. else {
  101521. callback();
  101522. }
  101523. }
  101524. }, false);
  101525. xhr.addEventListener("error", function () {
  101526. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  101527. callback();
  101528. }, false);
  101529. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101530. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101531. }
  101532. xhr.send();
  101533. }
  101534. else {
  101535. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  101536. callback();
  101537. }
  101538. };
  101539. /**
  101540. * Validates if xhr data is correct
  101541. * @param xhr defines the request to validate
  101542. * @param dataType defines the expected data type
  101543. * @returns true if data is correct
  101544. */
  101545. Database._ValidateXHRData = function (xhr, dataType) {
  101546. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  101547. if (dataType === void 0) { dataType = 7; }
  101548. try {
  101549. if (dataType & 1) {
  101550. if (xhr.responseText && xhr.responseText.length > 0) {
  101551. return true;
  101552. }
  101553. else if (dataType === 1) {
  101554. return false;
  101555. }
  101556. }
  101557. if (dataType & 2) {
  101558. // Check header width and height since there is no "TGA" magic number
  101559. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  101560. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  101561. return true;
  101562. }
  101563. else if (dataType === 2) {
  101564. return false;
  101565. }
  101566. }
  101567. if (dataType & 4) {
  101568. // Check for the "DDS" magic number
  101569. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  101570. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  101571. return true;
  101572. }
  101573. else {
  101574. return false;
  101575. }
  101576. }
  101577. }
  101578. catch (e) {
  101579. // Global protection
  101580. }
  101581. return false;
  101582. };
  101583. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  101584. Database.IsUASupportingBlobStorage = true;
  101585. /**
  101586. * Gets a boolean indicating if Database storate is enabled (off by default)
  101587. */
  101588. Database.IDBStorageEnabled = false;
  101589. Database._ParseURL = function (url) {
  101590. var a = document.createElement('a');
  101591. a.href = url;
  101592. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  101593. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  101594. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  101595. return absLocation;
  101596. };
  101597. Database._ReturnFullUrlLocation = function (url) {
  101598. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  101599. return (Database._ParseURL(window.location.href) + url);
  101600. }
  101601. else {
  101602. return url;
  101603. }
  101604. };
  101605. return Database;
  101606. }());
  101607. /***/ }),
  101608. /***/ "./Offline/index.ts":
  101609. /*!**************************!*\
  101610. !*** ./Offline/index.ts ***!
  101611. \**************************/
  101612. /*! exports provided: Database */
  101613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101614. "use strict";
  101615. __webpack_require__.r(__webpack_exports__);
  101616. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  101617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  101618. /***/ }),
  101619. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  101620. /*!******************************************************!*\
  101621. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  101622. \******************************************************/
  101623. /*! exports provided: BoxParticleEmitter */
  101624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101625. "use strict";
  101626. __webpack_require__.r(__webpack_exports__);
  101627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  101628. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101630. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101631. /**
  101632. * Particle emitter emitting particles from the inside of a box.
  101633. * It emits the particles randomly between 2 given directions.
  101634. */
  101635. var BoxParticleEmitter = /** @class */ (function () {
  101636. /**
  101637. * Creates a new instance BoxParticleEmitter
  101638. */
  101639. function BoxParticleEmitter() {
  101640. /**
  101641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101642. */
  101643. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101644. /**
  101645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101646. */
  101647. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101648. /**
  101649. * 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.
  101650. */
  101651. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  101652. /**
  101653. * 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.
  101654. */
  101655. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  101656. }
  101657. /**
  101658. * Called by the particle System when the direction is computed for the created particle.
  101659. * @param worldMatrix is the world matrix of the particle system
  101660. * @param directionToUpdate is the direction vector to update with the result
  101661. * @param particle is the particle we are computed the direction for
  101662. */
  101663. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101664. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101665. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101666. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101667. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101668. };
  101669. /**
  101670. * Called by the particle System when the position is computed for the created particle.
  101671. * @param worldMatrix is the world matrix of the particle system
  101672. * @param positionToUpdate is the position vector to update with the result
  101673. * @param particle is the particle we are computed the position for
  101674. */
  101675. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101676. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  101677. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  101678. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  101679. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101680. };
  101681. /**
  101682. * Clones the current emitter and returns a copy of it
  101683. * @returns the new emitter
  101684. */
  101685. BoxParticleEmitter.prototype.clone = function () {
  101686. var newOne = new BoxParticleEmitter();
  101687. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101688. return newOne;
  101689. };
  101690. /**
  101691. * Called by the GPUParticleSystem to setup the update shader
  101692. * @param effect defines the update shader
  101693. */
  101694. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  101695. effect.setVector3("direction1", this.direction1);
  101696. effect.setVector3("direction2", this.direction2);
  101697. effect.setVector3("minEmitBox", this.minEmitBox);
  101698. effect.setVector3("maxEmitBox", this.maxEmitBox);
  101699. };
  101700. /**
  101701. * Returns a string to use to update the GPU particles update shader
  101702. * @returns a string containng the defines string
  101703. */
  101704. BoxParticleEmitter.prototype.getEffectDefines = function () {
  101705. return "#define BOXEMITTER";
  101706. };
  101707. /**
  101708. * Returns the string "BoxParticleEmitter"
  101709. * @returns a string containing the class name
  101710. */
  101711. BoxParticleEmitter.prototype.getClassName = function () {
  101712. return "BoxParticleEmitter";
  101713. };
  101714. /**
  101715. * Serializes the particle system to a JSON object.
  101716. * @returns the JSON object
  101717. */
  101718. BoxParticleEmitter.prototype.serialize = function () {
  101719. var serializationObject = {};
  101720. serializationObject.type = this.getClassName();
  101721. serializationObject.direction1 = this.direction1.asArray();
  101722. serializationObject.direction2 = this.direction2.asArray();
  101723. serializationObject.minEmitBox = this.minEmitBox.asArray();
  101724. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  101725. return serializationObject;
  101726. };
  101727. /**
  101728. * Parse properties from a JSON object
  101729. * @param serializationObject defines the JSON object
  101730. */
  101731. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  101732. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101733. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101734. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  101735. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  101736. };
  101737. return BoxParticleEmitter;
  101738. }());
  101739. /***/ }),
  101740. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  101741. /*!*******************************************************!*\
  101742. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  101743. \*******************************************************/
  101744. /*! exports provided: ConeParticleEmitter */
  101745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101746. "use strict";
  101747. __webpack_require__.r(__webpack_exports__);
  101748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  101749. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101750. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101751. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101752. /**
  101753. * Particle emitter emitting particles from the inside of a cone.
  101754. * It emits the particles alongside the cone volume from the base to the particle.
  101755. * The emission direction might be randomized.
  101756. */
  101757. var ConeParticleEmitter = /** @class */ (function () {
  101758. /**
  101759. * Creates a new instance ConeParticleEmitter
  101760. * @param radius the radius of the emission cone (1 by default)
  101761. * @param angle the cone base angle (PI by default)
  101762. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101763. */
  101764. function ConeParticleEmitter(radius, angle,
  101765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101766. directionRandomizer) {
  101767. if (radius === void 0) { radius = 1; }
  101768. if (angle === void 0) { angle = Math.PI; }
  101769. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101770. this.directionRandomizer = directionRandomizer;
  101771. /**
  101772. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101773. */
  101774. this.radiusRange = 1;
  101775. /**
  101776. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101777. */
  101778. this.heightRange = 1;
  101779. /**
  101780. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101781. */
  101782. this.emitFromSpawnPointOnly = false;
  101783. this.angle = angle;
  101784. this.radius = radius;
  101785. }
  101786. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  101787. /**
  101788. * Gets or sets the radius of the emission cone
  101789. */
  101790. get: function () {
  101791. return this._radius;
  101792. },
  101793. set: function (value) {
  101794. this._radius = value;
  101795. this._buildHeight();
  101796. },
  101797. enumerable: true,
  101798. configurable: true
  101799. });
  101800. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101801. /**
  101802. * Gets or sets the angle of the emission cone
  101803. */
  101804. get: function () {
  101805. return this._angle;
  101806. },
  101807. set: function (value) {
  101808. this._angle = value;
  101809. this._buildHeight();
  101810. },
  101811. enumerable: true,
  101812. configurable: true
  101813. });
  101814. ConeParticleEmitter.prototype._buildHeight = function () {
  101815. if (this._angle !== 0) {
  101816. this._height = this._radius / Math.tan(this._angle / 2);
  101817. }
  101818. else {
  101819. this._height = 1;
  101820. }
  101821. };
  101822. /**
  101823. * Called by the particle System when the direction is computed for the created particle.
  101824. * @param worldMatrix is the world matrix of the particle system
  101825. * @param directionToUpdate is the direction vector to update with the result
  101826. * @param particle is the particle we are computed the direction for
  101827. */
  101828. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101829. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  101830. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  101831. }
  101832. else {
  101833. // measure the direction Vector from the emitter to the particle.
  101834. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101835. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101836. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101837. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101838. direction.x += randX;
  101839. direction.y += randY;
  101840. direction.z += randZ;
  101841. direction.normalize();
  101842. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101843. }
  101844. };
  101845. /**
  101846. * Called by the particle System when the position is computed for the created particle.
  101847. * @param worldMatrix is the world matrix of the particle system
  101848. * @param positionToUpdate is the position vector to update with the result
  101849. * @param particle is the particle we are computed the position for
  101850. */
  101851. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101852. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  101853. var h;
  101854. if (!this.emitFromSpawnPointOnly) {
  101855. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  101856. // Better distribution in a cone at normal angles.
  101857. h = 1 - h * h;
  101858. }
  101859. else {
  101860. h = 0.0001;
  101861. }
  101862. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  101863. radius = radius * h;
  101864. var randX = radius * Math.sin(s);
  101865. var randZ = radius * Math.cos(s);
  101866. var randY = h * this._height;
  101867. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101868. };
  101869. /**
  101870. * Clones the current emitter and returns a copy of it
  101871. * @returns the new emitter
  101872. */
  101873. ConeParticleEmitter.prototype.clone = function () {
  101874. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  101875. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101876. return newOne;
  101877. };
  101878. /**
  101879. * Called by the GPUParticleSystem to setup the update shader
  101880. * @param effect defines the update shader
  101881. */
  101882. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  101883. effect.setFloat2("radius", this._radius, this.radiusRange);
  101884. effect.setFloat("coneAngle", this._angle);
  101885. effect.setFloat2("height", this._height, this.heightRange);
  101886. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101887. };
  101888. /**
  101889. * Returns a string to use to update the GPU particles update shader
  101890. * @returns a string containng the defines string
  101891. */
  101892. ConeParticleEmitter.prototype.getEffectDefines = function () {
  101893. var defines = "#define CONEEMITTER";
  101894. if (this.emitFromSpawnPointOnly) {
  101895. defines += "\n#define CONEEMITTERSPAWNPOINT";
  101896. }
  101897. return defines;
  101898. };
  101899. /**
  101900. * Returns the string "ConeParticleEmitter"
  101901. * @returns a string containing the class name
  101902. */
  101903. ConeParticleEmitter.prototype.getClassName = function () {
  101904. return "ConeParticleEmitter";
  101905. };
  101906. /**
  101907. * Serializes the particle system to a JSON object.
  101908. * @returns the JSON object
  101909. */
  101910. ConeParticleEmitter.prototype.serialize = function () {
  101911. var serializationObject = {};
  101912. serializationObject.type = this.getClassName();
  101913. serializationObject.radius = this._radius;
  101914. serializationObject.angle = this._angle;
  101915. serializationObject.directionRandomizer = this.directionRandomizer;
  101916. return serializationObject;
  101917. };
  101918. /**
  101919. * Parse properties from a JSON object
  101920. * @param serializationObject defines the JSON object
  101921. */
  101922. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  101923. this.radius = serializationObject.radius;
  101924. this.angle = serializationObject.angle;
  101925. this.directionRandomizer = serializationObject.directionRandomizer;
  101926. };
  101927. return ConeParticleEmitter;
  101928. }());
  101929. /***/ }),
  101930. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  101931. /*!***********************************************************!*\
  101932. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  101933. \***********************************************************/
  101934. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  101935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101936. "use strict";
  101937. __webpack_require__.r(__webpack_exports__);
  101938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  101939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  101940. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101941. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101942. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101943. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101944. /**
  101945. * Particle emitter emitting particles from the inside of a cylinder.
  101946. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101947. */
  101948. var CylinderParticleEmitter = /** @class */ (function () {
  101949. /**
  101950. * Creates a new instance CylinderParticleEmitter
  101951. * @param radius the radius of the emission cylinder (1 by default)
  101952. * @param height the height of the emission cylinder (1 by default)
  101953. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101954. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101955. */
  101956. function CylinderParticleEmitter(
  101957. /**
  101958. * The radius of the emission cylinder.
  101959. */
  101960. radius,
  101961. /**
  101962. * The height of the emission cylinder.
  101963. */
  101964. height,
  101965. /**
  101966. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101967. */
  101968. radiusRange,
  101969. /**
  101970. * How much to randomize the particle direction [0-1].
  101971. */
  101972. directionRandomizer) {
  101973. if (radius === void 0) { radius = 1; }
  101974. if (height === void 0) { height = 1; }
  101975. if (radiusRange === void 0) { radiusRange = 1; }
  101976. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101977. this.radius = radius;
  101978. this.height = height;
  101979. this.radiusRange = radiusRange;
  101980. this.directionRandomizer = directionRandomizer;
  101981. }
  101982. /**
  101983. * Called by the particle System when the direction is computed for the created particle.
  101984. * @param worldMatrix is the world matrix of the particle system
  101985. * @param directionToUpdate is the direction vector to update with the result
  101986. * @param particle is the particle we are computed the direction for
  101987. */
  101988. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101989. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101990. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  101991. var angle = Math.atan2(direction.x, direction.z);
  101992. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  101993. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  101994. direction.x = Math.sin(angle);
  101995. direction.z = Math.cos(angle);
  101996. direction.normalize();
  101997. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101998. };
  101999. /**
  102000. * Called by the particle System when the position is computed for the created particle.
  102001. * @param worldMatrix is the world matrix of the particle system
  102002. * @param positionToUpdate is the position vector to update with the result
  102003. * @param particle is the particle we are computed the position for
  102004. */
  102005. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102006. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  102007. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102008. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  102009. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  102010. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  102011. var xPos = positionRadius * Math.cos(angle);
  102012. var zPos = positionRadius * Math.sin(angle);
  102013. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  102014. };
  102015. /**
  102016. * Clones the current emitter and returns a copy of it
  102017. * @returns the new emitter
  102018. */
  102019. CylinderParticleEmitter.prototype.clone = function () {
  102020. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  102021. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102022. return newOne;
  102023. };
  102024. /**
  102025. * Called by the GPUParticleSystem to setup the update shader
  102026. * @param effect defines the update shader
  102027. */
  102028. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  102029. effect.setFloat("radius", this.radius);
  102030. effect.setFloat("height", this.height);
  102031. effect.setFloat("radiusRange", this.radiusRange);
  102032. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102033. };
  102034. /**
  102035. * Returns a string to use to update the GPU particles update shader
  102036. * @returns a string containng the defines string
  102037. */
  102038. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  102039. return "#define CYLINDEREMITTER";
  102040. };
  102041. /**
  102042. * Returns the string "CylinderParticleEmitter"
  102043. * @returns a string containing the class name
  102044. */
  102045. CylinderParticleEmitter.prototype.getClassName = function () {
  102046. return "CylinderParticleEmitter";
  102047. };
  102048. /**
  102049. * Serializes the particle system to a JSON object.
  102050. * @returns the JSON object
  102051. */
  102052. CylinderParticleEmitter.prototype.serialize = function () {
  102053. var serializationObject = {};
  102054. serializationObject.type = this.getClassName();
  102055. serializationObject.radius = this.radius;
  102056. serializationObject.height = this.height;
  102057. serializationObject.radiusRange = this.radiusRange;
  102058. serializationObject.directionRandomizer = this.directionRandomizer;
  102059. return serializationObject;
  102060. };
  102061. /**
  102062. * Parse properties from a JSON object
  102063. * @param serializationObject defines the JSON object
  102064. */
  102065. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  102066. this.radius = serializationObject.radius;
  102067. this.height = serializationObject.height;
  102068. this.radiusRange = serializationObject.radiusRange;
  102069. this.directionRandomizer = serializationObject.directionRandomizer;
  102070. };
  102071. return CylinderParticleEmitter;
  102072. }());
  102073. /**
  102074. * Particle emitter emitting particles from the inside of a cylinder.
  102075. * It emits the particles randomly between two vectors.
  102076. */
  102077. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  102078. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  102079. /**
  102080. * Creates a new instance CylinderDirectedParticleEmitter
  102081. * @param radius the radius of the emission cylinder (1 by default)
  102082. * @param height the height of the emission cylinder (1 by default)
  102083. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102084. * @param direction1 the min limit of the emission direction (up vector by default)
  102085. * @param direction2 the max limit of the emission direction (up vector by default)
  102086. */
  102087. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  102088. /**
  102089. * The min limit of the emission direction.
  102090. */
  102091. direction1,
  102092. /**
  102093. * The max limit of the emission direction.
  102094. */
  102095. direction2) {
  102096. if (radius === void 0) { radius = 1; }
  102097. if (height === void 0) { height = 1; }
  102098. if (radiusRange === void 0) { radiusRange = 1; }
  102099. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102100. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102101. var _this = _super.call(this, radius, height, radiusRange) || this;
  102102. _this.direction1 = direction1;
  102103. _this.direction2 = direction2;
  102104. return _this;
  102105. }
  102106. /**
  102107. * Called by the particle System when the direction is computed for the created particle.
  102108. * @param worldMatrix is the world matrix of the particle system
  102109. * @param directionToUpdate is the direction vector to update with the result
  102110. * @param particle is the particle we are computed the direction for
  102111. */
  102112. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102113. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102114. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102115. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102116. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102117. };
  102118. /**
  102119. * Clones the current emitter and returns a copy of it
  102120. * @returns the new emitter
  102121. */
  102122. CylinderDirectedParticleEmitter.prototype.clone = function () {
  102123. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  102124. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102125. return newOne;
  102126. };
  102127. /**
  102128. * Called by the GPUParticleSystem to setup the update shader
  102129. * @param effect defines the update shader
  102130. */
  102131. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102132. effect.setFloat("radius", this.radius);
  102133. effect.setFloat("height", this.height);
  102134. effect.setFloat("radiusRange", this.radiusRange);
  102135. effect.setVector3("direction1", this.direction1);
  102136. effect.setVector3("direction2", this.direction2);
  102137. };
  102138. /**
  102139. * Returns a string to use to update the GPU particles update shader
  102140. * @returns a string containng the defines string
  102141. */
  102142. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102143. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  102144. };
  102145. /**
  102146. * Returns the string "CylinderDirectedParticleEmitter"
  102147. * @returns a string containing the class name
  102148. */
  102149. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  102150. return "CylinderDirectedParticleEmitter";
  102151. };
  102152. /**
  102153. * Serializes the particle system to a JSON object.
  102154. * @returns the JSON object
  102155. */
  102156. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  102157. var serializationObject = _super.prototype.serialize.call(this);
  102158. serializationObject.direction1 = this.direction1.asArray();
  102159. serializationObject.direction2 = this.direction2.asArray();
  102160. return serializationObject;
  102161. };
  102162. /**
  102163. * Parse properties from a JSON object
  102164. * @param serializationObject defines the JSON object
  102165. */
  102166. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102167. _super.prototype.parse.call(this, serializationObject);
  102168. this.direction1.copyFrom(serializationObject.direction1);
  102169. this.direction2.copyFrom(serializationObject.direction2);
  102170. };
  102171. return CylinderDirectedParticleEmitter;
  102172. }(CylinderParticleEmitter));
  102173. /***/ }),
  102174. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  102175. /*!**************************************************************!*\
  102176. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  102177. \**************************************************************/
  102178. /*! exports provided: HemisphericParticleEmitter */
  102179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102180. "use strict";
  102181. __webpack_require__.r(__webpack_exports__);
  102182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  102183. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102184. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102185. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102186. /**
  102187. * Particle emitter emitting particles from the inside of a hemisphere.
  102188. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  102189. */
  102190. var HemisphericParticleEmitter = /** @class */ (function () {
  102191. /**
  102192. * Creates a new instance HemisphericParticleEmitter
  102193. * @param radius the radius of the emission hemisphere (1 by default)
  102194. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102195. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102196. */
  102197. function HemisphericParticleEmitter(
  102198. /**
  102199. * The radius of the emission hemisphere.
  102200. */
  102201. radius,
  102202. /**
  102203. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102204. */
  102205. radiusRange,
  102206. /**
  102207. * How much to randomize the particle direction [0-1].
  102208. */
  102209. directionRandomizer) {
  102210. if (radius === void 0) { radius = 1; }
  102211. if (radiusRange === void 0) { radiusRange = 1; }
  102212. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102213. this.radius = radius;
  102214. this.radiusRange = radiusRange;
  102215. this.directionRandomizer = directionRandomizer;
  102216. }
  102217. /**
  102218. * Called by the particle System when the direction is computed for the created particle.
  102219. * @param worldMatrix is the world matrix of the particle system
  102220. * @param directionToUpdate is the direction vector to update with the result
  102221. * @param particle is the particle we are computed the direction for
  102222. */
  102223. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102224. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102225. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102226. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102227. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102228. direction.x += randX;
  102229. direction.y += randY;
  102230. direction.z += randZ;
  102231. direction.normalize();
  102232. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102233. };
  102234. /**
  102235. * Called by the particle System when the position is computed for the created particle.
  102236. * @param worldMatrix is the world matrix of the particle system
  102237. * @param positionToUpdate is the position vector to update with the result
  102238. * @param particle is the particle we are computed the position for
  102239. */
  102240. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102241. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102242. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102243. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102244. var theta = Math.acos(2 * v - 1);
  102245. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102246. var randY = randRadius * Math.cos(theta);
  102247. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102248. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  102249. };
  102250. /**
  102251. * Clones the current emitter and returns a copy of it
  102252. * @returns the new emitter
  102253. */
  102254. HemisphericParticleEmitter.prototype.clone = function () {
  102255. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  102256. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102257. return newOne;
  102258. };
  102259. /**
  102260. * Called by the GPUParticleSystem to setup the update shader
  102261. * @param effect defines the update shader
  102262. */
  102263. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  102264. effect.setFloat("radius", this.radius);
  102265. effect.setFloat("radiusRange", this.radiusRange);
  102266. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102267. };
  102268. /**
  102269. * Returns a string to use to update the GPU particles update shader
  102270. * @returns a string containng the defines string
  102271. */
  102272. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  102273. return "#define HEMISPHERICEMITTER";
  102274. };
  102275. /**
  102276. * Returns the string "HemisphericParticleEmitter"
  102277. * @returns a string containing the class name
  102278. */
  102279. HemisphericParticleEmitter.prototype.getClassName = function () {
  102280. return "HemisphericParticleEmitter";
  102281. };
  102282. /**
  102283. * Serializes the particle system to a JSON object.
  102284. * @returns the JSON object
  102285. */
  102286. HemisphericParticleEmitter.prototype.serialize = function () {
  102287. var serializationObject = {};
  102288. serializationObject.type = this.getClassName();
  102289. serializationObject.radius = this.radius;
  102290. serializationObject.radiusRange = this.radiusRange;
  102291. serializationObject.directionRandomizer = this.directionRandomizer;
  102292. return serializationObject;
  102293. };
  102294. /**
  102295. * Parse properties from a JSON object
  102296. * @param serializationObject defines the JSON object
  102297. */
  102298. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  102299. this.radius = serializationObject.radius;
  102300. this.radiusRange = serializationObject.radiusRange;
  102301. this.directionRandomizer = serializationObject.directionRandomizer;
  102302. };
  102303. return HemisphericParticleEmitter;
  102304. }());
  102305. /***/ }),
  102306. /***/ "./Particles/EmitterTypes/index.ts":
  102307. /*!*****************************************!*\
  102308. !*** ./Particles/EmitterTypes/index.ts ***!
  102309. \*****************************************/
  102310. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  102311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102312. "use strict";
  102313. __webpack_require__.r(__webpack_exports__);
  102314. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  102316. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  102317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  102318. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  102319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  102320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  102321. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  102322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  102323. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  102324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  102325. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  102326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  102327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  102328. /***/ }),
  102329. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  102330. /*!********************************************************!*\
  102331. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  102332. \********************************************************/
  102333. /*! exports provided: PointParticleEmitter */
  102334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102335. "use strict";
  102336. __webpack_require__.r(__webpack_exports__);
  102337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  102338. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102339. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102340. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102341. /**
  102342. * Particle emitter emitting particles from a point.
  102343. * It emits the particles randomly between 2 given directions.
  102344. */
  102345. var PointParticleEmitter = /** @class */ (function () {
  102346. /**
  102347. * Creates a new instance PointParticleEmitter
  102348. */
  102349. function PointParticleEmitter() {
  102350. /**
  102351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102352. */
  102353. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102354. /**
  102355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102356. */
  102357. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102358. }
  102359. /**
  102360. * Called by the particle System when the direction is computed for the created particle.
  102361. * @param worldMatrix is the world matrix of the particle system
  102362. * @param directionToUpdate is the direction vector to update with the result
  102363. * @param particle is the particle we are computed the direction for
  102364. */
  102365. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102366. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102367. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102368. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102369. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102370. };
  102371. /**
  102372. * Called by the particle System when the position is computed for the created particle.
  102373. * @param worldMatrix is the world matrix of the particle system
  102374. * @param positionToUpdate is the position vector to update with the result
  102375. * @param particle is the particle we are computed the position for
  102376. */
  102377. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102378. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  102379. };
  102380. /**
  102381. * Clones the current emitter and returns a copy of it
  102382. * @returns the new emitter
  102383. */
  102384. PointParticleEmitter.prototype.clone = function () {
  102385. var newOne = new PointParticleEmitter();
  102386. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102387. return newOne;
  102388. };
  102389. /**
  102390. * Called by the GPUParticleSystem to setup the update shader
  102391. * @param effect defines the update shader
  102392. */
  102393. PointParticleEmitter.prototype.applyToShader = function (effect) {
  102394. effect.setVector3("direction1", this.direction1);
  102395. effect.setVector3("direction2", this.direction2);
  102396. };
  102397. /**
  102398. * Returns a string to use to update the GPU particles update shader
  102399. * @returns a string containng the defines string
  102400. */
  102401. PointParticleEmitter.prototype.getEffectDefines = function () {
  102402. return "#define POINTEMITTER";
  102403. };
  102404. /**
  102405. * Returns the string "PointParticleEmitter"
  102406. * @returns a string containing the class name
  102407. */
  102408. PointParticleEmitter.prototype.getClassName = function () {
  102409. return "PointParticleEmitter";
  102410. };
  102411. /**
  102412. * Serializes the particle system to a JSON object.
  102413. * @returns the JSON object
  102414. */
  102415. PointParticleEmitter.prototype.serialize = function () {
  102416. var serializationObject = {};
  102417. serializationObject.type = this.getClassName();
  102418. serializationObject.direction1 = this.direction1.asArray();
  102419. serializationObject.direction2 = this.direction2.asArray();
  102420. return serializationObject;
  102421. };
  102422. /**
  102423. * Parse properties from a JSON object
  102424. * @param serializationObject defines the JSON object
  102425. */
  102426. PointParticleEmitter.prototype.parse = function (serializationObject) {
  102427. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102428. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102429. };
  102430. return PointParticleEmitter;
  102431. }());
  102432. /***/ }),
  102433. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  102434. /*!*********************************************************!*\
  102435. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  102436. \*********************************************************/
  102437. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  102438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102439. "use strict";
  102440. __webpack_require__.r(__webpack_exports__);
  102441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  102442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  102443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102444. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102445. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102446. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102447. /**
  102448. * Particle emitter emitting particles from the inside of a sphere.
  102449. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102450. */
  102451. var SphereParticleEmitter = /** @class */ (function () {
  102452. /**
  102453. * Creates a new instance SphereParticleEmitter
  102454. * @param radius the radius of the emission sphere (1 by default)
  102455. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102456. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102457. */
  102458. function SphereParticleEmitter(
  102459. /**
  102460. * The radius of the emission sphere.
  102461. */
  102462. radius,
  102463. /**
  102464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102465. */
  102466. radiusRange,
  102467. /**
  102468. * How much to randomize the particle direction [0-1].
  102469. */
  102470. directionRandomizer) {
  102471. if (radius === void 0) { radius = 1; }
  102472. if (radiusRange === void 0) { radiusRange = 1; }
  102473. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102474. this.radius = radius;
  102475. this.radiusRange = radiusRange;
  102476. this.directionRandomizer = directionRandomizer;
  102477. }
  102478. /**
  102479. * Called by the particle System when the direction is computed for the created particle.
  102480. * @param worldMatrix is the world matrix of the particle system
  102481. * @param directionToUpdate is the direction vector to update with the result
  102482. * @param particle is the particle we are computed the direction for
  102483. */
  102484. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102485. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102486. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102487. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102488. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102489. direction.x += randX;
  102490. direction.y += randY;
  102491. direction.z += randZ;
  102492. direction.normalize();
  102493. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102494. };
  102495. /**
  102496. * Called by the particle System when the position is computed for the created particle.
  102497. * @param worldMatrix is the world matrix of the particle system
  102498. * @param positionToUpdate is the position vector to update with the result
  102499. * @param particle is the particle we are computed the position for
  102500. */
  102501. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102502. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102503. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102504. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102505. var theta = Math.acos(2 * v - 1);
  102506. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102507. var randY = randRadius * Math.cos(theta);
  102508. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102509. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102510. };
  102511. /**
  102512. * Clones the current emitter and returns a copy of it
  102513. * @returns the new emitter
  102514. */
  102515. SphereParticleEmitter.prototype.clone = function () {
  102516. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  102517. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102518. return newOne;
  102519. };
  102520. /**
  102521. * Called by the GPUParticleSystem to setup the update shader
  102522. * @param effect defines the update shader
  102523. */
  102524. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  102525. effect.setFloat("radius", this.radius);
  102526. effect.setFloat("radiusRange", this.radiusRange);
  102527. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102528. };
  102529. /**
  102530. * Returns a string to use to update the GPU particles update shader
  102531. * @returns a string containng the defines string
  102532. */
  102533. SphereParticleEmitter.prototype.getEffectDefines = function () {
  102534. return "#define SPHEREEMITTER";
  102535. };
  102536. /**
  102537. * Returns the string "SphereParticleEmitter"
  102538. * @returns a string containing the class name
  102539. */
  102540. SphereParticleEmitter.prototype.getClassName = function () {
  102541. return "SphereParticleEmitter";
  102542. };
  102543. /**
  102544. * Serializes the particle system to a JSON object.
  102545. * @returns the JSON object
  102546. */
  102547. SphereParticleEmitter.prototype.serialize = function () {
  102548. var serializationObject = {};
  102549. serializationObject.type = this.getClassName();
  102550. serializationObject.radius = this.radius;
  102551. serializationObject.radiusRange = this.radiusRange;
  102552. serializationObject.directionRandomizer = this.directionRandomizer;
  102553. return serializationObject;
  102554. };
  102555. /**
  102556. * Parse properties from a JSON object
  102557. * @param serializationObject defines the JSON object
  102558. */
  102559. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  102560. this.radius = serializationObject.radius;
  102561. this.radiusRange = serializationObject.radiusRange;
  102562. this.directionRandomizer = serializationObject.directionRandomizer;
  102563. };
  102564. return SphereParticleEmitter;
  102565. }());
  102566. /**
  102567. * Particle emitter emitting particles from the inside of a sphere.
  102568. * It emits the particles randomly between two vectors.
  102569. */
  102570. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  102571. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  102572. /**
  102573. * Creates a new instance SphereDirectedParticleEmitter
  102574. * @param radius the radius of the emission sphere (1 by default)
  102575. * @param direction1 the min limit of the emission direction (up vector by default)
  102576. * @param direction2 the max limit of the emission direction (up vector by default)
  102577. */
  102578. function SphereDirectedParticleEmitter(radius,
  102579. /**
  102580. * The min limit of the emission direction.
  102581. */
  102582. direction1,
  102583. /**
  102584. * The max limit of the emission direction.
  102585. */
  102586. direction2) {
  102587. if (radius === void 0) { radius = 1; }
  102588. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102589. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102590. var _this = _super.call(this, radius) || this;
  102591. _this.direction1 = direction1;
  102592. _this.direction2 = direction2;
  102593. return _this;
  102594. }
  102595. /**
  102596. * Called by the particle System when the direction is computed for the created particle.
  102597. * @param worldMatrix is the world matrix of the particle system
  102598. * @param directionToUpdate is the direction vector to update with the result
  102599. * @param particle is the particle we are computed the direction for
  102600. */
  102601. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102602. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102603. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102604. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102605. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102606. };
  102607. /**
  102608. * Clones the current emitter and returns a copy of it
  102609. * @returns the new emitter
  102610. */
  102611. SphereDirectedParticleEmitter.prototype.clone = function () {
  102612. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  102613. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102614. return newOne;
  102615. };
  102616. /**
  102617. * Called by the GPUParticleSystem to setup the update shader
  102618. * @param effect defines the update shader
  102619. */
  102620. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102621. effect.setFloat("radius", this.radius);
  102622. effect.setFloat("radiusRange", this.radiusRange);
  102623. effect.setVector3("direction1", this.direction1);
  102624. effect.setVector3("direction2", this.direction2);
  102625. };
  102626. /**
  102627. * Returns a string to use to update the GPU particles update shader
  102628. * @returns a string containng the defines string
  102629. */
  102630. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102631. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  102632. };
  102633. /**
  102634. * Returns the string "SphereDirectedParticleEmitter"
  102635. * @returns a string containing the class name
  102636. */
  102637. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  102638. return "SphereDirectedParticleEmitter";
  102639. };
  102640. /**
  102641. * Serializes the particle system to a JSON object.
  102642. * @returns the JSON object
  102643. */
  102644. SphereDirectedParticleEmitter.prototype.serialize = function () {
  102645. var serializationObject = _super.prototype.serialize.call(this);
  102646. serializationObject.direction1 = this.direction1.asArray();
  102647. serializationObject.direction2 = this.direction2.asArray();
  102648. return serializationObject;
  102649. };
  102650. /**
  102651. * Parse properties from a JSON object
  102652. * @param serializationObject defines the JSON object
  102653. */
  102654. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102655. _super.prototype.parse.call(this, serializationObject);
  102656. this.direction1.copyFrom(serializationObject.direction1);
  102657. this.direction2.copyFrom(serializationObject.direction2);
  102658. };
  102659. return SphereDirectedParticleEmitter;
  102660. }(SphereParticleEmitter));
  102661. /***/ }),
  102662. /***/ "./Particles/baseParticleSystem.ts":
  102663. /*!*****************************************!*\
  102664. !*** ./Particles/baseParticleSystem.ts ***!
  102665. \*****************************************/
  102666. /*! exports provided: BaseParticleSystem */
  102667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102668. "use strict";
  102669. __webpack_require__.r(__webpack_exports__);
  102670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  102671. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102672. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102673. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  102674. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102675. /**
  102676. * This represents the base class for particle system in Babylon.
  102677. * 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.
  102678. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  102679. * @example https://doc.babylonjs.com/babylon101/particles
  102680. */
  102681. var BaseParticleSystem = /** @class */ (function () {
  102682. /**
  102683. * Instantiates a particle system.
  102684. * 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.
  102685. * @param name The name of the particle system
  102686. */
  102687. function BaseParticleSystem(name) {
  102688. /**
  102689. * List of animations used by the particle system.
  102690. */
  102691. this.animations = [];
  102692. /**
  102693. * The rendering group used by the Particle system to chose when to render.
  102694. */
  102695. this.renderingGroupId = 0;
  102696. /**
  102697. * The emitter represents the Mesh or position we are attaching the particle system to.
  102698. */
  102699. this.emitter = null;
  102700. /**
  102701. * The maximum number of particles to emit per frame
  102702. */
  102703. this.emitRate = 10;
  102704. /**
  102705. * If you want to launch only a few particles at once, that can be done, as well.
  102706. */
  102707. this.manualEmitCount = -1;
  102708. /**
  102709. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102710. */
  102711. this.updateSpeed = 0.01;
  102712. /**
  102713. * The amount of time the particle system is running (depends of the overall update speed).
  102714. */
  102715. this.targetStopDuration = 0;
  102716. /**
  102717. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102718. */
  102719. this.disposeOnStop = false;
  102720. /**
  102721. * Minimum power of emitting particles.
  102722. */
  102723. this.minEmitPower = 1;
  102724. /**
  102725. * Maximum power of emitting particles.
  102726. */
  102727. this.maxEmitPower = 1;
  102728. /**
  102729. * Minimum life time of emitting particles.
  102730. */
  102731. this.minLifeTime = 1;
  102732. /**
  102733. * Maximum life time of emitting particles.
  102734. */
  102735. this.maxLifeTime = 1;
  102736. /**
  102737. * Minimum Size of emitting particles.
  102738. */
  102739. this.minSize = 1;
  102740. /**
  102741. * Maximum Size of emitting particles.
  102742. */
  102743. this.maxSize = 1;
  102744. /**
  102745. * Minimum scale of emitting particles on X axis.
  102746. */
  102747. this.minScaleX = 1;
  102748. /**
  102749. * Maximum scale of emitting particles on X axis.
  102750. */
  102751. this.maxScaleX = 1;
  102752. /**
  102753. * Minimum scale of emitting particles on Y axis.
  102754. */
  102755. this.minScaleY = 1;
  102756. /**
  102757. * Maximum scale of emitting particles on Y axis.
  102758. */
  102759. this.maxScaleY = 1;
  102760. /**
  102761. * Gets or sets the minimal initial rotation in radians.
  102762. */
  102763. this.minInitialRotation = 0;
  102764. /**
  102765. * Gets or sets the maximal initial rotation in radians.
  102766. */
  102767. this.maxInitialRotation = 0;
  102768. /**
  102769. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102770. */
  102771. this.minAngularSpeed = 0;
  102772. /**
  102773. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102774. */
  102775. this.maxAngularSpeed = 0;
  102776. /**
  102777. * The layer mask we are rendering the particles through.
  102778. */
  102779. this.layerMask = 0x0FFFFFFF;
  102780. /**
  102781. * This can help using your own shader to render the particle system.
  102782. * The according effect will be created
  102783. */
  102784. this.customShader = null;
  102785. /**
  102786. * By default particle system starts as soon as they are created. This prevents the
  102787. * automatic start to happen and let you decide when to start emitting particles.
  102788. */
  102789. this.preventAutoStart = false;
  102790. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102791. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102792. /**
  102793. * Callback triggered when the particle animation is ending.
  102794. */
  102795. this.onAnimationEnd = null;
  102796. /**
  102797. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102798. */
  102799. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102800. /**
  102801. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102802. * to override the particles.
  102803. */
  102804. this.forceDepthWrite = false;
  102805. /** 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 */
  102806. this.preWarmCycles = 0;
  102807. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102808. this.preWarmStepOffset = 1;
  102809. /**
  102810. * 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)
  102811. */
  102812. this.spriteCellChangeSpeed = 1;
  102813. /**
  102814. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102815. */
  102816. this.startSpriteCellID = 0;
  102817. /**
  102818. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102819. */
  102820. this.endSpriteCellID = 0;
  102821. /**
  102822. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102823. */
  102824. this.spriteCellWidth = 0;
  102825. /**
  102826. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102827. */
  102828. this.spriteCellHeight = 0;
  102829. /**
  102830. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102831. */
  102832. this.spriteRandomStartCell = false;
  102833. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102834. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102835. /**
  102836. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102837. */
  102838. this.beginAnimationOnStart = false;
  102839. /**
  102840. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102841. */
  102842. this.beginAnimationFrom = 0;
  102843. /**
  102844. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102845. */
  102846. this.beginAnimationTo = 60;
  102847. /**
  102848. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102849. */
  102850. this.beginAnimationLoop = false;
  102851. /**
  102852. * You can use gravity if you want to give an orientation to your particles.
  102853. */
  102854. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102855. this._colorGradients = null;
  102856. this._sizeGradients = null;
  102857. this._lifeTimeGradients = null;
  102858. this._angularSpeedGradients = null;
  102859. this._velocityGradients = null;
  102860. this._limitVelocityGradients = null;
  102861. this._dragGradients = null;
  102862. this._emitRateGradients = null;
  102863. this._startSizeGradients = null;
  102864. this._rampGradients = null;
  102865. this._colorRemapGradients = null;
  102866. this._alphaRemapGradients = null;
  102867. /**
  102868. * Defines the delay in milliseconds before starting the system (0 by default)
  102869. */
  102870. this.startDelay = 0;
  102871. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102872. this.limitVelocityDamping = 0.4;
  102873. /**
  102874. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102875. */
  102876. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102877. /**
  102878. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102879. */
  102880. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102881. /**
  102882. * Color the particle will have at the end of its lifetime
  102883. */
  102884. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  102885. /**
  102886. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  102887. */
  102888. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102889. /** @hidden */
  102890. this._isSubEmitter = false;
  102891. /**
  102892. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102893. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102894. */
  102895. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  102896. this._isBillboardBased = true;
  102897. /**
  102898. * Local cache of defines for image processing.
  102899. */
  102900. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  102901. this.id = name;
  102902. this.name = name;
  102903. }
  102904. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  102905. /**
  102906. * Gets or sets a texture used to add random noise to particle positions
  102907. */
  102908. get: function () {
  102909. return this._noiseTexture;
  102910. },
  102911. set: function (value) {
  102912. if (this._noiseTexture === value) {
  102913. return;
  102914. }
  102915. this._noiseTexture = value;
  102916. this._reset();
  102917. },
  102918. enumerable: true,
  102919. configurable: true
  102920. });
  102921. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  102922. /**
  102923. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  102924. */
  102925. get: function () {
  102926. return this._isAnimationSheetEnabled;
  102927. },
  102928. set: function (value) {
  102929. if (this._isAnimationSheetEnabled == value) {
  102930. return;
  102931. }
  102932. this._isAnimationSheetEnabled = value;
  102933. this._reset();
  102934. },
  102935. enumerable: true,
  102936. configurable: true
  102937. });
  102938. /**
  102939. * Get hosting scene
  102940. * @returns the scene
  102941. */
  102942. BaseParticleSystem.prototype.getScene = function () {
  102943. return this._scene;
  102944. };
  102945. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  102946. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  102947. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  102948. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  102949. };
  102950. /**
  102951. * Gets the current list of drag gradients.
  102952. * You must use addDragGradient and removeDragGradient to udpate this list
  102953. * @returns the list of drag gradients
  102954. */
  102955. BaseParticleSystem.prototype.getDragGradients = function () {
  102956. return this._dragGradients;
  102957. };
  102958. /**
  102959. * Gets the current list of limit velocity gradients.
  102960. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  102961. * @returns the list of limit velocity gradients
  102962. */
  102963. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  102964. return this._limitVelocityGradients;
  102965. };
  102966. /**
  102967. * Gets the current list of color gradients.
  102968. * You must use addColorGradient and removeColorGradient to udpate this list
  102969. * @returns the list of color gradients
  102970. */
  102971. BaseParticleSystem.prototype.getColorGradients = function () {
  102972. return this._colorGradients;
  102973. };
  102974. /**
  102975. * Gets the current list of size gradients.
  102976. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102977. * @returns the list of size gradients
  102978. */
  102979. BaseParticleSystem.prototype.getSizeGradients = function () {
  102980. return this._sizeGradients;
  102981. };
  102982. /**
  102983. * Gets the current list of color remap gradients.
  102984. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102985. * @returns the list of color remap gradients
  102986. */
  102987. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  102988. return this._colorRemapGradients;
  102989. };
  102990. /**
  102991. * Gets the current list of alpha remap gradients.
  102992. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102993. * @returns the list of alpha remap gradients
  102994. */
  102995. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  102996. return this._alphaRemapGradients;
  102997. };
  102998. /**
  102999. * Gets the current list of life time gradients.
  103000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  103001. * @returns the list of life time gradients
  103002. */
  103003. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  103004. return this._lifeTimeGradients;
  103005. };
  103006. /**
  103007. * Gets the current list of angular speed gradients.
  103008. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  103009. * @returns the list of angular speed gradients
  103010. */
  103011. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  103012. return this._angularSpeedGradients;
  103013. };
  103014. /**
  103015. * Gets the current list of velocity gradients.
  103016. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  103017. * @returns the list of velocity gradients
  103018. */
  103019. BaseParticleSystem.prototype.getVelocityGradients = function () {
  103020. return this._velocityGradients;
  103021. };
  103022. /**
  103023. * Gets the current list of start size gradients.
  103024. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  103025. * @returns the list of start size gradients
  103026. */
  103027. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  103028. return this._startSizeGradients;
  103029. };
  103030. /**
  103031. * Gets the current list of emit rate gradients.
  103032. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  103033. * @returns the list of emit rate gradients
  103034. */
  103035. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  103036. return this._emitRateGradients;
  103037. };
  103038. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  103039. /**
  103040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103041. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103042. */
  103043. get: function () {
  103044. if (this.particleEmitterType.direction1) {
  103045. return this.particleEmitterType.direction1;
  103046. }
  103047. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103048. },
  103049. set: function (value) {
  103050. if (this.particleEmitterType.direction1) {
  103051. this.particleEmitterType.direction1 = value;
  103052. }
  103053. },
  103054. enumerable: true,
  103055. configurable: true
  103056. });
  103057. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  103058. /**
  103059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103060. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103061. */
  103062. get: function () {
  103063. if (this.particleEmitterType.direction2) {
  103064. return this.particleEmitterType.direction2;
  103065. }
  103066. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103067. },
  103068. set: function (value) {
  103069. if (this.particleEmitterType.direction2) {
  103070. this.particleEmitterType.direction2 = value;
  103071. }
  103072. },
  103073. enumerable: true,
  103074. configurable: true
  103075. });
  103076. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  103077. /**
  103078. * 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.
  103079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103080. */
  103081. get: function () {
  103082. if (this.particleEmitterType.minEmitBox) {
  103083. return this.particleEmitterType.minEmitBox;
  103084. }
  103085. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103086. },
  103087. set: function (value) {
  103088. if (this.particleEmitterType.minEmitBox) {
  103089. this.particleEmitterType.minEmitBox = value;
  103090. }
  103091. },
  103092. enumerable: true,
  103093. configurable: true
  103094. });
  103095. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  103096. /**
  103097. * 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.
  103098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103099. */
  103100. get: function () {
  103101. if (this.particleEmitterType.maxEmitBox) {
  103102. return this.particleEmitterType.maxEmitBox;
  103103. }
  103104. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103105. },
  103106. set: function (value) {
  103107. if (this.particleEmitterType.maxEmitBox) {
  103108. this.particleEmitterType.maxEmitBox = value;
  103109. }
  103110. },
  103111. enumerable: true,
  103112. configurable: true
  103113. });
  103114. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  103115. /**
  103116. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  103117. */
  103118. get: function () {
  103119. return this._isBillboardBased;
  103120. },
  103121. set: function (value) {
  103122. if (this._isBillboardBased === value) {
  103123. return;
  103124. }
  103125. this._isBillboardBased = value;
  103126. this._reset();
  103127. },
  103128. enumerable: true,
  103129. configurable: true
  103130. });
  103131. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  103132. /**
  103133. * Gets the image processing configuration used either in this material.
  103134. */
  103135. get: function () {
  103136. return this._imageProcessingConfiguration;
  103137. },
  103138. /**
  103139. * Sets the Default image processing configuration used either in the this material.
  103140. *
  103141. * If sets to null, the scene one is in use.
  103142. */
  103143. set: function (value) {
  103144. this._attachImageProcessingConfiguration(value);
  103145. },
  103146. enumerable: true,
  103147. configurable: true
  103148. });
  103149. /**
  103150. * Attaches a new image processing configuration to the Standard Material.
  103151. * @param configuration
  103152. */
  103153. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  103154. if (configuration === this._imageProcessingConfiguration) {
  103155. return;
  103156. }
  103157. // Pick the scene configuration if needed.
  103158. if (!configuration) {
  103159. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  103160. }
  103161. else {
  103162. this._imageProcessingConfiguration = configuration;
  103163. }
  103164. };
  103165. /** @hidden */
  103166. BaseParticleSystem.prototype._reset = function () {
  103167. };
  103168. /** @hidden */
  103169. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103170. if (!gradients) {
  103171. return this;
  103172. }
  103173. var index = 0;
  103174. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  103175. var valueGradient = gradients_1[_i];
  103176. if (valueGradient.gradient === gradient) {
  103177. gradients.splice(index, 1);
  103178. break;
  103179. }
  103180. index++;
  103181. }
  103182. if (texture) {
  103183. texture.dispose();
  103184. }
  103185. return this;
  103186. };
  103187. /**
  103188. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  103189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103191. * @returns the emitter
  103192. */
  103193. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  103194. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  103195. particleEmitter.direction1 = direction1;
  103196. particleEmitter.direction2 = direction2;
  103197. this.particleEmitterType = particleEmitter;
  103198. return particleEmitter;
  103199. };
  103200. /**
  103201. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103202. * @param radius The radius of the hemisphere to emit from
  103203. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103204. * @returns the emitter
  103205. */
  103206. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  103207. if (radius === void 0) { radius = 1; }
  103208. if (radiusRange === void 0) { radiusRange = 1; }
  103209. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  103210. this.particleEmitterType = particleEmitter;
  103211. return particleEmitter;
  103212. };
  103213. /**
  103214. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103215. * @param radius The radius of the sphere to emit from
  103216. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103217. * @returns the emitter
  103218. */
  103219. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  103220. if (radius === void 0) { radius = 1; }
  103221. if (radiusRange === void 0) { radiusRange = 1; }
  103222. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  103223. this.particleEmitterType = particleEmitter;
  103224. return particleEmitter;
  103225. };
  103226. /**
  103227. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103228. * @param radius The radius of the sphere to emit from
  103229. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103230. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103231. * @returns the emitter
  103232. */
  103233. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  103234. if (radius === void 0) { radius = 1; }
  103235. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103236. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103237. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  103238. this.particleEmitterType = particleEmitter;
  103239. return particleEmitter;
  103240. };
  103241. /**
  103242. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103243. * @param radius The radius of the emission cylinder
  103244. * @param height The height of the emission cylinder
  103245. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103246. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103247. * @returns the emitter
  103248. */
  103249. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  103250. if (radius === void 0) { radius = 1; }
  103251. if (height === void 0) { height = 1; }
  103252. if (radiusRange === void 0) { radiusRange = 1; }
  103253. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103254. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  103255. this.particleEmitterType = particleEmitter;
  103256. return particleEmitter;
  103257. };
  103258. /**
  103259. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103260. * @param radius The radius of the cylinder to emit from
  103261. * @param height The height of the emission cylinder
  103262. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103265. * @returns the emitter
  103266. */
  103267. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  103268. if (radius === void 0) { radius = 1; }
  103269. if (height === void 0) { height = 1; }
  103270. if (radiusRange === void 0) { radiusRange = 1; }
  103271. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103272. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103273. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  103274. this.particleEmitterType = particleEmitter;
  103275. return particleEmitter;
  103276. };
  103277. /**
  103278. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103279. * @param radius The radius of the cone to emit from
  103280. * @param angle The base angle of the cone
  103281. * @returns the emitter
  103282. */
  103283. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  103284. if (radius === void 0) { radius = 1; }
  103285. if (angle === void 0) { angle = Math.PI / 4; }
  103286. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  103287. this.particleEmitterType = particleEmitter;
  103288. return particleEmitter;
  103289. };
  103290. /**
  103291. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103294. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103295. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103296. * @returns the emitter
  103297. */
  103298. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  103299. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  103300. this.particleEmitterType = particleEmitter;
  103301. this.direction1 = direction1;
  103302. this.direction2 = direction2;
  103303. this.minEmitBox = minEmitBox;
  103304. this.maxEmitBox = maxEmitBox;
  103305. return particleEmitter;
  103306. };
  103307. /**
  103308. * Source color is added to the destination color without alpha affecting the result
  103309. */
  103310. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  103311. /**
  103312. * Blend current color and particle color using particle’s alpha
  103313. */
  103314. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  103315. /**
  103316. * Add current color and particle color multiplied by particle’s alpha
  103317. */
  103318. BaseParticleSystem.BLENDMODE_ADD = 2;
  103319. /**
  103320. * Multiply current color with particle color
  103321. */
  103322. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  103323. /**
  103324. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  103325. */
  103326. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  103327. return BaseParticleSystem;
  103328. }());
  103329. /***/ }),
  103330. /***/ "./Particles/gpuParticleSystem.ts":
  103331. /*!****************************************!*\
  103332. !*** ./Particles/gpuParticleSystem.ts ***!
  103333. \****************************************/
  103334. /*! exports provided: GPUParticleSystem */
  103335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103336. "use strict";
  103337. __webpack_require__.r(__webpack_exports__);
  103338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  103339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103340. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103341. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103342. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103343. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103344. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103345. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103346. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103347. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103348. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  103349. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103350. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103351. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103352. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103353. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103354. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103355. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103357. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  103358. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  103359. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  103360. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  103361. /**
  103362. * This represents a GPU particle system in Babylon
  103363. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103364. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103365. */
  103366. var GPUParticleSystem = /** @class */ (function (_super) {
  103367. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  103368. /**
  103369. * Instantiates a GPU particle system.
  103370. * 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.
  103371. * @param name The name of the particle system
  103372. * @param options The options used to create the system
  103373. * @param scene The scene the particle system belongs to
  103374. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103375. */
  103376. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  103377. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103378. var _this = _super.call(this, name) || this;
  103379. /**
  103380. * The layer mask we are rendering the particles through.
  103381. */
  103382. _this.layerMask = 0x0FFFFFFF;
  103383. _this._accumulatedCount = 0;
  103384. _this._targetIndex = 0;
  103385. _this._currentRenderId = -1;
  103386. _this._started = false;
  103387. _this._stopped = false;
  103388. _this._timeDelta = 0;
  103389. _this._actualFrame = 0;
  103390. _this._rawTextureWidth = 256;
  103391. /**
  103392. * An event triggered when the system is disposed.
  103393. */
  103394. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103395. /**
  103396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103397. * to override the particles.
  103398. */
  103399. _this.forceDepthWrite = false;
  103400. _this._preWarmDone = false;
  103401. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  103402. // Setup the default processing configuration to the scene.
  103403. _this._attachImageProcessingConfiguration(null);
  103404. _this._engine = _this._scene.getEngine();
  103405. if (!options.randomTextureSize) {
  103406. delete options.randomTextureSize;
  103407. }
  103408. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  103409. var optionsAsNumber = options;
  103410. if (isFinite(optionsAsNumber)) {
  103411. fullOptions.capacity = optionsAsNumber;
  103412. }
  103413. _this._capacity = fullOptions.capacity;
  103414. _this._activeCount = fullOptions.capacity;
  103415. _this._currentActiveCount = 0;
  103416. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  103417. _this._scene.particleSystems.push(_this);
  103418. _this._updateEffectOptions = {
  103419. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  103420. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  103421. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  103422. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  103423. uniformBuffersNames: [],
  103424. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  103425. defines: "",
  103426. fallbacks: null,
  103427. onCompiled: null,
  103428. onError: null,
  103429. indexParameters: null,
  103430. maxSimultaneousLights: 0,
  103431. transformFeedbackVaryings: []
  103432. };
  103433. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  103434. // Random data
  103435. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  103436. var d = [];
  103437. for (var i = 0; i < maxTextureSize; ++i) {
  103438. d.push(Math.random());
  103439. d.push(Math.random());
  103440. d.push(Math.random());
  103441. d.push(Math.random());
  103442. }
  103443. _this._randomTexture = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURETYPE_FLOAT);
  103444. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103445. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103446. d = [];
  103447. for (var i = 0; i < maxTextureSize; ++i) {
  103448. d.push(Math.random());
  103449. d.push(Math.random());
  103450. d.push(Math.random());
  103451. d.push(Math.random());
  103452. }
  103453. _this._randomTexture2 = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURETYPE_FLOAT);
  103454. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103455. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103456. _this._randomTextureSize = maxTextureSize;
  103457. return _this;
  103458. }
  103459. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  103460. /**
  103461. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103462. */
  103463. get: function () {
  103464. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  103465. return false;
  103466. }
  103467. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  103468. },
  103469. enumerable: true,
  103470. configurable: true
  103471. });
  103472. /**
  103473. * Gets the maximum number of particles active at the same time.
  103474. * @returns The max number of active particles.
  103475. */
  103476. GPUParticleSystem.prototype.getCapacity = function () {
  103477. return this._capacity;
  103478. };
  103479. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  103480. /**
  103481. * Gets or set the number of active particles
  103482. */
  103483. get: function () {
  103484. return this._activeCount;
  103485. },
  103486. set: function (value) {
  103487. this._activeCount = Math.min(value, this._capacity);
  103488. },
  103489. enumerable: true,
  103490. configurable: true
  103491. });
  103492. /**
  103493. * Is this system ready to be used/rendered
  103494. * @return true if the system is ready
  103495. */
  103496. GPUParticleSystem.prototype.isReady = function () {
  103497. if (!this._updateEffect) {
  103498. this._recreateUpdateEffect();
  103499. this._recreateRenderEffect();
  103500. return false;
  103501. }
  103502. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  103503. return false;
  103504. }
  103505. return true;
  103506. };
  103507. /**
  103508. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103509. * @returns True if it has been started, otherwise false.
  103510. */
  103511. GPUParticleSystem.prototype.isStarted = function () {
  103512. return this._started;
  103513. };
  103514. /**
  103515. * Starts the particle system and begins to emit
  103516. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103517. */
  103518. GPUParticleSystem.prototype.start = function (delay) {
  103519. var _this = this;
  103520. if (delay === void 0) { delay = this.startDelay; }
  103521. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  103522. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  103523. }
  103524. if (delay) {
  103525. setTimeout(function () {
  103526. _this.start(0);
  103527. }, delay);
  103528. return;
  103529. }
  103530. this._started = true;
  103531. this._stopped = false;
  103532. this._preWarmDone = false;
  103533. // Animations
  103534. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  103535. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  103536. }
  103537. };
  103538. /**
  103539. * Stops the particle system.
  103540. */
  103541. GPUParticleSystem.prototype.stop = function () {
  103542. this._stopped = true;
  103543. };
  103544. /**
  103545. * Remove all active particles
  103546. */
  103547. GPUParticleSystem.prototype.reset = function () {
  103548. this._releaseBuffers();
  103549. this._releaseVAOs();
  103550. this._currentActiveCount = 0;
  103551. this._targetIndex = 0;
  103552. };
  103553. /**
  103554. * Returns the string "GPUParticleSystem"
  103555. * @returns a string containing the class name
  103556. */
  103557. GPUParticleSystem.prototype.getClassName = function () {
  103558. return "GPUParticleSystem";
  103559. };
  103560. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103561. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  103562. this._releaseBuffers();
  103563. return this;
  103564. };
  103565. /**
  103566. * Adds a new color gradient
  103567. * @param gradient defines the gradient to use (between 0 and 1)
  103568. * @param color1 defines the color to affect to the specified gradient
  103569. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103570. * @returns the current particle system
  103571. */
  103572. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  103573. if (!this._colorGradients) {
  103574. this._colorGradients = [];
  103575. }
  103576. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  103577. colorGradient.gradient = gradient;
  103578. colorGradient.color1 = color1;
  103579. this._colorGradients.push(colorGradient);
  103580. this._colorGradients.sort(function (a, b) {
  103581. if (a.gradient < b.gradient) {
  103582. return -1;
  103583. }
  103584. else if (a.gradient > b.gradient) {
  103585. return 1;
  103586. }
  103587. return 0;
  103588. });
  103589. if (this._colorGradientsTexture) {
  103590. this._colorGradientsTexture.dispose();
  103591. this._colorGradientsTexture = null;
  103592. }
  103593. this._releaseBuffers();
  103594. return this;
  103595. };
  103596. /**
  103597. * Remove a specific color gradient
  103598. * @param gradient defines the gradient to remove
  103599. * @returns the current particle system
  103600. */
  103601. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  103602. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  103603. this._colorGradientsTexture = null;
  103604. return this;
  103605. };
  103606. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  103607. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  103608. valueGradient.gradient = gradient;
  103609. valueGradient.factor1 = factor;
  103610. factorGradients.push(valueGradient);
  103611. factorGradients.sort(function (a, b) {
  103612. if (a.gradient < b.gradient) {
  103613. return -1;
  103614. }
  103615. else if (a.gradient > b.gradient) {
  103616. return 1;
  103617. }
  103618. return 0;
  103619. });
  103620. this._releaseBuffers();
  103621. };
  103622. /**
  103623. * Adds a new size gradient
  103624. * @param gradient defines the gradient to use (between 0 and 1)
  103625. * @param factor defines the size factor to affect to the specified gradient
  103626. * @returns the current particle system
  103627. */
  103628. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  103629. if (!this._sizeGradients) {
  103630. this._sizeGradients = [];
  103631. }
  103632. this._addFactorGradient(this._sizeGradients, gradient, factor);
  103633. if (this._sizeGradientsTexture) {
  103634. this._sizeGradientsTexture.dispose();
  103635. this._sizeGradientsTexture = null;
  103636. }
  103637. this._releaseBuffers();
  103638. return this;
  103639. };
  103640. /**
  103641. * Remove a specific size gradient
  103642. * @param gradient defines the gradient to remove
  103643. * @returns the current particle system
  103644. */
  103645. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  103646. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  103647. this._sizeGradientsTexture = null;
  103648. return this;
  103649. };
  103650. /**
  103651. * Adds a new angular speed gradient
  103652. * @param gradient defines the gradient to use (between 0 and 1)
  103653. * @param factor defines the angular speed to affect to the specified gradient
  103654. * @returns the current particle system
  103655. */
  103656. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  103657. if (!this._angularSpeedGradients) {
  103658. this._angularSpeedGradients = [];
  103659. }
  103660. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  103661. if (this._angularSpeedGradientsTexture) {
  103662. this._angularSpeedGradientsTexture.dispose();
  103663. this._angularSpeedGradientsTexture = null;
  103664. }
  103665. this._releaseBuffers();
  103666. return this;
  103667. };
  103668. /**
  103669. * Remove a specific angular speed gradient
  103670. * @param gradient defines the gradient to remove
  103671. * @returns the current particle system
  103672. */
  103673. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  103674. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  103675. this._angularSpeedGradientsTexture = null;
  103676. return this;
  103677. };
  103678. /**
  103679. * Adds a new velocity gradient
  103680. * @param gradient defines the gradient to use (between 0 and 1)
  103681. * @param factor defines the velocity to affect to the specified gradient
  103682. * @returns the current particle system
  103683. */
  103684. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  103685. if (!this._velocityGradients) {
  103686. this._velocityGradients = [];
  103687. }
  103688. this._addFactorGradient(this._velocityGradients, gradient, factor);
  103689. if (this._velocityGradientsTexture) {
  103690. this._velocityGradientsTexture.dispose();
  103691. this._velocityGradientsTexture = null;
  103692. }
  103693. this._releaseBuffers();
  103694. return this;
  103695. };
  103696. /**
  103697. * Remove a specific velocity gradient
  103698. * @param gradient defines the gradient to remove
  103699. * @returns the current particle system
  103700. */
  103701. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  103702. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  103703. this._velocityGradientsTexture = null;
  103704. return this;
  103705. };
  103706. /**
  103707. * Adds a new limit velocity gradient
  103708. * @param gradient defines the gradient to use (between 0 and 1)
  103709. * @param factor defines the limit velocity value to affect to the specified gradient
  103710. * @returns the current particle system
  103711. */
  103712. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  103713. if (!this._limitVelocityGradients) {
  103714. this._limitVelocityGradients = [];
  103715. }
  103716. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  103717. if (this._limitVelocityGradientsTexture) {
  103718. this._limitVelocityGradientsTexture.dispose();
  103719. this._limitVelocityGradientsTexture = null;
  103720. }
  103721. this._releaseBuffers();
  103722. return this;
  103723. };
  103724. /**
  103725. * Remove a specific limit velocity gradient
  103726. * @param gradient defines the gradient to remove
  103727. * @returns the current particle system
  103728. */
  103729. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  103730. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  103731. this._limitVelocityGradientsTexture = null;
  103732. return this;
  103733. };
  103734. /**
  103735. * Adds a new drag gradient
  103736. * @param gradient defines the gradient to use (between 0 and 1)
  103737. * @param factor defines the drag value to affect to the specified gradient
  103738. * @returns the current particle system
  103739. */
  103740. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  103741. if (!this._dragGradients) {
  103742. this._dragGradients = [];
  103743. }
  103744. this._addFactorGradient(this._dragGradients, gradient, factor);
  103745. if (this._dragGradientsTexture) {
  103746. this._dragGradientsTexture.dispose();
  103747. this._dragGradientsTexture = null;
  103748. }
  103749. this._releaseBuffers();
  103750. return this;
  103751. };
  103752. /**
  103753. * Remove a specific drag gradient
  103754. * @param gradient defines the gradient to remove
  103755. * @returns the current particle system
  103756. */
  103757. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  103758. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  103759. this._dragGradientsTexture = null;
  103760. return this;
  103761. };
  103762. /**
  103763. * Not supported by GPUParticleSystem
  103764. * @param gradient defines the gradient to use (between 0 and 1)
  103765. * @param factor defines the emit rate value to affect to the specified gradient
  103766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103767. * @returns the current particle system
  103768. */
  103769. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  103770. // Do nothing as emit rate is not supported by GPUParticleSystem
  103771. return this;
  103772. };
  103773. /**
  103774. * Not supported by GPUParticleSystem
  103775. * @param gradient defines the gradient to remove
  103776. * @returns the current particle system
  103777. */
  103778. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  103779. // Do nothing as emit rate is not supported by GPUParticleSystem
  103780. return this;
  103781. };
  103782. /**
  103783. * Not supported by GPUParticleSystem
  103784. * @param gradient defines the gradient to use (between 0 and 1)
  103785. * @param factor defines the start size value to affect to the specified gradient
  103786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103787. * @returns the current particle system
  103788. */
  103789. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  103790. // Do nothing as start size is not supported by GPUParticleSystem
  103791. return this;
  103792. };
  103793. /**
  103794. * Not supported by GPUParticleSystem
  103795. * @param gradient defines the gradient to remove
  103796. * @returns the current particle system
  103797. */
  103798. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103799. // Do nothing as start size is not supported by GPUParticleSystem
  103800. return this;
  103801. };
  103802. /**
  103803. * Not supported by GPUParticleSystem
  103804. * @param gradient defines the gradient to use (between 0 and 1)
  103805. * @param min defines the color remap minimal range
  103806. * @param max defines the color remap maximal range
  103807. * @returns the current particle system
  103808. */
  103809. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103810. // Do nothing as start size is not supported by GPUParticleSystem
  103811. return this;
  103812. };
  103813. /**
  103814. * Not supported by GPUParticleSystem
  103815. * @param gradient defines the gradient to remove
  103816. * @returns the current particle system
  103817. */
  103818. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103819. // Do nothing as start size is not supported by GPUParticleSystem
  103820. return this;
  103821. };
  103822. /**
  103823. * Not supported by GPUParticleSystem
  103824. * @param gradient defines the gradient to use (between 0 and 1)
  103825. * @param min defines the alpha remap minimal range
  103826. * @param max defines the alpha remap maximal range
  103827. * @returns the current particle system
  103828. */
  103829. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  103830. // Do nothing as start size is not supported by GPUParticleSystem
  103831. return this;
  103832. };
  103833. /**
  103834. * Not supported by GPUParticleSystem
  103835. * @param gradient defines the gradient to remove
  103836. * @returns the current particle system
  103837. */
  103838. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  103839. // Do nothing as start size is not supported by GPUParticleSystem
  103840. return this;
  103841. };
  103842. /**
  103843. * Not supported by GPUParticleSystem
  103844. * @param gradient defines the gradient to use (between 0 and 1)
  103845. * @param color defines the color to affect to the specified gradient
  103846. * @returns the current particle system
  103847. */
  103848. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  103849. //Not supported by GPUParticleSystem
  103850. return this;
  103851. };
  103852. /**
  103853. * Not supported by GPUParticleSystem
  103854. * @param gradient defines the gradient to remove
  103855. * @returns the current particle system
  103856. */
  103857. GPUParticleSystem.prototype.removeRampGradient = function () {
  103858. //Not supported by GPUParticleSystem
  103859. return this;
  103860. };
  103861. /**
  103862. * Not supported by GPUParticleSystem
  103863. * @returns the list of ramp gradients
  103864. */
  103865. GPUParticleSystem.prototype.getRampGradients = function () {
  103866. return null;
  103867. };
  103868. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  103869. /**
  103870. * Not supported by GPUParticleSystem
  103871. * Gets or sets a boolean indicating that ramp gradients must be used
  103872. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  103873. */
  103874. get: function () {
  103875. //Not supported by GPUParticleSystem
  103876. return false;
  103877. },
  103878. set: function (value) {
  103879. //Not supported by GPUParticleSystem
  103880. },
  103881. enumerable: true,
  103882. configurable: true
  103883. });
  103884. /**
  103885. * Not supported by GPUParticleSystem
  103886. * @param gradient defines the gradient to use (between 0 and 1)
  103887. * @param factor defines the life time factor to affect to the specified gradient
  103888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103889. * @returns the current particle system
  103890. */
  103891. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  103892. //Not supported by GPUParticleSystem
  103893. return this;
  103894. };
  103895. /**
  103896. * Not supported by GPUParticleSystem
  103897. * @param gradient defines the gradient to remove
  103898. * @returns the current particle system
  103899. */
  103900. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  103901. //Not supported by GPUParticleSystem
  103902. return this;
  103903. };
  103904. GPUParticleSystem.prototype._reset = function () {
  103905. this._releaseBuffers();
  103906. };
  103907. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  103908. var updateVertexBuffers = {};
  103909. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  103910. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  103911. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  103912. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  103913. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  103914. var offset = 12;
  103915. if (!this._colorGradientsTexture) {
  103916. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  103917. offset += 4;
  103918. }
  103919. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  103920. offset += 3;
  103921. if (!this._isBillboardBased) {
  103922. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  103923. offset += 3;
  103924. }
  103925. if (this._angularSpeedGradientsTexture) {
  103926. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  103927. offset += 1;
  103928. }
  103929. else {
  103930. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  103931. offset += 2;
  103932. }
  103933. if (this._isAnimationSheetEnabled) {
  103934. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  103935. offset += 1;
  103936. if (this.spriteRandomStartCell) {
  103937. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  103938. offset += 1;
  103939. }
  103940. }
  103941. if (this.noiseTexture) {
  103942. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  103943. offset += 3;
  103944. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  103945. offset += 3;
  103946. }
  103947. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  103948. this._engine.bindArrayBuffer(null);
  103949. return vao;
  103950. };
  103951. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  103952. var renderVertexBuffers = {};
  103953. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  103954. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  103955. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  103956. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  103957. var offset = 12;
  103958. if (!this._colorGradientsTexture) {
  103959. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  103960. offset += 4;
  103961. }
  103962. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  103963. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  103964. }
  103965. offset += 3; // Direction
  103966. if (!this._isBillboardBased) {
  103967. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  103968. offset += 3;
  103969. }
  103970. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  103971. if (this._angularSpeedGradientsTexture) {
  103972. offset++;
  103973. }
  103974. else {
  103975. offset += 2;
  103976. }
  103977. if (this._isAnimationSheetEnabled) {
  103978. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  103979. offset += 1;
  103980. if (this.spriteRandomStartCell) {
  103981. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  103982. offset += 1;
  103983. }
  103984. }
  103985. if (this.noiseTexture) {
  103986. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  103987. offset += 3;
  103988. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  103989. offset += 3;
  103990. }
  103991. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  103992. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  103993. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  103994. this._engine.bindArrayBuffer(null);
  103995. return vao;
  103996. };
  103997. GPUParticleSystem.prototype._initialize = function (force) {
  103998. if (force === void 0) { force = false; }
  103999. if (this._buffer0 && !force) {
  104000. return;
  104001. }
  104002. var engine = this._scene.getEngine();
  104003. var data = new Array();
  104004. this._attributesStrideSize = 21;
  104005. this._targetIndex = 0;
  104006. if (!this.isBillboardBased) {
  104007. this._attributesStrideSize += 3;
  104008. }
  104009. if (this._colorGradientsTexture) {
  104010. this._attributesStrideSize -= 4;
  104011. }
  104012. if (this._angularSpeedGradientsTexture) {
  104013. this._attributesStrideSize -= 1;
  104014. }
  104015. if (this._isAnimationSheetEnabled) {
  104016. this._attributesStrideSize += 1;
  104017. if (this.spriteRandomStartCell) {
  104018. this._attributesStrideSize += 1;
  104019. }
  104020. }
  104021. if (this.noiseTexture) {
  104022. this._attributesStrideSize += 6;
  104023. }
  104024. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  104025. // position
  104026. data.push(0.0);
  104027. data.push(0.0);
  104028. data.push(0.0);
  104029. // Age and life
  104030. data.push(0.0); // create the particle as a dead one to create a new one at start
  104031. data.push(0.0);
  104032. // Seed
  104033. data.push(Math.random());
  104034. data.push(Math.random());
  104035. data.push(Math.random());
  104036. data.push(Math.random());
  104037. // Size
  104038. data.push(0.0);
  104039. data.push(0.0);
  104040. data.push(0.0);
  104041. if (!this._colorGradientsTexture) {
  104042. // color
  104043. data.push(0.0);
  104044. data.push(0.0);
  104045. data.push(0.0);
  104046. data.push(0.0);
  104047. }
  104048. // direction
  104049. data.push(0.0);
  104050. data.push(0.0);
  104051. data.push(0.0);
  104052. if (!this.isBillboardBased) {
  104053. // initialDirection
  104054. data.push(0.0);
  104055. data.push(0.0);
  104056. data.push(0.0);
  104057. }
  104058. // angle
  104059. data.push(0.0);
  104060. if (!this._angularSpeedGradientsTexture) {
  104061. data.push(0.0);
  104062. }
  104063. if (this._isAnimationSheetEnabled) {
  104064. data.push(0.0);
  104065. if (this.spriteRandomStartCell) {
  104066. data.push(0.0);
  104067. }
  104068. }
  104069. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  104070. data.push(Math.random());
  104071. data.push(Math.random());
  104072. data.push(Math.random());
  104073. data.push(Math.random());
  104074. data.push(Math.random());
  104075. data.push(Math.random());
  104076. }
  104077. }
  104078. // Sprite data
  104079. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  104080. -0.5, 0.5, 0, 1,
  104081. -0.5, -0.5, 0, 0,
  104082. 0.5, -0.5, 1, 0]);
  104083. // Buffers
  104084. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104085. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104086. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  104087. // Update VAO
  104088. this._updateVAO = [];
  104089. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  104090. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  104091. // Render VAO
  104092. this._renderVAO = [];
  104093. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  104094. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  104095. // Links
  104096. this._sourceBuffer = this._buffer0;
  104097. this._targetBuffer = this._buffer1;
  104098. };
  104099. /** @hidden */
  104100. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  104101. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  104102. if (this._isBillboardBased) {
  104103. defines += "\n#define BILLBOARD";
  104104. }
  104105. if (this._colorGradientsTexture) {
  104106. defines += "\n#define COLORGRADIENTS";
  104107. }
  104108. if (this._sizeGradientsTexture) {
  104109. defines += "\n#define SIZEGRADIENTS";
  104110. }
  104111. if (this._angularSpeedGradientsTexture) {
  104112. defines += "\n#define ANGULARSPEEDGRADIENTS";
  104113. }
  104114. if (this._velocityGradientsTexture) {
  104115. defines += "\n#define VELOCITYGRADIENTS";
  104116. }
  104117. if (this._limitVelocityGradientsTexture) {
  104118. defines += "\n#define LIMITVELOCITYGRADIENTS";
  104119. }
  104120. if (this._dragGradientsTexture) {
  104121. defines += "\n#define DRAGGRADIENTS";
  104122. }
  104123. if (this.isAnimationSheetEnabled) {
  104124. defines += "\n#define ANIMATESHEET";
  104125. if (this.spriteRandomStartCell) {
  104126. defines += "\n#define ANIMATESHEETRANDOMSTART";
  104127. }
  104128. }
  104129. if (this.noiseTexture) {
  104130. defines += "\n#define NOISE";
  104131. }
  104132. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  104133. return;
  104134. }
  104135. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  104136. if (!this._colorGradientsTexture) {
  104137. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  104138. }
  104139. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  104140. if (!this._isBillboardBased) {
  104141. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  104142. }
  104143. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  104144. if (this.isAnimationSheetEnabled) {
  104145. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  104146. if (this.spriteRandomStartCell) {
  104147. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  104148. }
  104149. }
  104150. if (this.noiseTexture) {
  104151. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  104152. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  104153. }
  104154. this._updateEffectOptions.defines = defines;
  104155. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  104156. };
  104157. /** @hidden */
  104158. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  104159. var defines = "";
  104160. if (this._scene.clipPlane) {
  104161. defines = "\n#define CLIPPLANE";
  104162. }
  104163. if (this._scene.clipPlane2) {
  104164. defines = "\n#define CLIPPLANE2";
  104165. }
  104166. if (this._scene.clipPlane3) {
  104167. defines = "\n#define CLIPPLANE3";
  104168. }
  104169. if (this._scene.clipPlane4) {
  104170. defines = "\n#define CLIPPLANE4";
  104171. }
  104172. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  104173. defines = "\n#define BLENDMULTIPLYMODE";
  104174. }
  104175. if (this._isBillboardBased) {
  104176. defines += "\n#define BILLBOARD";
  104177. switch (this.billboardMode) {
  104178. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  104179. defines += "\n#define BILLBOARDY";
  104180. break;
  104181. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  104182. defines += "\n#define BILLBOARDSTRETCHED";
  104183. break;
  104184. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  104185. default:
  104186. break;
  104187. }
  104188. }
  104189. if (this._colorGradientsTexture) {
  104190. defines += "\n#define COLORGRADIENTS";
  104191. }
  104192. if (this.isAnimationSheetEnabled) {
  104193. defines += "\n#define ANIMATESHEET";
  104194. }
  104195. if (this._imageProcessingConfiguration) {
  104196. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  104197. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  104198. }
  104199. if (this._renderEffect && this._renderEffect.defines === defines) {
  104200. return;
  104201. }
  104202. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  104203. var samplers = ["textureSampler", "colorGradientSampler"];
  104204. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  104205. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  104206. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  104207. }
  104208. this._renderEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuRenderParticles", ["position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"], uniforms, samplers, this._scene.getEngine(), defines);
  104209. };
  104210. /**
  104211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104212. * @param preWarm defines if we are in the pre-warmimg phase
  104213. */
  104214. GPUParticleSystem.prototype.animate = function (preWarm) {
  104215. if (preWarm === void 0) { preWarm = false; }
  104216. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  104217. this._actualFrame += this._timeDelta;
  104218. if (!this._stopped) {
  104219. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  104220. this.stop();
  104221. }
  104222. }
  104223. };
  104224. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  104225. var texture = this[textureName];
  104226. if (!factorGradients || !factorGradients.length || texture) {
  104227. return;
  104228. }
  104229. var data = new Float32Array(this._rawTextureWidth);
  104230. for (var x = 0; x < this._rawTextureWidth; x++) {
  104231. var ratio = x / this._rawTextureWidth;
  104232. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  104233. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104234. });
  104235. }
  104236. this[textureName] = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"].CreateRTexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].NEAREST_SAMPLINGMODE);
  104237. };
  104238. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  104239. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  104240. };
  104241. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  104242. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  104243. };
  104244. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  104245. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  104246. };
  104247. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  104248. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  104249. };
  104250. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  104251. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  104252. };
  104253. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  104254. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  104255. return;
  104256. }
  104257. var data = new Uint8Array(this._rawTextureWidth * 4);
  104258. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  104259. for (var x = 0; x < this._rawTextureWidth; x++) {
  104260. var ratio = x / this._rawTextureWidth;
  104261. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  104262. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  104263. data[x * 4] = tmpColor.r * 255;
  104264. data[x * 4 + 1] = tmpColor.g * 255;
  104265. data[x * 4 + 2] = tmpColor.b * 255;
  104266. data[x * 4 + 3] = tmpColor.a * 255;
  104267. });
  104268. }
  104269. this._colorGradientsTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"].CreateRGBATexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].NEAREST_SAMPLINGMODE);
  104270. };
  104271. /**
  104272. * Renders the particle system in its current state
  104273. * @param preWarm defines if the system should only update the particles but not render them
  104274. * @returns the current number of particles
  104275. */
  104276. GPUParticleSystem.prototype.render = function (preWarm) {
  104277. if (preWarm === void 0) { preWarm = false; }
  104278. if (!this._started) {
  104279. return 0;
  104280. }
  104281. this._createColorGradientTexture();
  104282. this._createSizeGradientTexture();
  104283. this._createAngularSpeedGradientTexture();
  104284. this._createVelocityGradientTexture();
  104285. this._createLimitVelocityGradientTexture();
  104286. this._createDragGradientTexture();
  104287. this._recreateUpdateEffect();
  104288. this._recreateRenderEffect();
  104289. if (!this.isReady()) {
  104290. return 0;
  104291. }
  104292. if (!preWarm) {
  104293. if (!this._preWarmDone && this.preWarmCycles) {
  104294. for (var index = 0; index < this.preWarmCycles; index++) {
  104295. this.animate(true);
  104296. this.render(true);
  104297. }
  104298. this._preWarmDone = true;
  104299. }
  104300. if (this._currentRenderId === this._scene.getFrameId()) {
  104301. return 0;
  104302. }
  104303. this._currentRenderId = this._scene.getFrameId();
  104304. }
  104305. // Get everything ready to render
  104306. this._initialize();
  104307. this._accumulatedCount += this.emitRate * this._timeDelta;
  104308. if (this._accumulatedCount > 1) {
  104309. var intPart = this._accumulatedCount | 0;
  104310. this._accumulatedCount -= intPart;
  104311. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  104312. }
  104313. if (!this._currentActiveCount) {
  104314. return 0;
  104315. }
  104316. // Enable update effect
  104317. this._engine.enableEffect(this._updateEffect);
  104318. this._engine.setState(false);
  104319. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  104320. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  104321. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  104322. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  104323. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  104324. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  104325. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  104326. if (!this._colorGradientsTexture) {
  104327. this._updateEffect.setDirectColor4("color1", this.color1);
  104328. this._updateEffect.setDirectColor4("color2", this.color2);
  104329. }
  104330. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  104331. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  104332. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  104333. this._updateEffect.setVector3("gravity", this.gravity);
  104334. if (this._sizeGradientsTexture) {
  104335. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  104336. }
  104337. if (this._angularSpeedGradientsTexture) {
  104338. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  104339. }
  104340. if (this._velocityGradientsTexture) {
  104341. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  104342. }
  104343. if (this._limitVelocityGradientsTexture) {
  104344. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  104345. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  104346. }
  104347. if (this._dragGradientsTexture) {
  104348. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  104349. }
  104350. if (this.particleEmitterType) {
  104351. this.particleEmitterType.applyToShader(this._updateEffect);
  104352. }
  104353. if (this._isAnimationSheetEnabled) {
  104354. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  104355. }
  104356. if (this.noiseTexture) {
  104357. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  104358. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  104359. }
  104360. var emitterWM;
  104361. if (this.emitter.position) {
  104362. var emitterMesh = this.emitter;
  104363. emitterWM = emitterMesh.getWorldMatrix();
  104364. }
  104365. else {
  104366. var emitterPosition = this.emitter;
  104367. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104368. }
  104369. this._updateEffect.setMatrix("emitterWM", emitterWM);
  104370. // Bind source VAO
  104371. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  104372. // Update
  104373. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  104374. this._engine.setRasterizerState(false);
  104375. this._engine.beginTransformFeedback(true);
  104376. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  104377. this._engine.endTransformFeedback();
  104378. this._engine.setRasterizerState(true);
  104379. this._engine.bindTransformFeedbackBuffer(null);
  104380. if (!preWarm) {
  104381. // Enable render effect
  104382. this._engine.enableEffect(this._renderEffect);
  104383. var viewMatrix = this._scene.getViewMatrix();
  104384. this._renderEffect.setMatrix("view", viewMatrix);
  104385. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  104386. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  104387. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  104388. if (this._colorGradientsTexture) {
  104389. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  104390. }
  104391. else {
  104392. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  104393. }
  104394. if (this._isAnimationSheetEnabled && this.particleTexture) {
  104395. var baseSize = this.particleTexture.getBaseSize();
  104396. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  104397. }
  104398. if (this._isBillboardBased) {
  104399. var camera = this._scene.activeCamera;
  104400. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  104401. }
  104402. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  104403. var invView = viewMatrix.clone();
  104404. invView.invert();
  104405. this._renderEffect.setMatrix("invView", invView);
  104406. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  104407. }
  104408. // image processing
  104409. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  104410. this._imageProcessingConfiguration.bind(this._renderEffect);
  104411. }
  104412. // Draw order
  104413. switch (this.blendMode) {
  104414. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  104415. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  104416. break;
  104417. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  104418. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  104419. break;
  104420. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  104421. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  104422. break;
  104423. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  104424. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  104425. break;
  104426. }
  104427. if (this.forceDepthWrite) {
  104428. this._engine.setDepthWrite(true);
  104429. }
  104430. // Bind source VAO
  104431. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  104432. // Render
  104433. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  104434. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  104435. }
  104436. // Switch VAOs
  104437. this._targetIndex++;
  104438. if (this._targetIndex === 2) {
  104439. this._targetIndex = 0;
  104440. }
  104441. // Switch buffers
  104442. var tmpBuffer = this._sourceBuffer;
  104443. this._sourceBuffer = this._targetBuffer;
  104444. this._targetBuffer = tmpBuffer;
  104445. return this._currentActiveCount;
  104446. };
  104447. /**
  104448. * Rebuilds the particle system
  104449. */
  104450. GPUParticleSystem.prototype.rebuild = function () {
  104451. this._initialize(true);
  104452. };
  104453. GPUParticleSystem.prototype._releaseBuffers = function () {
  104454. if (this._buffer0) {
  104455. this._buffer0.dispose();
  104456. this._buffer0 = null;
  104457. }
  104458. if (this._buffer1) {
  104459. this._buffer1.dispose();
  104460. this._buffer1 = null;
  104461. }
  104462. if (this._spriteBuffer) {
  104463. this._spriteBuffer.dispose();
  104464. this._spriteBuffer = null;
  104465. }
  104466. };
  104467. GPUParticleSystem.prototype._releaseVAOs = function () {
  104468. if (!this._updateVAO) {
  104469. return;
  104470. }
  104471. for (var index = 0; index < this._updateVAO.length; index++) {
  104472. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  104473. }
  104474. this._updateVAO = [];
  104475. for (var index = 0; index < this._renderVAO.length; index++) {
  104476. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  104477. }
  104478. this._renderVAO = [];
  104479. };
  104480. /**
  104481. * Disposes the particle system and free the associated resources
  104482. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104483. */
  104484. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  104485. if (disposeTexture === void 0) { disposeTexture = true; }
  104486. var index = this._scene.particleSystems.indexOf(this);
  104487. if (index > -1) {
  104488. this._scene.particleSystems.splice(index, 1);
  104489. }
  104490. this._releaseBuffers();
  104491. this._releaseVAOs();
  104492. if (this._colorGradientsTexture) {
  104493. this._colorGradientsTexture.dispose();
  104494. this._colorGradientsTexture = null;
  104495. }
  104496. if (this._sizeGradientsTexture) {
  104497. this._sizeGradientsTexture.dispose();
  104498. this._sizeGradientsTexture = null;
  104499. }
  104500. if (this._angularSpeedGradientsTexture) {
  104501. this._angularSpeedGradientsTexture.dispose();
  104502. this._angularSpeedGradientsTexture = null;
  104503. }
  104504. if (this._velocityGradientsTexture) {
  104505. this._velocityGradientsTexture.dispose();
  104506. this._velocityGradientsTexture = null;
  104507. }
  104508. if (this._limitVelocityGradientsTexture) {
  104509. this._limitVelocityGradientsTexture.dispose();
  104510. this._limitVelocityGradientsTexture = null;
  104511. }
  104512. if (this._dragGradientsTexture) {
  104513. this._dragGradientsTexture.dispose();
  104514. this._dragGradientsTexture = null;
  104515. }
  104516. if (this._randomTexture) {
  104517. this._randomTexture.dispose();
  104518. this._randomTexture = null;
  104519. }
  104520. if (this._randomTexture2) {
  104521. this._randomTexture2.dispose();
  104522. this._randomTexture2 = null;
  104523. }
  104524. if (disposeTexture && this.particleTexture) {
  104525. this.particleTexture.dispose();
  104526. this.particleTexture = null;
  104527. }
  104528. if (disposeTexture && this.noiseTexture) {
  104529. this.noiseTexture.dispose();
  104530. this.noiseTexture = null;
  104531. }
  104532. // Callback
  104533. this.onDisposeObservable.notifyObservers(this);
  104534. this.onDisposeObservable.clear();
  104535. };
  104536. /**
  104537. * Clones the particle system.
  104538. * @param name The name of the cloned object
  104539. * @param newEmitter The new emitter to use
  104540. * @returns the cloned particle system
  104541. */
  104542. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  104543. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  104544. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  104545. if (newEmitter === undefined) {
  104546. newEmitter = this.emitter;
  104547. }
  104548. result.emitter = newEmitter;
  104549. if (this.particleTexture) {
  104550. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  104551. }
  104552. return result;
  104553. };
  104554. /**
  104555. * Serializes the particle system to a JSON object.
  104556. * @returns the JSON object
  104557. */
  104558. GPUParticleSystem.prototype.serialize = function () {
  104559. var serializationObject = {};
  104560. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  104561. serializationObject.activeParticleCount = this.activeParticleCount;
  104562. return serializationObject;
  104563. };
  104564. /**
  104565. * Parses a JSON object to create a GPU particle system.
  104566. * @param parsedParticleSystem The JSON object to parse
  104567. * @param scene The scene to create the particle system in
  104568. * @param rootUrl The root url to use to load external dependencies like texture
  104569. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104570. * @returns the parsed GPU particle system
  104571. */
  104572. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  104573. if (doNotStart === void 0) { doNotStart = false; }
  104574. var name = parsedParticleSystem.name;
  104575. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  104576. if (parsedParticleSystem.activeParticleCount) {
  104577. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  104578. }
  104579. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  104580. // Auto start
  104581. if (parsedParticleSystem.preventAutoStart) {
  104582. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  104583. }
  104584. if (!doNotStart && !particleSystem.preventAutoStart) {
  104585. particleSystem.start();
  104586. }
  104587. return particleSystem;
  104588. };
  104589. return GPUParticleSystem;
  104590. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  104591. /***/ }),
  104592. /***/ "./Particles/index.ts":
  104593. /*!****************************!*\
  104594. !*** ./Particles/index.ts ***!
  104595. \****************************/
  104596. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104598. "use strict";
  104599. __webpack_require__.r(__webpack_exports__);
  104600. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  104602. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  104604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  104606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  104607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  104608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  104609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  104610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  104611. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  104613. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  104615. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  104616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  104617. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  104619. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  104620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  104621. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  104623. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  104624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  104625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  104626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  104627. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  104628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  104629. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  104631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  104632. /***/ }),
  104633. /***/ "./Particles/particle.ts":
  104634. /*!*******************************!*\
  104635. !*** ./Particles/particle.ts ***!
  104636. \*******************************/
  104637. /*! exports provided: Particle */
  104638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104639. "use strict";
  104640. __webpack_require__.r(__webpack_exports__);
  104641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  104642. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104643. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104644. /**
  104645. * A particle represents one of the element emitted by a particle system.
  104646. * This is mainly define by its coordinates, direction, velocity and age.
  104647. */
  104648. var Particle = /** @class */ (function () {
  104649. /**
  104650. * Creates a new instance Particle
  104651. * @param particleSystem the particle system the particle belongs to
  104652. */
  104653. function Particle(
  104654. /**
  104655. * The particle system the particle belongs to.
  104656. */
  104657. particleSystem) {
  104658. this.particleSystem = particleSystem;
  104659. /**
  104660. * The world position of the particle in the scene.
  104661. */
  104662. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104663. /**
  104664. * The world direction of the particle in the scene.
  104665. */
  104666. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104667. /**
  104668. * The color of the particle.
  104669. */
  104670. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104671. /**
  104672. * The color change of the particle per step.
  104673. */
  104674. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104675. /**
  104676. * Defines how long will the life of the particle be.
  104677. */
  104678. this.lifeTime = 1.0;
  104679. /**
  104680. * The current age of the particle.
  104681. */
  104682. this.age = 0;
  104683. /**
  104684. * The current size of the particle.
  104685. */
  104686. this.size = 0;
  104687. /**
  104688. * The current scale of the particle.
  104689. */
  104690. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  104691. /**
  104692. * The current angle of the particle.
  104693. */
  104694. this.angle = 0;
  104695. /**
  104696. * Defines how fast is the angle changing.
  104697. */
  104698. this.angularSpeed = 0;
  104699. /**
  104700. * Defines the cell index used by the particle to be rendered from a sprite.
  104701. */
  104702. this.cellIndex = 0;
  104703. /** @hidden */
  104704. this._attachedSubEmitters = null;
  104705. /** @hidden */
  104706. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104707. /** @hidden */
  104708. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104709. /** @hidden */
  104710. this._currentSize1 = 0;
  104711. /** @hidden */
  104712. this._currentSize2 = 0;
  104713. /** @hidden */
  104714. this._currentAngularSpeed1 = 0;
  104715. /** @hidden */
  104716. this._currentAngularSpeed2 = 0;
  104717. /** @hidden */
  104718. this._currentVelocity1 = 0;
  104719. /** @hidden */
  104720. this._currentVelocity2 = 0;
  104721. /** @hidden */
  104722. this._currentLimitVelocity1 = 0;
  104723. /** @hidden */
  104724. this._currentLimitVelocity2 = 0;
  104725. /** @hidden */
  104726. this._currentDrag1 = 0;
  104727. /** @hidden */
  104728. this._currentDrag2 = 0;
  104729. this.id = Particle._Count++;
  104730. if (!this.particleSystem.isAnimationSheetEnabled) {
  104731. return;
  104732. }
  104733. this.updateCellInfoFromSystem();
  104734. }
  104735. Particle.prototype.updateCellInfoFromSystem = function () {
  104736. this.cellIndex = this.particleSystem.startSpriteCellID;
  104737. };
  104738. /**
  104739. * Defines how the sprite cell index is updated for the particle
  104740. */
  104741. Particle.prototype.updateCellIndex = function () {
  104742. var offsetAge = this.age;
  104743. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  104744. if (this.particleSystem.spriteRandomStartCell) {
  104745. if (this._randomCellOffset === undefined) {
  104746. this._randomCellOffset = Math.random() * this.lifeTime;
  104747. }
  104748. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  104749. changeSpeed = 1;
  104750. offsetAge = this._randomCellOffset;
  104751. }
  104752. else {
  104753. offsetAge += this._randomCellOffset;
  104754. }
  104755. }
  104756. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  104757. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  104758. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  104759. };
  104760. /** @hidden */
  104761. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  104762. if (subEmitter.particleSystem.emitter.position) {
  104763. var emitterMesh = subEmitter.particleSystem.emitter;
  104764. emitterMesh.position.copyFrom(this.position);
  104765. if (subEmitter.inheritDirection) {
  104766. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104767. // Look at using Y as forward
  104768. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  104769. }
  104770. }
  104771. else {
  104772. var emitterPosition = subEmitter.particleSystem.emitter;
  104773. emitterPosition.copyFrom(this.position);
  104774. }
  104775. // Set inheritedVelocityOffset to be used when new particles are created
  104776. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104777. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104778. };
  104779. /** @hidden */
  104780. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  104781. var _this = this;
  104782. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  104783. this._attachedSubEmitters.forEach(function (subEmitter) {
  104784. _this._inheritParticleInfoToSubEmitter(subEmitter);
  104785. });
  104786. }
  104787. };
  104788. /** @hidden */
  104789. Particle.prototype._reset = function () {
  104790. this.age = 0;
  104791. this._currentColorGradient = null;
  104792. this._currentSizeGradient = null;
  104793. this._currentAngularSpeedGradient = null;
  104794. this._currentVelocityGradient = null;
  104795. this._currentLimitVelocityGradient = null;
  104796. this._currentDragGradient = null;
  104797. this.cellIndex = this.particleSystem.startSpriteCellID;
  104798. this._randomCellOffset = undefined;
  104799. };
  104800. /**
  104801. * Copy the properties of particle to another one.
  104802. * @param other the particle to copy the information to.
  104803. */
  104804. Particle.prototype.copyTo = function (other) {
  104805. other.position.copyFrom(this.position);
  104806. if (this._initialDirection) {
  104807. if (other._initialDirection) {
  104808. other._initialDirection.copyFrom(this._initialDirection);
  104809. }
  104810. else {
  104811. other._initialDirection = this._initialDirection.clone();
  104812. }
  104813. }
  104814. else {
  104815. other._initialDirection = null;
  104816. }
  104817. other.direction.copyFrom(this.direction);
  104818. other.color.copyFrom(this.color);
  104819. other.colorStep.copyFrom(this.colorStep);
  104820. other.lifeTime = this.lifeTime;
  104821. other.age = this.age;
  104822. other._randomCellOffset = this._randomCellOffset;
  104823. other.size = this.size;
  104824. other.scale.copyFrom(this.scale);
  104825. other.angle = this.angle;
  104826. other.angularSpeed = this.angularSpeed;
  104827. other.particleSystem = this.particleSystem;
  104828. other.cellIndex = this.cellIndex;
  104829. other.id = this.id;
  104830. other._attachedSubEmitters = this._attachedSubEmitters;
  104831. if (this._currentColorGradient) {
  104832. other._currentColorGradient = this._currentColorGradient;
  104833. other._currentColor1.copyFrom(this._currentColor1);
  104834. other._currentColor2.copyFrom(this._currentColor2);
  104835. }
  104836. if (this._currentSizeGradient) {
  104837. other._currentSizeGradient = this._currentSizeGradient;
  104838. other._currentSize1 = this._currentSize1;
  104839. other._currentSize2 = this._currentSize2;
  104840. }
  104841. if (this._currentAngularSpeedGradient) {
  104842. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  104843. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  104844. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  104845. }
  104846. if (this._currentVelocityGradient) {
  104847. other._currentVelocityGradient = this._currentVelocityGradient;
  104848. other._currentVelocity1 = this._currentVelocity1;
  104849. other._currentVelocity2 = this._currentVelocity2;
  104850. }
  104851. if (this._currentLimitVelocityGradient) {
  104852. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  104853. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  104854. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  104855. }
  104856. if (this._currentDragGradient) {
  104857. other._currentDragGradient = this._currentDragGradient;
  104858. other._currentDrag1 = this._currentDrag1;
  104859. other._currentDrag2 = this._currentDrag2;
  104860. }
  104861. if (this.particleSystem.isAnimationSheetEnabled) {
  104862. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  104863. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  104864. }
  104865. if (this.particleSystem.useRampGradients) {
  104866. other.remapData.copyFrom(this.remapData);
  104867. }
  104868. if (this._randomNoiseCoordinates1) {
  104869. if (other._randomNoiseCoordinates1) {
  104870. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  104871. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  104872. }
  104873. else {
  104874. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  104875. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  104876. }
  104877. }
  104878. };
  104879. Particle._Count = 0;
  104880. return Particle;
  104881. }());
  104882. /***/ }),
  104883. /***/ "./Particles/particleHelper.ts":
  104884. /*!*************************************!*\
  104885. !*** ./Particles/particleHelper.ts ***!
  104886. \*************************************/
  104887. /*! exports provided: ParticleHelper */
  104888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104889. "use strict";
  104890. __webpack_require__.r(__webpack_exports__);
  104891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  104892. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104893. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104894. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104895. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104896. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104897. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104898. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104899. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104900. /**
  104901. * This class is made for on one-liner static method to help creating particle system set.
  104902. */
  104903. var ParticleHelper = /** @class */ (function () {
  104904. function ParticleHelper() {
  104905. }
  104906. /**
  104907. * Create a default particle system that you can tweak
  104908. * @param emitter defines the emitter to use
  104909. * @param capacity defines the system capacity (default is 500 particles)
  104910. * @param scene defines the hosting scene
  104911. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104912. * @returns the new Particle system
  104913. */
  104914. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  104915. if (capacity === void 0) { capacity = 500; }
  104916. if (useGPU === void 0) { useGPU = false; }
  104917. var system;
  104918. if (useGPU) {
  104919. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  104920. }
  104921. else {
  104922. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  104923. }
  104924. system.emitter = emitter;
  104925. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  104926. system.createConeEmitter(0.1, Math.PI / 4);
  104927. // Particle color
  104928. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104929. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104930. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  104931. // Particle Size
  104932. system.minSize = 0.1;
  104933. system.maxSize = 0.1;
  104934. // Emission speed
  104935. system.minEmitPower = 2;
  104936. system.maxEmitPower = 2;
  104937. // Update speed
  104938. system.updateSpeed = 1 / 60;
  104939. system.emitRate = 30;
  104940. return system;
  104941. };
  104942. /**
  104943. * This is the main static method (one-liner) of this helper to create different particle systems
  104944. * @param type This string represents the type to the particle system to create
  104945. * @param scene The scene where the particle system should live
  104946. * @param gpu If the system will use gpu
  104947. * @returns the ParticleSystemSet created
  104948. */
  104949. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  104950. if (gpu === void 0) { gpu = false; }
  104951. if (!scene) {
  104952. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  104953. }
  104954. var token = {};
  104955. scene._addPendingData(token);
  104956. return new Promise(function (resolve, reject) {
  104957. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  104958. scene._removePendingData(token);
  104959. return reject("Particle system with GPU is not supported.");
  104960. }
  104961. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  104962. scene._removePendingData(token);
  104963. var newData = JSON.parse(data.toString());
  104964. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  104965. }, undefined, undefined, undefined, function () {
  104966. scene._removePendingData(token);
  104967. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  104968. });
  104969. });
  104970. };
  104971. /**
  104972. * Static function used to export a particle system to a ParticleSystemSet variable.
  104973. * Please note that the emitter shape is not exported
  104974. * @param systems defines the particle systems to export
  104975. * @returns the created particle system set
  104976. */
  104977. ParticleHelper.ExportSet = function (systems) {
  104978. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  104979. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  104980. var system = systems_1[_i];
  104981. set.systems.push(system);
  104982. }
  104983. return set;
  104984. };
  104985. /**
  104986. * Gets or sets base Assets URL
  104987. */
  104988. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  104989. return ParticleHelper;
  104990. }());
  104991. /***/ }),
  104992. /***/ "./Particles/particleSystem.ts":
  104993. /*!*************************************!*\
  104994. !*** ./Particles/particleSystem.ts ***!
  104995. \*************************************/
  104996. /*! exports provided: ParticleSystem */
  104997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104998. "use strict";
  104999. __webpack_require__.r(__webpack_exports__);
  105000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  105001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105002. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105003. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105005. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105006. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105007. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  105008. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105009. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105010. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105011. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105012. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105013. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  105014. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105015. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105016. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105017. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105018. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105019. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105020. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105021. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105022. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105023. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  105024. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  105025. /**
  105026. * This represents a particle system in Babylon.
  105027. * 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.
  105028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105029. * @example https://doc.babylonjs.com/babylon101/particles
  105030. */
  105031. var ParticleSystem = /** @class */ (function (_super) {
  105032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  105033. /**
  105034. * Instantiates a particle system.
  105035. * 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.
  105036. * @param name The name of the particle system
  105037. * @param capacity The max number of particles alive at the same time
  105038. * @param scene The scene the particle system belongs to
  105039. * @param customEffect a custom effect used to change the way particles are rendered by default
  105040. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105041. * @param epsilon Offset used to render the particles
  105042. */
  105043. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  105044. if (customEffect === void 0) { customEffect = null; }
  105045. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105046. if (epsilon === void 0) { epsilon = 0.01; }
  105047. var _this = _super.call(this, name) || this;
  105048. /**
  105049. * @hidden
  105050. */
  105051. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  105052. /**
  105053. * An event triggered when the system is disposed
  105054. */
  105055. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105056. _this._particles = new Array();
  105057. _this._stockParticles = new Array();
  105058. _this._newPartsExcess = 0;
  105059. _this._vertexBuffers = {};
  105060. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105061. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105062. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105063. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105064. _this._currentRenderId = -1;
  105065. _this._useInstancing = false;
  105066. _this._started = false;
  105067. _this._stopped = false;
  105068. _this._actualFrame = 0;
  105069. /** @hidden */
  105070. _this._currentEmitRate1 = 0;
  105071. /** @hidden */
  105072. _this._currentEmitRate2 = 0;
  105073. /** @hidden */
  105074. _this._currentStartSize1 = 0;
  105075. /** @hidden */
  105076. _this._currentStartSize2 = 0;
  105077. _this._rawTextureWidth = 256;
  105078. _this._useRampGradients = false;
  105079. /**
  105080. * @hidden
  105081. * If the particle systems emitter should be disposed when the particle system is disposed
  105082. */
  105083. _this._disposeEmitterOnDispose = false;
  105084. // start of sub system methods
  105085. /**
  105086. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  105087. * Its lifetime will start back at 0.
  105088. */
  105089. _this.recycleParticle = function (particle) {
  105090. // move particle from activeParticle list to stock particles
  105091. var lastParticle = _this._particles.pop();
  105092. if (lastParticle !== particle) {
  105093. lastParticle.copyTo(particle);
  105094. }
  105095. _this._stockParticles.push(lastParticle);
  105096. };
  105097. _this._createParticle = function () {
  105098. var particle;
  105099. if (_this._stockParticles.length !== 0) {
  105100. particle = _this._stockParticles.pop();
  105101. particle._reset();
  105102. }
  105103. else {
  105104. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  105105. }
  105106. // Attach emitters
  105107. if (_this._subEmitters && _this._subEmitters.length > 0) {
  105108. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  105109. particle._attachedSubEmitters = [];
  105110. subEmitters.forEach(function (subEmitter) {
  105111. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  105112. var newEmitter = subEmitter.clone();
  105113. particle._attachedSubEmitters.push(newEmitter);
  105114. newEmitter.particleSystem.start();
  105115. }
  105116. });
  105117. }
  105118. return particle;
  105119. };
  105120. _this._emitFromParticle = function (particle) {
  105121. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  105122. return;
  105123. }
  105124. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  105125. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  105126. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  105127. var subSystem = subEmitter.clone();
  105128. particle._inheritParticleInfoToSubEmitter(subSystem);
  105129. subSystem.particleSystem._rootParticleSystem = _this;
  105130. _this.activeSubSystems.push(subSystem.particleSystem);
  105131. subSystem.particleSystem.start();
  105132. }
  105133. });
  105134. };
  105135. _this._capacity = capacity;
  105136. _this._epsilon = epsilon;
  105137. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105138. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  105139. // Setup the default processing configuration to the scene.
  105140. _this._attachImageProcessingConfiguration(null);
  105141. _this._customEffect = customEffect;
  105142. _this._scene.particleSystems.push(_this);
  105143. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  105144. _this._createIndexBuffer();
  105145. _this._createVertexBuffers();
  105146. // Default emitter type
  105147. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  105148. // Update
  105149. _this.updateFunction = function (particles) {
  105150. var noiseTextureSize = null;
  105151. var noiseTextureData = null;
  105152. if (_this.noiseTexture) { // We need to get texture data back to CPU
  105153. noiseTextureSize = _this.noiseTexture.getSize();
  105154. noiseTextureData = (_this.noiseTexture.getContent());
  105155. }
  105156. var _loop_1 = function () {
  105157. particle = particles[index];
  105158. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  105159. var previousAge = particle.age;
  105160. particle.age += scaledUpdateSpeed;
  105161. // Evaluate step to death
  105162. if (particle.age > particle.lifeTime) {
  105163. var diff = particle.age - previousAge;
  105164. var oldDiff = particle.lifeTime - previousAge;
  105165. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  105166. particle.age = particle.lifeTime;
  105167. }
  105168. var ratio = particle.age / particle.lifeTime;
  105169. // Color
  105170. if (_this._colorGradients && _this._colorGradients.length > 0) {
  105171. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  105172. if (currentGradient !== particle._currentColorGradient) {
  105173. particle._currentColor1.copyFrom(particle._currentColor2);
  105174. nextGradient.getColorToRef(particle._currentColor2);
  105175. particle._currentColorGradient = currentGradient;
  105176. }
  105177. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  105178. });
  105179. }
  105180. else {
  105181. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  105182. particle.color.addInPlace(_this._scaledColorStep);
  105183. if (particle.color.a < 0) {
  105184. particle.color.a = 0;
  105185. }
  105186. }
  105187. // Angular speed
  105188. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  105189. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  105190. if (currentGradient !== particle._currentAngularSpeedGradient) {
  105191. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  105192. particle._currentAngularSpeed2 = nextGradient.getFactor();
  105193. particle._currentAngularSpeedGradient = currentGradient;
  105194. }
  105195. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  105196. });
  105197. }
  105198. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  105199. // Direction
  105200. var directionScale = scaledUpdateSpeed;
  105201. /// Velocity
  105202. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  105203. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  105204. if (currentGradient !== particle._currentVelocityGradient) {
  105205. particle._currentVelocity1 = particle._currentVelocity2;
  105206. particle._currentVelocity2 = nextGradient.getFactor();
  105207. particle._currentVelocityGradient = currentGradient;
  105208. }
  105209. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  105210. });
  105211. }
  105212. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  105213. /// Limit velocity
  105214. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  105215. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  105216. if (currentGradient !== particle._currentLimitVelocityGradient) {
  105217. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  105218. particle._currentLimitVelocity2 = nextGradient.getFactor();
  105219. particle._currentLimitVelocityGradient = currentGradient;
  105220. }
  105221. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  105222. var currentVelocity = particle.direction.length();
  105223. if (currentVelocity > limitVelocity) {
  105224. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  105225. }
  105226. });
  105227. }
  105228. /// Drag
  105229. if (_this._dragGradients && _this._dragGradients.length > 0) {
  105230. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  105231. if (currentGradient !== particle._currentDragGradient) {
  105232. particle._currentDrag1 = particle._currentDrag2;
  105233. particle._currentDrag2 = nextGradient.getFactor();
  105234. particle._currentDragGradient = currentGradient;
  105235. }
  105236. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  105237. _this._scaledDirection.scaleInPlace(1.0 - drag);
  105238. });
  105239. }
  105240. particle.position.addInPlace(_this._scaledDirection);
  105241. // Noise
  105242. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  105243. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105244. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105245. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105246. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  105247. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  105248. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  105249. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  105250. particle.direction.addInPlace(scaledForce);
  105251. }
  105252. // Gravity
  105253. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  105254. particle.direction.addInPlace(_this._scaledGravity);
  105255. // Size
  105256. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  105257. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  105258. if (currentGradient !== particle._currentSizeGradient) {
  105259. particle._currentSize1 = particle._currentSize2;
  105260. particle._currentSize2 = nextGradient.getFactor();
  105261. particle._currentSizeGradient = currentGradient;
  105262. }
  105263. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  105264. });
  105265. }
  105266. // Remap data
  105267. if (_this._useRampGradients) {
  105268. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  105269. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  105270. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105271. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105272. particle.remapData.x = min;
  105273. particle.remapData.y = max - min;
  105274. });
  105275. }
  105276. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  105277. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  105278. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105279. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105280. particle.remapData.z = min;
  105281. particle.remapData.w = max - min;
  105282. });
  105283. }
  105284. }
  105285. if (_this._isAnimationSheetEnabled) {
  105286. particle.updateCellIndex();
  105287. }
  105288. // Update the position of the attached sub-emitters to match their attached particle
  105289. particle._inheritParticleInfoToSubEmitters();
  105290. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  105291. _this._emitFromParticle(particle);
  105292. if (particle._attachedSubEmitters) {
  105293. particle._attachedSubEmitters.forEach(function (subEmitter) {
  105294. subEmitter.particleSystem.disposeOnStop = true;
  105295. subEmitter.particleSystem.stop();
  105296. });
  105297. particle._attachedSubEmitters = null;
  105298. }
  105299. _this.recycleParticle(particle);
  105300. index--;
  105301. return "continue";
  105302. }
  105303. };
  105304. var particle;
  105305. for (var index = 0; index < particles.length; index++) {
  105306. _loop_1();
  105307. }
  105308. };
  105309. return _this;
  105310. }
  105311. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  105312. /**
  105313. * Sets a callback that will be triggered when the system is disposed
  105314. */
  105315. set: function (callback) {
  105316. if (this._onDisposeObserver) {
  105317. this.onDisposeObservable.remove(this._onDisposeObserver);
  105318. }
  105319. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  105320. },
  105321. enumerable: true,
  105322. configurable: true
  105323. });
  105324. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  105325. /** Gets or sets a boolean indicating that ramp gradients must be used
  105326. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105327. */
  105328. get: function () {
  105329. return this._useRampGradients;
  105330. },
  105331. set: function (value) {
  105332. if (this._useRampGradients === value) {
  105333. return;
  105334. }
  105335. this._useRampGradients = value;
  105336. this._resetEffect();
  105337. },
  105338. enumerable: true,
  105339. configurable: true
  105340. });
  105341. Object.defineProperty(ParticleSystem.prototype, "particles", {
  105342. //end of Sub-emitter
  105343. /**
  105344. * Gets the current list of active particles
  105345. */
  105346. get: function () {
  105347. return this._particles;
  105348. },
  105349. enumerable: true,
  105350. configurable: true
  105351. });
  105352. /**
  105353. * Returns the string "ParticleSystem"
  105354. * @returns a string containing the class name
  105355. */
  105356. ParticleSystem.prototype.getClassName = function () {
  105357. return "ParticleSystem";
  105358. };
  105359. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  105360. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105361. newGradient.gradient = gradient;
  105362. newGradient.factor1 = factor;
  105363. newGradient.factor2 = factor2;
  105364. factorGradients.push(newGradient);
  105365. factorGradients.sort(function (a, b) {
  105366. if (a.gradient < b.gradient) {
  105367. return -1;
  105368. }
  105369. else if (a.gradient > b.gradient) {
  105370. return 1;
  105371. }
  105372. return 0;
  105373. });
  105374. };
  105375. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  105376. if (!factorGradients) {
  105377. return;
  105378. }
  105379. var index = 0;
  105380. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  105381. var factorGradient = factorGradients_1[_i];
  105382. if (factorGradient.gradient === gradient) {
  105383. factorGradients.splice(index, 1);
  105384. break;
  105385. }
  105386. index++;
  105387. }
  105388. };
  105389. /**
  105390. * Adds a new life time gradient
  105391. * @param gradient defines the gradient to use (between 0 and 1)
  105392. * @param factor defines the life time factor to affect to the specified gradient
  105393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105394. * @returns the current particle system
  105395. */
  105396. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105397. if (!this._lifeTimeGradients) {
  105398. this._lifeTimeGradients = [];
  105399. }
  105400. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  105401. return this;
  105402. };
  105403. /**
  105404. * Remove a specific life time gradient
  105405. * @param gradient defines the gradient to remove
  105406. * @returns the current particle system
  105407. */
  105408. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105409. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  105410. return this;
  105411. };
  105412. /**
  105413. * Adds a new size gradient
  105414. * @param gradient defines the gradient to use (between 0 and 1)
  105415. * @param factor defines the size factor to affect to the specified gradient
  105416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105417. * @returns the current particle system
  105418. */
  105419. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  105420. if (!this._sizeGradients) {
  105421. this._sizeGradients = [];
  105422. }
  105423. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  105424. return this;
  105425. };
  105426. /**
  105427. * Remove a specific size gradient
  105428. * @param gradient defines the gradient to remove
  105429. * @returns the current particle system
  105430. */
  105431. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105432. this._removeFactorGradient(this._sizeGradients, gradient);
  105433. return this;
  105434. };
  105435. /**
  105436. * Adds a new color remap gradient
  105437. * @param gradient defines the gradient to use (between 0 and 1)
  105438. * @param min defines the color remap minimal range
  105439. * @param max defines the color remap maximal range
  105440. * @returns the current particle system
  105441. */
  105442. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105443. if (!this._colorRemapGradients) {
  105444. this._colorRemapGradients = [];
  105445. }
  105446. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  105447. return this;
  105448. };
  105449. /**
  105450. * Remove a specific color remap gradient
  105451. * @param gradient defines the gradient to remove
  105452. * @returns the current particle system
  105453. */
  105454. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  105455. this._removeFactorGradient(this._colorRemapGradients, gradient);
  105456. return this;
  105457. };
  105458. /**
  105459. * Adds a new alpha remap gradient
  105460. * @param gradient defines the gradient to use (between 0 and 1)
  105461. * @param min defines the alpha remap minimal range
  105462. * @param max defines the alpha remap maximal range
  105463. * @returns the current particle system
  105464. */
  105465. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105466. if (!this._alphaRemapGradients) {
  105467. this._alphaRemapGradients = [];
  105468. }
  105469. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  105470. return this;
  105471. };
  105472. /**
  105473. * Remove a specific alpha remap gradient
  105474. * @param gradient defines the gradient to remove
  105475. * @returns the current particle system
  105476. */
  105477. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  105478. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  105479. return this;
  105480. };
  105481. /**
  105482. * Adds a new angular speed gradient
  105483. * @param gradient defines the gradient to use (between 0 and 1)
  105484. * @param factor defines the angular speed to affect to the specified gradient
  105485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105486. * @returns the current particle system
  105487. */
  105488. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  105489. if (!this._angularSpeedGradients) {
  105490. this._angularSpeedGradients = [];
  105491. }
  105492. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  105493. return this;
  105494. };
  105495. /**
  105496. * Remove a specific angular speed gradient
  105497. * @param gradient defines the gradient to remove
  105498. * @returns the current particle system
  105499. */
  105500. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105501. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  105502. return this;
  105503. };
  105504. /**
  105505. * Adds a new velocity gradient
  105506. * @param gradient defines the gradient to use (between 0 and 1)
  105507. * @param factor defines the velocity to affect to the specified gradient
  105508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105509. * @returns the current particle system
  105510. */
  105511. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  105512. if (!this._velocityGradients) {
  105513. this._velocityGradients = [];
  105514. }
  105515. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  105516. return this;
  105517. };
  105518. /**
  105519. * Remove a specific velocity gradient
  105520. * @param gradient defines the gradient to remove
  105521. * @returns the current particle system
  105522. */
  105523. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105524. this._removeFactorGradient(this._velocityGradients, gradient);
  105525. return this;
  105526. };
  105527. /**
  105528. * Adds a new limit velocity gradient
  105529. * @param gradient defines the gradient to use (between 0 and 1)
  105530. * @param factor defines the limit velocity value to affect to the specified gradient
  105531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105532. * @returns the current particle system
  105533. */
  105534. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  105535. if (!this._limitVelocityGradients) {
  105536. this._limitVelocityGradients = [];
  105537. }
  105538. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  105539. return this;
  105540. };
  105541. /**
  105542. * Remove a specific limit velocity gradient
  105543. * @param gradient defines the gradient to remove
  105544. * @returns the current particle system
  105545. */
  105546. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105547. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  105548. return this;
  105549. };
  105550. /**
  105551. * Adds a new drag gradient
  105552. * @param gradient defines the gradient to use (between 0 and 1)
  105553. * @param factor defines the drag value to affect to the specified gradient
  105554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105555. * @returns the current particle system
  105556. */
  105557. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  105558. if (!this._dragGradients) {
  105559. this._dragGradients = [];
  105560. }
  105561. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  105562. return this;
  105563. };
  105564. /**
  105565. * Remove a specific drag gradient
  105566. * @param gradient defines the gradient to remove
  105567. * @returns the current particle system
  105568. */
  105569. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  105570. this._removeFactorGradient(this._dragGradients, gradient);
  105571. return this;
  105572. };
  105573. /**
  105574. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  105575. * @param gradient defines the gradient to use (between 0 and 1)
  105576. * @param factor defines the emit rate value to affect to the specified gradient
  105577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105578. * @returns the current particle system
  105579. */
  105580. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105581. if (!this._emitRateGradients) {
  105582. this._emitRateGradients = [];
  105583. }
  105584. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  105585. return this;
  105586. };
  105587. /**
  105588. * Remove a specific emit rate gradient
  105589. * @param gradient defines the gradient to remove
  105590. * @returns the current particle system
  105591. */
  105592. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105593. this._removeFactorGradient(this._emitRateGradients, gradient);
  105594. return this;
  105595. };
  105596. /**
  105597. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  105598. * @param gradient defines the gradient to use (between 0 and 1)
  105599. * @param factor defines the start size value to affect to the specified gradient
  105600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105601. * @returns the current particle system
  105602. */
  105603. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105604. if (!this._startSizeGradients) {
  105605. this._startSizeGradients = [];
  105606. }
  105607. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  105608. return this;
  105609. };
  105610. /**
  105611. * Remove a specific start size gradient
  105612. * @param gradient defines the gradient to remove
  105613. * @returns the current particle system
  105614. */
  105615. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105616. this._removeFactorGradient(this._emitRateGradients, gradient);
  105617. return this;
  105618. };
  105619. ParticleSystem.prototype._createRampGradientTexture = function () {
  105620. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  105621. return;
  105622. }
  105623. var data = new Uint8Array(this._rawTextureWidth * 4);
  105624. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  105625. for (var x = 0; x < this._rawTextureWidth; x++) {
  105626. var ratio = x / this._rawTextureWidth;
  105627. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  105628. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  105629. data[x * 4] = tmpColor.r * 255;
  105630. data[x * 4 + 1] = tmpColor.g * 255;
  105631. data[x * 4 + 2] = tmpColor.b * 255;
  105632. data[x * 4 + 3] = 255;
  105633. });
  105634. }
  105635. 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);
  105636. };
  105637. /**
  105638. * Gets the current list of ramp gradients.
  105639. * You must use addRampGradient and removeRampGradient to udpate this list
  105640. * @returns the list of ramp gradients
  105641. */
  105642. ParticleSystem.prototype.getRampGradients = function () {
  105643. return this._rampGradients;
  105644. };
  105645. /**
  105646. * Adds a new ramp gradient used to remap particle colors
  105647. * @param gradient defines the gradient to use (between 0 and 1)
  105648. * @param color defines the color to affect to the specified gradient
  105649. * @returns the current particle system
  105650. */
  105651. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105652. if (!this._rampGradients) {
  105653. this._rampGradients = [];
  105654. }
  105655. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  105656. rampGradient.gradient = gradient;
  105657. rampGradient.color = color;
  105658. this._rampGradients.push(rampGradient);
  105659. this._rampGradients.sort(function (a, b) {
  105660. if (a.gradient < b.gradient) {
  105661. return -1;
  105662. }
  105663. else if (a.gradient > b.gradient) {
  105664. return 1;
  105665. }
  105666. return 0;
  105667. });
  105668. if (this._rampGradientsTexture) {
  105669. this._rampGradientsTexture.dispose();
  105670. this._rampGradientsTexture = null;
  105671. }
  105672. this._createRampGradientTexture();
  105673. return this;
  105674. };
  105675. /**
  105676. * Remove a specific ramp gradient
  105677. * @param gradient defines the gradient to remove
  105678. * @returns the current particle system
  105679. */
  105680. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  105681. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  105682. this._rampGradientsTexture = null;
  105683. if (this._rampGradients && this._rampGradients.length > 0) {
  105684. this._createRampGradientTexture();
  105685. }
  105686. return this;
  105687. };
  105688. /**
  105689. * Adds a new color gradient
  105690. * @param gradient defines the gradient to use (between 0 and 1)
  105691. * @param color1 defines the color to affect to the specified gradient
  105692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105693. * @returns this particle system
  105694. */
  105695. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105696. if (!this._colorGradients) {
  105697. this._colorGradients = [];
  105698. }
  105699. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105700. colorGradient.gradient = gradient;
  105701. colorGradient.color1 = color1;
  105702. colorGradient.color2 = color2;
  105703. this._colorGradients.push(colorGradient);
  105704. this._colorGradients.sort(function (a, b) {
  105705. if (a.gradient < b.gradient) {
  105706. return -1;
  105707. }
  105708. else if (a.gradient > b.gradient) {
  105709. return 1;
  105710. }
  105711. return 0;
  105712. });
  105713. return this;
  105714. };
  105715. /**
  105716. * Remove a specific color gradient
  105717. * @param gradient defines the gradient to remove
  105718. * @returns this particle system
  105719. */
  105720. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  105721. if (!this._colorGradients) {
  105722. return this;
  105723. }
  105724. var index = 0;
  105725. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  105726. var colorGradient = _a[_i];
  105727. if (colorGradient.gradient === gradient) {
  105728. this._colorGradients.splice(index, 1);
  105729. break;
  105730. }
  105731. index++;
  105732. }
  105733. return this;
  105734. };
  105735. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  105736. u = Math.abs(u) * 0.5 + 0.5;
  105737. v = Math.abs(v) * 0.5 + 0.5;
  105738. var wrappedU = ((u * width) % width) | 0;
  105739. var wrappedV = ((v * height) % height) | 0;
  105740. var position = (wrappedU + wrappedV * width) * 4;
  105741. return pixels[position] / 255;
  105742. };
  105743. ParticleSystem.prototype._reset = function () {
  105744. this._resetEffect();
  105745. };
  105746. ParticleSystem.prototype._resetEffect = function () {
  105747. if (this._vertexBuffer) {
  105748. this._vertexBuffer.dispose();
  105749. this._vertexBuffer = null;
  105750. }
  105751. if (this._spriteBuffer) {
  105752. this._spriteBuffer.dispose();
  105753. this._spriteBuffer = null;
  105754. }
  105755. this._createVertexBuffers();
  105756. };
  105757. ParticleSystem.prototype._createVertexBuffers = function () {
  105758. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  105759. if (this._isAnimationSheetEnabled) {
  105760. this._vertexBufferSize += 1;
  105761. }
  105762. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105763. this._vertexBufferSize += 3;
  105764. }
  105765. if (this._useRampGradients) {
  105766. this._vertexBufferSize += 4;
  105767. }
  105768. var engine = this._scene.getEngine();
  105769. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  105770. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  105771. var dataOffset = 0;
  105772. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105773. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  105774. dataOffset += 3;
  105775. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105776. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  105777. dataOffset += 4;
  105778. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105779. this._vertexBuffers["angle"] = options;
  105780. dataOffset += 1;
  105781. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105782. this._vertexBuffers["size"] = size;
  105783. dataOffset += 2;
  105784. if (this._isAnimationSheetEnabled) {
  105785. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105786. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  105787. dataOffset += 1;
  105788. }
  105789. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105790. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105791. this._vertexBuffers["direction"] = directionBuffer;
  105792. dataOffset += 3;
  105793. }
  105794. if (this._useRampGradients) {
  105795. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105796. this._vertexBuffers["remapData"] = rampDataBuffer;
  105797. dataOffset += 4;
  105798. }
  105799. var offsets;
  105800. if (this._useInstancing) {
  105801. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105802. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105803. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105804. }
  105805. else {
  105806. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105807. dataOffset += 2;
  105808. }
  105809. this._vertexBuffers["offset"] = offsets;
  105810. };
  105811. ParticleSystem.prototype._createIndexBuffer = function () {
  105812. if (this._useInstancing) {
  105813. return;
  105814. }
  105815. var indices = [];
  105816. var index = 0;
  105817. for (var count = 0; count < this._capacity; count++) {
  105818. indices.push(index);
  105819. indices.push(index + 1);
  105820. indices.push(index + 2);
  105821. indices.push(index);
  105822. indices.push(index + 2);
  105823. indices.push(index + 3);
  105824. index += 4;
  105825. }
  105826. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  105827. };
  105828. /**
  105829. * Gets the maximum number of particles active at the same time.
  105830. * @returns The max number of active particles.
  105831. */
  105832. ParticleSystem.prototype.getCapacity = function () {
  105833. return this._capacity;
  105834. };
  105835. /**
  105836. * Gets whether there are still active particles in the system.
  105837. * @returns True if it is alive, otherwise false.
  105838. */
  105839. ParticleSystem.prototype.isAlive = function () {
  105840. return this._alive;
  105841. };
  105842. /**
  105843. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105844. * @returns True if it has been started, otherwise false.
  105845. */
  105846. ParticleSystem.prototype.isStarted = function () {
  105847. return this._started;
  105848. };
  105849. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  105850. var _this = this;
  105851. this._subEmitters = new Array();
  105852. if (this.subEmitters) {
  105853. this.subEmitters.forEach(function (subEmitter) {
  105854. if (subEmitter instanceof ParticleSystem) {
  105855. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  105856. }
  105857. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  105858. _this._subEmitters.push([subEmitter]);
  105859. }
  105860. else if (subEmitter instanceof Array) {
  105861. _this._subEmitters.push(subEmitter);
  105862. }
  105863. });
  105864. }
  105865. };
  105866. /**
  105867. * Starts the particle system and begins to emit
  105868. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105869. */
  105870. ParticleSystem.prototype.start = function (delay) {
  105871. var _this = this;
  105872. if (delay === void 0) { delay = this.startDelay; }
  105873. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  105874. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  105875. }
  105876. if (delay) {
  105877. setTimeout(function () {
  105878. _this.start(0);
  105879. }, delay);
  105880. return;
  105881. }
  105882. // Convert the subEmitters field to the constant type field _subEmitters
  105883. this._prepareSubEmitterInternalArray();
  105884. this._started = true;
  105885. this._stopped = false;
  105886. this._actualFrame = 0;
  105887. if (this._subEmitters && this._subEmitters.length != 0) {
  105888. this.activeSubSystems = new Array();
  105889. }
  105890. // Reset emit gradient so it acts the same on every start
  105891. if (this._emitRateGradients) {
  105892. if (this._emitRateGradients.length > 0) {
  105893. this._currentEmitRateGradient = this._emitRateGradients[0];
  105894. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  105895. this._currentEmitRate2 = this._currentEmitRate1;
  105896. }
  105897. if (this._emitRateGradients.length > 1) {
  105898. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  105899. }
  105900. }
  105901. // Reset start size gradient so it acts the same on every start
  105902. if (this._startSizeGradients) {
  105903. if (this._startSizeGradients.length > 0) {
  105904. this._currentStartSizeGradient = this._startSizeGradients[0];
  105905. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  105906. this._currentStartSize2 = this._currentStartSize1;
  105907. }
  105908. if (this._startSizeGradients.length > 1) {
  105909. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  105910. }
  105911. }
  105912. if (this.preWarmCycles) {
  105913. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  105914. this.emitter.computeWorldMatrix(true);
  105915. }
  105916. var noiseTextureAsProcedural_1 = this.noiseTexture;
  105917. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  105918. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  105919. setTimeout(function () {
  105920. for (var index = 0; index < _this.preWarmCycles; index++) {
  105921. _this.animate(true);
  105922. noiseTextureAsProcedural_1.render();
  105923. }
  105924. });
  105925. });
  105926. }
  105927. else {
  105928. for (var index = 0; index < this.preWarmCycles; index++) {
  105929. this.animate(true);
  105930. }
  105931. }
  105932. }
  105933. // Animations
  105934. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  105935. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  105936. }
  105937. };
  105938. /**
  105939. * Stops the particle system.
  105940. * @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.
  105941. */
  105942. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  105943. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  105944. this._stopped = true;
  105945. if (stopSubEmitters) {
  105946. this._stopSubEmitters();
  105947. }
  105948. };
  105949. // animation sheet
  105950. /**
  105951. * Remove all active particles
  105952. */
  105953. ParticleSystem.prototype.reset = function () {
  105954. this._stockParticles = [];
  105955. this._particles = [];
  105956. };
  105957. /**
  105958. * @hidden (for internal use only)
  105959. */
  105960. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  105961. var offset = index * this._vertexBufferSize;
  105962. this._vertexData[offset++] = particle.position.x;
  105963. this._vertexData[offset++] = particle.position.y;
  105964. this._vertexData[offset++] = particle.position.z;
  105965. this._vertexData[offset++] = particle.color.r;
  105966. this._vertexData[offset++] = particle.color.g;
  105967. this._vertexData[offset++] = particle.color.b;
  105968. this._vertexData[offset++] = particle.color.a;
  105969. this._vertexData[offset++] = particle.angle;
  105970. this._vertexData[offset++] = particle.scale.x * particle.size;
  105971. this._vertexData[offset++] = particle.scale.y * particle.size;
  105972. if (this._isAnimationSheetEnabled) {
  105973. this._vertexData[offset++] = particle.cellIndex;
  105974. }
  105975. if (!this._isBillboardBased) {
  105976. if (particle._initialDirection) {
  105977. this._vertexData[offset++] = particle._initialDirection.x;
  105978. this._vertexData[offset++] = particle._initialDirection.y;
  105979. this._vertexData[offset++] = particle._initialDirection.z;
  105980. }
  105981. else {
  105982. this._vertexData[offset++] = particle.direction.x;
  105983. this._vertexData[offset++] = particle.direction.y;
  105984. this._vertexData[offset++] = particle.direction.z;
  105985. }
  105986. }
  105987. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105988. this._vertexData[offset++] = particle.direction.x;
  105989. this._vertexData[offset++] = particle.direction.y;
  105990. this._vertexData[offset++] = particle.direction.z;
  105991. }
  105992. if (this._useRampGradients) {
  105993. this._vertexData[offset++] = particle.remapData.x;
  105994. this._vertexData[offset++] = particle.remapData.y;
  105995. this._vertexData[offset++] = particle.remapData.z;
  105996. this._vertexData[offset++] = particle.remapData.w;
  105997. }
  105998. if (!this._useInstancing) {
  105999. if (this._isAnimationSheetEnabled) {
  106000. if (offsetX === 0) {
  106001. offsetX = this._epsilon;
  106002. }
  106003. else if (offsetX === 1) {
  106004. offsetX = 1 - this._epsilon;
  106005. }
  106006. if (offsetY === 0) {
  106007. offsetY = this._epsilon;
  106008. }
  106009. else if (offsetY === 1) {
  106010. offsetY = 1 - this._epsilon;
  106011. }
  106012. }
  106013. this._vertexData[offset++] = offsetX;
  106014. this._vertexData[offset++] = offsetY;
  106015. }
  106016. };
  106017. ParticleSystem.prototype._stopSubEmitters = function () {
  106018. if (!this.activeSubSystems) {
  106019. return;
  106020. }
  106021. this.activeSubSystems.forEach(function (subSystem) {
  106022. subSystem.stop(true);
  106023. });
  106024. this.activeSubSystems = new Array();
  106025. };
  106026. ParticleSystem.prototype._removeFromRoot = function () {
  106027. if (!this._rootParticleSystem) {
  106028. return;
  106029. }
  106030. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  106031. if (index !== -1) {
  106032. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  106033. }
  106034. this._rootParticleSystem = null;
  106035. };
  106036. // End of sub system methods
  106037. ParticleSystem.prototype._update = function (newParticles) {
  106038. var _this = this;
  106039. // Update current
  106040. this._alive = this._particles.length > 0;
  106041. if (this.emitter.position) {
  106042. var emitterMesh = this.emitter;
  106043. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  106044. }
  106045. else {
  106046. var emitterPosition = this.emitter;
  106047. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106048. }
  106049. this.updateFunction(this._particles);
  106050. // Add new ones
  106051. var particle;
  106052. var _loop_2 = function () {
  106053. if (this_1._particles.length === this_1._capacity) {
  106054. return "break";
  106055. }
  106056. particle = this_1._createParticle();
  106057. this_1._particles.push(particle);
  106058. // Emitter
  106059. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  106060. if (this_1.startPositionFunction) {
  106061. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106062. }
  106063. else {
  106064. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106065. }
  106066. if (this_1.startDirectionFunction) {
  106067. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106068. }
  106069. else {
  106070. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106071. }
  106072. if (emitPower === 0) {
  106073. if (!particle._initialDirection) {
  106074. particle._initialDirection = particle.direction.clone();
  106075. }
  106076. else {
  106077. particle._initialDirection.copyFrom(particle.direction);
  106078. }
  106079. }
  106080. else {
  106081. particle._initialDirection = null;
  106082. }
  106083. particle.direction.scaleInPlace(emitPower);
  106084. // Life time
  106085. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  106086. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  106087. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  106088. var factorGradient1 = currentGradient;
  106089. var factorGradient2 = nextGradient;
  106090. var lifeTime1 = factorGradient1.getFactor();
  106091. var lifeTime2 = factorGradient2.getFactor();
  106092. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  106093. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  106094. });
  106095. }
  106096. else {
  106097. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  106098. }
  106099. // Size
  106100. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  106101. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  106102. }
  106103. else {
  106104. particle._currentSizeGradient = this_1._sizeGradients[0];
  106105. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  106106. particle.size = particle._currentSize1;
  106107. if (this_1._sizeGradients.length > 1) {
  106108. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  106109. }
  106110. else {
  106111. particle._currentSize2 = particle._currentSize1;
  106112. }
  106113. }
  106114. // Size and scale
  106115. 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));
  106116. // Adjust scale by start size
  106117. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  106118. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  106119. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  106120. if (currentGradient !== _this._currentStartSizeGradient) {
  106121. _this._currentStartSize1 = _this._currentStartSize2;
  106122. _this._currentStartSize2 = nextGradient.getFactor();
  106123. _this._currentStartSizeGradient = currentGradient;
  106124. }
  106125. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  106126. particle.scale.scaleInPlace(value);
  106127. });
  106128. }
  106129. // Angle
  106130. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  106131. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  106132. }
  106133. else {
  106134. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  106135. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  106136. particle._currentAngularSpeed1 = particle.angularSpeed;
  106137. if (this_1._angularSpeedGradients.length > 1) {
  106138. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  106139. }
  106140. else {
  106141. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  106142. }
  106143. }
  106144. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  106145. // Velocity
  106146. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  106147. particle._currentVelocityGradient = this_1._velocityGradients[0];
  106148. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  106149. if (this_1._velocityGradients.length > 1) {
  106150. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  106151. }
  106152. else {
  106153. particle._currentVelocity2 = particle._currentVelocity1;
  106154. }
  106155. }
  106156. // Limit velocity
  106157. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  106158. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  106159. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  106160. if (this_1._limitVelocityGradients.length > 1) {
  106161. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  106162. }
  106163. else {
  106164. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  106165. }
  106166. }
  106167. // Drag
  106168. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  106169. particle._currentDragGradient = this_1._dragGradients[0];
  106170. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  106171. if (this_1._dragGradients.length > 1) {
  106172. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  106173. }
  106174. else {
  106175. particle._currentDrag2 = particle._currentDrag1;
  106176. }
  106177. }
  106178. // Color
  106179. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  106180. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  106181. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  106182. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  106183. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  106184. }
  106185. else {
  106186. particle._currentColorGradient = this_1._colorGradients[0];
  106187. particle._currentColorGradient.getColorToRef(particle.color);
  106188. particle._currentColor1.copyFrom(particle.color);
  106189. if (this_1._colorGradients.length > 1) {
  106190. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  106191. }
  106192. else {
  106193. particle._currentColor2.copyFrom(particle.color);
  106194. }
  106195. }
  106196. // Sheet
  106197. if (this_1._isAnimationSheetEnabled) {
  106198. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  106199. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  106200. }
  106201. // Inherited Velocity
  106202. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  106203. // Ramp
  106204. if (this_1._useRampGradients) {
  106205. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  106206. }
  106207. // Noise texture coordinates
  106208. if (this_1.noiseTexture) {
  106209. if (particle._randomNoiseCoordinates1) {
  106210. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  106211. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  106212. }
  106213. else {
  106214. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106215. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106216. }
  106217. }
  106218. // Update the position of the attached sub-emitters to match their attached particle
  106219. particle._inheritParticleInfoToSubEmitters();
  106220. };
  106221. var this_1 = this, step;
  106222. for (var index = 0; index < newParticles; index++) {
  106223. var state_1 = _loop_2();
  106224. if (state_1 === "break")
  106225. break;
  106226. }
  106227. };
  106228. /** @hidden */
  106229. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  106230. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106231. if (isBillboardBased === void 0) { isBillboardBased = false; }
  106232. if (useRampGradients === void 0) { useRampGradients = false; }
  106233. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  106234. if (isAnimationSheetEnabled) {
  106235. attributeNamesOrOptions.push("cellIndex");
  106236. }
  106237. if (!isBillboardBased) {
  106238. attributeNamesOrOptions.push("direction");
  106239. }
  106240. if (useRampGradients) {
  106241. attributeNamesOrOptions.push("remapData");
  106242. }
  106243. return attributeNamesOrOptions;
  106244. };
  106245. /** @hidden */
  106246. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  106247. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106248. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  106249. if (isAnimationSheetEnabled) {
  106250. effectCreationOption.push("particlesInfos");
  106251. }
  106252. return effectCreationOption;
  106253. };
  106254. /** @hidden */
  106255. ParticleSystem.prototype._getEffect = function (blendMode) {
  106256. if (this._customEffect) {
  106257. return this._customEffect;
  106258. }
  106259. var defines = [];
  106260. if (this._scene.clipPlane) {
  106261. defines.push("#define CLIPPLANE");
  106262. }
  106263. if (this._scene.clipPlane2) {
  106264. defines.push("#define CLIPPLANE2");
  106265. }
  106266. if (this._scene.clipPlane3) {
  106267. defines.push("#define CLIPPLANE3");
  106268. }
  106269. if (this._scene.clipPlane4) {
  106270. defines.push("#define CLIPPLANE4");
  106271. }
  106272. if (this._isAnimationSheetEnabled) {
  106273. defines.push("#define ANIMATESHEET");
  106274. }
  106275. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  106276. defines.push("#define BLENDMULTIPLYMODE");
  106277. }
  106278. if (this._useRampGradients) {
  106279. defines.push("#define RAMPGRADIENT");
  106280. }
  106281. if (this._isBillboardBased) {
  106282. defines.push("#define BILLBOARD");
  106283. switch (this.billboardMode) {
  106284. case ParticleSystem.BILLBOARDMODE_Y:
  106285. defines.push("#define BILLBOARDY");
  106286. break;
  106287. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  106288. defines.push("#define BILLBOARDSTRETCHED");
  106289. break;
  106290. case ParticleSystem.BILLBOARDMODE_ALL:
  106291. default:
  106292. break;
  106293. }
  106294. }
  106295. if (this._imageProcessingConfiguration) {
  106296. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106297. defines.push(this._imageProcessingConfigurationDefines.toString());
  106298. }
  106299. // Effect
  106300. var join = defines.join("\n");
  106301. if (this._cachedDefines !== join) {
  106302. this._cachedDefines = join;
  106303. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  106304. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  106305. var samplers = ["diffuseSampler", "rampSampler"];
  106306. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  106307. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  106308. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106309. }
  106310. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  106311. }
  106312. return this._effect;
  106313. };
  106314. /**
  106315. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106316. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  106317. */
  106318. ParticleSystem.prototype.animate = function (preWarmOnly) {
  106319. var _this = this;
  106320. if (preWarmOnly === void 0) { preWarmOnly = false; }
  106321. if (!this._started) {
  106322. return;
  106323. }
  106324. if (!preWarmOnly) {
  106325. // Check
  106326. if (!this.isReady()) {
  106327. return;
  106328. }
  106329. if (this._currentRenderId === this._scene.getFrameId()) {
  106330. return;
  106331. }
  106332. this._currentRenderId = this._scene.getFrameId();
  106333. }
  106334. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106335. // Determine the number of particles we need to create
  106336. var newParticles;
  106337. if (this.manualEmitCount > -1) {
  106338. newParticles = this.manualEmitCount;
  106339. this._newPartsExcess = 0;
  106340. this.manualEmitCount = 0;
  106341. }
  106342. else {
  106343. var rate_1 = this.emitRate;
  106344. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  106345. var ratio = this._actualFrame / this.targetStopDuration;
  106346. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  106347. if (currentGradient !== _this._currentEmitRateGradient) {
  106348. _this._currentEmitRate1 = _this._currentEmitRate2;
  106349. _this._currentEmitRate2 = nextGradient.getFactor();
  106350. _this._currentEmitRateGradient = currentGradient;
  106351. }
  106352. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  106353. });
  106354. }
  106355. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  106356. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  106357. }
  106358. if (this._newPartsExcess > 1.0) {
  106359. newParticles += this._newPartsExcess >> 0;
  106360. this._newPartsExcess -= this._newPartsExcess >> 0;
  106361. }
  106362. this._alive = false;
  106363. if (!this._stopped) {
  106364. this._actualFrame += this._scaledUpdateSpeed;
  106365. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106366. this.stop();
  106367. }
  106368. }
  106369. else {
  106370. newParticles = 0;
  106371. }
  106372. this._update(newParticles);
  106373. // Stopped?
  106374. if (this._stopped) {
  106375. if (!this._alive) {
  106376. this._started = false;
  106377. if (this.onAnimationEnd) {
  106378. this.onAnimationEnd();
  106379. }
  106380. if (this.disposeOnStop) {
  106381. this._scene._toBeDisposed.push(this);
  106382. }
  106383. }
  106384. }
  106385. if (!preWarmOnly) {
  106386. // Update VBO
  106387. var offset = 0;
  106388. for (var index = 0; index < this._particles.length; index++) {
  106389. var particle = this._particles[index];
  106390. this._appendParticleVertices(offset, particle);
  106391. offset += this._useInstancing ? 1 : 4;
  106392. }
  106393. if (this._vertexBuffer) {
  106394. this._vertexBuffer.update(this._vertexData);
  106395. }
  106396. }
  106397. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  106398. this.stop();
  106399. }
  106400. };
  106401. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  106402. this._appendParticleVertex(offset++, particle, 0, 0);
  106403. if (!this._useInstancing) {
  106404. this._appendParticleVertex(offset++, particle, 1, 0);
  106405. this._appendParticleVertex(offset++, particle, 1, 1);
  106406. this._appendParticleVertex(offset++, particle, 0, 1);
  106407. }
  106408. };
  106409. /**
  106410. * Rebuilds the particle system.
  106411. */
  106412. ParticleSystem.prototype.rebuild = function () {
  106413. this._createIndexBuffer();
  106414. if (this._vertexBuffer) {
  106415. this._vertexBuffer._rebuild();
  106416. }
  106417. };
  106418. /**
  106419. * Is this system ready to be used/rendered
  106420. * @return true if the system is ready
  106421. */
  106422. ParticleSystem.prototype.isReady = function () {
  106423. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106424. return false;
  106425. }
  106426. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106427. if (!this._getEffect(this.blendMode).isReady()) {
  106428. return false;
  106429. }
  106430. }
  106431. else {
  106432. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  106433. return false;
  106434. }
  106435. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  106436. return false;
  106437. }
  106438. }
  106439. return true;
  106440. };
  106441. ParticleSystem.prototype._render = function (blendMode) {
  106442. var effect = this._getEffect(blendMode);
  106443. var engine = this._scene.getEngine();
  106444. // Render
  106445. engine.enableEffect(effect);
  106446. var viewMatrix = this._scene.getViewMatrix();
  106447. effect.setTexture("diffuseSampler", this.particleTexture);
  106448. effect.setMatrix("view", viewMatrix);
  106449. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  106450. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106451. var baseSize = this.particleTexture.getBaseSize();
  106452. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106453. }
  106454. effect.setVector2("translationPivot", this.translationPivot);
  106455. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  106456. if (this._isBillboardBased) {
  106457. var camera = this._scene.activeCamera;
  106458. effect.setVector3("eyePosition", camera.globalPosition);
  106459. }
  106460. if (this._rampGradientsTexture) {
  106461. effect.setTexture("rampSampler", this._rampGradientsTexture);
  106462. }
  106463. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106464. var invView = viewMatrix.clone();
  106465. invView.invert();
  106466. effect.setMatrix("invView", invView);
  106467. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  106468. }
  106469. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  106470. // image processing
  106471. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106472. this._imageProcessingConfiguration.bind(effect);
  106473. }
  106474. // Draw order
  106475. switch (blendMode) {
  106476. case ParticleSystem.BLENDMODE_ADD:
  106477. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  106478. break;
  106479. case ParticleSystem.BLENDMODE_ONEONE:
  106480. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  106481. break;
  106482. case ParticleSystem.BLENDMODE_STANDARD:
  106483. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  106484. break;
  106485. case ParticleSystem.BLENDMODE_MULTIPLY:
  106486. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  106487. break;
  106488. }
  106489. if (this._useInstancing) {
  106490. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  106491. }
  106492. else {
  106493. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  106494. }
  106495. return this._particles.length;
  106496. };
  106497. /**
  106498. * Renders the particle system in its current state.
  106499. * @returns the current number of particles
  106500. */
  106501. ParticleSystem.prototype.render = function () {
  106502. // Check
  106503. if (!this.isReady() || !this._particles.length) {
  106504. return 0;
  106505. }
  106506. var engine = this._scene.getEngine();
  106507. engine.setState(false);
  106508. if (this.forceDepthWrite) {
  106509. engine.setDepthWrite(true);
  106510. }
  106511. var outparticles = 0;
  106512. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106513. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  106514. }
  106515. outparticles = this._render(this.blendMode);
  106516. engine.unbindInstanceAttributes();
  106517. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  106518. return outparticles;
  106519. };
  106520. /**
  106521. * Disposes the particle system and free the associated resources
  106522. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106523. */
  106524. ParticleSystem.prototype.dispose = function (disposeTexture) {
  106525. if (disposeTexture === void 0) { disposeTexture = true; }
  106526. if (this._vertexBuffer) {
  106527. this._vertexBuffer.dispose();
  106528. this._vertexBuffer = null;
  106529. }
  106530. if (this._spriteBuffer) {
  106531. this._spriteBuffer.dispose();
  106532. this._spriteBuffer = null;
  106533. }
  106534. if (this._indexBuffer) {
  106535. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  106536. this._indexBuffer = null;
  106537. }
  106538. if (disposeTexture && this.particleTexture) {
  106539. this.particleTexture.dispose();
  106540. this.particleTexture = null;
  106541. }
  106542. if (disposeTexture && this.noiseTexture) {
  106543. this.noiseTexture.dispose();
  106544. this.noiseTexture = null;
  106545. }
  106546. if (this._rampGradientsTexture) {
  106547. this._rampGradientsTexture.dispose();
  106548. this._rampGradientsTexture = null;
  106549. }
  106550. this._removeFromRoot();
  106551. if (this._subEmitters && this._subEmitters.length) {
  106552. for (var index = 0; index < this._subEmitters.length; index++) {
  106553. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  106554. var subEmitter = _a[_i];
  106555. subEmitter.dispose();
  106556. }
  106557. }
  106558. this._subEmitters = [];
  106559. this.subEmitters = [];
  106560. }
  106561. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  106562. this.emitter.dispose(true);
  106563. }
  106564. // Remove from scene
  106565. var index = this._scene.particleSystems.indexOf(this);
  106566. if (index > -1) {
  106567. this._scene.particleSystems.splice(index, 1);
  106568. }
  106569. this._scene._activeParticleSystems.dispose();
  106570. // Callback
  106571. this.onDisposeObservable.notifyObservers(this);
  106572. this.onDisposeObservable.clear();
  106573. this.reset();
  106574. };
  106575. // Clone
  106576. /**
  106577. * Clones the particle system.
  106578. * @param name The name of the cloned object
  106579. * @param newEmitter The new emitter to use
  106580. * @returns the cloned particle system
  106581. */
  106582. ParticleSystem.prototype.clone = function (name, newEmitter) {
  106583. var custom = null;
  106584. var program = null;
  106585. if (this.customShader != null) {
  106586. program = this.customShader;
  106587. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106588. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106589. }
  106590. else if (this._customEffect) {
  106591. custom = this._customEffect;
  106592. }
  106593. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  106594. result.customShader = program;
  106595. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  106596. if (newEmitter === undefined) {
  106597. newEmitter = this.emitter;
  106598. }
  106599. result.noiseTexture = this.noiseTexture;
  106600. result.emitter = newEmitter;
  106601. if (this.particleTexture) {
  106602. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  106603. }
  106604. // Clone gradients
  106605. if (this._colorGradients) {
  106606. this._colorGradients.forEach(function (v) {
  106607. result.addColorGradient(v.gradient, v.color1, v.color2);
  106608. });
  106609. }
  106610. if (this._dragGradients) {
  106611. this._dragGradients.forEach(function (v) {
  106612. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  106613. });
  106614. }
  106615. if (this._angularSpeedGradients) {
  106616. this._angularSpeedGradients.forEach(function (v) {
  106617. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  106618. });
  106619. }
  106620. if (this._emitRateGradients) {
  106621. this._emitRateGradients.forEach(function (v) {
  106622. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  106623. });
  106624. }
  106625. if (this._lifeTimeGradients) {
  106626. this._lifeTimeGradients.forEach(function (v) {
  106627. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  106628. });
  106629. }
  106630. if (this._limitVelocityGradients) {
  106631. this._limitVelocityGradients.forEach(function (v) {
  106632. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  106633. });
  106634. }
  106635. if (this._sizeGradients) {
  106636. this._sizeGradients.forEach(function (v) {
  106637. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  106638. });
  106639. }
  106640. if (this._startSizeGradients) {
  106641. this._startSizeGradients.forEach(function (v) {
  106642. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  106643. });
  106644. }
  106645. if (this._velocityGradients) {
  106646. this._velocityGradients.forEach(function (v) {
  106647. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  106648. });
  106649. }
  106650. if (this._rampGradients) {
  106651. this._rampGradients.forEach(function (v) {
  106652. result.addRampGradient(v.gradient, v.color);
  106653. });
  106654. }
  106655. if (this._colorRemapGradients) {
  106656. this._colorRemapGradients.forEach(function (v) {
  106657. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  106658. });
  106659. }
  106660. if (this._alphaRemapGradients) {
  106661. this._alphaRemapGradients.forEach(function (v) {
  106662. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  106663. });
  106664. }
  106665. if (!this.preventAutoStart) {
  106666. result.start();
  106667. }
  106668. return result;
  106669. };
  106670. /**
  106671. * Serializes the particle system to a JSON object.
  106672. * @returns the JSON object
  106673. */
  106674. ParticleSystem.prototype.serialize = function () {
  106675. var serializationObject = {};
  106676. ParticleSystem._Serialize(serializationObject, this);
  106677. serializationObject.textureMask = this.textureMask.asArray();
  106678. serializationObject.customShader = this.customShader;
  106679. serializationObject.preventAutoStart = this.preventAutoStart;
  106680. // SubEmitters
  106681. if (this.subEmitters) {
  106682. serializationObject.subEmitters = [];
  106683. if (!this._subEmitters) {
  106684. this._prepareSubEmitterInternalArray();
  106685. }
  106686. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  106687. var subs = _a[_i];
  106688. var cell = [];
  106689. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  106690. var sub = subs_1[_b];
  106691. cell.push(sub.serialize());
  106692. }
  106693. serializationObject.subEmitters.push(cell);
  106694. }
  106695. }
  106696. return serializationObject;
  106697. };
  106698. /** @hidden */
  106699. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  106700. serializationObject.name = particleSystem.name;
  106701. serializationObject.id = particleSystem.id;
  106702. serializationObject.capacity = particleSystem.getCapacity();
  106703. // Emitter
  106704. if (particleSystem.emitter.position) {
  106705. var emitterMesh = particleSystem.emitter;
  106706. serializationObject.emitterId = emitterMesh.id;
  106707. }
  106708. else {
  106709. var emitterPosition = particleSystem.emitter;
  106710. serializationObject.emitter = emitterPosition.asArray();
  106711. }
  106712. // Emitter
  106713. if (particleSystem.particleEmitterType) {
  106714. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  106715. }
  106716. if (particleSystem.particleTexture) {
  106717. serializationObject.textureName = particleSystem.particleTexture.name;
  106718. serializationObject.invertY = particleSystem.particleTexture._invertY;
  106719. }
  106720. // Animations
  106721. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  106722. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  106723. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  106724. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  106725. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  106726. // Particle system
  106727. serializationObject.startDelay = particleSystem.startDelay;
  106728. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  106729. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  106730. serializationObject.billboardMode = particleSystem.billboardMode;
  106731. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  106732. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  106733. serializationObject.minSize = particleSystem.minSize;
  106734. serializationObject.maxSize = particleSystem.maxSize;
  106735. serializationObject.minScaleX = particleSystem.minScaleX;
  106736. serializationObject.maxScaleX = particleSystem.maxScaleX;
  106737. serializationObject.minScaleY = particleSystem.minScaleY;
  106738. serializationObject.maxScaleY = particleSystem.maxScaleY;
  106739. serializationObject.minEmitPower = particleSystem.minEmitPower;
  106740. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  106741. serializationObject.minLifeTime = particleSystem.minLifeTime;
  106742. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  106743. serializationObject.emitRate = particleSystem.emitRate;
  106744. serializationObject.gravity = particleSystem.gravity.asArray();
  106745. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  106746. serializationObject.color1 = particleSystem.color1.asArray();
  106747. serializationObject.color2 = particleSystem.color2.asArray();
  106748. serializationObject.colorDead = particleSystem.colorDead.asArray();
  106749. serializationObject.updateSpeed = particleSystem.updateSpeed;
  106750. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  106751. serializationObject.blendMode = particleSystem.blendMode;
  106752. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  106753. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  106754. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  106755. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  106756. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  106757. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  106758. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  106759. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  106760. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  106761. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  106762. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  106763. var colorGradients = particleSystem.getColorGradients();
  106764. if (colorGradients) {
  106765. serializationObject.colorGradients = [];
  106766. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  106767. var colorGradient = colorGradients_1[_i];
  106768. var serializedGradient = {
  106769. gradient: colorGradient.gradient,
  106770. color1: colorGradient.color1.asArray()
  106771. };
  106772. if (colorGradient.color2) {
  106773. serializedGradient.color2 = colorGradient.color2.asArray();
  106774. }
  106775. serializationObject.colorGradients.push(serializedGradient);
  106776. }
  106777. }
  106778. var rampGradients = particleSystem.getRampGradients();
  106779. if (rampGradients) {
  106780. serializationObject.rampGradients = [];
  106781. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  106782. var rampGradient = rampGradients_1[_a];
  106783. var serializedGradient = {
  106784. gradient: rampGradient.gradient,
  106785. color: rampGradient.color.asArray()
  106786. };
  106787. serializationObject.rampGradients.push(serializedGradient);
  106788. }
  106789. serializationObject.useRampGradients = particleSystem.useRampGradients;
  106790. }
  106791. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106792. if (colorRemapGradients) {
  106793. serializationObject.colorRemapGradients = [];
  106794. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106795. var colorRemapGradient = colorRemapGradients_1[_b];
  106796. var serializedGradient = {
  106797. gradient: colorRemapGradient.gradient,
  106798. factor1: colorRemapGradient.factor1
  106799. };
  106800. if (colorRemapGradient.factor2 !== undefined) {
  106801. serializedGradient.factor2 = colorRemapGradient.factor2;
  106802. }
  106803. serializationObject.colorRemapGradients.push(serializedGradient);
  106804. }
  106805. }
  106806. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106807. if (alphaRemapGradients) {
  106808. serializationObject.alphaRemapGradients = [];
  106809. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106810. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106811. var serializedGradient = {
  106812. gradient: alphaRemapGradient.gradient,
  106813. factor1: alphaRemapGradient.factor1
  106814. };
  106815. if (alphaRemapGradient.factor2 !== undefined) {
  106816. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106817. }
  106818. serializationObject.alphaRemapGradients.push(serializedGradient);
  106819. }
  106820. }
  106821. var sizeGradients = particleSystem.getSizeGradients();
  106822. if (sizeGradients) {
  106823. serializationObject.sizeGradients = [];
  106824. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106825. var sizeGradient = sizeGradients_1[_d];
  106826. var serializedGradient = {
  106827. gradient: sizeGradient.gradient,
  106828. factor1: sizeGradient.factor1
  106829. };
  106830. if (sizeGradient.factor2 !== undefined) {
  106831. serializedGradient.factor2 = sizeGradient.factor2;
  106832. }
  106833. serializationObject.sizeGradients.push(serializedGradient);
  106834. }
  106835. }
  106836. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  106837. if (angularSpeedGradients) {
  106838. serializationObject.angularSpeedGradients = [];
  106839. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  106840. var angularSpeedGradient = angularSpeedGradients_1[_e];
  106841. var serializedGradient = {
  106842. gradient: angularSpeedGradient.gradient,
  106843. factor1: angularSpeedGradient.factor1
  106844. };
  106845. if (angularSpeedGradient.factor2 !== undefined) {
  106846. serializedGradient.factor2 = angularSpeedGradient.factor2;
  106847. }
  106848. serializationObject.angularSpeedGradients.push(serializedGradient);
  106849. }
  106850. }
  106851. var velocityGradients = particleSystem.getVelocityGradients();
  106852. if (velocityGradients) {
  106853. serializationObject.velocityGradients = [];
  106854. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  106855. var velocityGradient = velocityGradients_1[_f];
  106856. var serializedGradient = {
  106857. gradient: velocityGradient.gradient,
  106858. factor1: velocityGradient.factor1
  106859. };
  106860. if (velocityGradient.factor2 !== undefined) {
  106861. serializedGradient.factor2 = velocityGradient.factor2;
  106862. }
  106863. serializationObject.velocityGradients.push(serializedGradient);
  106864. }
  106865. }
  106866. var dragGradients = particleSystem.getDragGradients();
  106867. if (dragGradients) {
  106868. serializationObject.dragyGradients = [];
  106869. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  106870. var dragGradient = dragGradients_1[_g];
  106871. var serializedGradient = {
  106872. gradient: dragGradient.gradient,
  106873. factor1: dragGradient.factor1
  106874. };
  106875. if (dragGradient.factor2 !== undefined) {
  106876. serializedGradient.factor2 = dragGradient.factor2;
  106877. }
  106878. serializationObject.dragGradients.push(serializedGradient);
  106879. }
  106880. }
  106881. var emitRateGradients = particleSystem.getEmitRateGradients();
  106882. if (emitRateGradients) {
  106883. serializationObject.emitRateGradients = [];
  106884. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  106885. var emitRateGradient = emitRateGradients_1[_h];
  106886. var serializedGradient = {
  106887. gradient: emitRateGradient.gradient,
  106888. factor1: emitRateGradient.factor1
  106889. };
  106890. if (emitRateGradient.factor2 !== undefined) {
  106891. serializedGradient.factor2 = emitRateGradient.factor2;
  106892. }
  106893. serializationObject.emitRateGradients.push(serializedGradient);
  106894. }
  106895. }
  106896. var startSizeGradients = particleSystem.getStartSizeGradients();
  106897. if (startSizeGradients) {
  106898. serializationObject.startSizeGradients = [];
  106899. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  106900. var startSizeGradient = startSizeGradients_1[_j];
  106901. var serializedGradient = {
  106902. gradient: startSizeGradient.gradient,
  106903. factor1: startSizeGradient.factor1
  106904. };
  106905. if (startSizeGradient.factor2 !== undefined) {
  106906. serializedGradient.factor2 = startSizeGradient.factor2;
  106907. }
  106908. serializationObject.startSizeGradients.push(serializedGradient);
  106909. }
  106910. }
  106911. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  106912. if (lifeTimeGradients) {
  106913. serializationObject.lifeTimeGradients = [];
  106914. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  106915. var lifeTimeGradient = lifeTimeGradients_1[_k];
  106916. var serializedGradient = {
  106917. gradient: lifeTimeGradient.gradient,
  106918. factor1: lifeTimeGradient.factor1
  106919. };
  106920. if (lifeTimeGradient.factor2 !== undefined) {
  106921. serializedGradient.factor2 = lifeTimeGradient.factor2;
  106922. }
  106923. serializationObject.lifeTimeGradients.push(serializedGradient);
  106924. }
  106925. }
  106926. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  106927. if (limitVelocityGradients) {
  106928. serializationObject.limitVelocityGradients = [];
  106929. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  106930. var limitVelocityGradient = limitVelocityGradients_1[_l];
  106931. var serializedGradient = {
  106932. gradient: limitVelocityGradient.gradient,
  106933. factor1: limitVelocityGradient.factor1
  106934. };
  106935. if (limitVelocityGradient.factor2 !== undefined) {
  106936. serializedGradient.factor2 = limitVelocityGradient.factor2;
  106937. }
  106938. serializationObject.limitVelocityGradients.push(serializedGradient);
  106939. }
  106940. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  106941. }
  106942. if (particleSystem.noiseTexture) {
  106943. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  106944. }
  106945. };
  106946. /** @hidden */
  106947. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  106948. // Texture
  106949. if (parsedParticleSystem.textureName) {
  106950. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  106951. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  106952. }
  106953. // Emitter
  106954. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  106955. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  106956. }
  106957. else if (parsedParticleSystem.emitterId) {
  106958. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  106959. }
  106960. else {
  106961. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  106962. }
  106963. // Misc.
  106964. if (parsedParticleSystem.renderingGroupId !== undefined) {
  106965. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  106966. }
  106967. if (parsedParticleSystem.isBillboardBased !== undefined) {
  106968. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  106969. }
  106970. if (parsedParticleSystem.billboardMode !== undefined) {
  106971. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  106972. }
  106973. // Animations
  106974. if (parsedParticleSystem.animations) {
  106975. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  106976. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  106977. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  106978. if (internalClass) {
  106979. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  106980. }
  106981. }
  106982. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  106983. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  106984. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  106985. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  106986. }
  106987. if (parsedParticleSystem.autoAnimate) {
  106988. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  106989. }
  106990. // Particle system
  106991. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  106992. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  106993. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  106994. particleSystem.minSize = parsedParticleSystem.minSize;
  106995. particleSystem.maxSize = parsedParticleSystem.maxSize;
  106996. if (parsedParticleSystem.minScaleX) {
  106997. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  106998. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  106999. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  107000. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  107001. }
  107002. if (parsedParticleSystem.preWarmCycles !== undefined) {
  107003. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  107004. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  107005. }
  107006. if (parsedParticleSystem.minInitialRotation !== undefined) {
  107007. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  107008. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  107009. }
  107010. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  107011. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  107012. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  107013. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  107014. particleSystem.emitRate = parsedParticleSystem.emitRate;
  107015. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  107016. if (parsedParticleSystem.noiseStrength) {
  107017. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  107018. }
  107019. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  107020. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  107021. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  107022. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  107023. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  107024. particleSystem.blendMode = parsedParticleSystem.blendMode;
  107025. if (parsedParticleSystem.colorGradients) {
  107026. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  107027. var colorGradient = _a[_i];
  107028. particleSystem.addColorGradient(colorGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(colorGradient.color1), colorGradient.color2 ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(colorGradient.color2) : undefined);
  107029. }
  107030. }
  107031. if (parsedParticleSystem.rampGradients) {
  107032. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  107033. var rampGradient = _c[_b];
  107034. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  107035. }
  107036. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  107037. }
  107038. if (parsedParticleSystem.colorRemapGradients) {
  107039. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  107040. var colorRemapGradient = _e[_d];
  107041. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  107042. }
  107043. }
  107044. if (parsedParticleSystem.alphaRemapGradients) {
  107045. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  107046. var alphaRemapGradient = _g[_f];
  107047. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  107048. }
  107049. }
  107050. if (parsedParticleSystem.sizeGradients) {
  107051. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  107052. var sizeGradient = _j[_h];
  107053. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107054. }
  107055. }
  107056. if (parsedParticleSystem.sizeGradients) {
  107057. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  107058. var sizeGradient = _l[_k];
  107059. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107060. }
  107061. }
  107062. if (parsedParticleSystem.angularSpeedGradients) {
  107063. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  107064. var angularSpeedGradient = _o[_m];
  107065. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  107066. }
  107067. }
  107068. if (parsedParticleSystem.velocityGradients) {
  107069. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  107070. var velocityGradient = _q[_p];
  107071. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  107072. }
  107073. }
  107074. if (parsedParticleSystem.dragGradients) {
  107075. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  107076. var dragGradient = _s[_r];
  107077. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  107078. }
  107079. }
  107080. if (parsedParticleSystem.emitRateGradients) {
  107081. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  107082. var emitRateGradient = _u[_t];
  107083. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  107084. }
  107085. }
  107086. if (parsedParticleSystem.startSizeGradients) {
  107087. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  107088. var startSizeGradient = _w[_v];
  107089. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  107090. }
  107091. }
  107092. if (parsedParticleSystem.lifeTimeGradients) {
  107093. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  107094. var lifeTimeGradient = _y[_x];
  107095. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  107096. }
  107097. }
  107098. if (parsedParticleSystem.limitVelocityGradients) {
  107099. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  107100. var limitVelocityGradient = _0[_z];
  107101. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  107102. }
  107103. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  107104. }
  107105. if (parsedParticleSystem.noiseTexture) {
  107106. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  107107. }
  107108. // Emitter
  107109. var emitterType;
  107110. if (parsedParticleSystem.particleEmitterType) {
  107111. switch (parsedParticleSystem.particleEmitterType.type) {
  107112. case "SphereParticleEmitter":
  107113. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  107114. break;
  107115. case "SphereDirectedParticleEmitter":
  107116. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  107117. break;
  107118. case "ConeEmitter":
  107119. case "ConeParticleEmitter":
  107120. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  107121. break;
  107122. case "CylinderParticleEmitter":
  107123. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  107124. break;
  107125. case "HemisphericParticleEmitter":
  107126. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  107127. break;
  107128. case "BoxEmitter":
  107129. case "BoxParticleEmitter":
  107130. default:
  107131. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107132. break;
  107133. }
  107134. emitterType.parse(parsedParticleSystem.particleEmitterType);
  107135. }
  107136. else {
  107137. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107138. emitterType.parse(parsedParticleSystem);
  107139. }
  107140. particleSystem.particleEmitterType = emitterType;
  107141. // Animation sheet
  107142. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  107143. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  107144. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  107145. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  107146. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  107147. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  107148. };
  107149. /**
  107150. * Parses a JSON object to create a particle system.
  107151. * @param parsedParticleSystem The JSON object to parse
  107152. * @param scene The scene to create the particle system in
  107153. * @param rootUrl The root url to use to load external dependencies like texture
  107154. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107155. * @returns the Parsed particle system
  107156. */
  107157. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107158. if (doNotStart === void 0) { doNotStart = false; }
  107159. var name = parsedParticleSystem.name;
  107160. var custom = null;
  107161. var program = null;
  107162. if (parsedParticleSystem.customShader) {
  107163. program = parsedParticleSystem.customShader;
  107164. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107165. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107166. }
  107167. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  107168. particleSystem.customShader = program;
  107169. if (parsedParticleSystem.id) {
  107170. particleSystem.id = parsedParticleSystem.id;
  107171. }
  107172. // SubEmitters
  107173. if (parsedParticleSystem.subEmitters) {
  107174. particleSystem.subEmitters = [];
  107175. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  107176. var cell = _a[_i];
  107177. var cellArray = [];
  107178. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  107179. var sub = cell_1[_b];
  107180. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  107181. }
  107182. particleSystem.subEmitters.push(cellArray);
  107183. }
  107184. }
  107185. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  107186. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  107187. // Auto start
  107188. if (parsedParticleSystem.preventAutoStart) {
  107189. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  107190. }
  107191. if (!doNotStart && !particleSystem.preventAutoStart) {
  107192. particleSystem.start();
  107193. }
  107194. return particleSystem;
  107195. };
  107196. /**
  107197. * Billboard mode will only apply to Y axis
  107198. */
  107199. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  107200. /**
  107201. * Billboard mode will apply to all axes
  107202. */
  107203. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107204. /**
  107205. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  107206. */
  107207. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  107208. return ParticleSystem;
  107209. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  107210. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  107211. /***/ }),
  107212. /***/ "./Particles/particleSystemComponent.ts":
  107213. /*!**********************************************!*\
  107214. !*** ./Particles/particleSystemComponent.ts ***!
  107215. \**********************************************/
  107216. /*! exports provided: _IDoNeedToBeInTheBuild */
  107217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107218. "use strict";
  107219. __webpack_require__.r(__webpack_exports__);
  107220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  107221. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107222. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107223. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  107224. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107225. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107226. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  107227. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107228. // Adds the parsers to the scene parsers.
  107229. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  107230. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  107231. if (!individualParser) {
  107232. return;
  107233. }
  107234. // Particles Systems
  107235. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  107236. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  107237. var parsedParticleSystem = parsedData.particleSystems[index];
  107238. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  107239. }
  107240. }
  107241. });
  107242. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  107243. if (parsedParticleSystem.activeParticleCount) {
  107244. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107245. return ps;
  107246. }
  107247. else {
  107248. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107249. return ps;
  107250. }
  107251. });
  107252. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  107253. if (uniformsNames === void 0) { uniformsNames = []; }
  107254. if (samplers === void 0) { samplers = []; }
  107255. if (defines === void 0) { defines = ""; }
  107256. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  107257. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  107258. if (defines.indexOf(" BILLBOARD") === -1) {
  107259. defines += "\n#define BILLBOARD\n";
  107260. }
  107261. if (samplers.indexOf("diffuseSampler") === -1) {
  107262. samplers.push("diffuseSampler");
  107263. }
  107264. return this.createEffect({
  107265. vertex: "particles",
  107266. fragmentElement: fragmentName
  107267. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  107268. };
  107269. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  107270. var results = new Array();
  107271. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107272. var particleSystem = this.getScene().particleSystems[index];
  107273. if (particleSystem.emitter === this) {
  107274. results.push(particleSystem);
  107275. }
  107276. }
  107277. return results;
  107278. };
  107279. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  107280. var results = new Array();
  107281. var descendants = this.getDescendants();
  107282. descendants.push(this);
  107283. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107284. var particleSystem = this.getScene().particleSystems[index];
  107285. var emitter = particleSystem.emitter;
  107286. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  107287. results.push(particleSystem);
  107288. }
  107289. }
  107290. return results;
  107291. };
  107292. /**
  107293. * @hidden
  107294. */
  107295. var _IDoNeedToBeInTheBuild = 42;
  107296. /***/ }),
  107297. /***/ "./Particles/particleSystemSet.ts":
  107298. /*!****************************************!*\
  107299. !*** ./Particles/particleSystemSet.ts ***!
  107300. \****************************************/
  107301. /*! exports provided: ParticleSystemSet */
  107302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107303. "use strict";
  107304. __webpack_require__.r(__webpack_exports__);
  107305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  107306. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107307. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  107308. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107309. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107310. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  107311. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  107312. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107313. /** Internal class used to store shapes for emitters */
  107314. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  107315. function ParticleSystemSetEmitterCreationOptions() {
  107316. }
  107317. return ParticleSystemSetEmitterCreationOptions;
  107318. }());
  107319. /**
  107320. * Represents a set of particle systems working together to create a specific effect
  107321. */
  107322. var ParticleSystemSet = /** @class */ (function () {
  107323. function ParticleSystemSet() {
  107324. /**
  107325. * Gets the particle system list
  107326. */
  107327. this.systems = new Array();
  107328. }
  107329. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  107330. /**
  107331. * Gets the emitter node used with this set
  107332. */
  107333. get: function () {
  107334. return this._emitterNode;
  107335. },
  107336. enumerable: true,
  107337. configurable: true
  107338. });
  107339. /**
  107340. * Creates a new emitter mesh as a sphere
  107341. * @param options defines the options used to create the sphere
  107342. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107343. * @param scene defines the hosting scene
  107344. */
  107345. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  107346. if (this._emitterNode) {
  107347. this._emitterNode.dispose();
  107348. }
  107349. this._emitterCreationOptions = {
  107350. kind: "Sphere",
  107351. options: options,
  107352. renderingGroupId: renderingGroupId
  107353. };
  107354. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  107355. emitterMesh.renderingGroupId = renderingGroupId;
  107356. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  107357. material.emissiveColor = options.color;
  107358. emitterMesh.material = material;
  107359. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107360. var system = _a[_i];
  107361. system.emitter = emitterMesh;
  107362. }
  107363. this._emitterNode = emitterMesh;
  107364. };
  107365. /**
  107366. * Starts all particle systems of the set
  107367. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107368. */
  107369. ParticleSystemSet.prototype.start = function (emitter) {
  107370. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107371. var system = _a[_i];
  107372. if (emitter) {
  107373. system.emitter = emitter;
  107374. }
  107375. system.start();
  107376. }
  107377. };
  107378. /**
  107379. * Release all associated resources
  107380. */
  107381. ParticleSystemSet.prototype.dispose = function () {
  107382. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107383. var system = _a[_i];
  107384. system.dispose();
  107385. }
  107386. this.systems = [];
  107387. if (this._emitterNode) {
  107388. this._emitterNode.dispose();
  107389. this._emitterNode = null;
  107390. }
  107391. };
  107392. /**
  107393. * Serialize the set into a JSON compatible object
  107394. * @returns a JSON compatible representation of the set
  107395. */
  107396. ParticleSystemSet.prototype.serialize = function () {
  107397. var result = {};
  107398. result.systems = [];
  107399. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107400. var system = _a[_i];
  107401. result.systems.push(system.serialize());
  107402. }
  107403. if (this._emitterNode) {
  107404. result.emitter = this._emitterCreationOptions;
  107405. }
  107406. return result;
  107407. };
  107408. /**
  107409. * Parse a new ParticleSystemSet from a serialized source
  107410. * @param data defines a JSON compatible representation of the set
  107411. * @param scene defines the hosting scene
  107412. * @param gpu defines if we want GPU particles or CPU particles
  107413. * @returns a new ParticleSystemSet
  107414. */
  107415. ParticleSystemSet.Parse = function (data, scene, gpu) {
  107416. if (gpu === void 0) { gpu = false; }
  107417. var result = new ParticleSystemSet();
  107418. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  107419. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107420. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  107421. var system = _a[_i];
  107422. 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));
  107423. }
  107424. if (data.emitter) {
  107425. var options = data.emitter.options;
  107426. switch (data.emitter.kind) {
  107427. case "Sphere":
  107428. result.setEmitterAsSphere({
  107429. diameter: options.diameter,
  107430. segments: options.segments,
  107431. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  107432. }, data.emitter.renderingGroupId, scene);
  107433. break;
  107434. }
  107435. }
  107436. return result;
  107437. };
  107438. return ParticleSystemSet;
  107439. }());
  107440. /***/ }),
  107441. /***/ "./Particles/solidParticle.ts":
  107442. /*!************************************!*\
  107443. !*** ./Particles/solidParticle.ts ***!
  107444. \************************************/
  107445. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  107446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107447. "use strict";
  107448. __webpack_require__.r(__webpack_exports__);
  107449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  107450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  107451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  107452. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107453. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107454. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  107455. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107456. /**
  107457. * Represents one particle of a solid particle system.
  107458. */
  107459. var SolidParticle = /** @class */ (function () {
  107460. /**
  107461. * Creates a Solid Particle object.
  107462. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107463. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  107464. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107465. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107466. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107467. * @param shapeId (integer) is the model shape identifier in the SPS.
  107468. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107469. * @param sps defines the sps it is associated to
  107470. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107471. */
  107472. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  107473. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  107474. /**
  107475. * particle global index
  107476. */
  107477. this.idx = 0;
  107478. /**
  107479. * The color of the particle
  107480. */
  107481. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107482. /**
  107483. * The world space position of the particle.
  107484. */
  107485. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107486. /**
  107487. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107488. */
  107489. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107490. /**
  107491. * The scaling of the particle.
  107492. */
  107493. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  107494. /**
  107495. * The uvs of the particle.
  107496. */
  107497. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  107498. /**
  107499. * The current speed of the particle.
  107500. */
  107501. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107502. /**
  107503. * The pivot point in the particle local space.
  107504. */
  107505. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107506. /**
  107507. * Must the particle be translated from its pivot point in its local space ?
  107508. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107509. * Default : false
  107510. */
  107511. this.translateFromPivot = false;
  107512. /**
  107513. * Is the particle active or not ?
  107514. */
  107515. this.alive = true;
  107516. /**
  107517. * Is the particle visible or not ?
  107518. */
  107519. this.isVisible = true;
  107520. /**
  107521. * Index of this particle in the global "positions" array (Internal use)
  107522. * @hidden
  107523. */
  107524. this._pos = 0;
  107525. /**
  107526. * @hidden Index of this particle in the global "indices" array (Internal use)
  107527. */
  107528. this._ind = 0;
  107529. /**
  107530. * ModelShape id of this particle
  107531. */
  107532. this.shapeId = 0;
  107533. /**
  107534. * Index of the particle in its shape id (Internal use)
  107535. */
  107536. this.idxInShape = 0;
  107537. /**
  107538. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107539. */
  107540. this._stillInvisible = false;
  107541. /**
  107542. * @hidden Last computed particle rotation matrix
  107543. */
  107544. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  107545. /**
  107546. * Parent particle Id, if any.
  107547. * Default null.
  107548. */
  107549. this.parentId = null;
  107550. /**
  107551. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107552. * The possible values are :
  107553. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107554. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107555. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107557. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107558. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107559. * */
  107560. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  107561. /**
  107562. * @hidden Internal global position in the SPS.
  107563. */
  107564. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107565. this.idx = particleIndex;
  107566. this._pos = positionIndex;
  107567. this._ind = indiceIndex;
  107568. this._model = model;
  107569. this.shapeId = shapeId;
  107570. this.idxInShape = idxInShape;
  107571. this._sps = sps;
  107572. if (modelBoundingInfo) {
  107573. this._modelBoundingInfo = modelBoundingInfo;
  107574. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  107575. }
  107576. }
  107577. Object.defineProperty(SolidParticle.prototype, "scale", {
  107578. /**
  107579. * Legacy support, changed scale to scaling
  107580. */
  107581. get: function () {
  107582. return this.scaling;
  107583. },
  107584. /**
  107585. * Legacy support, changed scale to scaling
  107586. */
  107587. set: function (scale) {
  107588. this.scaling = scale;
  107589. },
  107590. enumerable: true,
  107591. configurable: true
  107592. });
  107593. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  107594. /**
  107595. * Legacy support, changed quaternion to rotationQuaternion
  107596. */
  107597. get: function () {
  107598. return this.rotationQuaternion;
  107599. },
  107600. /**
  107601. * Legacy support, changed quaternion to rotationQuaternion
  107602. */
  107603. set: function (q) {
  107604. this.rotationQuaternion = q;
  107605. },
  107606. enumerable: true,
  107607. configurable: true
  107608. });
  107609. /**
  107610. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107611. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107612. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107613. * @returns true if it intersects
  107614. */
  107615. SolidParticle.prototype.intersectsMesh = function (target) {
  107616. if (!this._boundingInfo || !target._boundingInfo) {
  107617. return false;
  107618. }
  107619. if (this._sps._bSphereOnly) {
  107620. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  107621. }
  107622. return this._boundingInfo.intersects(target._boundingInfo, false);
  107623. };
  107624. /**
  107625. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107626. * A particle is in the frustum if its bounding box intersects the frustum
  107627. * @param frustumPlanes defines the frustum to test
  107628. * @returns true if the particle is in the frustum planes
  107629. */
  107630. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  107631. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  107632. };
  107633. /**
  107634. * get the rotation matrix of the particle
  107635. * @hidden
  107636. */
  107637. SolidParticle.prototype.getRotationMatrix = function (m) {
  107638. var quaternion;
  107639. if (this.rotationQuaternion) {
  107640. quaternion = this.rotationQuaternion;
  107641. }
  107642. else {
  107643. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107644. var rotation = this.rotation;
  107645. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107646. }
  107647. quaternion.toRotationMatrix(m);
  107648. };
  107649. return SolidParticle;
  107650. }());
  107651. /**
  107652. * Represents the shape of the model used by one particle of a solid particle system.
  107653. * SPS internal tool, don't use it manually.
  107654. */
  107655. var ModelShape = /** @class */ (function () {
  107656. /**
  107657. * 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.
  107658. * SPS internal tool, don't use it manually.
  107659. * @hidden
  107660. */
  107661. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  107662. /**
  107663. * length of the shape in the model indices array (internal use)
  107664. * @hidden
  107665. */
  107666. this._indicesLength = 0;
  107667. this.shapeID = id;
  107668. this._shape = shape;
  107669. this._indicesLength = indicesLength;
  107670. this._shapeUV = shapeUV;
  107671. this._positionFunction = posFunction;
  107672. this._vertexFunction = vtxFunction;
  107673. }
  107674. return ModelShape;
  107675. }());
  107676. /**
  107677. * Represents a Depth Sorted Particle in the solid particle system.
  107678. */
  107679. var DepthSortedParticle = /** @class */ (function () {
  107680. function DepthSortedParticle() {
  107681. /**
  107682. * Index of the particle in the "indices" array
  107683. */
  107684. this.ind = 0;
  107685. /**
  107686. * Length of the particle shape in the "indices" array
  107687. */
  107688. this.indicesLength = 0;
  107689. /**
  107690. * Squared distance from the particle to the camera
  107691. */
  107692. this.sqDistance = 0.0;
  107693. }
  107694. return DepthSortedParticle;
  107695. }());
  107696. /***/ }),
  107697. /***/ "./Particles/solidParticleSystem.ts":
  107698. /*!******************************************!*\
  107699. !*** ./Particles/solidParticleSystem.ts ***!
  107700. \******************************************/
  107701. /*! exports provided: SolidParticleSystem */
  107702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107703. "use strict";
  107704. __webpack_require__.r(__webpack_exports__);
  107705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  107706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107707. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107708. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  107709. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107710. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  107711. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107712. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107713. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107714. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  107715. /**
  107716. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107717. *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.
  107718. * The SPS is also a particle system. It provides some methods to manage the particles.
  107719. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107720. *
  107721. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  107722. */
  107723. var SolidParticleSystem = /** @class */ (function () {
  107724. /**
  107725. * Creates a SPS (Solid Particle System) object.
  107726. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107727. * @param scene (Scene) is the scene in which the SPS is added.
  107728. * @param options defines the options of the sps e.g.
  107729. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107730. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107731. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107732. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107733. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107734. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107735. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107736. */
  107737. function SolidParticleSystem(name, scene, options) {
  107738. /**
  107739. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107740. * Example : var p = SPS.particles[i];
  107741. */
  107742. this.particles = new Array();
  107743. /**
  107744. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107745. */
  107746. this.nbParticles = 0;
  107747. /**
  107748. * If the particles must ever face the camera (default false). Useful for planar particles.
  107749. */
  107750. this.billboard = false;
  107751. /**
  107752. * Recompute normals when adding a shape
  107753. */
  107754. this.recomputeNormals = true;
  107755. /**
  107756. * This a counter ofr your own usage. It's not set by any SPS functions.
  107757. */
  107758. this.counter = 0;
  107759. /**
  107760. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107761. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  107762. */
  107763. this.vars = {};
  107764. /**
  107765. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107766. * @hidden
  107767. */
  107768. this._bSphereOnly = false;
  107769. /**
  107770. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107771. * @hidden
  107772. */
  107773. this._bSphereRadiusFactor = 1.0;
  107774. this._positions = new Array();
  107775. this._indices = new Array();
  107776. this._normals = new Array();
  107777. this._colors = new Array();
  107778. this._uvs = new Array();
  107779. this._index = 0; // indices index
  107780. this._updatable = true;
  107781. this._pickable = false;
  107782. this._isVisibilityBoxLocked = false;
  107783. this._alwaysVisible = false;
  107784. this._depthSort = false;
  107785. this._shapeCounter = 0;
  107786. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  107787. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107788. this._computeParticleColor = true;
  107789. this._computeParticleTexture = true;
  107790. this._computeParticleRotation = true;
  107791. this._computeParticleVertex = false;
  107792. this._computeBoundingBox = false;
  107793. this._depthSortParticles = true;
  107794. this._mustUnrotateFixedNormals = false;
  107795. this._particlesIntersect = false;
  107796. this._needs32Bits = false;
  107797. this.name = name;
  107798. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107799. this._camera = scene.activeCamera;
  107800. this._pickable = options ? options.isPickable : false;
  107801. this._depthSort = options ? options.enableDepthSort : false;
  107802. this._particlesIntersect = options ? options.particleIntersection : false;
  107803. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107804. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107805. if (options && options.updatable !== undefined) {
  107806. this._updatable = options.updatable;
  107807. }
  107808. else {
  107809. this._updatable = true;
  107810. }
  107811. if (this._pickable) {
  107812. this.pickedParticles = [];
  107813. }
  107814. if (this._depthSort) {
  107815. this.depthSortedParticles = [];
  107816. }
  107817. }
  107818. /**
  107819. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107820. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107821. * @returns the created mesh
  107822. */
  107823. SolidParticleSystem.prototype.buildMesh = function () {
  107824. if (this.nbParticles === 0) {
  107825. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  107826. this.addShape(triangle, 1);
  107827. triangle.dispose();
  107828. }
  107829. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  107830. this._positions32 = new Float32Array(this._positions);
  107831. this._uvs32 = new Float32Array(this._uvs);
  107832. this._colors32 = new Float32Array(this._colors);
  107833. if (this.recomputeNormals) {
  107834. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  107835. }
  107836. this._normals32 = new Float32Array(this._normals);
  107837. this._fixedNormal32 = new Float32Array(this._normals);
  107838. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  107839. this._unrotateFixedNormals();
  107840. }
  107841. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  107842. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  107843. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107844. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107845. if (this._uvs32.length > 0) {
  107846. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107847. }
  107848. if (this._colors32.length > 0) {
  107849. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107850. }
  107851. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  107852. vertexData.applyToMesh(mesh, this._updatable);
  107853. this.mesh = mesh;
  107854. this.mesh.isPickable = this._pickable;
  107855. // free memory
  107856. if (!this._depthSort) {
  107857. this._indices = null;
  107858. }
  107859. this._positions = null;
  107860. this._normals = null;
  107861. this._uvs = null;
  107862. this._colors = null;
  107863. if (!this._updatable) {
  107864. this.particles.length = 0;
  107865. }
  107866. return mesh;
  107867. };
  107868. /**
  107869. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107870. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107871. * Thus the particles generated from `digest()` have their property `position` set yet.
  107872. * @param mesh ( Mesh ) is the mesh to be digested
  107873. * @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
  107874. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107875. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107876. * @returns the current SPS
  107877. */
  107878. SolidParticleSystem.prototype.digest = function (mesh, options) {
  107879. var size = (options && options.facetNb) || 1;
  107880. var number = (options && options.number) || 0;
  107881. var delta = (options && options.delta) || 0;
  107882. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107883. var meshInd = mesh.getIndices();
  107884. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107885. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107886. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107887. var f = 0; // facet counter
  107888. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  107889. // compute size from number
  107890. if (number) {
  107891. number = (number > totalFacets) ? totalFacets : number;
  107892. size = Math.round(totalFacets / number);
  107893. delta = 0;
  107894. }
  107895. else {
  107896. size = (size > totalFacets) ? totalFacets : size;
  107897. }
  107898. var facetPos = []; // submesh positions
  107899. var facetInd = []; // submesh indices
  107900. var facetUV = []; // submesh UV
  107901. var facetCol = []; // submesh colors
  107902. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107903. var sizeO = size;
  107904. while (f < totalFacets) {
  107905. size = sizeO + Math.floor((1 + delta) * Math.random());
  107906. if (f > totalFacets - size) {
  107907. size = totalFacets - f;
  107908. }
  107909. // reset temp arrays
  107910. facetPos.length = 0;
  107911. facetInd.length = 0;
  107912. facetUV.length = 0;
  107913. facetCol.length = 0;
  107914. // iterate over "size" facets
  107915. var fi = 0;
  107916. for (var j = f * 3; j < (f + size) * 3; j++) {
  107917. facetInd.push(fi);
  107918. var i = meshInd[j];
  107919. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  107920. if (meshUV) {
  107921. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  107922. }
  107923. if (meshCol) {
  107924. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  107925. }
  107926. fi++;
  107927. }
  107928. // create a model shape for each single particle
  107929. var idx = this.nbParticles;
  107930. var shape = this._posToShape(facetPos);
  107931. var shapeUV = this._uvsToShapeUV(facetUV);
  107932. // compute the barycenter of the shape
  107933. var v;
  107934. for (v = 0; v < shape.length; v++) {
  107935. barycenter.addInPlace(shape[v]);
  107936. }
  107937. barycenter.scaleInPlace(1 / shape.length);
  107938. // shift the shape from its barycenter to the origin
  107939. for (v = 0; v < shape.length; v++) {
  107940. shape[v].subtractInPlace(barycenter);
  107941. }
  107942. var bInfo;
  107943. if (this._particlesIntersect) {
  107944. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  107945. }
  107946. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  107947. // add the particle in the SPS
  107948. var currentPos = this._positions.length;
  107949. var currentInd = this._indices.length;
  107950. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  107951. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  107952. // initialize the particle position
  107953. this.particles[this.nbParticles].position.addInPlace(barycenter);
  107954. this._index += shape.length;
  107955. idx++;
  107956. this.nbParticles++;
  107957. this._shapeCounter++;
  107958. f += size;
  107959. }
  107960. return this;
  107961. };
  107962. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107963. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  107964. var index = 0;
  107965. var idx = 0;
  107966. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107967. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107968. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107969. for (var p = 0; p < this.particles.length; p++) {
  107970. var particle = this.particles[p];
  107971. var shape = particle._model._shape;
  107972. // computing the inverse of the rotation matrix from the quaternion
  107973. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  107974. if (particle.rotationQuaternion) {
  107975. particle.rotationQuaternion.conjugateToRef(quaternion);
  107976. }
  107977. else {
  107978. var rotation = particle.rotation;
  107979. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107980. quaternion.conjugateInPlace();
  107981. }
  107982. quaternion.toRotationMatrix(invertedRotMatrix);
  107983. for (var pt = 0; pt < shape.length; pt++) {
  107984. idx = index + pt * 3;
  107985. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  107986. tmpNormal.toArray(this._fixedNormal32, idx);
  107987. }
  107988. index = idx + 3;
  107989. }
  107990. };
  107991. //reset copy
  107992. SolidParticleSystem.prototype._resetCopy = function () {
  107993. var copy = this._copy;
  107994. copy.position.setAll(0);
  107995. copy.rotation.setAll(0);
  107996. copy.rotationQuaternion = null;
  107997. copy.scaling.setAll(1);
  107998. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  107999. copy.color = null;
  108000. copy.translateFromPivot = false;
  108001. };
  108002. // _meshBuilder : inserts the shape model in the global SPS mesh
  108003. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  108004. var i;
  108005. var u = 0;
  108006. var c = 0;
  108007. var n = 0;
  108008. this._resetCopy();
  108009. var copy = this._copy;
  108010. if (options && options.positionFunction) { // call to custom positionFunction
  108011. options.positionFunction(copy, idx, idxInShape);
  108012. this._mustUnrotateFixedNormals = true;
  108013. }
  108014. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108015. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108016. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108017. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108018. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108019. copy.getRotationMatrix(rotMatrix);
  108020. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  108021. if (copy.translateFromPivot) {
  108022. pivotBackTranslation.setAll(0.0);
  108023. }
  108024. else {
  108025. pivotBackTranslation.copyFrom(scaledPivot);
  108026. }
  108027. for (i = 0; i < shape.length; i++) {
  108028. tmpVertex.copyFrom(shape[i]);
  108029. if (options && options.vertexFunction) {
  108030. options.vertexFunction(copy, tmpVertex, i);
  108031. }
  108032. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108033. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108034. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  108035. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  108036. if (meshUV) {
  108037. var copyUvs = copy.uvs;
  108038. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  108039. u += 2;
  108040. }
  108041. if (copy.color) {
  108042. this._color = copy.color;
  108043. }
  108044. else {
  108045. var color = this._color;
  108046. if (meshCol && meshCol[c] !== undefined) {
  108047. color.r = meshCol[c];
  108048. color.g = meshCol[c + 1];
  108049. color.b = meshCol[c + 2];
  108050. color.a = meshCol[c + 3];
  108051. }
  108052. else {
  108053. color.r = 1.0;
  108054. color.g = 1.0;
  108055. color.b = 1.0;
  108056. color.a = 1.0;
  108057. }
  108058. }
  108059. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  108060. c += 4;
  108061. if (!this.recomputeNormals && meshNor) {
  108062. tmpVertex.x = meshNor[n];
  108063. tmpVertex.y = meshNor[n + 1];
  108064. tmpVertex.z = meshNor[n + 2];
  108065. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  108066. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  108067. n += 3;
  108068. }
  108069. }
  108070. for (i = 0; i < meshInd.length; i++) {
  108071. var current_ind = p + meshInd[i];
  108072. indices.push(current_ind);
  108073. if (current_ind > 65535) {
  108074. this._needs32Bits = true;
  108075. }
  108076. }
  108077. if (this._pickable) {
  108078. var nbfaces = meshInd.length / 3;
  108079. for (i = 0; i < nbfaces; i++) {
  108080. this.pickedParticles.push({ idx: idx, faceId: i });
  108081. }
  108082. }
  108083. if (this._depthSort) {
  108084. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  108085. }
  108086. return copy;
  108087. };
  108088. // returns a shape array from positions array
  108089. SolidParticleSystem.prototype._posToShape = function (positions) {
  108090. var shape = [];
  108091. for (var i = 0; i < positions.length; i += 3) {
  108092. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  108093. }
  108094. return shape;
  108095. };
  108096. // returns a shapeUV array from a Vector4 uvs
  108097. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  108098. var shapeUV = [];
  108099. if (uvs) {
  108100. for (var i = 0; i < uvs.length; i++) {
  108101. shapeUV.push(uvs[i]);
  108102. }
  108103. }
  108104. return shapeUV;
  108105. };
  108106. // adds a new particle object in the particles array
  108107. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  108108. if (bInfo === void 0) { bInfo = null; }
  108109. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  108110. this.particles.push(sp);
  108111. return sp;
  108112. };
  108113. /**
  108114. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108115. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  108116. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108117. * @param nb (positive integer) the number of particles to be created from this model
  108118. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108119. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108120. * @returns the number of shapes in the system
  108121. */
  108122. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  108123. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108124. var meshInd = mesh.getIndices();
  108125. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108126. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108127. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108128. var bbInfo;
  108129. if (this._particlesIntersect) {
  108130. bbInfo = mesh.getBoundingInfo();
  108131. }
  108132. var shape = this._posToShape(meshPos);
  108133. var shapeUV = this._uvsToShapeUV(meshUV);
  108134. var posfunc = options ? options.positionFunction : null;
  108135. var vtxfunc = options ? options.vertexFunction : null;
  108136. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  108137. // particles
  108138. var sp;
  108139. var currentCopy;
  108140. var idx = this.nbParticles;
  108141. for (var i = 0; i < nb; i++) {
  108142. var currentPos = this._positions.length;
  108143. var currentInd = this._indices.length;
  108144. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  108145. if (this._updatable) {
  108146. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  108147. sp.position.copyFrom(currentCopy.position);
  108148. sp.rotation.copyFrom(currentCopy.rotation);
  108149. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  108150. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  108151. }
  108152. if (currentCopy.color && sp.color) {
  108153. sp.color.copyFrom(currentCopy.color);
  108154. }
  108155. sp.scaling.copyFrom(currentCopy.scaling);
  108156. sp.uvs.copyFrom(currentCopy.uvs);
  108157. }
  108158. this._index += shape.length;
  108159. idx++;
  108160. }
  108161. this.nbParticles += nb;
  108162. this._shapeCounter++;
  108163. return this._shapeCounter - 1;
  108164. };
  108165. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108166. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  108167. this._resetCopy();
  108168. var copy = this._copy;
  108169. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  108170. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  108171. }
  108172. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108173. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108174. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108175. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108176. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108177. copy.getRotationMatrix(rotMatrix);
  108178. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  108179. if (copy.translateFromPivot) {
  108180. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  108181. }
  108182. else {
  108183. pivotBackTranslation.copyFrom(scaledPivot);
  108184. }
  108185. var shape = particle._model._shape;
  108186. for (var pt = 0; pt < shape.length; pt++) {
  108187. tmpVertex.copyFrom(shape[pt]);
  108188. if (particle._model._vertexFunction) {
  108189. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  108190. }
  108191. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108192. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108193. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  108194. }
  108195. particle.position.setAll(0.0);
  108196. particle.rotation.setAll(0.0);
  108197. particle.rotationQuaternion = null;
  108198. particle.scaling.setAll(1.0);
  108199. particle.uvs.setAll(0.0);
  108200. particle.pivot.setAll(0.0);
  108201. particle.translateFromPivot = false;
  108202. particle.parentId = null;
  108203. };
  108204. /**
  108205. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108206. * @returns the SPS.
  108207. */
  108208. SolidParticleSystem.prototype.rebuildMesh = function () {
  108209. for (var p = 0; p < this.particles.length; p++) {
  108210. this._rebuildParticle(this.particles[p]);
  108211. }
  108212. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  108213. return this;
  108214. };
  108215. /**
  108216. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108217. * This method calls `updateParticle()` for each particle of the SPS.
  108218. * For an animated SPS, it is usually called within the render loop.
  108219. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108220. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108221. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108222. * @returns the SPS.
  108223. */
  108224. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  108225. if (start === void 0) { start = 0; }
  108226. if (end === void 0) { end = this.nbParticles - 1; }
  108227. if (update === void 0) { update = true; }
  108228. if (!this._updatable) {
  108229. return this;
  108230. }
  108231. // custom beforeUpdate
  108232. this.beforeUpdateParticles(start, end, update);
  108233. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108234. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  108235. var mesh = this.mesh;
  108236. var colors32 = this._colors32;
  108237. var positions32 = this._positions32;
  108238. var normals32 = this._normals32;
  108239. var uvs32 = this._uvs32;
  108240. var indices32 = this._indices32;
  108241. var indices = this._indices;
  108242. var fixedNormal32 = this._fixedNormal32;
  108243. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  108244. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  108245. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  108246. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  108247. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  108248. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  108249. var camInvertedPosition = tempVectors[10].setAll(0);
  108250. // cases when the World Matrix is to be computed first
  108251. if (this.billboard || this._depthSort) {
  108252. this.mesh.computeWorldMatrix(true);
  108253. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  108254. }
  108255. // if the particles will always face the camera
  108256. if (this.billboard) {
  108257. // compute the camera position and un-rotate it by the current mesh rotation
  108258. var tmpVertex = tempVectors[0];
  108259. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  108260. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  108261. camAxisZ.normalize();
  108262. // same for camera up vector extracted from the cam view matrix
  108263. var view = this._camera.getViewMatrix(true);
  108264. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  108265. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  108266. camAxisY.normalize();
  108267. camAxisX.normalize();
  108268. }
  108269. // if depthSort, compute the camera global position in the mesh local system
  108270. if (this._depthSort) {
  108271. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  108272. }
  108273. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  108274. var idx = 0; // current position index in the global array positions32
  108275. var index = 0; // position start index in the global array positions32 of the current particle
  108276. var colidx = 0; // current color index in the global array colors32
  108277. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  108278. var uvidx = 0; // current uv index in the global array uvs32
  108279. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  108280. var pt = 0; // current index in the particle model shape
  108281. if (this.mesh.isFacetDataEnabled) {
  108282. this._computeBoundingBox = true;
  108283. }
  108284. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  108285. if (this._computeBoundingBox) {
  108286. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  108287. var boundingInfo = this.mesh._boundingInfo;
  108288. if (boundingInfo) {
  108289. minimum.copyFrom(boundingInfo.minimum);
  108290. maximum.copyFrom(boundingInfo.maximum);
  108291. }
  108292. }
  108293. }
  108294. // particle loop
  108295. index = this.particles[start]._pos;
  108296. var vpos = (index / 3) | 0;
  108297. colorIndex = vpos * 4;
  108298. uvIndex = vpos * 2;
  108299. for (var p = start; p <= end; p++) {
  108300. var particle = this.particles[p];
  108301. // call to custom user function to update the particle properties
  108302. this.updateParticle(particle);
  108303. var shape = particle._model._shape;
  108304. var shapeUV = particle._model._shapeUV;
  108305. var particleRotationMatrix = particle._rotationMatrix;
  108306. var particlePosition = particle.position;
  108307. var particleRotation = particle.rotation;
  108308. var particleScaling = particle.scaling;
  108309. var particleGlobalPosition = particle._globalPosition;
  108310. // camera-particle distance for depth sorting
  108311. if (this._depthSort && this._depthSortParticles) {
  108312. var dsp = this.depthSortedParticles[p];
  108313. dsp.ind = particle._ind;
  108314. dsp.indicesLength = particle._model._indicesLength;
  108315. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  108316. }
  108317. // skip the computations for inactive or already invisible particles
  108318. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  108319. // increment indexes for the next particle
  108320. pt = shape.length;
  108321. index += pt * 3;
  108322. colorIndex += pt * 4;
  108323. uvIndex += pt * 2;
  108324. continue;
  108325. }
  108326. if (particle.isVisible) {
  108327. particle._stillInvisible = false; // un-mark permanent invisibility
  108328. var scaledPivot = tempVectors[12];
  108329. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  108330. // particle rotation matrix
  108331. if (this.billboard) {
  108332. particleRotation.x = 0.0;
  108333. particleRotation.y = 0.0;
  108334. }
  108335. if (this._computeParticleRotation || this.billboard) {
  108336. particle.getRotationMatrix(rotMatrix);
  108337. }
  108338. var particleHasParent = (particle.parentId !== null);
  108339. if (particleHasParent) {
  108340. var parent_1 = this.particles[particle.parentId];
  108341. var parentRotationMatrix = parent_1._rotationMatrix;
  108342. var parentGlobalPosition = parent_1._globalPosition;
  108343. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  108344. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  108345. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  108346. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  108347. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  108348. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  108349. if (this._computeParticleRotation || this.billboard) {
  108350. var rotMatrixValues = rotMatrix.m;
  108351. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  108352. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  108353. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  108354. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  108355. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  108356. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  108357. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  108358. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  108359. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  108360. }
  108361. }
  108362. else {
  108363. particleGlobalPosition.x = particlePosition.x;
  108364. particleGlobalPosition.y = particlePosition.y;
  108365. particleGlobalPosition.z = particlePosition.z;
  108366. if (this._computeParticleRotation || this.billboard) {
  108367. var rotMatrixValues = rotMatrix.m;
  108368. particleRotationMatrix[0] = rotMatrixValues[0];
  108369. particleRotationMatrix[1] = rotMatrixValues[1];
  108370. particleRotationMatrix[2] = rotMatrixValues[2];
  108371. particleRotationMatrix[3] = rotMatrixValues[4];
  108372. particleRotationMatrix[4] = rotMatrixValues[5];
  108373. particleRotationMatrix[5] = rotMatrixValues[6];
  108374. particleRotationMatrix[6] = rotMatrixValues[8];
  108375. particleRotationMatrix[7] = rotMatrixValues[9];
  108376. particleRotationMatrix[8] = rotMatrixValues[10];
  108377. }
  108378. }
  108379. var pivotBackTranslation = tempVectors[11];
  108380. if (particle.translateFromPivot) {
  108381. pivotBackTranslation.setAll(0.0);
  108382. }
  108383. else {
  108384. pivotBackTranslation.copyFrom(scaledPivot);
  108385. }
  108386. // particle vertex loop
  108387. for (pt = 0; pt < shape.length; pt++) {
  108388. idx = index + pt * 3;
  108389. colidx = colorIndex + pt * 4;
  108390. uvidx = uvIndex + pt * 2;
  108391. var tmpVertex = tempVectors[0];
  108392. tmpVertex.copyFrom(shape[pt]);
  108393. if (this._computeParticleVertex) {
  108394. this.updateParticleVertex(particle, tmpVertex, pt);
  108395. }
  108396. // positions
  108397. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  108398. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  108399. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  108400. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  108401. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  108402. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  108403. rotatedX += pivotBackTranslation.x;
  108404. rotatedY += pivotBackTranslation.y;
  108405. rotatedZ += pivotBackTranslation.z;
  108406. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108407. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108408. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108409. if (this._computeBoundingBox) {
  108410. minimum.minimizeInPlaceFromFloats(px, py, pz);
  108411. maximum.maximizeInPlaceFromFloats(px, py, pz);
  108412. }
  108413. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  108414. if (!this._computeParticleVertex) {
  108415. var normalx = fixedNormal32[idx];
  108416. var normaly = fixedNormal32[idx + 1];
  108417. var normalz = fixedNormal32[idx + 2];
  108418. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  108419. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  108420. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  108421. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  108422. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  108423. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  108424. }
  108425. if (this._computeParticleColor && particle.color) {
  108426. var color = particle.color;
  108427. var colors32_1 = this._colors32;
  108428. colors32_1[colidx] = color.r;
  108429. colors32_1[colidx + 1] = color.g;
  108430. colors32_1[colidx + 2] = color.b;
  108431. colors32_1[colidx + 3] = color.a;
  108432. }
  108433. if (this._computeParticleTexture) {
  108434. var uvs = particle.uvs;
  108435. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108436. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108437. }
  108438. }
  108439. }
  108440. // particle just set invisible : scaled to zero and positioned at the origin
  108441. else {
  108442. particle._stillInvisible = true; // mark the particle as invisible
  108443. for (pt = 0; pt < shape.length; pt++) {
  108444. idx = index + pt * 3;
  108445. colidx = colorIndex + pt * 4;
  108446. uvidx = uvIndex + pt * 2;
  108447. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  108448. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  108449. if (this._computeParticleColor && particle.color) {
  108450. var color = particle.color;
  108451. colors32[colidx] = color.r;
  108452. colors32[colidx + 1] = color.g;
  108453. colors32[colidx + 2] = color.b;
  108454. colors32[colidx + 3] = color.a;
  108455. }
  108456. if (this._computeParticleTexture) {
  108457. var uvs = particle.uvs;
  108458. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108459. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108460. }
  108461. }
  108462. }
  108463. // if the particle intersections must be computed : update the bbInfo
  108464. if (this._particlesIntersect) {
  108465. var bInfo = particle._boundingInfo;
  108466. var bBox = bInfo.boundingBox;
  108467. var bSphere = bInfo.boundingSphere;
  108468. var modelBoundingInfo = particle._modelBoundingInfo;
  108469. if (!this._bSphereOnly) {
  108470. // place, scale and rotate the particle bbox within the SPS local system, then update it
  108471. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  108472. var tempMin = tempVectors[1];
  108473. var tempMax = tempVectors[2];
  108474. tempMin.setAll(Number.MAX_VALUE);
  108475. tempMax.setAll(-Number.MAX_VALUE);
  108476. for (var b = 0; b < 8; b++) {
  108477. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  108478. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  108479. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  108480. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  108481. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  108482. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  108483. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108484. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108485. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108486. tempMin.minimizeInPlaceFromFloats(x, y, z);
  108487. tempMax.maximizeInPlaceFromFloats(x, y, z);
  108488. }
  108489. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  108490. }
  108491. // place and scale the particle bouding sphere in the SPS local system, then update it
  108492. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  108493. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  108494. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  108495. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  108496. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  108497. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  108498. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  108499. }
  108500. // increment indexes for the next particle
  108501. index = idx + 3;
  108502. colorIndex = colidx + 4;
  108503. uvIndex = uvidx + 2;
  108504. }
  108505. // if the VBO must be updated
  108506. if (update) {
  108507. if (this._computeParticleColor) {
  108508. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  108509. }
  108510. if (this._computeParticleTexture) {
  108511. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  108512. }
  108513. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  108514. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  108515. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  108516. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  108517. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  108518. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  108519. for (var i = 0; i < normals32.length; i++) {
  108520. fixedNormal32[i] = normals32[i];
  108521. }
  108522. }
  108523. if (!mesh.areNormalsFrozen) {
  108524. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  108525. }
  108526. }
  108527. if (this._depthSort && this._depthSortParticles) {
  108528. var depthSortedParticles = this.depthSortedParticles;
  108529. depthSortedParticles.sort(depthSortFunction);
  108530. var dspl = depthSortedParticles.length;
  108531. var sid = 0;
  108532. for (var sorted = 0; sorted < dspl; sorted++) {
  108533. var lind = depthSortedParticles[sorted].indicesLength;
  108534. var sind = depthSortedParticles[sorted].ind;
  108535. for (var i = 0; i < lind; i++) {
  108536. indices32[sid] = indices[sind + i];
  108537. sid++;
  108538. }
  108539. }
  108540. mesh.updateIndices(indices32);
  108541. }
  108542. }
  108543. if (this._computeBoundingBox) {
  108544. if (mesh._boundingInfo) {
  108545. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  108546. }
  108547. else {
  108548. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  108549. }
  108550. }
  108551. this.afterUpdateParticles(start, end, update);
  108552. return this;
  108553. };
  108554. /**
  108555. * Disposes the SPS.
  108556. */
  108557. SolidParticleSystem.prototype.dispose = function () {
  108558. this.mesh.dispose();
  108559. this.vars = null;
  108560. // drop references to internal big arrays for the GC
  108561. this._positions = null;
  108562. this._indices = null;
  108563. this._normals = null;
  108564. this._uvs = null;
  108565. this._colors = null;
  108566. this._indices32 = null;
  108567. this._positions32 = null;
  108568. this._normals32 = null;
  108569. this._fixedNormal32 = null;
  108570. this._uvs32 = null;
  108571. this._colors32 = null;
  108572. this.pickedParticles = null;
  108573. };
  108574. /**
  108575. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108576. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108577. * @returns the SPS.
  108578. */
  108579. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  108580. if (!this._isVisibilityBoxLocked) {
  108581. this.mesh.refreshBoundingInfo();
  108582. }
  108583. return this;
  108584. };
  108585. /**
  108586. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108587. * @param size the size (float) of the visibility box
  108588. * note : this doesn't lock the SPS mesh bounding box.
  108589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108590. */
  108591. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  108592. var vis = size / 2;
  108593. this.mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-vis, -vis, -vis), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vis, vis, vis));
  108594. };
  108595. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  108596. /**
  108597. * Gets whether the SPS as always visible or not
  108598. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108599. */
  108600. get: function () {
  108601. return this._alwaysVisible;
  108602. },
  108603. /**
  108604. * Sets the SPS as always visible or not
  108605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108606. */
  108607. set: function (val) {
  108608. this._alwaysVisible = val;
  108609. this.mesh.alwaysSelectAsActiveMesh = val;
  108610. },
  108611. enumerable: true,
  108612. configurable: true
  108613. });
  108614. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  108615. /**
  108616. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108618. */
  108619. get: function () {
  108620. return this._isVisibilityBoxLocked;
  108621. },
  108622. /**
  108623. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108624. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108625. */
  108626. set: function (val) {
  108627. this._isVisibilityBoxLocked = val;
  108628. var boundingInfo = this.mesh.getBoundingInfo();
  108629. boundingInfo.isLocked = val;
  108630. },
  108631. enumerable: true,
  108632. configurable: true
  108633. });
  108634. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  108635. /**
  108636. * Gets if `setParticles()` computes the particle rotations or not.
  108637. * Default value : true. The SPS is faster when it's set to false.
  108638. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108639. */
  108640. get: function () {
  108641. return this._computeParticleRotation;
  108642. },
  108643. /**
  108644. * Tells to `setParticles()` to compute the particle rotations or not.
  108645. * Default value : true. The SPS is faster when it's set to false.
  108646. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108647. */
  108648. set: function (val) {
  108649. this._computeParticleRotation = val;
  108650. },
  108651. enumerable: true,
  108652. configurable: true
  108653. });
  108654. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  108655. /**
  108656. * Gets if `setParticles()` computes the particle colors or not.
  108657. * Default value : true. The SPS is faster when it's set to false.
  108658. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108659. */
  108660. get: function () {
  108661. return this._computeParticleColor;
  108662. },
  108663. /**
  108664. * Tells to `setParticles()` to compute the particle colors or not.
  108665. * Default value : true. The SPS is faster when it's set to false.
  108666. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108667. */
  108668. set: function (val) {
  108669. this._computeParticleColor = val;
  108670. },
  108671. enumerable: true,
  108672. configurable: true
  108673. });
  108674. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  108675. /**
  108676. * Gets if `setParticles()` computes the particle textures or not.
  108677. * Default value : true. The SPS is faster when it's set to false.
  108678. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108679. */
  108680. get: function () {
  108681. return this._computeParticleTexture;
  108682. },
  108683. set: function (val) {
  108684. this._computeParticleTexture = val;
  108685. },
  108686. enumerable: true,
  108687. configurable: true
  108688. });
  108689. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  108690. /**
  108691. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108692. * Default value : false. The SPS is faster when it's set to false.
  108693. * Note : the particle custom vertex positions aren't stored values.
  108694. */
  108695. get: function () {
  108696. return this._computeParticleVertex;
  108697. },
  108698. /**
  108699. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108700. * Default value : false. The SPS is faster when it's set to false.
  108701. * Note : the particle custom vertex positions aren't stored values.
  108702. */
  108703. set: function (val) {
  108704. this._computeParticleVertex = val;
  108705. },
  108706. enumerable: true,
  108707. configurable: true
  108708. });
  108709. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  108710. /**
  108711. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108712. */
  108713. get: function () {
  108714. return this._computeBoundingBox;
  108715. },
  108716. /**
  108717. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108718. */
  108719. set: function (val) {
  108720. this._computeBoundingBox = val;
  108721. },
  108722. enumerable: true,
  108723. configurable: true
  108724. });
  108725. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  108726. /**
  108727. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108728. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108729. * Default : `true`
  108730. */
  108731. get: function () {
  108732. return this._depthSortParticles;
  108733. },
  108734. /**
  108735. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108736. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108737. * Default : `true`
  108738. */
  108739. set: function (val) {
  108740. this._depthSortParticles = val;
  108741. },
  108742. enumerable: true,
  108743. configurable: true
  108744. });
  108745. // =======================================================================
  108746. // Particle behavior logic
  108747. // these following methods may be overwritten by the user to fit his needs
  108748. /**
  108749. * This function does nothing. It may be overwritten to set all the particle first values.
  108750. * The SPS doesn't call this function, you may have to call it by your own.
  108751. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108752. */
  108753. SolidParticleSystem.prototype.initParticles = function () {
  108754. };
  108755. /**
  108756. * This function does nothing. It may be overwritten to recycle a particle.
  108757. * The SPS doesn't call this function, you may have to call it by your own.
  108758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108759. * @param particle The particle to recycle
  108760. * @returns the recycled particle
  108761. */
  108762. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  108763. return particle;
  108764. };
  108765. /**
  108766. * Updates a particle : this function should be overwritten by the user.
  108767. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108768. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108769. * @example : just set a particle position or velocity and recycle conditions
  108770. * @param particle The particle to update
  108771. * @returns the updated particle
  108772. */
  108773. SolidParticleSystem.prototype.updateParticle = function (particle) {
  108774. return particle;
  108775. };
  108776. /**
  108777. * Updates a vertex of a particle : it can be overwritten by the user.
  108778. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108779. * @param particle the current particle
  108780. * @param vertex the current index of the current particle
  108781. * @param pt the index of the current vertex in the particle shape
  108782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  108783. * @example : just set a vertex particle position
  108784. * @returns the updated vertex
  108785. */
  108786. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  108787. return vertex;
  108788. };
  108789. /**
  108790. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108791. * This does nothing and may be overwritten by the user.
  108792. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108793. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108794. * @param update the boolean update value actually passed to setParticles()
  108795. */
  108796. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108797. };
  108798. /**
  108799. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108800. * This will be passed three parameters.
  108801. * This does nothing and may be overwritten by the user.
  108802. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108803. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108804. * @param update the boolean update value actually passed to setParticles()
  108805. */
  108806. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108807. };
  108808. return SolidParticleSystem;
  108809. }());
  108810. /***/ }),
  108811. /***/ "./Particles/subEmitter.ts":
  108812. /*!*********************************!*\
  108813. !*** ./Particles/subEmitter.ts ***!
  108814. \*********************************/
  108815. /*! exports provided: SubEmitterType, SubEmitter */
  108816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108817. "use strict";
  108818. __webpack_require__.r(__webpack_exports__);
  108819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108821. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108822. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108823. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108824. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  108825. /**
  108826. * Type of sub emitter
  108827. */
  108828. var SubEmitterType;
  108829. (function (SubEmitterType) {
  108830. /**
  108831. * Attached to the particle over it's lifetime
  108832. */
  108833. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  108834. /**
  108835. * Created when the particle dies
  108836. */
  108837. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  108838. })(SubEmitterType || (SubEmitterType = {}));
  108839. /**
  108840. * Sub emitter class used to emit particles from an existing particle
  108841. */
  108842. var SubEmitter = /** @class */ (function () {
  108843. /**
  108844. * Creates a sub emitter
  108845. * @param particleSystem the particle system to be used by the sub emitter
  108846. */
  108847. function SubEmitter(
  108848. /**
  108849. * the particle system to be used by the sub emitter
  108850. */
  108851. particleSystem) {
  108852. this.particleSystem = particleSystem;
  108853. /**
  108854. * Type of the submitter (Default: END)
  108855. */
  108856. this.type = SubEmitterType.END;
  108857. /**
  108858. * 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)
  108859. * Note: This only is supported when using an emitter of type Mesh
  108860. */
  108861. this.inheritDirection = false;
  108862. /**
  108863. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  108864. */
  108865. this.inheritedVelocityAmount = 0;
  108866. // Create mesh as emitter to support rotation
  108867. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  108868. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  108869. }
  108870. // Automatically dispose of subemitter when system is disposed
  108871. particleSystem.onDisposeObservable.add(function () {
  108872. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  108873. particleSystem.emitter.dispose();
  108874. }
  108875. });
  108876. }
  108877. /**
  108878. * Clones the sub emitter
  108879. * @returns the cloned sub emitter
  108880. */
  108881. SubEmitter.prototype.clone = function () {
  108882. // Clone particle system
  108883. var emitter = this.particleSystem.emitter;
  108884. if (!emitter) {
  108885. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108886. }
  108887. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  108888. emitter = emitter.clone();
  108889. }
  108890. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  108891. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  108892. emitter.isVisible = false;
  108893. }
  108894. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  108895. // Clone properties
  108896. clone.type = this.type;
  108897. clone.inheritDirection = this.inheritDirection;
  108898. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108899. clone.particleSystem._disposeEmitterOnDispose = true;
  108900. clone.particleSystem.disposeOnStop = true;
  108901. return clone;
  108902. };
  108903. /**
  108904. * Serialize current object to a JSON object
  108905. * @returns the serialized object
  108906. */
  108907. SubEmitter.prototype.serialize = function () {
  108908. var serializationObject = {};
  108909. serializationObject.type = this.type;
  108910. serializationObject.inheritDirection = this.inheritDirection;
  108911. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108912. serializationObject.particleSystem = this.particleSystem.serialize();
  108913. return serializationObject;
  108914. };
  108915. /** @hidden */
  108916. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  108917. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  108918. };
  108919. /**
  108920. * Creates a new SubEmitter from a serialized JSON version
  108921. * @param serializationObject defines the JSON object to read from
  108922. * @param scene defines the hosting scene
  108923. * @param rootUrl defines the rootUrl for data loading
  108924. * @returns a new SubEmitter
  108925. */
  108926. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  108927. var system = serializationObject.particleSystem;
  108928. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  108929. subEmitter.type = serializationObject.type;
  108930. subEmitter.inheritDirection = serializationObject.inheritDirection;
  108931. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  108932. subEmitter.particleSystem._isSubEmitter = true;
  108933. return subEmitter;
  108934. };
  108935. /** Release associated resources */
  108936. SubEmitter.prototype.dispose = function () {
  108937. this.particleSystem.dispose();
  108938. };
  108939. return SubEmitter;
  108940. }());
  108941. /***/ }),
  108942. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  108943. /*!*****************************************!*\
  108944. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  108945. \*****************************************/
  108946. /*! exports provided: AmmoJSPlugin */
  108947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108948. "use strict";
  108949. __webpack_require__.r(__webpack_exports__);
  108950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  108951. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108953. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108954. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108955. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108956. /**
  108957. * AmmoJS Physics plugin
  108958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108959. * @see https://github.com/kripken/ammo.js/
  108960. */
  108961. var AmmoJSPlugin = /** @class */ (function () {
  108962. /**
  108963. * Initializes the ammoJS plugin
  108964. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108965. * @param ammoInjection can be used to inject your own ammo reference
  108966. */
  108967. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  108968. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108969. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  108970. var _this = this;
  108971. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108972. /**
  108973. * Reference to the Ammo library
  108974. */
  108975. this.bjsAMMO = {};
  108976. /**
  108977. * Name of the plugin
  108978. */
  108979. this.name = "AmmoJSPlugin";
  108980. this._timeStep = 1 / 60;
  108981. this._fixedTimeStep = 1 / 60;
  108982. this._maxSteps = 5;
  108983. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  108984. this._tmpContactCallbackResult = false;
  108985. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108986. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  108987. if (typeof ammoInjection === "function") {
  108988. ammoInjection(this.bjsAMMO);
  108989. }
  108990. else {
  108991. this.bjsAMMO = ammoInjection;
  108992. }
  108993. if (!this.isSupported()) {
  108994. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  108995. return;
  108996. }
  108997. // Initialize the physics world
  108998. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  108999. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  109000. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  109001. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  109002. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  109003. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  109004. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  109005. // Create temp ammo variables
  109006. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  109007. this._tmpAmmoTransform.setIdentity();
  109008. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  109009. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  109010. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  109011. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  109012. }
  109013. /**
  109014. * Sets the gravity of the physics world (m/(s^2))
  109015. * @param gravity Gravity to set
  109016. */
  109017. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  109018. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  109019. this.world.setGravity(this._tmpAmmoVectorA);
  109020. };
  109021. /**
  109022. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109023. * @param timeStep timestep to use in seconds
  109024. */
  109025. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109026. this._timeStep = timeStep;
  109027. };
  109028. /**
  109029. * 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)
  109030. * @param fixedTimeStep fixedTimeStep to use in seconds
  109031. */
  109032. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  109033. this._fixedTimeStep = fixedTimeStep;
  109034. };
  109035. /**
  109036. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109037. * @param maxSteps the maximum number of steps by the physics engine per frame
  109038. */
  109039. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  109040. this._maxSteps = maxSteps;
  109041. };
  109042. /**
  109043. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109044. * @returns the current timestep in seconds
  109045. */
  109046. AmmoJSPlugin.prototype.getTimeStep = function () {
  109047. return this._timeStep;
  109048. };
  109049. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  109050. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  109051. this._tmpContactCallbackResult = false;
  109052. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109053. return this._tmpContactCallbackResult;
  109054. };
  109055. // Ammo's collision events have some weird quirks
  109056. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  109057. // so only fire event if both contactTest and contactPairTest have a hit
  109058. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  109059. this._tmpContactCallbackResult = false;
  109060. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109061. return this._tmpContactCallbackResult;
  109062. };
  109063. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  109064. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  109065. //
  109066. // When maxSteps is 0 do the entire simulation in one step
  109067. // 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)
  109068. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  109069. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  109070. if (timeStep === void 0) { timeStep = 1 / 60; }
  109071. if (maxSteps === void 0) { maxSteps = 10; }
  109072. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  109073. if (maxSteps == 0) {
  109074. this.world.stepSimulation(timeStep, 0);
  109075. }
  109076. else {
  109077. while (maxSteps > 0 && timeStep > 0) {
  109078. if (timeStep - fixedTimeStep < fixedTimeStep) {
  109079. this.world.stepSimulation(timeStep, 0);
  109080. timeStep = 0;
  109081. }
  109082. else {
  109083. timeStep -= fixedTimeStep;
  109084. this.world.stepSimulation(fixedTimeStep, 0);
  109085. }
  109086. maxSteps--;
  109087. }
  109088. }
  109089. };
  109090. /**
  109091. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109092. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109093. * After the step the babylon meshes are set to the position of the physics imposters
  109094. * @param delta amount of time to step forward
  109095. * @param impostors array of imposters to update before/after the step
  109096. */
  109097. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109098. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  109099. var impostor = impostors_1[_i];
  109100. // Update physics world objects to match babylon world
  109101. impostor.beforeStep();
  109102. }
  109103. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  109104. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  109105. var mainImpostor = impostors_2[_a];
  109106. // After physics update make babylon world objects match physics world objects
  109107. mainImpostor.afterStep();
  109108. // Handle collision event
  109109. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  109110. if (this._isImpostorInContact(mainImpostor)) {
  109111. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  109112. var collideCallback = _c[_b];
  109113. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  109114. var otherImpostor = _e[_d];
  109115. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  109116. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  109117. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  109118. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  109119. }
  109120. }
  109121. }
  109122. }
  109123. }
  109124. }
  109125. }
  109126. };
  109127. /**
  109128. * Applies an implulse on the imposter
  109129. * @param impostor imposter to apply impulse
  109130. * @param force amount of force to be applied to the imposter
  109131. * @param contactPoint the location to apply the impulse on the imposter
  109132. */
  109133. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109134. impostor.physicsBody.activate();
  109135. var worldPoint = this._tmpAmmoVectorA;
  109136. var impulse = this._tmpAmmoVectorB;
  109137. // Convert contactPoint into world space
  109138. if (impostor.object && impostor.object.getWorldMatrix) {
  109139. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109140. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109141. contactPoint = this._tmpVector;
  109142. }
  109143. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109144. impulse.setValue(force.x, force.y, force.z);
  109145. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109146. };
  109147. /**
  109148. * Applies a force on the imposter
  109149. * @param impostor imposter to apply force
  109150. * @param force amount of force to be applied to the imposter
  109151. * @param contactPoint the location to apply the force on the imposter
  109152. */
  109153. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109154. impostor.physicsBody.activate();
  109155. var worldPoint = this._tmpAmmoVectorA;
  109156. var impulse = this._tmpAmmoVectorB;
  109157. // Convert contactPoint into world space
  109158. if (impostor.object && impostor.object.getWorldMatrix) {
  109159. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109160. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109161. contactPoint = this._tmpVector;
  109162. }
  109163. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109164. impulse.setValue(force.x, force.y, force.z);
  109165. impostor.physicsBody.applyForce(impulse, worldPoint);
  109166. };
  109167. /**
  109168. * Creates a physics body using the plugin
  109169. * @param impostor the imposter to create the physics body on
  109170. */
  109171. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109172. impostor._pluginData = { toDispose: [] };
  109173. //parent-child relationship
  109174. if (impostor.parent) {
  109175. if (impostor.physicsBody) {
  109176. this.removePhysicsBody(impostor);
  109177. impostor.forceUpdate();
  109178. }
  109179. return;
  109180. }
  109181. if (impostor.isBodyInitRequired()) {
  109182. var colShape = this._createShape(impostor);
  109183. var mass = impostor.getParam("mass");
  109184. impostor._pluginData.mass = mass;
  109185. var localInertia = new Ammo.btVector3(0, 0, 0);
  109186. var startTransform = new Ammo.btTransform();
  109187. startTransform.setIdentity();
  109188. if (mass !== 0) {
  109189. colShape.calculateLocalInertia(mass, localInertia);
  109190. }
  109191. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  109192. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  109193. startTransform.setOrigin(this._tmpAmmoVectorA);
  109194. startTransform.setRotation(this._tmpAmmoQuaternion);
  109195. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  109196. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  109197. var body = new Ammo.btRigidBody(rbInfo);
  109198. // Make objects kinematic if it's mass is 0
  109199. if (mass === 0) {
  109200. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  109201. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  109202. }
  109203. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  109204. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  109205. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  109206. }
  109207. this.world.addRigidBody(body);
  109208. impostor.physicsBody = body;
  109209. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  109210. this.setBodyFriction(impostor, impostor.getParam("friction"));
  109211. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  109212. }
  109213. };
  109214. /**
  109215. * Removes the physics body from the imposter and disposes of the body's memory
  109216. * @param impostor imposter to remove the physics body from
  109217. */
  109218. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109219. var _this = this;
  109220. if (this.world) {
  109221. this.world.removeRigidBody(impostor.physicsBody);
  109222. impostor._pluginData.toDispose.forEach(function (d) {
  109223. _this.bjsAMMO.destroy(d);
  109224. });
  109225. }
  109226. };
  109227. /**
  109228. * Generates a joint
  109229. * @param impostorJoint the imposter joint to create the joint with
  109230. */
  109231. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109232. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109233. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109234. if (!mainBody || !connectedBody) {
  109235. return;
  109236. }
  109237. var jointData = impostorJoint.joint.jointData;
  109238. if (!jointData.mainPivot) {
  109239. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109240. }
  109241. if (!jointData.connectedPivot) {
  109242. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109243. }
  109244. var joint;
  109245. switch (impostorJoint.joint.type) {
  109246. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  109247. var distance = jointData.maxDistance;
  109248. if (distance) {
  109249. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  109250. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  109251. }
  109252. 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));
  109253. break;
  109254. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  109255. if (!jointData.mainAxis) {
  109256. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109257. }
  109258. if (!jointData.connectedAxis) {
  109259. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109260. }
  109261. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  109262. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  109263. 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);
  109264. break;
  109265. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  109266. 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));
  109267. break;
  109268. default:
  109269. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  109270. 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));
  109271. break;
  109272. }
  109273. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  109274. impostorJoint.joint.physicsJoint = joint;
  109275. };
  109276. /**
  109277. * Removes a joint
  109278. * @param impostorJoint the imposter joint to remove the joint from
  109279. */
  109280. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109281. if (this.world) {
  109282. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109283. }
  109284. };
  109285. // adds all verticies (including child verticies) to the triangle mesh
  109286. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  109287. var _this = this;
  109288. var triangleCount = 0;
  109289. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  109290. var indices = object.getIndices();
  109291. if (!indices) {
  109292. indices = [];
  109293. }
  109294. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  109295. if (!vertexPositions) {
  109296. vertexPositions = [];
  109297. }
  109298. object.computeWorldMatrix(false);
  109299. var faceCount = indices.length / 3;
  109300. for (var i = 0; i < faceCount; i++) {
  109301. var triPoints = [];
  109302. for (var point = 0; point < 3; point++) {
  109303. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[(indices[(i * 3) + point] * 3) + 0], vertexPositions[(indices[(i * 3) + point] * 3) + 1], vertexPositions[(indices[(i * 3) + point] * 3) + 2]);
  109304. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  109305. v.subtractInPlace(topLevelObject.position);
  109306. var vec;
  109307. if (point == 0) {
  109308. vec = this._tmpAmmoVectorA;
  109309. }
  109310. else if (point == 1) {
  109311. vec = this._tmpAmmoVectorB;
  109312. }
  109313. else {
  109314. vec = this._tmpAmmoVectorC;
  109315. }
  109316. vec.setValue(v.x, v.y, v.z);
  109317. triPoints.push(vec);
  109318. }
  109319. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  109320. triangleCount++;
  109321. }
  109322. object.getChildMeshes().forEach(function (m) {
  109323. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  109324. });
  109325. }
  109326. return triangleCount;
  109327. };
  109328. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  109329. var _this = this;
  109330. if (ignoreChildren === void 0) { ignoreChildren = false; }
  109331. var object = impostor.object;
  109332. var returnValue;
  109333. var extendSize = impostor.getObjectExtendSize();
  109334. if (!ignoreChildren) {
  109335. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  109336. returnValue = new Ammo.btCompoundShape();
  109337. // Add shape of all children to the compound shape
  109338. var childrenAdded = 0;
  109339. meshChildren.forEach(function (childMesh) {
  109340. var childImpostor = childMesh.getPhysicsImpostor();
  109341. if (childImpostor) {
  109342. var shape = _this._createShape(childImpostor);
  109343. // Position needs to be scaled based on parent's scaling
  109344. var parentMat = childMesh.parent.getWorldMatrix().clone();
  109345. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109346. parentMat.decompose(s);
  109347. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  109348. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  109349. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  109350. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  109351. childImpostor.dispose();
  109352. childrenAdded++;
  109353. }
  109354. });
  109355. if (childrenAdded > 0) {
  109356. // Add parents shape as a child if present
  109357. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  109358. var shape = this._createShape(impostor, true);
  109359. if (shape) {
  109360. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  109361. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  109362. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  109363. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  109364. }
  109365. }
  109366. return returnValue;
  109367. }
  109368. else {
  109369. // If no children with impostors create the actual shape below instead
  109370. Ammo.destroy(returnValue);
  109371. returnValue = null;
  109372. }
  109373. }
  109374. switch (impostor.type) {
  109375. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  109376. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109377. break;
  109378. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  109379. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109380. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  109381. break;
  109382. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  109383. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  109384. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109385. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  109386. break;
  109387. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  109388. var tetraMesh = new Ammo.btTriangleMesh();
  109389. impostor._pluginData.toDispose.concat([tetraMesh]);
  109390. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  109391. if (triangeCount == 0) {
  109392. returnValue = new Ammo.btCompoundShape();
  109393. }
  109394. else {
  109395. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  109396. }
  109397. break;
  109398. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  109399. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  109400. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109401. break;
  109402. default:
  109403. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  109404. break;
  109405. }
  109406. return returnValue;
  109407. };
  109408. /**
  109409. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109410. * @param impostor imposter containing the physics body and babylon object
  109411. */
  109412. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109413. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109414. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  109415. if (!impostor.object.rotationQuaternion) {
  109416. if (impostor.object.rotation) {
  109417. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109418. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  109419. }
  109420. }
  109421. else {
  109422. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109423. }
  109424. };
  109425. /**
  109426. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109427. * @param impostor imposter containing the physics body and babylon object
  109428. * @param newPosition new position
  109429. * @param newRotation new rotation
  109430. */
  109431. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109432. var trans = impostor.physicsBody.getWorldTransform();
  109433. // If rotation/position has changed update and activate riged body
  109434. if (trans.getOrigin().x() != newPosition.x ||
  109435. trans.getOrigin().y() != newPosition.y ||
  109436. trans.getOrigin().z() != newPosition.z ||
  109437. trans.getRotation().x() != newRotation.x ||
  109438. trans.getRotation().y() != newRotation.y ||
  109439. trans.getRotation().z() != newRotation.z ||
  109440. trans.getRotation().w() != newRotation.w) {
  109441. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  109442. trans.setOrigin(this._tmpAmmoVectorA);
  109443. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  109444. trans.setRotation(this._tmpAmmoQuaternion);
  109445. impostor.physicsBody.setWorldTransform(trans);
  109446. if (impostor.mass == 0) {
  109447. // Kinematic objects must be updated using motion state
  109448. var motionState = impostor.physicsBody.getMotionState();
  109449. if (motionState) {
  109450. motionState.setWorldTransform(trans);
  109451. }
  109452. }
  109453. else {
  109454. impostor.physicsBody.activate();
  109455. }
  109456. }
  109457. };
  109458. /**
  109459. * If this plugin is supported
  109460. * @returns true if its supported
  109461. */
  109462. AmmoJSPlugin.prototype.isSupported = function () {
  109463. return this.bjsAMMO !== undefined;
  109464. };
  109465. /**
  109466. * Sets the linear velocity of the physics body
  109467. * @param impostor imposter to set the velocity on
  109468. * @param velocity velocity to set
  109469. */
  109470. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109471. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109472. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  109473. };
  109474. /**
  109475. * Sets the angular velocity of the physics body
  109476. * @param impostor imposter to set the velocity on
  109477. * @param velocity velocity to set
  109478. */
  109479. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109480. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109481. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  109482. };
  109483. /**
  109484. * gets the linear velocity
  109485. * @param impostor imposter to get linear velocity from
  109486. * @returns linear velocity
  109487. */
  109488. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109489. var v = impostor.physicsBody.getLinearVelocity();
  109490. if (!v) {
  109491. return null;
  109492. }
  109493. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109494. };
  109495. /**
  109496. * gets the angular velocity
  109497. * @param impostor imposter to get angular velocity from
  109498. * @returns angular velocity
  109499. */
  109500. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109501. var v = impostor.physicsBody.getAngularVelocity();
  109502. if (!v) {
  109503. return null;
  109504. }
  109505. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109506. };
  109507. /**
  109508. * Sets the mass of physics body
  109509. * @param impostor imposter to set the mass on
  109510. * @param mass mass to set
  109511. */
  109512. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109513. impostor.physicsBody.setMassProps(mass);
  109514. impostor._pluginData.mass = mass;
  109515. };
  109516. /**
  109517. * Gets the mass of the physics body
  109518. * @param impostor imposter to get the mass from
  109519. * @returns mass
  109520. */
  109521. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  109522. return impostor._pluginData.mass;
  109523. };
  109524. /**
  109525. * Gets friction of the impostor
  109526. * @param impostor impostor to get friction from
  109527. * @returns friction value
  109528. */
  109529. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109530. return impostor._pluginData.friction;
  109531. };
  109532. /**
  109533. * Sets friction of the impostor
  109534. * @param impostor impostor to set friction on
  109535. * @param friction friction value
  109536. */
  109537. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109538. impostor.physicsBody.setFriction(friction);
  109539. impostor._pluginData.friction = friction;
  109540. };
  109541. /**
  109542. * Gets restitution of the impostor
  109543. * @param impostor impostor to get restitution from
  109544. * @returns restitution value
  109545. */
  109546. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109547. return impostor._pluginData.restitution;
  109548. };
  109549. /**
  109550. * Sets resitution of the impostor
  109551. * @param impostor impostor to set resitution on
  109552. * @param restitution resitution value
  109553. */
  109554. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109555. impostor.physicsBody.setRestitution(restitution);
  109556. impostor._pluginData.restitution = restitution;
  109557. };
  109558. /**
  109559. * Sleeps the physics body and stops it from being active
  109560. * @param impostor impostor to sleep
  109561. */
  109562. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  109563. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  109564. };
  109565. /**
  109566. * Activates the physics body
  109567. * @param impostor impostor to activate
  109568. */
  109569. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109570. impostor.physicsBody.activate();
  109571. };
  109572. /**
  109573. * Updates the distance parameters of the joint
  109574. * @param joint joint to update
  109575. * @param maxDistance maximum distance of the joint
  109576. * @param minDistance minimum distance of the joint
  109577. */
  109578. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109579. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  109580. };
  109581. /**
  109582. * Sets a motor on the joint
  109583. * @param joint joint to set motor on
  109584. * @param speed speed of the motor
  109585. * @param maxForce maximum force of the motor
  109586. * @param motorIndex index of the motor
  109587. */
  109588. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109589. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  109590. };
  109591. /**
  109592. * Sets the motors limit
  109593. * @param joint joint to set limit on
  109594. * @param upperLimit upper limit
  109595. * @param lowerLimit lower limit
  109596. */
  109597. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109598. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  109599. };
  109600. /**
  109601. * Syncs the position and rotation of a mesh with the impostor
  109602. * @param mesh mesh to sync
  109603. * @param impostor impostor to update the mesh with
  109604. */
  109605. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109606. var body = impostor.physicsBody;
  109607. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109608. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  109609. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  109610. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  109611. if (mesh.rotationQuaternion) {
  109612. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  109613. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  109614. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  109615. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  109616. }
  109617. };
  109618. /**
  109619. * Gets the radius of the impostor
  109620. * @param impostor impostor to get radius from
  109621. * @returns the radius
  109622. */
  109623. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  109624. var exntend = impostor.getObjectExtendSize();
  109625. return exntend.x / 2;
  109626. };
  109627. /**
  109628. * Gets the box size of the impostor
  109629. * @param impostor impostor to get box size from
  109630. * @param result the resulting box size
  109631. */
  109632. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109633. var exntend = impostor.getObjectExtendSize();
  109634. result.x = exntend.x;
  109635. result.y = exntend.y;
  109636. result.z = exntend.z;
  109637. };
  109638. /**
  109639. * Disposes of the impostor
  109640. */
  109641. AmmoJSPlugin.prototype.dispose = function () {
  109642. // Dispose of world
  109643. Ammo.destroy(this.world);
  109644. Ammo.destroy(this._solver);
  109645. Ammo.destroy(this._overlappingPairCache);
  109646. Ammo.destroy(this._dispatcher);
  109647. Ammo.destroy(this._collisionConfiguration);
  109648. // Dispose of tmp variables
  109649. Ammo.destroy(this._tmpAmmoVectorA);
  109650. Ammo.destroy(this._tmpAmmoVectorB);
  109651. Ammo.destroy(this._tmpAmmoVectorC);
  109652. Ammo.destroy(this._tmpAmmoTransform);
  109653. Ammo.destroy(this._tmpAmmoQuaternion);
  109654. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  109655. this.world = null;
  109656. };
  109657. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  109658. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  109659. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  109660. return AmmoJSPlugin;
  109661. }());
  109662. /***/ }),
  109663. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  109664. /*!*******************************************!*\
  109665. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  109666. \*******************************************/
  109667. /*! exports provided: CannonJSPlugin */
  109668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109669. "use strict";
  109670. __webpack_require__.r(__webpack_exports__);
  109671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  109672. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109673. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109674. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109675. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109676. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109677. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109678. /** @hidden */
  109679. var CannonJSPlugin = /** @class */ (function () {
  109680. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  109681. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109682. if (iterations === void 0) { iterations = 10; }
  109683. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  109684. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109685. this.name = "CannonJSPlugin";
  109686. this._physicsMaterials = new Array();
  109687. this._fixedTimeStep = 1 / 60;
  109688. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  109689. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  109690. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109691. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109692. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  109693. this.BJSCANNON = cannonInjection;
  109694. if (!this.isSupported()) {
  109695. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  109696. return;
  109697. }
  109698. this._extendNamespace();
  109699. this.world = new this.BJSCANNON.World();
  109700. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  109701. this.world.solver.iterations = iterations;
  109702. }
  109703. CannonJSPlugin.prototype.setGravity = function (gravity) {
  109704. this.world.gravity.copy(gravity);
  109705. };
  109706. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  109707. this._fixedTimeStep = timeStep;
  109708. };
  109709. CannonJSPlugin.prototype.getTimeStep = function () {
  109710. return this._fixedTimeStep;
  109711. };
  109712. CannonJSPlugin.prototype.executeStep = function (delta) {
  109713. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  109714. };
  109715. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109716. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109717. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109718. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109719. };
  109720. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109721. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109722. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109723. impostor.physicsBody.applyForce(impulse, worldPoint);
  109724. };
  109725. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109726. //parent-child relationship. Does this impostor has a parent impostor?
  109727. if (impostor.parent) {
  109728. if (impostor.physicsBody) {
  109729. this.removePhysicsBody(impostor);
  109730. //TODO is that needed?
  109731. impostor.forceUpdate();
  109732. }
  109733. return;
  109734. }
  109735. //should a new body be created for this impostor?
  109736. if (impostor.isBodyInitRequired()) {
  109737. var shape = this._createShape(impostor);
  109738. //unregister events, if body is being changed
  109739. var oldBody = impostor.physicsBody;
  109740. if (oldBody) {
  109741. this.removePhysicsBody(impostor);
  109742. }
  109743. //create the body and material
  109744. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  109745. var bodyCreationObject = {
  109746. mass: impostor.getParam("mass"),
  109747. material: material
  109748. };
  109749. // A simple extend, in case native options were used.
  109750. var nativeOptions = impostor.getParam("nativeOptions");
  109751. for (var key in nativeOptions) {
  109752. if (nativeOptions.hasOwnProperty(key)) {
  109753. bodyCreationObject[key] = nativeOptions[key];
  109754. }
  109755. }
  109756. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  109757. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  109758. this.world.addEventListener("preStep", impostor.beforeStep);
  109759. this.world.addEventListener("postStep", impostor.afterStep);
  109760. impostor.physicsBody.addShape(shape);
  109761. this.world.add(impostor.physicsBody);
  109762. //try to keep the body moving in the right direction by taking old properties.
  109763. //Should be tested!
  109764. if (oldBody) {
  109765. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  109766. impostor.physicsBody[param].copy(oldBody[param]);
  109767. });
  109768. }
  109769. this._processChildMeshes(impostor);
  109770. }
  109771. //now update the body's transformation
  109772. this._updatePhysicsBodyTransformation(impostor);
  109773. };
  109774. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  109775. var _this = this;
  109776. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  109777. var currentRotation = mainImpostor.object.rotationQuaternion;
  109778. if (meshChildren.length) {
  109779. var processMesh = function (localPosition, mesh) {
  109780. if (!currentRotation || !mesh.rotationQuaternion) {
  109781. return;
  109782. }
  109783. var childImpostor = mesh.getPhysicsImpostor();
  109784. if (childImpostor) {
  109785. var parent = childImpostor.parent;
  109786. if (parent !== mainImpostor) {
  109787. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  109788. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  109789. if (childImpostor.physicsBody) {
  109790. _this.removePhysicsBody(childImpostor);
  109791. childImpostor.physicsBody = null;
  109792. }
  109793. childImpostor.parent = mainImpostor;
  109794. childImpostor.resetUpdateFlags();
  109795. 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));
  109796. //Add the mass of the children.
  109797. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  109798. }
  109799. }
  109800. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109801. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109802. };
  109803. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109804. }
  109805. };
  109806. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109807. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109808. this.world.removeEventListener("preStep", impostor.beforeStep);
  109809. this.world.removeEventListener("postStep", impostor.afterStep);
  109810. this.world.remove(impostor.physicsBody);
  109811. };
  109812. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109813. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109814. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109815. if (!mainBody || !connectedBody) {
  109816. return;
  109817. }
  109818. var constraint;
  109819. var jointData = impostorJoint.joint.jointData;
  109820. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109821. var constraintData = {
  109822. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109823. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109824. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109825. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  109826. maxForce: jointData.nativeParams.maxForce,
  109827. collideConnected: !!jointData.collision
  109828. };
  109829. switch (impostorJoint.joint.type) {
  109830. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  109831. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  109832. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  109833. break;
  109834. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  109835. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  109836. break;
  109837. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  109838. var springData = jointData;
  109839. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  109840. restLength: springData.length,
  109841. stiffness: springData.stiffness,
  109842. damping: springData.damping,
  109843. localAnchorA: constraintData.pivotA,
  109844. localAnchorB: constraintData.pivotB
  109845. });
  109846. break;
  109847. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  109848. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  109849. break;
  109850. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  109851. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  109852. default:
  109853. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  109854. break;
  109855. }
  109856. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  109857. constraint.collideConnected = !!jointData.collision;
  109858. impostorJoint.joint.physicsJoint = constraint;
  109859. //don't add spring as constraint, as it is not one.
  109860. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109861. this.world.addConstraint(constraint);
  109862. }
  109863. else {
  109864. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  109865. constraint.applyForce();
  109866. };
  109867. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109868. }
  109869. };
  109870. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109871. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109872. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109873. }
  109874. else {
  109875. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109876. }
  109877. };
  109878. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  109879. var index;
  109880. var mat;
  109881. for (index = 0; index < this._physicsMaterials.length; index++) {
  109882. mat = this._physicsMaterials[index];
  109883. if (mat.friction === friction && mat.restitution === restitution) {
  109884. return mat;
  109885. }
  109886. }
  109887. var currentMat = new this.BJSCANNON.Material(name);
  109888. currentMat.friction = friction;
  109889. currentMat.restitution = restitution;
  109890. this._physicsMaterials.push(currentMat);
  109891. return currentMat;
  109892. };
  109893. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  109894. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  109895. };
  109896. CannonJSPlugin.prototype._createShape = function (impostor) {
  109897. var object = impostor.object;
  109898. var returnValue;
  109899. var extendSize = impostor.getObjectExtendSize();
  109900. switch (impostor.type) {
  109901. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  109902. var radiusX = extendSize.x;
  109903. var radiusY = extendSize.y;
  109904. var radiusZ = extendSize.z;
  109905. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  109906. break;
  109907. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  109908. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  109909. var nativeParams = impostor.getParam("nativeOptions");
  109910. if (!nativeParams) {
  109911. nativeParams = {};
  109912. }
  109913. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  109914. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  109915. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  109916. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  109917. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  109918. // Rotate 90 degrees as this shape is horizontal in cannon
  109919. var quat = new this.BJSCANNON.Quaternion();
  109920. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  109921. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  109922. returnValue.transformAllPoints(translation, quat);
  109923. break;
  109924. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  109925. var box = extendSize.scale(0.5);
  109926. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  109927. break;
  109928. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  109929. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  109930. returnValue = new this.BJSCANNON.Plane();
  109931. break;
  109932. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  109933. // should transform the vertex data to world coordinates!!
  109934. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  109935. var rawFaces = object.getIndices ? object.getIndices() : [];
  109936. if (!rawVerts) {
  109937. return;
  109938. }
  109939. // get only scale! so the object could transform correctly.
  109940. var oldPosition = object.position.clone();
  109941. var oldRotation = object.rotation && object.rotation.clone();
  109942. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  109943. object.position.copyFromFloats(0, 0, 0);
  109944. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109945. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109946. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109947. var transform = object.computeWorldMatrix(true);
  109948. // convert rawVerts to object space
  109949. var temp = new Array();
  109950. var index;
  109951. for (index = 0; index < rawVerts.length; index += 3) {
  109952. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  109953. }
  109954. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  109955. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  109956. //now set back the transformation!
  109957. object.position.copyFrom(oldPosition);
  109958. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  109959. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  109960. break;
  109961. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  109962. var oldPosition2 = object.position.clone();
  109963. var oldRotation2 = object.rotation && object.rotation.clone();
  109964. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  109965. object.position.copyFromFloats(0, 0, 0);
  109966. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109967. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109968. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109969. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  109970. returnValue = this._createHeightmap(object);
  109971. object.position.copyFrom(oldPosition2);
  109972. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  109973. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  109974. object.computeWorldMatrix(true);
  109975. break;
  109976. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  109977. returnValue = new this.BJSCANNON.Particle();
  109978. break;
  109979. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  109980. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  109981. break;
  109982. }
  109983. return returnValue;
  109984. };
  109985. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  109986. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  109987. var transform = object.computeWorldMatrix(true);
  109988. // convert rawVerts to object space
  109989. var temp = new Array();
  109990. var index;
  109991. for (index = 0; index < pos.length; index += 3) {
  109992. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  109993. }
  109994. pos = temp;
  109995. var matrix = new Array();
  109996. //For now pointDepth will not be used and will be automatically calculated.
  109997. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  109998. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  109999. var boundingInfo = object.getBoundingInfo();
  110000. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  110001. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  110002. var elementSize = dim * 2 / arraySize;
  110003. for (var i = 0; i < pos.length; i = i + 3) {
  110004. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  110005. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  110006. var y = -pos[i + 2] + minY;
  110007. if (!matrix[x]) {
  110008. matrix[x] = [];
  110009. }
  110010. if (!matrix[x][z]) {
  110011. matrix[x][z] = y;
  110012. }
  110013. matrix[x][z] = Math.max(y, matrix[x][z]);
  110014. }
  110015. for (var x = 0; x <= arraySize; ++x) {
  110016. if (!matrix[x]) {
  110017. var loc = 1;
  110018. while (!matrix[(x + loc) % arraySize]) {
  110019. loc++;
  110020. }
  110021. matrix[x] = matrix[(x + loc) % arraySize].slice();
  110022. //console.log("missing x", x);
  110023. }
  110024. for (var z = 0; z <= arraySize; ++z) {
  110025. if (!matrix[x][z]) {
  110026. var loc = 1;
  110027. var newValue;
  110028. while (newValue === undefined) {
  110029. newValue = matrix[x][(z + loc++) % arraySize];
  110030. }
  110031. matrix[x][z] = newValue;
  110032. }
  110033. }
  110034. }
  110035. var shape = new this.BJSCANNON.Heightfield(matrix, {
  110036. elementSize: elementSize
  110037. });
  110038. //For future reference, needed for body transformation
  110039. shape.minY = minY;
  110040. return shape;
  110041. };
  110042. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  110043. var object = impostor.object;
  110044. //make sure it is updated...
  110045. object.computeWorldMatrix && object.computeWorldMatrix(true);
  110046. // The delta between the mesh position and the mesh bounding box center
  110047. var bInfo = object.getBoundingInfo();
  110048. if (!bInfo) {
  110049. return;
  110050. }
  110051. var center = impostor.getObjectCenter();
  110052. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  110053. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  110054. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  110055. this._tmpPosition.copyFrom(center);
  110056. var quaternion = object.rotationQuaternion;
  110057. if (!quaternion) {
  110058. return;
  110059. }
  110060. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  110061. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  110062. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110063. //-90 DEG in X, precalculated
  110064. quaternion = quaternion.multiply(this._minus90X);
  110065. //Invert! (Precalculated, 90 deg in X)
  110066. //No need to clone. this will never change.
  110067. impostor.setDeltaRotation(this._plus90X);
  110068. }
  110069. //If it is a heightfield, if should be centered.
  110070. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110071. var mesh = object;
  110072. var boundingInfo = mesh.getBoundingInfo();
  110073. //calculate the correct body position:
  110074. var rotationQuaternion = mesh.rotationQuaternion;
  110075. mesh.rotationQuaternion = this._tmpUnityRotation;
  110076. mesh.computeWorldMatrix(true);
  110077. //get original center with no rotation
  110078. var c = center.clone();
  110079. var oldPivot = mesh.getPivotMatrix();
  110080. if (oldPivot) {
  110081. // create a copy the pivot Matrix as it is modified in place
  110082. oldPivot = oldPivot.clone();
  110083. }
  110084. else {
  110085. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  110086. }
  110087. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  110088. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  110089. mesh.setPreTransformMatrix(p);
  110090. mesh.computeWorldMatrix(true);
  110091. //calculate the translation
  110092. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  110093. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  110094. //add it inverted to the delta
  110095. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  110096. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  110097. //rotation is back
  110098. mesh.rotationQuaternion = rotationQuaternion;
  110099. mesh.setPreTransformMatrix(oldPivot);
  110100. mesh.computeWorldMatrix(true);
  110101. }
  110102. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  110103. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  110104. //this._tmpPosition.copyFrom(object.position);
  110105. }
  110106. impostor.setDeltaPosition(this._tmpDeltaPosition);
  110107. //Now update the impostor object
  110108. impostor.physicsBody.position.copy(this._tmpPosition);
  110109. impostor.physicsBody.quaternion.copy(quaternion);
  110110. };
  110111. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110112. impostor.object.position.copyFrom(impostor.physicsBody.position);
  110113. if (impostor.object.rotationQuaternion) {
  110114. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  110115. }
  110116. };
  110117. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110118. impostor.physicsBody.position.copy(newPosition);
  110119. impostor.physicsBody.quaternion.copy(newRotation);
  110120. };
  110121. CannonJSPlugin.prototype.isSupported = function () {
  110122. return this.BJSCANNON !== undefined;
  110123. };
  110124. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110125. impostor.physicsBody.velocity.copy(velocity);
  110126. };
  110127. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110128. impostor.physicsBody.angularVelocity.copy(velocity);
  110129. };
  110130. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110131. var v = impostor.physicsBody.velocity;
  110132. if (!v) {
  110133. return null;
  110134. }
  110135. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110136. };
  110137. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110138. var v = impostor.physicsBody.angularVelocity;
  110139. if (!v) {
  110140. return null;
  110141. }
  110142. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110143. };
  110144. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110145. impostor.physicsBody.mass = mass;
  110146. impostor.physicsBody.updateMassProperties();
  110147. };
  110148. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  110149. return impostor.physicsBody.mass;
  110150. };
  110151. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  110152. return impostor.physicsBody.material.friction;
  110153. };
  110154. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110155. impostor.physicsBody.material.friction = friction;
  110156. };
  110157. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110158. return impostor.physicsBody.material.restitution;
  110159. };
  110160. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110161. impostor.physicsBody.material.restitution = restitution;
  110162. };
  110163. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  110164. impostor.physicsBody.sleep();
  110165. };
  110166. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  110167. impostor.physicsBody.wakeUp();
  110168. };
  110169. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  110170. joint.physicsJoint.distance = maxDistance;
  110171. };
  110172. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110173. // if (!motorIndex) {
  110174. // joint.physicsJoint.enableMotor();
  110175. // }
  110176. // }
  110177. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110178. // if (!motorIndex) {
  110179. // joint.physicsJoint.disableMotor();
  110180. // }
  110181. // }
  110182. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110183. if (!motorIndex) {
  110184. joint.physicsJoint.enableMotor();
  110185. joint.physicsJoint.setMotorSpeed(speed);
  110186. if (maxForce) {
  110187. this.setLimit(joint, maxForce);
  110188. }
  110189. }
  110190. };
  110191. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  110192. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  110193. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  110194. };
  110195. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110196. var body = impostor.physicsBody;
  110197. mesh.position.x = body.position.x;
  110198. mesh.position.y = body.position.y;
  110199. mesh.position.z = body.position.z;
  110200. if (mesh.rotationQuaternion) {
  110201. mesh.rotationQuaternion.x = body.quaternion.x;
  110202. mesh.rotationQuaternion.y = body.quaternion.y;
  110203. mesh.rotationQuaternion.z = body.quaternion.z;
  110204. mesh.rotationQuaternion.w = body.quaternion.w;
  110205. }
  110206. };
  110207. CannonJSPlugin.prototype.getRadius = function (impostor) {
  110208. var shape = impostor.physicsBody.shapes[0];
  110209. return shape.boundingSphereRadius;
  110210. };
  110211. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110212. var shape = impostor.physicsBody.shapes[0];
  110213. result.x = shape.halfExtents.x * 2;
  110214. result.y = shape.halfExtents.y * 2;
  110215. result.z = shape.halfExtents.z * 2;
  110216. };
  110217. CannonJSPlugin.prototype.dispose = function () {
  110218. };
  110219. CannonJSPlugin.prototype._extendNamespace = function () {
  110220. //this will force cannon to execute at least one step when using interpolation
  110221. var step_tmp1 = new this.BJSCANNON.Vec3();
  110222. var Engine = this.BJSCANNON;
  110223. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  110224. maxSubSteps = maxSubSteps || 10;
  110225. timeSinceLastCalled = timeSinceLastCalled || 0;
  110226. if (timeSinceLastCalled === 0) {
  110227. this.internalStep(dt);
  110228. this.time += dt;
  110229. }
  110230. else {
  110231. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  110232. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  110233. var t0 = performance.now();
  110234. for (var i = 0; i !== internalSteps; i++) {
  110235. this.internalStep(dt);
  110236. if (performance.now() - t0 > dt * 1000) {
  110237. break;
  110238. }
  110239. }
  110240. this.time += timeSinceLastCalled;
  110241. var h = this.time % dt;
  110242. var h_div_dt = h / dt;
  110243. var interpvelo = step_tmp1;
  110244. var bodies = this.bodies;
  110245. for (var j = 0; j !== bodies.length; j++) {
  110246. var b = bodies[j];
  110247. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  110248. b.position.vsub(b.previousPosition, interpvelo);
  110249. interpvelo.scale(h_div_dt, interpvelo);
  110250. b.position.vadd(interpvelo, b.interpolatedPosition);
  110251. }
  110252. else {
  110253. b.interpolatedPosition.copy(b.position);
  110254. b.interpolatedQuaternion.copy(b.quaternion);
  110255. }
  110256. }
  110257. }
  110258. };
  110259. };
  110260. return CannonJSPlugin;
  110261. }());
  110262. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  110263. /***/ }),
  110264. /***/ "./Physics/Plugins/index.ts":
  110265. /*!**********************************!*\
  110266. !*** ./Physics/Plugins/index.ts ***!
  110267. \**********************************/
  110268. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110270. "use strict";
  110271. __webpack_require__.r(__webpack_exports__);
  110272. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  110273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  110274. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  110275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  110276. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  110277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  110278. /***/ }),
  110279. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  110280. /*!*****************************************!*\
  110281. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  110282. \*****************************************/
  110283. /*! exports provided: OimoJSPlugin */
  110284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110285. "use strict";
  110286. __webpack_require__.r(__webpack_exports__);
  110287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  110288. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110289. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110290. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110291. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110292. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110293. /** @hidden */
  110294. var OimoJSPlugin = /** @class */ (function () {
  110295. function OimoJSPlugin(iterations, oimoInjection) {
  110296. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  110297. this.name = "OimoJSPlugin";
  110298. this._tmpImpostorsArray = [];
  110299. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110300. this.BJSOIMO = oimoInjection;
  110301. this.world = new this.BJSOIMO.World({
  110302. iterations: iterations
  110303. });
  110304. this.world.clear();
  110305. }
  110306. OimoJSPlugin.prototype.setGravity = function (gravity) {
  110307. this.world.gravity.copy(gravity);
  110308. };
  110309. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110310. this.world.timeStep = timeStep;
  110311. };
  110312. OimoJSPlugin.prototype.getTimeStep = function () {
  110313. return this.world.timeStep;
  110314. };
  110315. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110316. var _this = this;
  110317. impostors.forEach(function (impostor) {
  110318. impostor.beforeStep();
  110319. });
  110320. this.world.step();
  110321. impostors.forEach(function (impostor) {
  110322. impostor.afterStep();
  110323. //update the ordered impostors array
  110324. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  110325. });
  110326. //check for collisions
  110327. var contact = this.world.contacts;
  110328. while (contact !== null) {
  110329. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  110330. contact = contact.next;
  110331. continue;
  110332. }
  110333. //is this body colliding with any other? get the impostor
  110334. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  110335. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  110336. if (!mainImpostor || !collidingImpostor) {
  110337. contact = contact.next;
  110338. continue;
  110339. }
  110340. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  110341. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  110342. contact = contact.next;
  110343. }
  110344. };
  110345. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110346. var mass = impostor.physicsBody.mass;
  110347. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  110348. };
  110349. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110350. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  110351. this.applyImpulse(impostor, force, contactPoint);
  110352. };
  110353. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110354. var _this = this;
  110355. //parent-child relationship. Does this impostor has a parent impostor?
  110356. if (impostor.parent) {
  110357. if (impostor.physicsBody) {
  110358. this.removePhysicsBody(impostor);
  110359. //TODO is that needed?
  110360. impostor.forceUpdate();
  110361. }
  110362. return;
  110363. }
  110364. if (impostor.isBodyInitRequired()) {
  110365. var bodyConfig = {
  110366. name: impostor.uniqueId,
  110367. //Oimo must have mass, also for static objects.
  110368. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  110369. size: [],
  110370. type: [],
  110371. pos: [],
  110372. posShape: [],
  110373. rot: [],
  110374. rotShape: [],
  110375. move: impostor.getParam("mass") !== 0,
  110376. density: impostor.getParam("mass"),
  110377. friction: impostor.getParam("friction"),
  110378. restitution: impostor.getParam("restitution"),
  110379. //Supporting older versions of Oimo
  110380. world: this.world
  110381. };
  110382. var impostors = [impostor];
  110383. var addToArray = function (parent) {
  110384. if (!parent.getChildMeshes) {
  110385. return;
  110386. }
  110387. parent.getChildMeshes().forEach(function (m) {
  110388. if (m.physicsImpostor) {
  110389. impostors.push(m.physicsImpostor);
  110390. //m.physicsImpostor._init();
  110391. }
  110392. });
  110393. };
  110394. addToArray(impostor.object);
  110395. var checkWithEpsilon_1 = function (value) {
  110396. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  110397. };
  110398. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  110399. impostors.forEach(function (i) {
  110400. if (!i.object.rotationQuaternion) {
  110401. return;
  110402. }
  110403. //get the correct bounding box
  110404. var oldQuaternion = i.object.rotationQuaternion;
  110405. globalQuaternion_1 = oldQuaternion.clone();
  110406. var rot = oldQuaternion.toEulerAngles();
  110407. var extendSize = i.getObjectExtendSize();
  110408. var radToDeg = 57.295779513082320876;
  110409. if (i === impostor) {
  110410. var center = impostor.getObjectCenter();
  110411. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  110412. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  110413. //Can also use Array.prototype.push.apply
  110414. bodyConfig.pos.push(center.x);
  110415. bodyConfig.pos.push(center.y);
  110416. bodyConfig.pos.push(center.z);
  110417. bodyConfig.posShape.push(0, 0, 0);
  110418. bodyConfig.rotShape.push(0, 0, 0);
  110419. }
  110420. else {
  110421. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  110422. bodyConfig.posShape.push(localPosition.x);
  110423. bodyConfig.posShape.push(localPosition.y);
  110424. bodyConfig.posShape.push(localPosition.z);
  110425. bodyConfig.pos.push(0, 0, 0);
  110426. bodyConfig.rotShape.push(rot.x * radToDeg);
  110427. bodyConfig.rotShape.push(rot.y * radToDeg);
  110428. bodyConfig.rotShape.push(rot.z * radToDeg);
  110429. }
  110430. // register mesh
  110431. switch (i.type) {
  110432. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  110433. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  110434. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  110435. var radiusX = extendSize.x;
  110436. var radiusY = extendSize.y;
  110437. var radiusZ = extendSize.z;
  110438. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  110439. bodyConfig.type.push('sphere');
  110440. //due to the way oimo works with compounds, add 3 times
  110441. bodyConfig.size.push(size);
  110442. bodyConfig.size.push(size);
  110443. bodyConfig.size.push(size);
  110444. break;
  110445. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  110446. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  110447. var sizeY = checkWithEpsilon_1(extendSize.y);
  110448. bodyConfig.type.push('cylinder');
  110449. bodyConfig.size.push(sizeX);
  110450. bodyConfig.size.push(sizeY);
  110451. //due to the way oimo works with compounds, add one more value.
  110452. bodyConfig.size.push(sizeY);
  110453. break;
  110454. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  110455. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  110456. default:
  110457. var sizeX = checkWithEpsilon_1(extendSize.x);
  110458. var sizeY = checkWithEpsilon_1(extendSize.y);
  110459. var sizeZ = checkWithEpsilon_1(extendSize.z);
  110460. bodyConfig.type.push('box');
  110461. //if (i === impostor) {
  110462. bodyConfig.size.push(sizeX);
  110463. bodyConfig.size.push(sizeY);
  110464. bodyConfig.size.push(sizeZ);
  110465. //} else {
  110466. // bodyConfig.size.push(0,0,0);
  110467. //}
  110468. break;
  110469. }
  110470. //actually not needed, but hey...
  110471. i.object.rotationQuaternion = oldQuaternion;
  110472. });
  110473. impostor.physicsBody = this.world.add(bodyConfig);
  110474. // set the quaternion, ignoring the previously defined (euler) rotation
  110475. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  110476. // update with delta 0, so the body will reveive the new rotation.
  110477. impostor.physicsBody.updatePosition(0);
  110478. }
  110479. else {
  110480. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  110481. }
  110482. impostor.setDeltaPosition(this._tmpPositionVector);
  110483. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  110484. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  110485. };
  110486. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110487. //impostor.physicsBody.dispose();
  110488. //Same as : (older oimo versions)
  110489. this.world.removeRigidBody(impostor.physicsBody);
  110490. };
  110491. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110492. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110493. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110494. if (!mainBody || !connectedBody) {
  110495. return;
  110496. }
  110497. var jointData = impostorJoint.joint.jointData;
  110498. var options = jointData.nativeParams || {};
  110499. var type;
  110500. var nativeJointData = {
  110501. body1: mainBody,
  110502. body2: connectedBody,
  110503. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  110504. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  110505. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  110506. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  110507. min: options.min,
  110508. max: options.max,
  110509. collision: options.collision || jointData.collision,
  110510. spring: options.spring,
  110511. //supporting older version of Oimo
  110512. world: this.world
  110513. };
  110514. switch (impostorJoint.joint.type) {
  110515. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  110516. type = "jointBall";
  110517. break;
  110518. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  110519. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  110520. var springData = jointData;
  110521. nativeJointData.min = springData.length || nativeJointData.min;
  110522. //Max should also be set, just make sure it is at least min
  110523. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  110524. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  110525. type = "jointDistance";
  110526. nativeJointData.max = jointData.maxDistance;
  110527. break;
  110528. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  110529. type = "jointPrisme";
  110530. break;
  110531. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  110532. type = "jointSlide";
  110533. break;
  110534. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  110535. type = "jointWheel";
  110536. break;
  110537. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  110538. default:
  110539. type = "jointHinge";
  110540. break;
  110541. }
  110542. nativeJointData.type = type;
  110543. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  110544. };
  110545. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110546. //Bug in Oimo prevents us from disposing a joint in the playground
  110547. //joint.joint.physicsJoint.dispose();
  110548. //So we will bruteforce it!
  110549. try {
  110550. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  110551. }
  110552. catch (e) {
  110553. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  110554. }
  110555. };
  110556. OimoJSPlugin.prototype.isSupported = function () {
  110557. return this.BJSOIMO !== undefined;
  110558. };
  110559. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110560. if (!impostor.physicsBody.sleeping) {
  110561. //TODO check that
  110562. /*if (impostor.physicsBody.shapes.next) {
  110563. var parentShape = this._getLastShape(impostor.physicsBody);
  110564. impostor.object.position.copyFrom(parentShape.position);
  110565. console.log(parentShape.position);
  110566. } else {*/
  110567. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  110568. //}
  110569. if (impostor.object.rotationQuaternion) {
  110570. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  110571. }
  110572. }
  110573. };
  110574. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110575. var body = impostor.physicsBody;
  110576. body.position.copy(newPosition);
  110577. body.orientation.copy(newRotation);
  110578. body.syncShapes();
  110579. body.awake();
  110580. };
  110581. /*private _getLastShape(body: any): any {
  110582. var lastShape = body.shapes;
  110583. while (lastShape.next) {
  110584. lastShape = lastShape.next;
  110585. }
  110586. return lastShape;
  110587. }*/
  110588. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110589. impostor.physicsBody.linearVelocity.copy(velocity);
  110590. };
  110591. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110592. impostor.physicsBody.angularVelocity.copy(velocity);
  110593. };
  110594. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110595. var v = impostor.physicsBody.linearVelocity;
  110596. if (!v) {
  110597. return null;
  110598. }
  110599. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110600. };
  110601. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110602. var v = impostor.physicsBody.angularVelocity;
  110603. if (!v) {
  110604. return null;
  110605. }
  110606. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110607. };
  110608. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110609. var staticBody = mass === 0;
  110610. //this will actually set the body's density and not its mass.
  110611. //But this is how oimo treats the mass variable.
  110612. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  110613. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  110614. };
  110615. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  110616. return impostor.physicsBody.shapes.density;
  110617. };
  110618. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110619. return impostor.physicsBody.shapes.friction;
  110620. };
  110621. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110622. impostor.physicsBody.shapes.friction = friction;
  110623. };
  110624. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110625. return impostor.physicsBody.shapes.restitution;
  110626. };
  110627. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110628. impostor.physicsBody.shapes.restitution = restitution;
  110629. };
  110630. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  110631. impostor.physicsBody.sleep();
  110632. };
  110633. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110634. impostor.physicsBody.awake();
  110635. };
  110636. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110637. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  110638. if (minDistance !== void 0) {
  110639. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  110640. }
  110641. };
  110642. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110643. if (maxForce !== undefined) {
  110644. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with maxForce parameter");
  110645. }
  110646. speed *= -1;
  110647. //TODO separate rotational and transational motors.
  110648. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110649. if (motor) {
  110650. motor.setMotor(speed, maxForce);
  110651. }
  110652. };
  110653. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  110654. //TODO separate rotational and transational motors.
  110655. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110656. if (motor) {
  110657. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  110658. }
  110659. };
  110660. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110661. var body = impostor.physicsBody;
  110662. mesh.position.x = body.position.x;
  110663. mesh.position.y = body.position.y;
  110664. mesh.position.z = body.position.z;
  110665. if (mesh.rotationQuaternion) {
  110666. mesh.rotationQuaternion.x = body.orientation.x;
  110667. mesh.rotationQuaternion.y = body.orientation.y;
  110668. mesh.rotationQuaternion.z = body.orientation.z;
  110669. mesh.rotationQuaternion.w = body.orientation.s;
  110670. }
  110671. };
  110672. OimoJSPlugin.prototype.getRadius = function (impostor) {
  110673. return impostor.physicsBody.shapes.radius;
  110674. };
  110675. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110676. var shape = impostor.physicsBody.shapes;
  110677. result.x = shape.halfWidth * 2;
  110678. result.y = shape.halfHeight * 2;
  110679. result.z = shape.halfDepth * 2;
  110680. };
  110681. OimoJSPlugin.prototype.dispose = function () {
  110682. this.world.clear();
  110683. };
  110684. return OimoJSPlugin;
  110685. }());
  110686. /***/ }),
  110687. /***/ "./Physics/index.ts":
  110688. /*!**************************!*\
  110689. !*** ./Physics/index.ts ***!
  110690. \**************************/
  110691. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110693. "use strict";
  110694. __webpack_require__.r(__webpack_exports__);
  110695. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  110697. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  110698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  110699. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  110700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  110701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  110702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  110703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  110704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  110705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  110706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  110707. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  110708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  110709. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  110711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  110712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  110713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  110714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  110715. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  110716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  110717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  110718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  110719. /***/ }),
  110720. /***/ "./Physics/physicsEngine.ts":
  110721. /*!**********************************!*\
  110722. !*** ./Physics/physicsEngine.ts ***!
  110723. \**********************************/
  110724. /*! exports provided: PhysicsEngine */
  110725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110726. "use strict";
  110727. __webpack_require__.r(__webpack_exports__);
  110728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  110729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110730. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  110731. /**
  110732. * Class used to control physics engine
  110733. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110734. */
  110735. var PhysicsEngine = /** @class */ (function () {
  110736. /**
  110737. * Creates a new Physics Engine
  110738. * @param gravity defines the gravity vector used by the simulation
  110739. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110740. */
  110741. function PhysicsEngine(gravity, _physicsPlugin) {
  110742. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  110743. this._physicsPlugin = _physicsPlugin;
  110744. this._impostors = [];
  110745. this._joints = [];
  110746. if (!this._physicsPlugin.isSupported()) {
  110747. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  110748. + "Please make sure it is included.");
  110749. }
  110750. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  110751. this.setGravity(gravity);
  110752. this.setTimeStep();
  110753. }
  110754. /**
  110755. * Factory used to create the default physics plugin.
  110756. * @returns The default physics plugin
  110757. */
  110758. PhysicsEngine.DefaultPluginFactory = function () {
  110759. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  110760. };
  110761. /**
  110762. * Sets the gravity vector used by the simulation
  110763. * @param gravity defines the gravity vector to use
  110764. */
  110765. PhysicsEngine.prototype.setGravity = function (gravity) {
  110766. this.gravity = gravity;
  110767. this._physicsPlugin.setGravity(this.gravity);
  110768. };
  110769. /**
  110770. * Set the time step of the physics engine.
  110771. * Default is 1/60.
  110772. * To slow it down, enter 1/600 for example.
  110773. * To speed it up, 1/30
  110774. * @param newTimeStep defines the new timestep to apply to this world.
  110775. */
  110776. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  110777. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  110778. this._physicsPlugin.setTimeStep(newTimeStep);
  110779. };
  110780. /**
  110781. * Get the time step of the physics engine.
  110782. * @returns the current time step
  110783. */
  110784. PhysicsEngine.prototype.getTimeStep = function () {
  110785. return this._physicsPlugin.getTimeStep();
  110786. };
  110787. /**
  110788. * Release all resources
  110789. */
  110790. PhysicsEngine.prototype.dispose = function () {
  110791. this._impostors.forEach(function (impostor) {
  110792. impostor.dispose();
  110793. });
  110794. this._physicsPlugin.dispose();
  110795. };
  110796. /**
  110797. * Gets the name of the current physics plugin
  110798. * @returns the name of the plugin
  110799. */
  110800. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  110801. return this._physicsPlugin.name;
  110802. };
  110803. /**
  110804. * Adding a new impostor for the impostor tracking.
  110805. * This will be done by the impostor itself.
  110806. * @param impostor the impostor to add
  110807. */
  110808. PhysicsEngine.prototype.addImpostor = function (impostor) {
  110809. impostor.uniqueId = this._impostors.push(impostor);
  110810. //if no parent, generate the body
  110811. if (!impostor.parent) {
  110812. this._physicsPlugin.generatePhysicsBody(impostor);
  110813. }
  110814. };
  110815. /**
  110816. * Remove an impostor from the engine.
  110817. * This impostor and its mesh will not longer be updated by the physics engine.
  110818. * @param impostor the impostor to remove
  110819. */
  110820. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110821. var index = this._impostors.indexOf(impostor);
  110822. if (index > -1) {
  110823. var removed = this._impostors.splice(index, 1);
  110824. //Is it needed?
  110825. if (removed.length) {
  110826. //this will also remove it from the world.
  110827. removed[0].physicsBody = null;
  110828. }
  110829. }
  110830. };
  110831. /**
  110832. * Add a joint to the physics engine
  110833. * @param mainImpostor defines the main impostor to which the joint is added.
  110834. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  110835. * @param joint defines the joint that will connect both impostors.
  110836. */
  110837. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  110838. var impostorJoint = {
  110839. mainImpostor: mainImpostor,
  110840. connectedImpostor: connectedImpostor,
  110841. joint: joint
  110842. };
  110843. joint.physicsPlugin = this._physicsPlugin;
  110844. this._joints.push(impostorJoint);
  110845. this._physicsPlugin.generateJoint(impostorJoint);
  110846. };
  110847. /**
  110848. * Removes a joint from the simulation
  110849. * @param mainImpostor defines the impostor used with the joint
  110850. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  110851. * @param joint defines the joint to remove
  110852. */
  110853. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  110854. var matchingJoints = this._joints.filter(function (impostorJoint) {
  110855. return (impostorJoint.connectedImpostor === connectedImpostor
  110856. && impostorJoint.joint === joint
  110857. && impostorJoint.mainImpostor === mainImpostor);
  110858. });
  110859. if (matchingJoints.length) {
  110860. this._physicsPlugin.removeJoint(matchingJoints[0]);
  110861. //TODO remove it from the list as well
  110862. }
  110863. };
  110864. /**
  110865. * Called by the scene. No need to call it.
  110866. * @param delta defines the timespam between frames
  110867. */
  110868. PhysicsEngine.prototype._step = function (delta) {
  110869. var _this = this;
  110870. //check if any mesh has no body / requires an update
  110871. this._impostors.forEach(function (impostor) {
  110872. if (impostor.isBodyInitRequired()) {
  110873. _this._physicsPlugin.generatePhysicsBody(impostor);
  110874. }
  110875. });
  110876. if (delta > 0.1) {
  110877. delta = 0.1;
  110878. }
  110879. else if (delta <= 0) {
  110880. delta = 1.0 / 60.0;
  110881. }
  110882. this._physicsPlugin.executeStep(delta, this._impostors);
  110883. };
  110884. /**
  110885. * Gets the current plugin used to run the simulation
  110886. * @returns current plugin
  110887. */
  110888. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  110889. return this._physicsPlugin;
  110890. };
  110891. /**
  110892. * Gets the list of physic impostors
  110893. * @returns an array of PhysicsImpostor
  110894. */
  110895. PhysicsEngine.prototype.getImpostors = function () {
  110896. return this._impostors;
  110897. };
  110898. /**
  110899. * Gets the impostor for a physics enabled object
  110900. * @param object defines the object impersonated by the impostor
  110901. * @returns the PhysicsImpostor or null if not found
  110902. */
  110903. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  110904. for (var i = 0; i < this._impostors.length; ++i) {
  110905. if (this._impostors[i].object === object) {
  110906. return this._impostors[i];
  110907. }
  110908. }
  110909. return null;
  110910. };
  110911. /**
  110912. * Gets the impostor for a physics body object
  110913. * @param body defines physics body used by the impostor
  110914. * @returns the PhysicsImpostor or null if not found
  110915. */
  110916. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  110917. for (var i = 0; i < this._impostors.length; ++i) {
  110918. if (this._impostors[i].physicsBody === body) {
  110919. return this._impostors[i];
  110920. }
  110921. }
  110922. return null;
  110923. };
  110924. /**
  110925. * Global value used to control the smallest number supported by the simulation
  110926. */
  110927. PhysicsEngine.Epsilon = 0.001;
  110928. return PhysicsEngine;
  110929. }());
  110930. /***/ }),
  110931. /***/ "./Physics/physicsEngineComponent.ts":
  110932. /*!*******************************************!*\
  110933. !*** ./Physics/physicsEngineComponent.ts ***!
  110934. \*******************************************/
  110935. /*! exports provided: PhysicsEngineSceneComponent */
  110936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110937. "use strict";
  110938. __webpack_require__.r(__webpack_exports__);
  110939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  110940. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110941. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  110942. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110943. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  110944. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  110945. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110946. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110947. /**
  110948. * Gets the current physics engine
  110949. * @returns a IPhysicsEngine or null if none attached
  110950. */
  110951. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  110952. return this._physicsEngine;
  110953. };
  110954. /**
  110955. * Enables physics to the current scene
  110956. * @param gravity defines the scene's gravity for the physics engine
  110957. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110958. * @return a boolean indicating if the physics engine was initialized
  110959. */
  110960. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  110961. if (gravity === void 0) { gravity = null; }
  110962. if (this._physicsEngine) {
  110963. return true;
  110964. }
  110965. // Register the component to the scene
  110966. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  110967. if (!component) {
  110968. component = new PhysicsEngineSceneComponent(this);
  110969. this._addComponent(component);
  110970. }
  110971. try {
  110972. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  110973. return true;
  110974. }
  110975. catch (e) {
  110976. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  110977. return false;
  110978. }
  110979. };
  110980. /**
  110981. * Disables and disposes the physics engine associated with the scene
  110982. */
  110983. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  110984. if (!this._physicsEngine) {
  110985. return;
  110986. }
  110987. this._physicsEngine.dispose();
  110988. this._physicsEngine = null;
  110989. };
  110990. /**
  110991. * Gets a boolean indicating if there is an active physics engine
  110992. * @returns a boolean indicating if there is an active physics engine
  110993. */
  110994. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  110995. return this._physicsEngine !== undefined;
  110996. };
  110997. /**
  110998. * Deletes a physics compound impostor
  110999. * @param compound defines the compound to delete
  111000. */
  111001. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  111002. var mesh = compound.parts[0].mesh;
  111003. if (mesh.physicsImpostor) {
  111004. mesh.physicsImpostor.dispose( /*true*/);
  111005. mesh.physicsImpostor = null;
  111006. }
  111007. };
  111008. /** @hidden */
  111009. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  111010. if (this._physicsEngine) {
  111011. this.onBeforePhysicsObservable.notifyObservers(this);
  111012. this._physicsEngine._step(step / 1000);
  111013. this.onAfterPhysicsObservable.notifyObservers(this);
  111014. }
  111015. };
  111016. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  111017. get: function () {
  111018. return this._physicsImpostor;
  111019. },
  111020. set: function (value) {
  111021. var _this = this;
  111022. if (this._physicsImpostor === value) {
  111023. return;
  111024. }
  111025. if (this._disposePhysicsObserver) {
  111026. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  111027. }
  111028. this._physicsImpostor = value;
  111029. if (value) {
  111030. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  111031. // Physics
  111032. if (_this.physicsImpostor) {
  111033. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  111034. _this.physicsImpostor = null;
  111035. }
  111036. });
  111037. }
  111038. },
  111039. enumerable: true,
  111040. configurable: true
  111041. });
  111042. /**
  111043. * Gets the current physics impostor
  111044. * @see http://doc.babylonjs.com/features/physics_engine
  111045. * @returns a physics impostor or null
  111046. */
  111047. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  111048. return this.physicsImpostor;
  111049. };
  111050. /**
  111051. * Apply a physic impulse to the mesh
  111052. * @param force defines the force to apply
  111053. * @param contactPoint defines where to apply the force
  111054. * @returns the current mesh
  111055. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111056. */
  111057. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  111058. if (!this.physicsImpostor) {
  111059. return this;
  111060. }
  111061. this.physicsImpostor.applyImpulse(force, contactPoint);
  111062. return this;
  111063. };
  111064. /**
  111065. * Creates a physic joint between two meshes
  111066. * @param otherMesh defines the other mesh to use
  111067. * @param pivot1 defines the pivot to use on this mesh
  111068. * @param pivot2 defines the pivot to use on the other mesh
  111069. * @param options defines additional options (can be plugin dependent)
  111070. * @returns the current mesh
  111071. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111072. */
  111073. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  111074. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  111075. return this;
  111076. }
  111077. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  111078. mainPivot: pivot1,
  111079. connectedPivot: pivot2,
  111080. nativeParams: options
  111081. });
  111082. return this;
  111083. };
  111084. /**
  111085. * Defines the physics engine scene component responsible to manage a physics engine
  111086. */
  111087. var PhysicsEngineSceneComponent = /** @class */ (function () {
  111088. /**
  111089. * Creates a new instance of the component for the given scene
  111090. * @param scene Defines the scene to register the component in
  111091. */
  111092. function PhysicsEngineSceneComponent(scene) {
  111093. var _this = this;
  111094. /**
  111095. * The component name helpful to identify the component in the list of scene components.
  111096. */
  111097. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  111098. this.scene = scene;
  111099. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111100. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111101. // Replace the function used to get the deterministic frame time
  111102. this.scene.getDeterministicFrameTime = function () {
  111103. if (_this.scene._physicsEngine) {
  111104. return _this.scene._physicsEngine.getTimeStep() * 1000;
  111105. }
  111106. return 1000.0 / 60.0;
  111107. };
  111108. }
  111109. /**
  111110. * Registers the component in a given scene
  111111. */
  111112. PhysicsEngineSceneComponent.prototype.register = function () {
  111113. };
  111114. /**
  111115. * Rebuilds the elements related to this component in case of
  111116. * context lost for instance.
  111117. */
  111118. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  111119. // Nothing to do for this component
  111120. };
  111121. /**
  111122. * Disposes the component and the associated ressources
  111123. */
  111124. PhysicsEngineSceneComponent.prototype.dispose = function () {
  111125. this.scene.onBeforePhysicsObservable.clear();
  111126. this.scene.onAfterPhysicsObservable.clear();
  111127. if (this.scene._physicsEngine) {
  111128. this.scene.disablePhysicsEngine();
  111129. }
  111130. };
  111131. return PhysicsEngineSceneComponent;
  111132. }());
  111133. /***/ }),
  111134. /***/ "./Physics/physicsHelper.ts":
  111135. /*!**********************************!*\
  111136. !*** ./Physics/physicsHelper.ts ***!
  111137. \**********************************/
  111138. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  111139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111140. "use strict";
  111141. __webpack_require__.r(__webpack_exports__);
  111142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  111143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  111144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  111145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  111146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  111147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  111148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  111149. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111151. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111152. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  111153. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  111154. /**
  111155. * A helper for physics simulations
  111156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111157. */
  111158. var PhysicsHelper = /** @class */ (function () {
  111159. /**
  111160. * Initializes the Physics helper
  111161. * @param scene Babylon.js scene
  111162. */
  111163. function PhysicsHelper(scene) {
  111164. this._scene = scene;
  111165. this._physicsEngine = this._scene.getPhysicsEngine();
  111166. if (!this._physicsEngine) {
  111167. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  111168. }
  111169. }
  111170. /**
  111171. * Applies a radial explosion impulse
  111172. * @param origin the origin of the explosion
  111173. * @param radius the explosion radius
  111174. * @param strength the explosion strength
  111175. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111176. * @returns A physics radial explosion event, or null
  111177. */
  111178. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  111179. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111180. if (!this._physicsEngine) {
  111181. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  111182. return null;
  111183. }
  111184. var impostors = this._physicsEngine.getImpostors();
  111185. if (impostors.length === 0) {
  111186. return null;
  111187. }
  111188. var event = new PhysicsRadialExplosionEvent(this._scene);
  111189. impostors.forEach(function (impostor) {
  111190. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111191. if (!impostorForceAndContactPoint) {
  111192. return;
  111193. }
  111194. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111195. });
  111196. event.dispose(false);
  111197. return event;
  111198. };
  111199. /**
  111200. * Applies a radial explosion force
  111201. * @param origin the origin of the explosion
  111202. * @param radius the explosion radius
  111203. * @param strength the explosion strength
  111204. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111205. * @returns A physics radial explosion event, or null
  111206. */
  111207. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  111208. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111209. if (!this._physicsEngine) {
  111210. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111211. return null;
  111212. }
  111213. var impostors = this._physicsEngine.getImpostors();
  111214. if (impostors.length === 0) {
  111215. return null;
  111216. }
  111217. var event = new PhysicsRadialExplosionEvent(this._scene);
  111218. impostors.forEach(function (impostor) {
  111219. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111220. if (!impostorForceAndContactPoint) {
  111221. return;
  111222. }
  111223. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111224. });
  111225. event.dispose(false);
  111226. return event;
  111227. };
  111228. /**
  111229. * Creates a gravitational field
  111230. * @param origin the origin of the explosion
  111231. * @param radius the explosion radius
  111232. * @param strength the explosion strength
  111233. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111234. * @returns A physics gravitational field event, or null
  111235. */
  111236. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  111237. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111238. if (!this._physicsEngine) {
  111239. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111240. return null;
  111241. }
  111242. var impostors = this._physicsEngine.getImpostors();
  111243. if (impostors.length === 0) {
  111244. return null;
  111245. }
  111246. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  111247. event.dispose(false);
  111248. return event;
  111249. };
  111250. /**
  111251. * Creates a physics updraft event
  111252. * @param origin the origin of the updraft
  111253. * @param radius the radius of the updraft
  111254. * @param strength the strength of the updraft
  111255. * @param height the height of the updraft
  111256. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111257. * @returns A physics updraft event, or null
  111258. */
  111259. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  111260. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  111261. if (!this._physicsEngine) {
  111262. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111263. return null;
  111264. }
  111265. if (this._physicsEngine.getImpostors().length === 0) {
  111266. return null;
  111267. }
  111268. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  111269. event.dispose(false);
  111270. return event;
  111271. };
  111272. /**
  111273. * Creates a physics vortex event
  111274. * @param origin the of the vortex
  111275. * @param radius the radius of the vortex
  111276. * @param strength the strength of the vortex
  111277. * @param height the height of the vortex
  111278. * @returns a Physics vortex event, or null
  111279. * A physics vortex event or null
  111280. */
  111281. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  111282. if (!this._physicsEngine) {
  111283. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111284. return null;
  111285. }
  111286. if (this._physicsEngine.getImpostors().length === 0) {
  111287. return null;
  111288. }
  111289. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  111290. event.dispose(false);
  111291. return event;
  111292. };
  111293. return PhysicsHelper;
  111294. }());
  111295. /**
  111296. * Represents a physics radial explosion event
  111297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111298. */
  111299. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  111300. /**
  111301. * Initializes a radial explosioin event
  111302. * @param scene BabylonJS scene
  111303. */
  111304. function PhysicsRadialExplosionEvent(scene) {
  111305. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  111306. this._rays = [];
  111307. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  111308. this._scene = scene;
  111309. }
  111310. /**
  111311. * Returns the data related to the radial explosion event (sphere & rays).
  111312. * @returns The radial explosion event data
  111313. */
  111314. PhysicsRadialExplosionEvent.prototype.getData = function () {
  111315. this._dataFetched = true;
  111316. return {
  111317. sphere: this._sphere,
  111318. rays: this._rays,
  111319. };
  111320. };
  111321. /**
  111322. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111323. * @param impostor A physics imposter
  111324. * @param origin the origin of the explosion
  111325. * @param radius the explosion radius
  111326. * @param strength the explosion strength
  111327. * @param falloff possible options: Constant & Linear
  111328. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  111329. */
  111330. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  111331. if (impostor.mass === 0) {
  111332. return null;
  111333. }
  111334. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  111335. return null;
  111336. }
  111337. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111338. return null;
  111339. }
  111340. var impostorObjectCenter = impostor.getObjectCenter();
  111341. var direction = impostorObjectCenter.subtract(origin);
  111342. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  111343. this._rays.push(ray);
  111344. var hit = ray.intersectsMesh(impostor.object);
  111345. var contactPoint = hit.pickedPoint;
  111346. if (!contactPoint) {
  111347. return null;
  111348. }
  111349. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  111350. if (distanceFromOrigin > radius) {
  111351. return null;
  111352. }
  111353. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  111354. ? strength
  111355. : strength * (1 - (distanceFromOrigin / radius));
  111356. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111357. return { force: force, contactPoint: contactPoint };
  111358. };
  111359. /**
  111360. * Disposes the sphere.
  111361. * @param force Specifies if the sphere should be disposed by force
  111362. */
  111363. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  111364. var _this = this;
  111365. if (force === void 0) { force = true; }
  111366. if (force) {
  111367. this._sphere.dispose();
  111368. }
  111369. else {
  111370. setTimeout(function () {
  111371. if (!_this._dataFetched) {
  111372. _this._sphere.dispose();
  111373. }
  111374. }, 0);
  111375. }
  111376. };
  111377. /*** Helpers ***/
  111378. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  111379. if (!this._sphere) {
  111380. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  111381. this._sphere.isVisible = false;
  111382. }
  111383. };
  111384. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  111385. var impostorObject = impostor.object;
  111386. this._prepareSphere();
  111387. this._sphere.position = origin;
  111388. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  111389. this._sphere._updateBoundingInfo();
  111390. this._sphere.computeWorldMatrix(true);
  111391. return this._sphere.intersectsMesh(impostorObject, true);
  111392. };
  111393. return PhysicsRadialExplosionEvent;
  111394. }());
  111395. /**
  111396. * Represents a gravitational field event
  111397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111398. */
  111399. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  111400. /**
  111401. * Initializes the physics gravitational field event
  111402. * @param physicsHelper A physics helper
  111403. * @param scene BabylonJS scene
  111404. * @param origin The origin position of the gravitational field event
  111405. * @param radius The radius of the gravitational field event
  111406. * @param strength The strength of the gravitational field event
  111407. * @param falloff The falloff for the gravitational field event
  111408. */
  111409. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  111410. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111411. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111412. this._physicsHelper = physicsHelper;
  111413. this._scene = scene;
  111414. this._origin = origin;
  111415. this._radius = radius;
  111416. this._strength = strength;
  111417. this._falloff = falloff;
  111418. this._tickCallback = this._tick.bind(this);
  111419. }
  111420. /**
  111421. * Returns the data related to the gravitational field event (sphere).
  111422. * @returns A gravitational field event
  111423. */
  111424. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  111425. this._dataFetched = true;
  111426. return {
  111427. sphere: this._sphere,
  111428. };
  111429. };
  111430. /**
  111431. * Enables the gravitational field.
  111432. */
  111433. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  111434. this._tickCallback.call(this);
  111435. this._scene.registerBeforeRender(this._tickCallback);
  111436. };
  111437. /**
  111438. * Disables the gravitational field.
  111439. */
  111440. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  111441. this._scene.unregisterBeforeRender(this._tickCallback);
  111442. };
  111443. /**
  111444. * Disposes the sphere.
  111445. * @param force The force to dispose from the gravitational field event
  111446. */
  111447. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  111448. var _this = this;
  111449. if (force === void 0) { force = true; }
  111450. if (force) {
  111451. this._sphere.dispose();
  111452. }
  111453. else {
  111454. setTimeout(function () {
  111455. if (!_this._dataFetched) {
  111456. _this._sphere.dispose();
  111457. }
  111458. }, 0);
  111459. }
  111460. };
  111461. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  111462. // Since the params won't change, we fetch the event only once
  111463. if (this._sphere) {
  111464. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111465. }
  111466. else {
  111467. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111468. if (radialExplosionEvent) {
  111469. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  111470. }
  111471. }
  111472. };
  111473. return PhysicsGravitationalFieldEvent;
  111474. }());
  111475. /**
  111476. * Represents a physics updraft event
  111477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111478. */
  111479. var PhysicsUpdraftEvent = /** @class */ (function () {
  111480. /**
  111481. * Initializes the physics updraft event
  111482. * @param _scene BabylonJS scene
  111483. * @param _origin The origin position of the updraft
  111484. * @param _radius The radius of the updraft
  111485. * @param _strength The strength of the updraft
  111486. * @param _height The height of the updraft
  111487. * @param _updraftMode The mode of the updraft
  111488. */
  111489. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  111490. this._scene = _scene;
  111491. this._origin = _origin;
  111492. this._radius = _radius;
  111493. this._strength = _strength;
  111494. this._height = _height;
  111495. this._updraftMode = _updraftMode;
  111496. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111497. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  111498. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  111499. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111500. this._physicsEngine = this._scene.getPhysicsEngine();
  111501. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111502. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111503. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111504. this._originDirection = this._origin.subtract(this._originTop).normalize();
  111505. }
  111506. this._tickCallback = this._tick.bind(this);
  111507. this._prepareCylinder();
  111508. }
  111509. /**
  111510. * Returns the data related to the updraft event (cylinder).
  111511. * @returns A physics updraft event
  111512. */
  111513. PhysicsUpdraftEvent.prototype.getData = function () {
  111514. this._dataFetched = true;
  111515. return {
  111516. cylinder: this._cylinder,
  111517. };
  111518. };
  111519. /**
  111520. * Enables the updraft.
  111521. */
  111522. PhysicsUpdraftEvent.prototype.enable = function () {
  111523. this._tickCallback.call(this);
  111524. this._scene.registerBeforeRender(this._tickCallback);
  111525. };
  111526. /**
  111527. * Disables the cortex.
  111528. */
  111529. PhysicsUpdraftEvent.prototype.disable = function () {
  111530. this._scene.unregisterBeforeRender(this._tickCallback);
  111531. };
  111532. /**
  111533. * Disposes the sphere.
  111534. * @param force Specifies if the updraft should be disposed by force
  111535. */
  111536. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  111537. var _this = this;
  111538. if (force === void 0) { force = true; }
  111539. if (!this._cylinder) {
  111540. return;
  111541. }
  111542. if (force) {
  111543. this._cylinder.dispose();
  111544. }
  111545. else {
  111546. setTimeout(function () {
  111547. if (!_this._dataFetched) {
  111548. _this._cylinder.dispose();
  111549. }
  111550. }, 0);
  111551. }
  111552. };
  111553. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111554. if (impostor.mass === 0) {
  111555. return null;
  111556. }
  111557. if (!this._intersectsWithCylinder(impostor)) {
  111558. return null;
  111559. }
  111560. var impostorObjectCenter = impostor.getObjectCenter();
  111561. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111562. var direction = this._originDirection;
  111563. }
  111564. else {
  111565. var direction = impostorObjectCenter.subtract(this._originTop);
  111566. }
  111567. var multiplier = this._strength * -1;
  111568. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111569. return { force: force, contactPoint: impostorObjectCenter };
  111570. };
  111571. PhysicsUpdraftEvent.prototype._tick = function () {
  111572. var _this = this;
  111573. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111574. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111575. if (!impostorForceAndContactPoint) {
  111576. return;
  111577. }
  111578. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111579. });
  111580. };
  111581. /*** Helpers ***/
  111582. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  111583. if (!this._cylinder) {
  111584. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  111585. height: this._height,
  111586. diameter: this._radius * 2,
  111587. }, this._scene);
  111588. this._cylinder.isVisible = false;
  111589. }
  111590. };
  111591. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  111592. var impostorObject = impostor.object;
  111593. this._cylinder.position = this._cylinderPosition;
  111594. return this._cylinder.intersectsMesh(impostorObject, true);
  111595. };
  111596. return PhysicsUpdraftEvent;
  111597. }());
  111598. /**
  111599. * Represents a physics vortex event
  111600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111601. */
  111602. var PhysicsVortexEvent = /** @class */ (function () {
  111603. /**
  111604. * Initializes the physics vortex event
  111605. * @param _scene The BabylonJS scene
  111606. * @param _origin The origin position of the vortex
  111607. * @param _radius The radius of the vortex
  111608. * @param _strength The strength of the vortex
  111609. * @param _height The height of the vortex
  111610. */
  111611. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  111612. this._scene = _scene;
  111613. this._origin = _origin;
  111614. this._radius = _radius;
  111615. this._strength = _strength;
  111616. this._height = _height;
  111617. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111618. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  111619. this._updraftMultiplier = 0.02;
  111620. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  111621. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111622. this._physicsEngine = this._scene.getPhysicsEngine();
  111623. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111624. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111625. this._tickCallback = this._tick.bind(this);
  111626. this._prepareCylinder();
  111627. }
  111628. /**
  111629. * Returns the data related to the vortex event (cylinder).
  111630. * @returns The physics vortex event data
  111631. */
  111632. PhysicsVortexEvent.prototype.getData = function () {
  111633. this._dataFetched = true;
  111634. return {
  111635. cylinder: this._cylinder,
  111636. };
  111637. };
  111638. /**
  111639. * Enables the vortex.
  111640. */
  111641. PhysicsVortexEvent.prototype.enable = function () {
  111642. this._tickCallback.call(this);
  111643. this._scene.registerBeforeRender(this._tickCallback);
  111644. };
  111645. /**
  111646. * Disables the cortex.
  111647. */
  111648. PhysicsVortexEvent.prototype.disable = function () {
  111649. this._scene.unregisterBeforeRender(this._tickCallback);
  111650. };
  111651. /**
  111652. * Disposes the sphere.
  111653. * @param force
  111654. */
  111655. PhysicsVortexEvent.prototype.dispose = function (force) {
  111656. var _this = this;
  111657. if (force === void 0) { force = true; }
  111658. if (force) {
  111659. this._cylinder.dispose();
  111660. }
  111661. else {
  111662. setTimeout(function () {
  111663. if (!_this._dataFetched) {
  111664. _this._cylinder.dispose();
  111665. }
  111666. }, 0);
  111667. }
  111668. };
  111669. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111670. if (impostor.mass === 0) {
  111671. return null;
  111672. }
  111673. if (!this._intersectsWithCylinder(impostor)) {
  111674. return null;
  111675. }
  111676. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111677. return null;
  111678. }
  111679. var impostorObjectCenter = impostor.getObjectCenter();
  111680. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  111681. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  111682. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  111683. var hit = ray.intersectsMesh(impostor.object);
  111684. var contactPoint = hit.pickedPoint;
  111685. if (!contactPoint) {
  111686. return null;
  111687. }
  111688. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  111689. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  111690. var directionToOrigin = contactPoint.normalize();
  111691. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111692. directionToOrigin = directionToOrigin.negate();
  111693. }
  111694. // TODO: find a more physically based solution
  111695. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111696. var forceX = directionToOrigin.x * this._strength / 8;
  111697. var forceY = directionToOrigin.y * this._updraftMultiplier;
  111698. var forceZ = directionToOrigin.z * this._strength / 8;
  111699. }
  111700. else {
  111701. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  111702. var forceY = this._originTop.y * this._updraftMultiplier;
  111703. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  111704. }
  111705. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  111706. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  111707. return { force: force, contactPoint: impostorObjectCenter };
  111708. };
  111709. PhysicsVortexEvent.prototype._tick = function () {
  111710. var _this = this;
  111711. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111712. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111713. if (!impostorForceAndContactPoint) {
  111714. return;
  111715. }
  111716. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111717. });
  111718. };
  111719. /*** Helpers ***/
  111720. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  111721. if (!this._cylinder) {
  111722. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  111723. height: this._height,
  111724. diameter: this._radius * 2,
  111725. }, this._scene);
  111726. this._cylinder.isVisible = false;
  111727. }
  111728. };
  111729. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  111730. var impostorObject = impostor.object;
  111731. this._cylinder.position = this._cylinderPosition;
  111732. return this._cylinder.intersectsMesh(impostorObject, true);
  111733. };
  111734. return PhysicsVortexEvent;
  111735. }());
  111736. /**
  111737. * The strenght of the force in correspondence to the distance of the affected object
  111738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111739. */
  111740. var PhysicsRadialImpulseFalloff;
  111741. (function (PhysicsRadialImpulseFalloff) {
  111742. /** Defines that impulse is constant in strength across it's whole radius */
  111743. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  111744. /** DEfines that impulse gets weaker if it's further from the origin */
  111745. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  111746. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  111747. /**
  111748. * The strength of the force in correspondence to the distance of the affected object
  111749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111750. */
  111751. var PhysicsUpdraftMode;
  111752. (function (PhysicsUpdraftMode) {
  111753. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111754. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  111755. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111756. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  111757. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  111758. /***/ }),
  111759. /***/ "./Physics/physicsImpostor.ts":
  111760. /*!************************************!*\
  111761. !*** ./Physics/physicsImpostor.ts ***!
  111762. \************************************/
  111763. /*! exports provided: PhysicsImpostor */
  111764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111765. "use strict";
  111766. __webpack_require__.r(__webpack_exports__);
  111767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  111768. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111769. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  111770. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111771. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111772. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111773. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111774. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  111775. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  111776. mass: jsonObject.physicsMass,
  111777. friction: jsonObject.physicsFriction,
  111778. restitution: jsonObject.physicsRestitution
  111779. }, scene);
  111780. };
  111781. /**
  111782. * Represents a physics imposter
  111783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111784. */
  111785. var PhysicsImpostor = /** @class */ (function () {
  111786. /**
  111787. * Initializes the physics imposter
  111788. * @param object The physics-enabled object used as the physics imposter
  111789. * @param type The type of the physics imposter
  111790. * @param _options The options for the physics imposter
  111791. * @param _scene The Babylon scene
  111792. */
  111793. function PhysicsImpostor(
  111794. /**
  111795. * The physics-enabled object used as the physics imposter
  111796. */
  111797. object,
  111798. /**
  111799. * The type of the physics imposter
  111800. */
  111801. type, _options, _scene) {
  111802. if (_options === void 0) { _options = { mass: 0 }; }
  111803. var _this = this;
  111804. this.object = object;
  111805. this.type = type;
  111806. this._options = _options;
  111807. this._scene = _scene;
  111808. this._bodyUpdateRequired = false;
  111809. this._onBeforePhysicsStepCallbacks = new Array();
  111810. this._onAfterPhysicsStepCallbacks = new Array();
  111811. /** @hidden */
  111812. this._onPhysicsCollideCallbacks = [];
  111813. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111814. this._isDisposed = false;
  111815. //temp variables for parent rotation calculations
  111816. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  111817. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111818. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111819. /**
  111820. * this function is executed by the physics engine.
  111821. */
  111822. this.beforeStep = function () {
  111823. if (!_this._physicsEngine) {
  111824. return;
  111825. }
  111826. _this.object.translate(_this._deltaPosition, -1);
  111827. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  111828. _this.object.computeWorldMatrix(false);
  111829. if (_this.object.parent && _this.object.rotationQuaternion) {
  111830. _this.getParentsRotation();
  111831. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  111832. }
  111833. else {
  111834. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  111835. }
  111836. if (!_this._options.disableBidirectionalTransformation) {
  111837. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  111838. }
  111839. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  111840. func(_this);
  111841. });
  111842. };
  111843. /**
  111844. * this function is executed by the physics engine
  111845. */
  111846. this.afterStep = function () {
  111847. if (!_this._physicsEngine) {
  111848. return;
  111849. }
  111850. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  111851. func(_this);
  111852. });
  111853. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  111854. // object has now its world rotation. needs to be converted to local.
  111855. if (_this.object.parent && _this.object.rotationQuaternion) {
  111856. _this.getParentsRotation();
  111857. _this._tmpQuat.conjugateInPlace();
  111858. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  111859. }
  111860. // take the position set and make it the absolute position of this object.
  111861. _this.object.setAbsolutePosition(_this.object.position);
  111862. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  111863. _this.object.translate(_this._deltaPosition, 1);
  111864. };
  111865. /**
  111866. * Legacy collision detection event support
  111867. */
  111868. this.onCollideEvent = null;
  111869. /**
  111870. * event and body object due to cannon's event-based architecture.
  111871. */
  111872. this.onCollide = function (e) {
  111873. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  111874. return;
  111875. }
  111876. if (!_this._physicsEngine) {
  111877. return;
  111878. }
  111879. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  111880. if (otherImpostor) {
  111881. // Legacy collision detection event support
  111882. if (_this.onCollideEvent) {
  111883. _this.onCollideEvent(_this, otherImpostor);
  111884. }
  111885. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  111886. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  111887. }).forEach(function (obj) {
  111888. obj.callback(_this, otherImpostor);
  111889. });
  111890. }
  111891. };
  111892. //sanity check!
  111893. if (!this.object) {
  111894. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  111895. return;
  111896. }
  111897. // Legacy support for old syntax.
  111898. if (!this._scene && object.getScene) {
  111899. this._scene = object.getScene();
  111900. }
  111901. if (!this._scene) {
  111902. return;
  111903. }
  111904. this._physicsEngine = this._scene.getPhysicsEngine();
  111905. if (!this._physicsEngine) {
  111906. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  111907. }
  111908. else {
  111909. //set the object's quaternion, if not set
  111910. if (!this.object.rotationQuaternion) {
  111911. if (this.object.rotation) {
  111912. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  111913. }
  111914. else {
  111915. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111916. }
  111917. }
  111918. //default options params
  111919. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  111920. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  111921. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  111922. this._joints = [];
  111923. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  111924. if (!this.object.parent || this._options.ignoreParent) {
  111925. this._init();
  111926. }
  111927. else if (this.object.parent.physicsImpostor) {
  111928. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  111929. }
  111930. }
  111931. }
  111932. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  111933. /**
  111934. * Specifies if the physics imposter is disposed
  111935. */
  111936. get: function () {
  111937. return this._isDisposed;
  111938. },
  111939. enumerable: true,
  111940. configurable: true
  111941. });
  111942. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  111943. /**
  111944. * Gets the mass of the physics imposter
  111945. */
  111946. get: function () {
  111947. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  111948. },
  111949. set: function (value) {
  111950. this.setMass(value);
  111951. },
  111952. enumerable: true,
  111953. configurable: true
  111954. });
  111955. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  111956. /**
  111957. * Gets the coefficient of friction
  111958. */
  111959. get: function () {
  111960. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  111961. },
  111962. /**
  111963. * Sets the coefficient of friction
  111964. */
  111965. set: function (value) {
  111966. if (!this._physicsEngine) {
  111967. return;
  111968. }
  111969. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  111970. },
  111971. enumerable: true,
  111972. configurable: true
  111973. });
  111974. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  111975. /**
  111976. * Gets the coefficient of restitution
  111977. */
  111978. get: function () {
  111979. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  111980. },
  111981. /**
  111982. * Sets the coefficient of restitution
  111983. */
  111984. set: function (value) {
  111985. if (!this._physicsEngine) {
  111986. return;
  111987. }
  111988. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  111989. },
  111990. enumerable: true,
  111991. configurable: true
  111992. });
  111993. /**
  111994. * This function will completly initialize this impostor.
  111995. * It will create a new body - but only if this mesh has no parent.
  111996. * If it has, this impostor will not be used other than to define the impostor
  111997. * of the child mesh.
  111998. * @hidden
  111999. */
  112000. PhysicsImpostor.prototype._init = function () {
  112001. if (!this._physicsEngine) {
  112002. return;
  112003. }
  112004. this._physicsEngine.removeImpostor(this);
  112005. this.physicsBody = null;
  112006. this._parent = this._parent || this._getPhysicsParent();
  112007. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  112008. this._physicsEngine.addImpostor(this);
  112009. }
  112010. };
  112011. PhysicsImpostor.prototype._getPhysicsParent = function () {
  112012. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  112013. var parentMesh = this.object.parent;
  112014. return parentMesh.physicsImpostor;
  112015. }
  112016. return null;
  112017. };
  112018. /**
  112019. * Should a new body be generated.
  112020. * @returns boolean specifying if body initialization is required
  112021. */
  112022. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  112023. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  112024. };
  112025. /**
  112026. * Sets the updated scaling
  112027. * @param updated Specifies if the scaling is updated
  112028. */
  112029. PhysicsImpostor.prototype.setScalingUpdated = function () {
  112030. this.forceUpdate();
  112031. };
  112032. /**
  112033. * Force a regeneration of this or the parent's impostor's body.
  112034. * Use under cautious - This will remove all joints already implemented.
  112035. */
  112036. PhysicsImpostor.prototype.forceUpdate = function () {
  112037. this._init();
  112038. if (this.parent && !this._options.ignoreParent) {
  112039. this.parent.forceUpdate();
  112040. }
  112041. };
  112042. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  112043. /*public get mesh(): AbstractMesh {
  112044. return this._mesh;
  112045. }*/
  112046. /**
  112047. * Gets the body that holds this impostor. Either its own, or its parent.
  112048. */
  112049. get: function () {
  112050. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  112051. },
  112052. /**
  112053. * Set the physics body. Used mainly by the physics engine/plugin
  112054. */
  112055. set: function (physicsBody) {
  112056. if (this._physicsBody && this._physicsEngine) {
  112057. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  112058. }
  112059. this._physicsBody = physicsBody;
  112060. this.resetUpdateFlags();
  112061. },
  112062. enumerable: true,
  112063. configurable: true
  112064. });
  112065. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  112066. /**
  112067. * Get the parent of the physics imposter
  112068. * @returns Physics imposter or null
  112069. */
  112070. get: function () {
  112071. return !this._options.ignoreParent && this._parent ? this._parent : null;
  112072. },
  112073. /**
  112074. * Sets the parent of the physics imposter
  112075. */
  112076. set: function (value) {
  112077. this._parent = value;
  112078. },
  112079. enumerable: true,
  112080. configurable: true
  112081. });
  112082. /**
  112083. * Resets the update flags
  112084. */
  112085. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  112086. this._bodyUpdateRequired = false;
  112087. };
  112088. /**
  112089. * Gets the object extend size
  112090. * @returns the object extend size
  112091. */
  112092. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  112093. if (this.object.getBoundingInfo) {
  112094. var q = this.object.rotationQuaternion;
  112095. //reset rotation
  112096. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  112097. //calculate the world matrix with no rotation
  112098. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112099. var boundingInfo = this.object.getBoundingInfo();
  112100. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  112101. //bring back the rotation
  112102. this.object.rotationQuaternion = q;
  112103. //calculate the world matrix with the new rotation
  112104. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112105. return size;
  112106. }
  112107. else {
  112108. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  112109. }
  112110. };
  112111. /**
  112112. * Gets the object center
  112113. * @returns The object center
  112114. */
  112115. PhysicsImpostor.prototype.getObjectCenter = function () {
  112116. if (this.object.getBoundingInfo) {
  112117. var boundingInfo = this.object.getBoundingInfo();
  112118. return boundingInfo.boundingBox.centerWorld;
  112119. }
  112120. else {
  112121. return this.object.position;
  112122. }
  112123. };
  112124. /**
  112125. * Get a specific parametes from the options parameter
  112126. * @param paramName The object parameter name
  112127. * @returns The object parameter
  112128. */
  112129. PhysicsImpostor.prototype.getParam = function (paramName) {
  112130. return this._options[paramName];
  112131. };
  112132. /**
  112133. * Sets a specific parameter in the options given to the physics plugin
  112134. * @param paramName The parameter name
  112135. * @param value The value of the parameter
  112136. */
  112137. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  112138. this._options[paramName] = value;
  112139. this._bodyUpdateRequired = true;
  112140. };
  112141. /**
  112142. * Specifically change the body's mass option. Won't recreate the physics body object
  112143. * @param mass The mass of the physics imposter
  112144. */
  112145. PhysicsImpostor.prototype.setMass = function (mass) {
  112146. if (this.getParam("mass") !== mass) {
  112147. this.setParam("mass", mass);
  112148. }
  112149. if (this._physicsEngine) {
  112150. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  112151. }
  112152. };
  112153. /**
  112154. * Gets the linear velocity
  112155. * @returns linear velocity or null
  112156. */
  112157. PhysicsImpostor.prototype.getLinearVelocity = function () {
  112158. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112159. };
  112160. /**
  112161. * Sets the linear velocity
  112162. * @param velocity linear velocity or null
  112163. */
  112164. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  112165. if (this._physicsEngine) {
  112166. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  112167. }
  112168. };
  112169. /**
  112170. * Gets the angular velocity
  112171. * @returns angular velocity or null
  112172. */
  112173. PhysicsImpostor.prototype.getAngularVelocity = function () {
  112174. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112175. };
  112176. /**
  112177. * Sets the angular velocity
  112178. * @param velocity The velocity or null
  112179. */
  112180. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  112181. if (this._physicsEngine) {
  112182. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  112183. }
  112184. };
  112185. /**
  112186. * Execute a function with the physics plugin native code
  112187. * Provide a function the will have two variables - the world object and the physics body object
  112188. * @param func The function to execute with the physics plugin native code
  112189. */
  112190. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  112191. if (this._physicsEngine) {
  112192. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  112193. }
  112194. };
  112195. /**
  112196. * Register a function that will be executed before the physics world is stepping forward
  112197. * @param func The function to execute before the physics world is stepped forward
  112198. */
  112199. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  112200. this._onBeforePhysicsStepCallbacks.push(func);
  112201. };
  112202. /**
  112203. * Unregister a function that will be executed before the physics world is stepping forward
  112204. * @param func The function to execute before the physics world is stepped forward
  112205. */
  112206. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  112207. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  112208. if (index > -1) {
  112209. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  112210. }
  112211. else {
  112212. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112213. }
  112214. };
  112215. /**
  112216. * Register a function that will be executed after the physics step
  112217. * @param func The function to execute after physics step
  112218. */
  112219. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  112220. this._onAfterPhysicsStepCallbacks.push(func);
  112221. };
  112222. /**
  112223. * Unregisters a function that will be executed after the physics step
  112224. * @param func The function to execute after physics step
  112225. */
  112226. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  112227. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  112228. if (index > -1) {
  112229. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  112230. }
  112231. else {
  112232. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112233. }
  112234. };
  112235. /**
  112236. * register a function that will be executed when this impostor collides against a different body
  112237. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112238. * @param func Callback that is executed on collision
  112239. */
  112240. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  112241. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112242. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  112243. };
  112244. /**
  112245. * Unregisters the physics imposter on contact
  112246. * @param collideAgainst The physics object to collide against
  112247. * @param func Callback to execute on collision
  112248. */
  112249. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  112250. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112251. var index = -1;
  112252. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  112253. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  112254. // chcek the arrays match
  112255. var sameList = cbDef.otherImpostors.every(function (impostor) {
  112256. return collidedAgainstList.indexOf(impostor) > -1;
  112257. });
  112258. if (sameList) {
  112259. index = idx;
  112260. }
  112261. return sameList;
  112262. }
  112263. return false;
  112264. });
  112265. if (found) {
  112266. this._onPhysicsCollideCallbacks.splice(index, 1);
  112267. }
  112268. else {
  112269. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112270. }
  112271. };
  112272. /**
  112273. * Get the parent rotation
  112274. * @returns The parent rotation
  112275. */
  112276. PhysicsImpostor.prototype.getParentsRotation = function () {
  112277. var parent = this.object.parent;
  112278. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  112279. while (parent) {
  112280. if (parent.rotationQuaternion) {
  112281. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  112282. }
  112283. else {
  112284. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  112285. }
  112286. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  112287. parent = parent.parent;
  112288. }
  112289. return this._tmpQuat;
  112290. };
  112291. /**
  112292. * Apply a force
  112293. * @param force The force to apply
  112294. * @param contactPoint The contact point for the force
  112295. * @returns The physics imposter
  112296. */
  112297. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  112298. if (this._physicsEngine) {
  112299. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  112300. }
  112301. return this;
  112302. };
  112303. /**
  112304. * Apply an impulse
  112305. * @param force The impulse force
  112306. * @param contactPoint The contact point for the impulse force
  112307. * @returns The physics imposter
  112308. */
  112309. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  112310. if (this._physicsEngine) {
  112311. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  112312. }
  112313. return this;
  112314. };
  112315. /**
  112316. * A help function to create a joint
  112317. * @param otherImpostor A physics imposter used to create a joint
  112318. * @param jointType The type of joint
  112319. * @param jointData The data for the joint
  112320. * @returns The physics imposter
  112321. */
  112322. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  112323. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  112324. this.addJoint(otherImpostor, joint);
  112325. return this;
  112326. };
  112327. /**
  112328. * Add a joint to this impostor with a different impostor
  112329. * @param otherImpostor A physics imposter used to add a joint
  112330. * @param joint The joint to add
  112331. * @returns The physics imposter
  112332. */
  112333. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  112334. this._joints.push({
  112335. otherImpostor: otherImpostor,
  112336. joint: joint
  112337. });
  112338. if (this._physicsEngine) {
  112339. this._physicsEngine.addJoint(this, otherImpostor, joint);
  112340. }
  112341. return this;
  112342. };
  112343. /**
  112344. * Will keep this body still, in a sleep mode.
  112345. * @returns the physics imposter
  112346. */
  112347. PhysicsImpostor.prototype.sleep = function () {
  112348. if (this._physicsEngine) {
  112349. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  112350. }
  112351. return this;
  112352. };
  112353. /**
  112354. * Wake the body up.
  112355. * @returns The physics imposter
  112356. */
  112357. PhysicsImpostor.prototype.wakeUp = function () {
  112358. if (this._physicsEngine) {
  112359. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  112360. }
  112361. return this;
  112362. };
  112363. /**
  112364. * Clones the physics imposter
  112365. * @param newObject The physics imposter clones to this physics-enabled object
  112366. * @returns A nullable physics imposter
  112367. */
  112368. PhysicsImpostor.prototype.clone = function (newObject) {
  112369. if (!newObject) {
  112370. return null;
  112371. }
  112372. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  112373. };
  112374. /**
  112375. * Disposes the physics imposter
  112376. */
  112377. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  112378. var _this = this;
  112379. //no dispose if no physics engine is available.
  112380. if (!this._physicsEngine) {
  112381. return;
  112382. }
  112383. this._joints.forEach(function (j) {
  112384. if (_this._physicsEngine) {
  112385. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  112386. }
  112387. });
  112388. //dispose the physics body
  112389. this._physicsEngine.removeImpostor(this);
  112390. if (this.parent) {
  112391. this.parent.forceUpdate();
  112392. }
  112393. else {
  112394. /*this._object.getChildMeshes().forEach(function(mesh) {
  112395. if (mesh.physicsImpostor) {
  112396. if (disposeChildren) {
  112397. mesh.physicsImpostor.dispose();
  112398. mesh.physicsImpostor = null;
  112399. }
  112400. }
  112401. })*/
  112402. }
  112403. this._isDisposed = true;
  112404. };
  112405. /**
  112406. * Sets the delta position
  112407. * @param position The delta position amount
  112408. */
  112409. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  112410. this._deltaPosition.copyFrom(position);
  112411. };
  112412. /**
  112413. * Sets the delta rotation
  112414. * @param rotation The delta rotation amount
  112415. */
  112416. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  112417. if (!this._deltaRotation) {
  112418. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112419. }
  112420. this._deltaRotation.copyFrom(rotation);
  112421. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  112422. };
  112423. /**
  112424. * Gets the box size of the physics imposter and stores the result in the input parameter
  112425. * @param result Stores the box size
  112426. * @returns The physics imposter
  112427. */
  112428. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  112429. if (this._physicsEngine) {
  112430. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  112431. }
  112432. return this;
  112433. };
  112434. /**
  112435. * Gets the radius of the physics imposter
  112436. * @returns Radius of the physics imposter
  112437. */
  112438. PhysicsImpostor.prototype.getRadius = function () {
  112439. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  112440. };
  112441. /**
  112442. * Sync a bone with this impostor
  112443. * @param bone The bone to sync to the impostor.
  112444. * @param boneMesh The mesh that the bone is influencing.
  112445. * @param jointPivot The pivot of the joint / bone in local space.
  112446. * @param distToJoint Optional distance from the impostor to the joint.
  112447. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112448. */
  112449. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  112450. var tempVec = PhysicsImpostor._tmpVecs[0];
  112451. var mesh = this.object;
  112452. if (mesh.rotationQuaternion) {
  112453. if (adjustRotation) {
  112454. var tempQuat = PhysicsImpostor._tmpQuat;
  112455. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  112456. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112457. }
  112458. else {
  112459. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112460. }
  112461. }
  112462. tempVec.x = 0;
  112463. tempVec.y = 0;
  112464. tempVec.z = 0;
  112465. if (jointPivot) {
  112466. tempVec.x = jointPivot.x;
  112467. tempVec.y = jointPivot.y;
  112468. tempVec.z = jointPivot.z;
  112469. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  112470. if (distToJoint === undefined || distToJoint === null) {
  112471. distToJoint = jointPivot.length();
  112472. }
  112473. tempVec.x *= distToJoint;
  112474. tempVec.y *= distToJoint;
  112475. tempVec.z *= distToJoint;
  112476. }
  112477. if (bone.getParent()) {
  112478. tempVec.addInPlace(mesh.getAbsolutePosition());
  112479. bone.setAbsolutePosition(tempVec, boneMesh);
  112480. }
  112481. else {
  112482. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  112483. boneMesh.position.x -= tempVec.x;
  112484. boneMesh.position.y -= tempVec.y;
  112485. boneMesh.position.z -= tempVec.z;
  112486. }
  112487. };
  112488. /**
  112489. * Sync impostor to a bone
  112490. * @param bone The bone that the impostor will be synced to.
  112491. * @param boneMesh The mesh that the bone is influencing.
  112492. * @param jointPivot The pivot of the joint / bone in local space.
  112493. * @param distToJoint Optional distance from the impostor to the joint.
  112494. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112495. * @param boneAxis Optional vector3 axis the bone is aligned with
  112496. */
  112497. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  112498. var mesh = this.object;
  112499. if (mesh.rotationQuaternion) {
  112500. if (adjustRotation) {
  112501. var tempQuat = PhysicsImpostor._tmpQuat;
  112502. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  112503. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  112504. }
  112505. else {
  112506. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  112507. }
  112508. }
  112509. var pos = PhysicsImpostor._tmpVecs[0];
  112510. var boneDir = PhysicsImpostor._tmpVecs[1];
  112511. if (!boneAxis) {
  112512. boneAxis = PhysicsImpostor._tmpVecs[2];
  112513. boneAxis.x = 0;
  112514. boneAxis.y = 1;
  112515. boneAxis.z = 0;
  112516. }
  112517. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  112518. bone.getAbsolutePositionToRef(boneMesh, pos);
  112519. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  112520. distToJoint = jointPivot.length();
  112521. }
  112522. if (distToJoint !== undefined && distToJoint !== null) {
  112523. pos.x += boneDir.x * distToJoint;
  112524. pos.y += boneDir.y * distToJoint;
  112525. pos.z += boneDir.z * distToJoint;
  112526. }
  112527. mesh.setAbsolutePosition(pos);
  112528. };
  112529. /**
  112530. * The default object size of the imposter
  112531. */
  112532. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  112533. /**
  112534. * The identity quaternion of the imposter
  112535. */
  112536. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112537. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  112538. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112539. //Impostor types
  112540. /**
  112541. * No-Imposter type
  112542. */
  112543. PhysicsImpostor.NoImpostor = 0;
  112544. /**
  112545. * Sphere-Imposter type
  112546. */
  112547. PhysicsImpostor.SphereImpostor = 1;
  112548. /**
  112549. * Box-Imposter type
  112550. */
  112551. PhysicsImpostor.BoxImpostor = 2;
  112552. /**
  112553. * Plane-Imposter type
  112554. */
  112555. PhysicsImpostor.PlaneImpostor = 3;
  112556. /**
  112557. * Mesh-imposter type
  112558. */
  112559. PhysicsImpostor.MeshImpostor = 4;
  112560. /**
  112561. * Cylinder-Imposter type
  112562. */
  112563. PhysicsImpostor.CylinderImpostor = 7;
  112564. /**
  112565. * Particle-Imposter type
  112566. */
  112567. PhysicsImpostor.ParticleImpostor = 8;
  112568. /**
  112569. * Heightmap-Imposter type
  112570. */
  112571. PhysicsImpostor.HeightmapImpostor = 9;
  112572. return PhysicsImpostor;
  112573. }());
  112574. /***/ }),
  112575. /***/ "./Physics/physicsJoint.ts":
  112576. /*!*********************************!*\
  112577. !*** ./Physics/physicsJoint.ts ***!
  112578. \*********************************/
  112579. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  112580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112581. "use strict";
  112582. __webpack_require__.r(__webpack_exports__);
  112583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  112584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  112585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  112586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  112587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  112588. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112589. /**
  112590. * This is a holder class for the physics joint created by the physics plugin
  112591. * It holds a set of functions to control the underlying joint
  112592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112593. */
  112594. var PhysicsJoint = /** @class */ (function () {
  112595. /**
  112596. * Initializes the physics joint
  112597. * @param type The type of the physics joint
  112598. * @param jointData The data for the physics joint
  112599. */
  112600. function PhysicsJoint(
  112601. /**
  112602. * The type of the physics joint
  112603. */
  112604. type,
  112605. /**
  112606. * The data for the physics joint
  112607. */
  112608. jointData) {
  112609. this.type = type;
  112610. this.jointData = jointData;
  112611. jointData.nativeParams = jointData.nativeParams || {};
  112612. }
  112613. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  112614. /**
  112615. * Gets the physics joint
  112616. */
  112617. get: function () {
  112618. return this._physicsJoint;
  112619. },
  112620. /**
  112621. * Sets the physics joint
  112622. */
  112623. set: function (newJoint) {
  112624. if (this._physicsJoint) {
  112625. //remove from the wolrd
  112626. }
  112627. this._physicsJoint = newJoint;
  112628. },
  112629. enumerable: true,
  112630. configurable: true
  112631. });
  112632. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  112633. /**
  112634. * Sets the physics plugin
  112635. */
  112636. set: function (physicsPlugin) {
  112637. this._physicsPlugin = physicsPlugin;
  112638. },
  112639. enumerable: true,
  112640. configurable: true
  112641. });
  112642. /**
  112643. * Execute a function that is physics-plugin specific.
  112644. * @param {Function} func the function that will be executed.
  112645. * It accepts two parameters: the physics world and the physics joint
  112646. */
  112647. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  112648. func(this._physicsPlugin.world, this._physicsJoint);
  112649. };
  112650. //TODO check if the native joints are the same
  112651. //Joint Types
  112652. /**
  112653. * Distance-Joint type
  112654. */
  112655. PhysicsJoint.DistanceJoint = 0;
  112656. /**
  112657. * Hinge-Joint type
  112658. */
  112659. PhysicsJoint.HingeJoint = 1;
  112660. /**
  112661. * Ball-and-Socket joint type
  112662. */
  112663. PhysicsJoint.BallAndSocketJoint = 2;
  112664. /**
  112665. * Wheel-Joint type
  112666. */
  112667. PhysicsJoint.WheelJoint = 3;
  112668. /**
  112669. * Slider-Joint type
  112670. */
  112671. PhysicsJoint.SliderJoint = 4;
  112672. //OIMO
  112673. /**
  112674. * Prismatic-Joint type
  112675. */
  112676. PhysicsJoint.PrismaticJoint = 5;
  112677. //
  112678. /**
  112679. * Universal-Joint type
  112680. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112681. */
  112682. PhysicsJoint.UniversalJoint = 6;
  112683. /**
  112684. * Hinge-Joint 2 type
  112685. */
  112686. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  112687. //Cannon
  112688. /**
  112689. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112690. */
  112691. PhysicsJoint.PointToPointJoint = 8;
  112692. //Cannon only at the moment
  112693. /**
  112694. * Spring-Joint type
  112695. */
  112696. PhysicsJoint.SpringJoint = 9;
  112697. /**
  112698. * Lock-Joint type
  112699. */
  112700. PhysicsJoint.LockJoint = 10;
  112701. return PhysicsJoint;
  112702. }());
  112703. /**
  112704. * A class representing a physics distance joint
  112705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112706. */
  112707. var DistanceJoint = /** @class */ (function (_super) {
  112708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  112709. /**
  112710. *
  112711. * @param jointData The data for the Distance-Joint
  112712. */
  112713. function DistanceJoint(jointData) {
  112714. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  112715. }
  112716. /**
  112717. * Update the predefined distance.
  112718. * @param maxDistance The maximum preferred distance
  112719. * @param minDistance The minimum preferred distance
  112720. */
  112721. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  112722. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  112723. };
  112724. return DistanceJoint;
  112725. }(PhysicsJoint));
  112726. /**
  112727. * Represents a Motor-Enabled Joint
  112728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112729. */
  112730. var MotorEnabledJoint = /** @class */ (function (_super) {
  112731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  112732. /**
  112733. * Initializes the Motor-Enabled Joint
  112734. * @param type The type of the joint
  112735. * @param jointData The physica joint data for the joint
  112736. */
  112737. function MotorEnabledJoint(type, jointData) {
  112738. return _super.call(this, type, jointData) || this;
  112739. }
  112740. /**
  112741. * Set the motor values.
  112742. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112743. * @param force the force to apply
  112744. * @param maxForce max force for this motor.
  112745. */
  112746. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  112747. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112748. };
  112749. /**
  112750. * Set the motor's limits.
  112751. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112752. * @param upperLimit The upper limit of the motor
  112753. * @param lowerLimit The lower limit of the motor
  112754. */
  112755. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112756. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112757. };
  112758. return MotorEnabledJoint;
  112759. }(PhysicsJoint));
  112760. /**
  112761. * This class represents a single physics Hinge-Joint
  112762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112763. */
  112764. var HingeJoint = /** @class */ (function (_super) {
  112765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  112766. /**
  112767. * Initializes the Hinge-Joint
  112768. * @param jointData The joint data for the Hinge-Joint
  112769. */
  112770. function HingeJoint(jointData) {
  112771. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  112772. }
  112773. /**
  112774. * Set the motor values.
  112775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112776. * @param {number} force the force to apply
  112777. * @param {number} maxForce max force for this motor.
  112778. */
  112779. HingeJoint.prototype.setMotor = function (force, maxForce) {
  112780. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112781. };
  112782. /**
  112783. * Set the motor's limits.
  112784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112785. * @param upperLimit The upper limit of the motor
  112786. * @param lowerLimit The lower limit of the motor
  112787. */
  112788. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112789. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112790. };
  112791. return HingeJoint;
  112792. }(MotorEnabledJoint));
  112793. /**
  112794. * This class represents a dual hinge physics joint (same as wheel joint)
  112795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112796. */
  112797. var Hinge2Joint = /** @class */ (function (_super) {
  112798. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  112799. /**
  112800. * Initializes the Hinge2-Joint
  112801. * @param jointData The joint data for the Hinge2-Joint
  112802. */
  112803. function Hinge2Joint(jointData) {
  112804. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  112805. }
  112806. /**
  112807. * Set the motor values.
  112808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112809. * @param {number} force the force to apply
  112810. * @param {number} maxForce max force for this motor.
  112811. * @param {motorIndex} the motor's index, 0 or 1.
  112812. */
  112813. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  112814. if (motorIndex === void 0) { motorIndex = 0; }
  112815. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  112816. };
  112817. /**
  112818. * Set the motor limits.
  112819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112820. * @param {number} upperLimit the upper limit
  112821. * @param {number} lowerLimit lower limit
  112822. * @param {motorIndex} the motor's index, 0 or 1.
  112823. */
  112824. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  112825. if (motorIndex === void 0) { motorIndex = 0; }
  112826. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  112827. };
  112828. return Hinge2Joint;
  112829. }(MotorEnabledJoint));
  112830. /***/ }),
  112831. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  112832. /*!****************************************************************************!*\
  112833. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  112834. \****************************************************************************/
  112835. /*! exports provided: DefaultRenderingPipeline */
  112836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112837. "use strict";
  112838. __webpack_require__.r(__webpack_exports__);
  112839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  112840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112841. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  112842. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  112843. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112844. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  112845. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  112846. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  112847. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  112848. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  112849. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  112850. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  112851. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112852. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112853. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  112854. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  112855. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  112856. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  112857. /**
  112858. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112859. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112860. */
  112861. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  112862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  112863. /**
  112864. * @constructor
  112865. * @param name - The rendering pipeline name (default: "")
  112866. * @param hdr - If high dynamic range textures should be used (default: true)
  112867. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112868. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112869. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112870. */
  112871. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  112872. if (name === void 0) { name = ""; }
  112873. if (hdr === void 0) { hdr = true; }
  112874. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  112875. if (automaticBuild === void 0) { automaticBuild = true; }
  112876. var _this = _super.call(this, scene.getEngine(), name) || this;
  112877. _this._camerasToBeAttached = [];
  112878. /**
  112879. * ID of the sharpen post process,
  112880. */
  112881. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  112882. /**
  112883. * @ignore
  112884. * ID of the image processing post process;
  112885. */
  112886. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  112887. /**
  112888. * @ignore
  112889. * ID of the Fast Approximate Anti-Aliasing post process;
  112890. */
  112891. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  112892. /**
  112893. * ID of the chromatic aberration post process,
  112894. */
  112895. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  112896. /**
  112897. * ID of the grain post process
  112898. */
  112899. _this.GrainPostProcessId = "GrainPostProcessEffect";
  112900. /**
  112901. * Glow post process which adds a glow to emmisive areas of the image
  112902. */
  112903. _this._glowLayer = null;
  112904. /**
  112905. * Animations which can be used to tweak settings over a period of time
  112906. */
  112907. _this.animations = [];
  112908. _this._imageProcessingConfigurationObserver = null;
  112909. // Values
  112910. _this._sharpenEnabled = false;
  112911. _this._bloomEnabled = false;
  112912. _this._depthOfFieldEnabled = false;
  112913. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  112914. _this._fxaaEnabled = false;
  112915. _this._imageProcessingEnabled = true;
  112916. _this._bloomScale = 0.5;
  112917. _this._chromaticAberrationEnabled = false;
  112918. _this._grainEnabled = false;
  112919. _this._buildAllowed = true;
  112920. _this._resizeObserver = null;
  112921. _this._hardwareScaleLevel = 1.0;
  112922. _this._bloomKernel = 64;
  112923. /**
  112924. * Specifies the weight of the bloom in the final rendering
  112925. */
  112926. _this._bloomWeight = 0.15;
  112927. /**
  112928. * Specifies the luma threshold for the area that will be blurred by the bloom
  112929. */
  112930. _this._bloomThreshold = 0.9;
  112931. _this._samples = 1;
  112932. _this._hasCleared = false;
  112933. _this._prevPostProcess = null;
  112934. _this._prevPrevPostProcess = null;
  112935. _this._depthOfFieldSceneObserver = null;
  112936. _this._cameras = cameras || scene.cameras;
  112937. _this._cameras = _this._cameras.slice();
  112938. _this._camerasToBeAttached = _this._cameras.slice();
  112939. _this._buildAllowed = automaticBuild;
  112940. // Initialize
  112941. _this._scene = scene;
  112942. var caps = _this._scene.getEngine().getCaps();
  112943. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  112944. // Misc
  112945. if (_this._hdr) {
  112946. if (caps.textureHalfFloatRender) {
  112947. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  112948. }
  112949. else if (caps.textureFloatRender) {
  112950. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  112951. }
  112952. }
  112953. else {
  112954. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  112955. }
  112956. // Attach
  112957. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112958. var engine = _this._scene.getEngine();
  112959. // Create post processes before hand so they can be modified before enabled.
  112960. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  112961. _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);
  112962. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  112963. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  112964. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  112965. _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);
  112966. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  112967. _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);
  112968. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  112969. _this._resizeObserver = engine.onResizeObservable.add(function () {
  112970. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  112971. _this.bloomKernel = _this.bloomKernel;
  112972. });
  112973. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  112974. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  112975. });
  112976. _this._buildPipeline();
  112977. return _this;
  112978. }
  112979. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  112980. get: function () {
  112981. return this._sharpenEnabled;
  112982. },
  112983. /**
  112984. * Enable or disable the sharpen process from the pipeline
  112985. */
  112986. set: function (enabled) {
  112987. if (this._sharpenEnabled === enabled) {
  112988. return;
  112989. }
  112990. this._sharpenEnabled = enabled;
  112991. this._buildPipeline();
  112992. },
  112993. enumerable: true,
  112994. configurable: true
  112995. });
  112996. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  112997. /**
  112998. * Specifies the size of the bloom blur kernel, relative to the final output size
  112999. */
  113000. get: function () {
  113001. return this._bloomKernel;
  113002. },
  113003. set: function (value) {
  113004. this._bloomKernel = value;
  113005. this.bloom.kernel = value / this._hardwareScaleLevel;
  113006. },
  113007. enumerable: true,
  113008. configurable: true
  113009. });
  113010. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  113011. get: function () {
  113012. return this._bloomWeight;
  113013. },
  113014. /**
  113015. * The strength of the bloom.
  113016. */
  113017. set: function (value) {
  113018. if (this._bloomWeight === value) {
  113019. return;
  113020. }
  113021. this.bloom.weight = value;
  113022. this._bloomWeight = value;
  113023. },
  113024. enumerable: true,
  113025. configurable: true
  113026. });
  113027. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  113028. get: function () {
  113029. return this._bloomThreshold;
  113030. },
  113031. /**
  113032. * The strength of the bloom.
  113033. */
  113034. set: function (value) {
  113035. if (this._bloomThreshold === value) {
  113036. return;
  113037. }
  113038. this.bloom.threshold = value;
  113039. this._bloomThreshold = value;
  113040. },
  113041. enumerable: true,
  113042. configurable: true
  113043. });
  113044. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  113045. get: function () {
  113046. return this._bloomScale;
  113047. },
  113048. /**
  113049. * The scale of the bloom, lower value will provide better performance.
  113050. */
  113051. set: function (value) {
  113052. if (this._bloomScale === value) {
  113053. return;
  113054. }
  113055. this._bloomScale = value;
  113056. // recreate bloom and dispose old as this setting is not dynamic
  113057. this._rebuildBloom();
  113058. this._buildPipeline();
  113059. },
  113060. enumerable: true,
  113061. configurable: true
  113062. });
  113063. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  113064. get: function () {
  113065. return this._bloomEnabled;
  113066. },
  113067. /**
  113068. * Enable or disable the bloom from the pipeline
  113069. */
  113070. set: function (enabled) {
  113071. if (this._bloomEnabled === enabled) {
  113072. return;
  113073. }
  113074. this._bloomEnabled = enabled;
  113075. this._buildPipeline();
  113076. },
  113077. enumerable: true,
  113078. configurable: true
  113079. });
  113080. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  113081. // recreate bloom and dispose old as this setting is not dynamic
  113082. var oldBloom = this.bloom;
  113083. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  113084. this.bloom.threshold = oldBloom.threshold;
  113085. for (var i = 0; i < this._cameras.length; i++) {
  113086. oldBloom.disposeEffects(this._cameras[i]);
  113087. }
  113088. };
  113089. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  113090. /**
  113091. * If the depth of field is enabled.
  113092. */
  113093. get: function () {
  113094. return this._depthOfFieldEnabled;
  113095. },
  113096. set: function (enabled) {
  113097. if (this._depthOfFieldEnabled === enabled) {
  113098. return;
  113099. }
  113100. this._depthOfFieldEnabled = enabled;
  113101. this._buildPipeline();
  113102. },
  113103. enumerable: true,
  113104. configurable: true
  113105. });
  113106. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  113107. /**
  113108. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113109. */
  113110. get: function () {
  113111. return this._depthOfFieldBlurLevel;
  113112. },
  113113. set: function (value) {
  113114. if (this._depthOfFieldBlurLevel === value) {
  113115. return;
  113116. }
  113117. this._depthOfFieldBlurLevel = value;
  113118. // recreate dof and dispose old as this setting is not dynamic
  113119. var oldDof = this.depthOfField;
  113120. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  113121. this.depthOfField.focalLength = oldDof.focalLength;
  113122. this.depthOfField.focusDistance = oldDof.focusDistance;
  113123. this.depthOfField.fStop = oldDof.fStop;
  113124. this.depthOfField.lensSize = oldDof.lensSize;
  113125. for (var i = 0; i < this._cameras.length; i++) {
  113126. oldDof.disposeEffects(this._cameras[i]);
  113127. }
  113128. this._buildPipeline();
  113129. },
  113130. enumerable: true,
  113131. configurable: true
  113132. });
  113133. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  113134. get: function () {
  113135. return this._fxaaEnabled;
  113136. },
  113137. /**
  113138. * If the anti aliasing is enabled.
  113139. */
  113140. set: function (enabled) {
  113141. if (this._fxaaEnabled === enabled) {
  113142. return;
  113143. }
  113144. this._fxaaEnabled = enabled;
  113145. this._buildPipeline();
  113146. },
  113147. enumerable: true,
  113148. configurable: true
  113149. });
  113150. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  113151. get: function () {
  113152. return this._samples;
  113153. },
  113154. /**
  113155. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113156. */
  113157. set: function (sampleCount) {
  113158. if (this._samples === sampleCount) {
  113159. return;
  113160. }
  113161. this._samples = sampleCount;
  113162. this._buildPipeline();
  113163. },
  113164. enumerable: true,
  113165. configurable: true
  113166. });
  113167. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  113168. get: function () {
  113169. return this._imageProcessingEnabled;
  113170. },
  113171. /**
  113172. * If image processing is enabled.
  113173. */
  113174. set: function (enabled) {
  113175. if (this._imageProcessingEnabled === enabled) {
  113176. return;
  113177. }
  113178. this._imageProcessingEnabled = enabled;
  113179. this._buildPipeline();
  113180. },
  113181. enumerable: true,
  113182. configurable: true
  113183. });
  113184. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  113185. get: function () {
  113186. return this._glowLayer == null;
  113187. },
  113188. /**
  113189. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113190. */
  113191. set: function (enabled) {
  113192. if (enabled && !this._glowLayer) {
  113193. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  113194. }
  113195. else if (!enabled && this._glowLayer) {
  113196. this._glowLayer.dispose();
  113197. this._glowLayer = null;
  113198. }
  113199. },
  113200. enumerable: true,
  113201. configurable: true
  113202. });
  113203. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  113204. get: function () {
  113205. return this._chromaticAberrationEnabled;
  113206. },
  113207. /**
  113208. * Enable or disable the chromaticAberration process from the pipeline
  113209. */
  113210. set: function (enabled) {
  113211. if (this._chromaticAberrationEnabled === enabled) {
  113212. return;
  113213. }
  113214. this._chromaticAberrationEnabled = enabled;
  113215. this._buildPipeline();
  113216. },
  113217. enumerable: true,
  113218. configurable: true
  113219. });
  113220. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  113221. get: function () {
  113222. return this._grainEnabled;
  113223. },
  113224. /**
  113225. * Enable or disable the grain process from the pipeline
  113226. */
  113227. set: function (enabled) {
  113228. if (this._grainEnabled === enabled) {
  113229. return;
  113230. }
  113231. this._grainEnabled = enabled;
  113232. this._buildPipeline();
  113233. },
  113234. enumerable: true,
  113235. configurable: true
  113236. });
  113237. /**
  113238. * Force the compilation of the entire pipeline.
  113239. */
  113240. DefaultRenderingPipeline.prototype.prepare = function () {
  113241. var previousState = this._buildAllowed;
  113242. this._buildAllowed = true;
  113243. this._buildPipeline();
  113244. this._buildAllowed = previousState;
  113245. };
  113246. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  113247. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  113248. if (this._hasCleared) {
  113249. postProcess.autoClear = false;
  113250. }
  113251. else {
  113252. postProcess.autoClear = true;
  113253. this._scene.autoClear = false;
  113254. this._hasCleared = true;
  113255. }
  113256. if (!skipTextureSharing) {
  113257. if (this._prevPrevPostProcess) {
  113258. postProcess.shareOutputWith(this._prevPrevPostProcess);
  113259. }
  113260. else {
  113261. postProcess.useOwnOutput();
  113262. }
  113263. if (this._prevPostProcess) {
  113264. this._prevPrevPostProcess = this._prevPostProcess;
  113265. }
  113266. this._prevPostProcess = postProcess;
  113267. }
  113268. };
  113269. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  113270. var _this = this;
  113271. if (!this._buildAllowed) {
  113272. return;
  113273. }
  113274. this._scene.autoClear = true;
  113275. var engine = this._scene.getEngine();
  113276. this._disposePostProcesses();
  113277. if (this._cameras !== null) {
  113278. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113279. // get back cameras to be used to reattach pipeline
  113280. this._cameras = this._camerasToBeAttached.slice();
  113281. }
  113282. this._reset();
  113283. this._prevPostProcess = null;
  113284. this._prevPrevPostProcess = null;
  113285. this._hasCleared = false;
  113286. if (this.depthOfFieldEnabled) {
  113287. // Multi camera suport
  113288. if (this._cameras.length > 1) {
  113289. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  113290. var camera = _a[_i];
  113291. var depthRenderer = this._scene.enableDepthRenderer(camera);
  113292. depthRenderer.useOnlyInActiveCamera = true;
  113293. }
  113294. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  113295. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  113296. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  113297. }
  113298. });
  113299. }
  113300. else {
  113301. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113302. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  113303. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  113304. }
  113305. if (!this.depthOfField._isReady()) {
  113306. this.depthOfField._updateEffects();
  113307. }
  113308. this.addEffect(this.depthOfField);
  113309. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  113310. }
  113311. else {
  113312. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113313. }
  113314. if (this.bloomEnabled) {
  113315. if (!this.bloom._isReady()) {
  113316. this.bloom._updateEffects();
  113317. }
  113318. this.addEffect(this.bloom);
  113319. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  113320. }
  113321. if (this._imageProcessingEnabled) {
  113322. 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);
  113323. if (this._hdr) {
  113324. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  113325. this._setAutoClearAndTextureSharing(this.imageProcessing);
  113326. }
  113327. else {
  113328. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  113329. }
  113330. }
  113331. if (this.sharpenEnabled) {
  113332. if (!this.sharpen.isReady()) {
  113333. this.sharpen.updateEffect();
  113334. }
  113335. this.addEffect(this._sharpenEffect);
  113336. this._setAutoClearAndTextureSharing(this.sharpen);
  113337. }
  113338. if (this.grainEnabled) {
  113339. if (!this.grain.isReady()) {
  113340. this.grain.updateEffect();
  113341. }
  113342. this.addEffect(this._grainEffect);
  113343. this._setAutoClearAndTextureSharing(this.grain);
  113344. }
  113345. if (this.chromaticAberrationEnabled) {
  113346. if (!this.chromaticAberration.isReady()) {
  113347. this.chromaticAberration.updateEffect();
  113348. }
  113349. this.addEffect(this._chromaticAberrationEffect);
  113350. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  113351. }
  113352. if (this.fxaaEnabled) {
  113353. 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);
  113354. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  113355. this._setAutoClearAndTextureSharing(this.fxaa, true);
  113356. }
  113357. if (this._cameras !== null) {
  113358. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113359. }
  113360. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  113361. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113362. }
  113363. };
  113364. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  113365. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  113366. for (var i = 0; i < this._cameras.length; i++) {
  113367. var camera = this._cameras[i];
  113368. if (this.imageProcessing) {
  113369. this.imageProcessing.dispose(camera);
  113370. }
  113371. if (this.fxaa) {
  113372. this.fxaa.dispose(camera);
  113373. }
  113374. // These are created in the constructor and should not be disposed on every pipeline change
  113375. if (disposeNonRecreated) {
  113376. if (this.sharpen) {
  113377. this.sharpen.dispose(camera);
  113378. }
  113379. if (this.depthOfField) {
  113380. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113381. this.depthOfField.disposeEffects(camera);
  113382. }
  113383. if (this.bloom) {
  113384. this.bloom.disposeEffects(camera);
  113385. }
  113386. if (this.chromaticAberration) {
  113387. this.chromaticAberration.dispose(camera);
  113388. }
  113389. if (this.grain) {
  113390. this.grain.dispose(camera);
  113391. }
  113392. if (this._glowLayer) {
  113393. this._glowLayer.dispose();
  113394. }
  113395. }
  113396. }
  113397. this.imageProcessing = null;
  113398. this.fxaa = null;
  113399. if (disposeNonRecreated) {
  113400. this.sharpen = null;
  113401. this._sharpenEffect = null;
  113402. this.depthOfField = null;
  113403. this.bloom = null;
  113404. this.chromaticAberration = null;
  113405. this._chromaticAberrationEffect = null;
  113406. this.grain = null;
  113407. this._grainEffect = null;
  113408. this._glowLayer = null;
  113409. }
  113410. };
  113411. /**
  113412. * Adds a camera to the pipeline
  113413. * @param camera the camera to be added
  113414. */
  113415. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  113416. this._camerasToBeAttached.push(camera);
  113417. this._buildPipeline();
  113418. };
  113419. /**
  113420. * Removes a camera from the pipeline
  113421. * @param camera the camera to remove
  113422. */
  113423. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  113424. var index = this._camerasToBeAttached.indexOf(camera);
  113425. this._camerasToBeAttached.splice(index, 1);
  113426. this._buildPipeline();
  113427. };
  113428. /**
  113429. * Dispose of the pipeline and stop all post processes
  113430. */
  113431. DefaultRenderingPipeline.prototype.dispose = function () {
  113432. this._disposePostProcesses(true);
  113433. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113434. this._scene.autoClear = true;
  113435. if (this._resizeObserver) {
  113436. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  113437. this._resizeObserver = null;
  113438. }
  113439. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  113440. _super.prototype.dispose.call(this);
  113441. };
  113442. /**
  113443. * Serialize the rendering pipeline (Used when exporting)
  113444. * @returns the serialized object
  113445. */
  113446. DefaultRenderingPipeline.prototype.serialize = function () {
  113447. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  113448. serializationObject.customType = "DefaultRenderingPipeline";
  113449. return serializationObject;
  113450. };
  113451. /**
  113452. * Parse the serialized pipeline
  113453. * @param source Source pipeline.
  113454. * @param scene The scene to load the pipeline to.
  113455. * @param rootUrl The URL of the serialized pipeline.
  113456. * @returns An instantiated pipeline from the serialized object.
  113457. */
  113458. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  113459. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  113460. };
  113461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113463. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  113464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113466. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  113467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113469. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  113470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113472. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  113473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113475. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  113476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113478. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  113479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113481. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  113482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113484. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  113485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113487. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  113488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113490. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  113491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113493. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  113494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113496. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  113497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113499. ], DefaultRenderingPipeline.prototype, "samples", null);
  113500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113502. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  113503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113505. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  113506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113508. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  113509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113511. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  113512. return DefaultRenderingPipeline;
  113513. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  113514. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  113515. /***/ }),
  113516. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  113517. /*!*********************************************************!*\
  113518. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  113519. \*********************************************************/
  113520. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  113521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113522. "use strict";
  113523. __webpack_require__.r(__webpack_exports__);
  113524. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  113525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  113526. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  113527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  113528. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  113529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  113530. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  113531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  113532. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  113533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  113534. /***/ }),
  113535. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  113536. /*!*************************************************************************!*\
  113537. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  113538. \*************************************************************************/
  113539. /*! exports provided: LensRenderingPipeline */
  113540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113541. "use strict";
  113542. __webpack_require__.r(__webpack_exports__);
  113543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  113544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113545. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113546. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113547. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113548. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113549. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113550. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  113551. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  113552. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  113553. /**
  113554. * BABYLON.JS Chromatic Aberration GLSL Shader
  113555. * Author: Olivier Guyot
  113556. * Separates very slightly R, G and B colors on the edges of the screen
  113557. * Inspired by Francois Tarlier & Martins Upitis
  113558. */
  113559. var LensRenderingPipeline = /** @class */ (function (_super) {
  113560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  113561. /**
  113562. * @constructor
  113563. *
  113564. * Effect parameters are as follow:
  113565. * {
  113566. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113567. * edge_blur: number; // from 0 to x (1 for realism)
  113568. * distortion: number; // from 0 to x (1 for realism)
  113569. * grain_amount: number; // from 0 to 1
  113570. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113571. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113572. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113573. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113574. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113575. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113576. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113577. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113578. * }
  113579. * Note: if an effect parameter is unset, effect is disabled
  113580. *
  113581. * @param name The rendering pipeline name
  113582. * @param parameters - An object containing all parameters (see above)
  113583. * @param scene The scene linked to this pipeline
  113584. * @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)
  113585. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113586. */
  113587. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  113588. if (ratio === void 0) { ratio = 1.0; }
  113589. var _this = _super.call(this, scene.getEngine(), name) || this;
  113590. // Lens effects can be of the following:
  113591. // - chromatic aberration (slight shift of RGB colors)
  113592. // - blur on the edge of the lens
  113593. // - lens distortion
  113594. // - depth-of-field blur & highlights enhancing
  113595. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  113596. // - grain effect (noise or custom texture)
  113597. // Two additional texture samplers are needed:
  113598. // - depth map (for depth-of-field)
  113599. // - grain texture
  113600. /**
  113601. * @ignore
  113602. * The chromatic aberration PostProcess id in the pipeline
  113603. */
  113604. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  113605. /**
  113606. * @ignore
  113607. * The highlights enhancing PostProcess id in the pipeline
  113608. */
  113609. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  113610. /**
  113611. * @ignore
  113612. * The depth-of-field PostProcess id in the pipeline
  113613. */
  113614. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  113615. _this._scene = scene;
  113616. // Fetch texture samplers
  113617. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113618. if (parameters.grain_texture) {
  113619. _this._grainTexture = parameters.grain_texture;
  113620. }
  113621. else {
  113622. _this._createGrainTexture();
  113623. }
  113624. // save parameters
  113625. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  113626. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  113627. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  113628. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  113629. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  113630. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  113631. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  113632. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  113633. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  113634. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  113635. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  113636. // Create effects
  113637. _this._createChromaticAberrationPostProcess(ratio);
  113638. _this._createHighlightsPostProcess(ratio);
  113639. _this._createDepthOfFieldPostProcess(ratio / 4);
  113640. // Set up pipeline
  113641. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  113642. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  113643. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  113644. if (_this._highlightsGain === -1) {
  113645. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  113646. }
  113647. // Finish
  113648. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113649. if (cameras) {
  113650. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113651. }
  113652. return _this;
  113653. }
  113654. // public methods (self explanatory)
  113655. /**
  113656. * Sets the amount of blur at the edges
  113657. * @param amount blur amount
  113658. */
  113659. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  113660. /**
  113661. * Sets edge blur to 0
  113662. */
  113663. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  113664. /**
  113665. * Sets the amout of grain
  113666. * @param amount Amount of grain
  113667. */
  113668. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  113669. /**
  113670. * Set grain amount to 0
  113671. */
  113672. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  113673. /**
  113674. * Sets the chromatic aberration amount
  113675. * @param amount amount of chromatic aberration
  113676. */
  113677. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  113678. /**
  113679. * Sets chromatic aberration amount to 0
  113680. */
  113681. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  113682. /**
  113683. * Sets the EdgeDistortion amount
  113684. * @param amount amount of EdgeDistortion
  113685. */
  113686. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  113687. /**
  113688. * Sets edge distortion to 0
  113689. */
  113690. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  113691. /**
  113692. * Sets the FocusDistance amount
  113693. * @param amount amount of FocusDistance
  113694. */
  113695. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  113696. /**
  113697. * Disables depth of field
  113698. */
  113699. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  113700. /**
  113701. * Sets the Aperture amount
  113702. * @param amount amount of Aperture
  113703. */
  113704. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  113705. /**
  113706. * Sets the DarkenOutOfFocus amount
  113707. * @param amount amount of DarkenOutOfFocus
  113708. */
  113709. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  113710. /**
  113711. * Creates a pentagon bokeh effect
  113712. */
  113713. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  113714. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  113715. };
  113716. /**
  113717. * Disables the pentagon bokeh effect
  113718. */
  113719. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  113720. this._highlightsPostProcess.updateEffect();
  113721. };
  113722. /**
  113723. * Enables noise blur
  113724. */
  113725. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  113726. /**
  113727. * Disables noise blur
  113728. */
  113729. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  113730. /**
  113731. * Sets the HighlightsGain amount
  113732. * @param amount amount of HighlightsGain
  113733. */
  113734. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  113735. this._highlightsGain = amount;
  113736. };
  113737. /**
  113738. * Sets the HighlightsThreshold amount
  113739. * @param amount amount of HighlightsThreshold
  113740. */
  113741. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  113742. if (this._highlightsGain === -1) {
  113743. this._highlightsGain = 1.0;
  113744. }
  113745. this._highlightsThreshold = amount;
  113746. };
  113747. /**
  113748. * Disables highlights
  113749. */
  113750. LensRenderingPipeline.prototype.disableHighlights = function () {
  113751. this._highlightsGain = -1;
  113752. };
  113753. /**
  113754. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113755. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113756. */
  113757. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113758. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113759. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113760. this._chromaticAberrationPostProcess = null;
  113761. this._highlightsPostProcess = null;
  113762. this._depthOfFieldPostProcess = null;
  113763. this._grainTexture.dispose();
  113764. if (disableDepthRender) {
  113765. this._scene.disableDepthRenderer();
  113766. }
  113767. };
  113768. // colors shifting and distortion
  113769. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  113770. var _this = this;
  113771. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  113772. [], // samplers
  113773. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113774. this._chromaticAberrationPostProcess.onApply = function (effect) {
  113775. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  113776. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113777. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113778. effect.setFloat('radialIntensity', 1);
  113779. effect.setFloat2('direction', 17, 17);
  113780. effect.setFloat2('centerPosition', 0.5, 0.5);
  113781. };
  113782. };
  113783. // highlights enhancing
  113784. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  113785. var _this = this;
  113786. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  113787. [], // samplers
  113788. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  113789. this._highlightsPostProcess.onApply = function (effect) {
  113790. effect.setFloat('gain', _this._highlightsGain);
  113791. effect.setFloat('threshold', _this._highlightsThreshold);
  113792. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  113793. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113794. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113795. };
  113796. };
  113797. // colors shifting and distortion
  113798. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  113799. var _this = this;
  113800. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  113801. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  113802. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  113803. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113804. this._depthOfFieldPostProcess.onApply = function (effect) {
  113805. effect.setTexture("depthSampler", _this._depthTexture);
  113806. effect.setTexture("grainSampler", _this._grainTexture);
  113807. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  113808. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  113809. effect.setFloat('grain_amount', _this._grainAmount);
  113810. effect.setBool('blur_noise', _this._blurNoise);
  113811. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113812. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113813. effect.setFloat('distortion', _this._distortion);
  113814. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  113815. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  113816. effect.setFloat('aperture', _this._dofAperture);
  113817. effect.setFloat('darken', _this._dofDarken);
  113818. effect.setFloat('edge_blur', _this._edgeBlur);
  113819. effect.setBool('highlights', (_this._highlightsGain !== -1));
  113820. if (_this._scene.activeCamera) {
  113821. effect.setFloat('near', _this._scene.activeCamera.minZ);
  113822. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  113823. }
  113824. };
  113825. };
  113826. // creates a black and white random noise texture, 512x512
  113827. LensRenderingPipeline.prototype._createGrainTexture = function () {
  113828. var size = 512;
  113829. 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);
  113830. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113831. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113832. var context = this._grainTexture.getContext();
  113833. var rand = function (min, max) {
  113834. return Math.random() * (max - min) + min;
  113835. };
  113836. var value;
  113837. for (var x = 0; x < size; x++) {
  113838. for (var y = 0; y < size; y++) {
  113839. value = Math.floor(rand(0.42, 0.58) * 255);
  113840. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  113841. context.fillRect(x, y, 1, 1);
  113842. }
  113843. }
  113844. this._grainTexture.update(false);
  113845. };
  113846. return LensRenderingPipeline;
  113847. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  113848. /***/ }),
  113849. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  113850. /*!**************************************************************************!*\
  113851. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  113852. \**************************************************************************/
  113853. /*! exports provided: SSAO2RenderingPipeline */
  113854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113855. "use strict";
  113856. __webpack_require__.r(__webpack_exports__);
  113857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  113858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113859. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113860. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113861. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113862. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113863. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113864. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113865. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113866. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113867. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113868. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113869. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113870. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  113871. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113872. /**
  113873. * Render pipeline to produce ssao effect
  113874. */
  113875. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  113876. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  113877. /**
  113878. * @constructor
  113879. * @param name The rendering pipeline name
  113880. * @param scene The scene linked to this pipeline
  113881. * @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 }
  113882. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113883. */
  113884. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  113885. var _this = _super.call(this, scene.getEngine(), name) || this;
  113886. // Members
  113887. /**
  113888. * @ignore
  113889. * The PassPostProcess id in the pipeline that contains the original scene color
  113890. */
  113891. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113892. /**
  113893. * @ignore
  113894. * The SSAO PostProcess id in the pipeline
  113895. */
  113896. _this.SSAORenderEffect = "SSAORenderEffect";
  113897. /**
  113898. * @ignore
  113899. * The horizontal blur PostProcess id in the pipeline
  113900. */
  113901. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113902. /**
  113903. * @ignore
  113904. * The vertical blur PostProcess id in the pipeline
  113905. */
  113906. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113907. /**
  113908. * @ignore
  113909. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113910. */
  113911. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113912. /**
  113913. * The output strength of the SSAO post-process. Default value is 1.0.
  113914. */
  113915. _this.totalStrength = 1.0;
  113916. /**
  113917. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113918. */
  113919. _this.maxZ = 100.0;
  113920. /**
  113921. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113922. */
  113923. _this.minZAspect = 0.2;
  113924. _this._samples = 8;
  113925. _this._textureSamples = 1;
  113926. _this._expensiveBlur = true;
  113927. /**
  113928. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113929. */
  113930. _this.radius = 2.0;
  113931. /**
  113932. * The base color of the SSAO post-process
  113933. * The final result is "base + ssao" between [0, 1]
  113934. */
  113935. _this.base = 0;
  113936. _this._firstUpdate = true;
  113937. _this._bits = new Uint32Array(1);
  113938. _this._scene = scene;
  113939. _this._ratio = ratio;
  113940. if (!_this.isSupported) {
  113941. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  113942. return _this;
  113943. }
  113944. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  113945. var blurRatio = _this._ratio.blurRatio || ratio;
  113946. // Set up assets
  113947. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  113948. _this._createRandomTexture();
  113949. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  113950. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  113951. _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);
  113952. _this._originalColorPostProcess.samples = _this.textureSamples;
  113953. _this._createSSAOPostProcess(1.0);
  113954. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  113955. _this._createSSAOCombinePostProcess(blurRatio);
  113956. // Set up pipeline
  113957. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113958. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113959. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113960. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113961. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113962. // Finish
  113963. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113964. if (cameras) {
  113965. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113966. }
  113967. return _this;
  113968. }
  113969. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  113970. get: function () {
  113971. return this._samples;
  113972. },
  113973. /**
  113974. * Number of samples used for the SSAO calculations. Default value is 8
  113975. */
  113976. set: function (n) {
  113977. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  113978. this._samples = n;
  113979. this._sampleSphere = this._generateHemisphere();
  113980. this._firstUpdate = true;
  113981. },
  113982. enumerable: true,
  113983. configurable: true
  113984. });
  113985. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  113986. get: function () {
  113987. return this._textureSamples;
  113988. },
  113989. /**
  113990. * Number of samples to use for antialiasing
  113991. */
  113992. set: function (n) {
  113993. this._textureSamples = n;
  113994. this._originalColorPostProcess.samples = n;
  113995. this._blurHPostProcess.samples = n;
  113996. this._blurVPostProcess.samples = n;
  113997. this._ssaoPostProcess.samples = n;
  113998. this._ssaoCombinePostProcess.samples = n;
  113999. },
  114000. enumerable: true,
  114001. configurable: true
  114002. });
  114003. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  114004. get: function () {
  114005. return this._expensiveBlur;
  114006. },
  114007. /**
  114008. * If bilateral blur should be used
  114009. */
  114010. set: function (b) {
  114011. 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"]);
  114012. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  114013. this._expensiveBlur = b;
  114014. this._firstUpdate = true;
  114015. },
  114016. enumerable: true,
  114017. configurable: true
  114018. });
  114019. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  114020. /**
  114021. * Support test.
  114022. */
  114023. get: function () {
  114024. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  114025. if (!engine) {
  114026. return false;
  114027. }
  114028. return engine.getCaps().drawBuffersExtension;
  114029. },
  114030. enumerable: true,
  114031. configurable: true
  114032. });
  114033. // Public Methods
  114034. /**
  114035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114036. */
  114037. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  114038. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  114039. for (var i = 0; i < this._scene.cameras.length; i++) {
  114040. var camera = this._scene.cameras[i];
  114041. this._originalColorPostProcess.dispose(camera);
  114042. this._ssaoPostProcess.dispose(camera);
  114043. this._blurHPostProcess.dispose(camera);
  114044. this._blurVPostProcess.dispose(camera);
  114045. this._ssaoCombinePostProcess.dispose(camera);
  114046. }
  114047. this._randomTexture.dispose();
  114048. if (disableGeometryBufferRenderer) {
  114049. this._scene.disableGeometryBufferRenderer();
  114050. }
  114051. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114052. _super.prototype.dispose.call(this);
  114053. };
  114054. // Private Methods
  114055. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  114056. var _this = this;
  114057. this._samplerOffsets = [];
  114058. var expensive = this.expensiveBlur;
  114059. for (var i = -8; i < 8; i++) {
  114060. this._samplerOffsets.push(i * 2 + 0.5);
  114061. }
  114062. 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");
  114063. this._blurHPostProcess.onApply = function (effect) {
  114064. if (!_this._scene.activeCamera) {
  114065. return;
  114066. }
  114067. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  114068. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114069. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114070. effect.setFloat("radius", _this.radius);
  114071. effect.setTexture("depthSampler", _this._depthTexture);
  114072. if (_this._firstUpdate) {
  114073. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114074. }
  114075. };
  114076. 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");
  114077. this._blurVPostProcess.onApply = function (effect) {
  114078. if (!_this._scene.activeCamera) {
  114079. return;
  114080. }
  114081. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  114082. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114083. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114084. effect.setFloat("radius", _this.radius);
  114085. effect.setTexture("depthSampler", _this._depthTexture);
  114086. if (_this._firstUpdate) {
  114087. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114088. _this._firstUpdate = false;
  114089. }
  114090. };
  114091. this._blurHPostProcess.samples = this.textureSamples;
  114092. this._blurVPostProcess.samples = this.textureSamples;
  114093. };
  114094. /** @hidden */
  114095. SSAO2RenderingPipeline.prototype._rebuild = function () {
  114096. this._firstUpdate = true;
  114097. _super.prototype._rebuild.call(this);
  114098. };
  114099. //Van der Corput radical inverse
  114100. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  114101. this._bits[0] = i;
  114102. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  114103. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  114104. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  114105. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  114106. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  114107. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  114108. };
  114109. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  114110. return [i / n, this._radicalInverse_VdC(i)];
  114111. };
  114112. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  114113. var phi = v * 2.0 * Math.PI;
  114114. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  114115. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  114116. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  114117. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  114118. };
  114119. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  114120. var numSamples = this.samples;
  114121. var result = [];
  114122. var vector;
  114123. var i = 0;
  114124. while (i < numSamples) {
  114125. if (numSamples < 16) {
  114126. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  114127. }
  114128. else {
  114129. var rand = this._hammersley(i, numSamples);
  114130. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  114131. }
  114132. result.push(vector.x, vector.y, vector.z);
  114133. i++;
  114134. }
  114135. return result;
  114136. };
  114137. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114138. var _this = this;
  114139. var numSamples = this.samples;
  114140. this._sampleSphere = this._generateHemisphere();
  114141. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  114142. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114143. "base", "range", "projection", "near", "far", "texelSize",
  114144. "xViewport", "yViewport", "maxZ", "minZAspect"
  114145. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114146. this._ssaoPostProcess.onApply = function (effect) {
  114147. if (_this._firstUpdate) {
  114148. effect.setArray3("sampleSphere", _this._sampleSphere);
  114149. effect.setFloat("randTextureTiles", 32.0);
  114150. }
  114151. if (!_this._scene.activeCamera) {
  114152. return;
  114153. }
  114154. effect.setFloat("samplesFactor", 1 / _this.samples);
  114155. effect.setFloat("totalStrength", _this.totalStrength);
  114156. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  114157. effect.setFloat("radius", _this.radius);
  114158. effect.setFloat("maxZ", _this.maxZ);
  114159. effect.setFloat("minZAspect", _this.minZAspect);
  114160. effect.setFloat("base", _this.base);
  114161. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114162. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114163. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  114164. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  114165. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  114166. effect.setTexture("textureSampler", _this._depthTexture);
  114167. effect.setTexture("normalSampler", _this._normalTexture);
  114168. effect.setTexture("randomSampler", _this._randomTexture);
  114169. };
  114170. this._ssaoPostProcess.samples = this.textureSamples;
  114171. };
  114172. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114173. var _this = this;
  114174. 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);
  114175. this._ssaoCombinePostProcess.onApply = function (effect) {
  114176. var viewport = _this._scene.activeCamera.viewport;
  114177. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  114178. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114179. };
  114180. this._ssaoCombinePostProcess.samples = this.textureSamples;
  114181. };
  114182. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  114183. var size = 128;
  114184. 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);
  114185. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114186. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114187. var context = this._randomTexture.getContext();
  114188. var rand = function (min, max) {
  114189. return Math.random() * (max - min) + min;
  114190. };
  114191. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114192. for (var x = 0; x < size; x++) {
  114193. for (var y = 0; y < size; y++) {
  114194. randVector.x = rand(0.0, 1.0);
  114195. randVector.y = rand(0.0, 1.0);
  114196. randVector.z = 0.0;
  114197. randVector.normalize();
  114198. randVector.scaleInPlace(255);
  114199. randVector.x = Math.floor(randVector.x);
  114200. randVector.y = Math.floor(randVector.y);
  114201. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114202. context.fillRect(x, y, 1, 1);
  114203. }
  114204. }
  114205. this._randomTexture.update(false);
  114206. };
  114207. /**
  114208. * Serialize the rendering pipeline (Used when exporting)
  114209. * @returns the serialized object
  114210. */
  114211. SSAO2RenderingPipeline.prototype.serialize = function () {
  114212. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  114213. serializationObject.customType = "SSAO2RenderingPipeline";
  114214. return serializationObject;
  114215. };
  114216. /**
  114217. * Parse the serialized pipeline
  114218. * @param source Source pipeline.
  114219. * @param scene The scene to load the pipeline to.
  114220. * @param rootUrl The URL of the serialized pipeline.
  114221. * @returns An instantiated pipeline from the serialized object.
  114222. */
  114223. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  114224. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114225. };
  114226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114228. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  114229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114231. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  114232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114234. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  114235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  114237. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  114238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  114240. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  114241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114243. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  114244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  114246. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  114247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114249. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  114250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114252. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  114253. return SSAO2RenderingPipeline;
  114254. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114255. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  114256. /***/ }),
  114257. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  114258. /*!*************************************************************************!*\
  114259. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  114260. \*************************************************************************/
  114261. /*! exports provided: SSAORenderingPipeline */
  114262. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114263. "use strict";
  114264. __webpack_require__.r(__webpack_exports__);
  114265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  114266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114267. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114268. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114269. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114270. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114271. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114272. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114273. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114274. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114275. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114276. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114277. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  114278. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114279. /**
  114280. * Render pipeline to produce ssao effect
  114281. */
  114282. var SSAORenderingPipeline = /** @class */ (function (_super) {
  114283. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  114284. /**
  114285. * @constructor
  114286. * @param name - The rendering pipeline name
  114287. * @param scene - The scene linked to this pipeline
  114288. * @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 }
  114289. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114290. */
  114291. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  114292. var _this = _super.call(this, scene.getEngine(), name) || this;
  114293. // Members
  114294. /**
  114295. * @ignore
  114296. * The PassPostProcess id in the pipeline that contains the original scene color
  114297. */
  114298. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114299. /**
  114300. * @ignore
  114301. * The SSAO PostProcess id in the pipeline
  114302. */
  114303. _this.SSAORenderEffect = "SSAORenderEffect";
  114304. /**
  114305. * @ignore
  114306. * The horizontal blur PostProcess id in the pipeline
  114307. */
  114308. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114309. /**
  114310. * @ignore
  114311. * The vertical blur PostProcess id in the pipeline
  114312. */
  114313. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114314. /**
  114315. * @ignore
  114316. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114317. */
  114318. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114319. /**
  114320. * The output strength of the SSAO post-process. Default value is 1.0.
  114321. */
  114322. _this.totalStrength = 1.0;
  114323. /**
  114324. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114325. */
  114326. _this.radius = 0.0001;
  114327. /**
  114328. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114329. * Must not be equal to fallOff and superior to fallOff.
  114330. * Default value is 0.975
  114331. */
  114332. _this.area = 0.0075;
  114333. /**
  114334. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114335. * Must not be equal to area and inferior to area.
  114336. * Default value is 0.0
  114337. */
  114338. _this.fallOff = 0.000001;
  114339. /**
  114340. * The base color of the SSAO post-process
  114341. * The final result is "base + ssao" between [0, 1]
  114342. */
  114343. _this.base = 0.5;
  114344. _this._firstUpdate = true;
  114345. _this._scene = scene;
  114346. // Set up assets
  114347. _this._createRandomTexture();
  114348. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114349. var ssaoRatio = ratio.ssaoRatio || ratio;
  114350. var combineRatio = ratio.combineRatio || ratio;
  114351. _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);
  114352. _this._createSSAOPostProcess(ssaoRatio);
  114353. _this._createBlurPostProcess(ssaoRatio);
  114354. _this._createSSAOCombinePostProcess(combineRatio);
  114355. // Set up pipeline
  114356. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114357. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114358. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114359. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114360. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114361. // Finish
  114362. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114363. if (cameras) {
  114364. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114365. }
  114366. return _this;
  114367. }
  114368. // Public Methods
  114369. /**
  114370. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114371. */
  114372. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114373. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114374. for (var i = 0; i < this._scene.cameras.length; i++) {
  114375. var camera = this._scene.cameras[i];
  114376. this._originalColorPostProcess.dispose(camera);
  114377. this._ssaoPostProcess.dispose(camera);
  114378. this._blurHPostProcess.dispose(camera);
  114379. this._blurVPostProcess.dispose(camera);
  114380. this._ssaoCombinePostProcess.dispose(camera);
  114381. }
  114382. this._randomTexture.dispose();
  114383. if (disableDepthRender) {
  114384. this._scene.disableDepthRenderer();
  114385. }
  114386. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114387. _super.prototype.dispose.call(this);
  114388. };
  114389. // Private Methods
  114390. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  114391. var _this = this;
  114392. var size = 16;
  114393. this._blurHPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurH", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), size, ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  114394. this._blurVPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurV", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), size, ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  114395. this._blurHPostProcess.onActivateObservable.add(function () {
  114396. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  114397. _this._blurHPostProcess.kernel = size * dw;
  114398. });
  114399. this._blurVPostProcess.onActivateObservable.add(function () {
  114400. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  114401. _this._blurVPostProcess.kernel = size * dw;
  114402. });
  114403. };
  114404. /** @hidden */
  114405. SSAORenderingPipeline.prototype._rebuild = function () {
  114406. this._firstUpdate = true;
  114407. _super.prototype._rebuild.call(this);
  114408. };
  114409. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114410. var _this = this;
  114411. var numSamples = 16;
  114412. var sampleSphere = [
  114413. 0.5381, 0.1856, -0.4319,
  114414. 0.1379, 0.2486, 0.4430,
  114415. 0.3371, 0.5679, -0.0057,
  114416. -0.6999, -0.0451, -0.0019,
  114417. 0.0689, -0.1598, -0.8547,
  114418. 0.0560, 0.0069, -0.1843,
  114419. -0.0146, 0.1402, 0.0762,
  114420. 0.0100, -0.1924, -0.0344,
  114421. -0.3577, -0.5301, -0.4358,
  114422. -0.3169, 0.1063, 0.0158,
  114423. 0.0103, -0.5869, 0.0046,
  114424. -0.0897, -0.4940, 0.3287,
  114425. 0.7119, -0.0154, -0.0918,
  114426. -0.0533, 0.0596, -0.5411,
  114427. 0.0352, -0.0631, 0.5460,
  114428. -0.4776, 0.2847, -0.0271
  114429. ];
  114430. var samplesFactor = 1.0 / numSamples;
  114431. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  114432. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114433. "area", "fallOff", "base", "range", "viewport"
  114434. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114435. this._ssaoPostProcess.onApply = function (effect) {
  114436. if (_this._firstUpdate) {
  114437. effect.setArray3("sampleSphere", sampleSphere);
  114438. effect.setFloat("samplesFactor", samplesFactor);
  114439. effect.setFloat("randTextureTiles", 4.0);
  114440. }
  114441. effect.setFloat("totalStrength", _this.totalStrength);
  114442. effect.setFloat("radius", _this.radius);
  114443. effect.setFloat("area", _this.area);
  114444. effect.setFloat("fallOff", _this.fallOff);
  114445. effect.setFloat("base", _this.base);
  114446. effect.setTexture("textureSampler", _this._depthTexture);
  114447. effect.setTexture("randomSampler", _this._randomTexture);
  114448. };
  114449. };
  114450. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114451. var _this = this;
  114452. 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);
  114453. this._ssaoCombinePostProcess.onApply = function (effect) {
  114454. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  114455. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114456. };
  114457. };
  114458. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  114459. var size = 512;
  114460. 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);
  114461. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114462. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114463. var context = this._randomTexture.getContext();
  114464. var rand = function (min, max) {
  114465. return Math.random() * (max - min) + min;
  114466. };
  114467. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114468. for (var x = 0; x < size; x++) {
  114469. for (var y = 0; y < size; y++) {
  114470. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  114471. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  114472. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  114473. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114474. context.fillRect(x, y, 1, 1);
  114475. }
  114476. }
  114477. this._randomTexture.update(false);
  114478. };
  114479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114481. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  114482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114484. ], SSAORenderingPipeline.prototype, "radius", void 0);
  114485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114487. ], SSAORenderingPipeline.prototype, "area", void 0);
  114488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114490. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  114491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114493. ], SSAORenderingPipeline.prototype, "base", void 0);
  114494. return SSAORenderingPipeline;
  114495. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  114496. /***/ }),
  114497. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  114498. /*!*****************************************************************************!*\
  114499. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  114500. \*****************************************************************************/
  114501. /*! exports provided: StandardRenderingPipeline */
  114502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114503. "use strict";
  114504. __webpack_require__.r(__webpack_exports__);
  114505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  114506. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114507. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114508. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114510. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  114511. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114512. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114513. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114514. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114515. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114516. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114517. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114518. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114519. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  114520. /**
  114521. * Standard rendering pipeline
  114522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114523. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114524. */
  114525. var StandardRenderingPipeline = /** @class */ (function (_super) {
  114526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  114527. /**
  114528. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114529. * @constructor
  114530. * @param name The rendering pipeline name
  114531. * @param scene The scene linked to this pipeline
  114532. * @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)
  114533. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114534. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114535. */
  114536. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  114537. if (originalPostProcess === void 0) { originalPostProcess = null; }
  114538. var _this = _super.call(this, scene.getEngine(), name) || this;
  114539. /**
  114540. * Post-process used to down scale an image x4
  114541. */
  114542. _this.downSampleX4PostProcess = null;
  114543. /**
  114544. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114545. */
  114546. _this.brightPassPostProcess = null;
  114547. /**
  114548. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114549. */
  114550. _this.blurHPostProcesses = [];
  114551. /**
  114552. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114553. */
  114554. _this.blurVPostProcesses = [];
  114555. /**
  114556. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114557. */
  114558. _this.textureAdderPostProcess = null;
  114559. /**
  114560. * Post-process used to create volumetric lighting effect
  114561. */
  114562. _this.volumetricLightPostProcess = null;
  114563. /**
  114564. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114565. */
  114566. _this.volumetricLightSmoothXPostProcess = null;
  114567. /**
  114568. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114569. */
  114570. _this.volumetricLightSmoothYPostProcess = null;
  114571. /**
  114572. * Post-process used to merge the volumetric light effect and the real scene color
  114573. */
  114574. _this.volumetricLightMergePostProces = null;
  114575. /**
  114576. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114577. */
  114578. _this.volumetricLightFinalPostProcess = null;
  114579. /**
  114580. * Base post-process used to calculate the average luminance of the final image for HDR
  114581. */
  114582. _this.luminancePostProcess = null;
  114583. /**
  114584. * Post-processes used to create down sample post-processes in order to get
  114585. * the average luminance of the final image for HDR
  114586. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114587. */
  114588. _this.luminanceDownSamplePostProcesses = [];
  114589. /**
  114590. * Post-process used to create a HDR effect (light adaptation)
  114591. */
  114592. _this.hdrPostProcess = null;
  114593. /**
  114594. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114595. */
  114596. _this.textureAdderFinalPostProcess = null;
  114597. /**
  114598. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114599. */
  114600. _this.lensFlareFinalPostProcess = null;
  114601. /**
  114602. * Post-process used to merge the final HDR post-process and the real scene color
  114603. */
  114604. _this.hdrFinalPostProcess = null;
  114605. /**
  114606. * Post-process used to create a lens flare effect
  114607. */
  114608. _this.lensFlarePostProcess = null;
  114609. /**
  114610. * Post-process that merges the result of the lens flare post-process and the real scene color
  114611. */
  114612. _this.lensFlareComposePostProcess = null;
  114613. /**
  114614. * Post-process used to create a motion blur effect
  114615. */
  114616. _this.motionBlurPostProcess = null;
  114617. /**
  114618. * Post-process used to create a depth of field effect
  114619. */
  114620. _this.depthOfFieldPostProcess = null;
  114621. /**
  114622. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114623. */
  114624. _this.fxaaPostProcess = null;
  114625. // Values
  114626. /**
  114627. * Represents the brightness threshold in order to configure the illuminated surfaces
  114628. */
  114629. _this.brightThreshold = 1.0;
  114630. /**
  114631. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114632. */
  114633. _this.blurWidth = 512.0;
  114634. /**
  114635. * Sets if the blur for highlighted surfaces must be only horizontal
  114636. */
  114637. _this.horizontalBlur = false;
  114638. /**
  114639. * Sets the overall exposure used by the pipeline
  114640. */
  114641. _this.exposure = 1.0;
  114642. /**
  114643. * Texture used typically to simulate "dirty" on camera lens
  114644. */
  114645. _this.lensTexture = null;
  114646. /**
  114647. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114648. */
  114649. _this.volumetricLightCoefficient = 0.2;
  114650. /**
  114651. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114652. */
  114653. _this.volumetricLightPower = 4.0;
  114654. /**
  114655. * Used the set the blur intensity to smooth the volumetric lights
  114656. */
  114657. _this.volumetricLightBlurScale = 64.0;
  114658. /**
  114659. * Light (spot or directional) used to generate the volumetric lights rays
  114660. * The source light must have a shadow generate so the pipeline can get its
  114661. * depth map
  114662. */
  114663. _this.sourceLight = null;
  114664. /**
  114665. * For eye adaptation, represents the minimum luminance the eye can see
  114666. */
  114667. _this.hdrMinimumLuminance = 1.0;
  114668. /**
  114669. * For eye adaptation, represents the decrease luminance speed
  114670. */
  114671. _this.hdrDecreaseRate = 0.5;
  114672. /**
  114673. * For eye adaptation, represents the increase luminance speed
  114674. */
  114675. _this.hdrIncreaseRate = 0.5;
  114676. /**
  114677. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114678. */
  114679. _this.lensColorTexture = null;
  114680. /**
  114681. * The overall strengh for the lens flare effect
  114682. */
  114683. _this.lensFlareStrength = 20.0;
  114684. /**
  114685. * Dispersion coefficient for lens flare ghosts
  114686. */
  114687. _this.lensFlareGhostDispersal = 1.4;
  114688. /**
  114689. * Main lens flare halo width
  114690. */
  114691. _this.lensFlareHaloWidth = 0.7;
  114692. /**
  114693. * Based on the lens distortion effect, defines how much the lens flare result
  114694. * is distorted
  114695. */
  114696. _this.lensFlareDistortionStrength = 16.0;
  114697. /**
  114698. * Lens star texture must be used to simulate rays on the flares and is available
  114699. * in the documentation
  114700. */
  114701. _this.lensStarTexture = null;
  114702. /**
  114703. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114704. * flare effect by taking account of the dirt texture
  114705. */
  114706. _this.lensFlareDirtTexture = null;
  114707. /**
  114708. * Represents the focal length for the depth of field effect
  114709. */
  114710. _this.depthOfFieldDistance = 10.0;
  114711. /**
  114712. * Represents the blur intensity for the blurred part of the depth of field effect
  114713. */
  114714. _this.depthOfFieldBlurWidth = 64.0;
  114715. /**
  114716. * For motion blur, defines how much the image is blurred by the movement
  114717. */
  114718. _this.motionStrength = 1.0;
  114719. /**
  114720. * List of animations for the pipeline (IAnimatable implementation)
  114721. */
  114722. _this.animations = [];
  114723. _this._currentDepthOfFieldSource = null;
  114724. _this._hdrCurrentLuminance = 1.0;
  114725. // Getters and setters
  114726. _this._bloomEnabled = false;
  114727. _this._depthOfFieldEnabled = false;
  114728. _this._vlsEnabled = false;
  114729. _this._lensFlareEnabled = false;
  114730. _this._hdrEnabled = false;
  114731. _this._motionBlurEnabled = false;
  114732. _this._fxaaEnabled = false;
  114733. _this._motionBlurSamples = 64.0;
  114734. _this._volumetricLightStepsCount = 50.0;
  114735. _this._samples = 1;
  114736. _this._cameras = cameras || [];
  114737. // Initialize
  114738. _this._scene = scene;
  114739. _this._basePostProcess = originalPostProcess;
  114740. _this._ratio = ratio;
  114741. // Misc
  114742. _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;
  114743. // Finish
  114744. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114745. _this._buildPipeline();
  114746. return _this;
  114747. }
  114748. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  114749. /**
  114750. * @ignore
  114751. * Specifies if the bloom pipeline is enabled
  114752. */
  114753. get: function () {
  114754. return this._bloomEnabled;
  114755. },
  114756. set: function (enabled) {
  114757. if (this._bloomEnabled === enabled) {
  114758. return;
  114759. }
  114760. this._bloomEnabled = enabled;
  114761. this._buildPipeline();
  114762. },
  114763. enumerable: true,
  114764. configurable: true
  114765. });
  114766. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  114767. /**
  114768. * @ignore
  114769. * Specifies if the depth of field pipeline is enabed
  114770. */
  114771. get: function () {
  114772. return this._depthOfFieldEnabled;
  114773. },
  114774. set: function (enabled) {
  114775. if (this._depthOfFieldEnabled === enabled) {
  114776. return;
  114777. }
  114778. this._depthOfFieldEnabled = enabled;
  114779. this._buildPipeline();
  114780. },
  114781. enumerable: true,
  114782. configurable: true
  114783. });
  114784. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  114785. /**
  114786. * @ignore
  114787. * Specifies if the lens flare pipeline is enabed
  114788. */
  114789. get: function () {
  114790. return this._lensFlareEnabled;
  114791. },
  114792. set: function (enabled) {
  114793. if (this._lensFlareEnabled === enabled) {
  114794. return;
  114795. }
  114796. this._lensFlareEnabled = enabled;
  114797. this._buildPipeline();
  114798. },
  114799. enumerable: true,
  114800. configurable: true
  114801. });
  114802. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  114803. /**
  114804. * @ignore
  114805. * Specifies if the HDR pipeline is enabled
  114806. */
  114807. get: function () {
  114808. return this._hdrEnabled;
  114809. },
  114810. set: function (enabled) {
  114811. if (this._hdrEnabled === enabled) {
  114812. return;
  114813. }
  114814. this._hdrEnabled = enabled;
  114815. this._buildPipeline();
  114816. },
  114817. enumerable: true,
  114818. configurable: true
  114819. });
  114820. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  114821. /**
  114822. * @ignore
  114823. * Specifies if the volumetric lights scattering effect is enabled
  114824. */
  114825. get: function () {
  114826. return this._vlsEnabled;
  114827. },
  114828. set: function (enabled) {
  114829. if (this._vlsEnabled === enabled) {
  114830. return;
  114831. }
  114832. if (enabled) {
  114833. var geometry = this._scene.enableGeometryBufferRenderer();
  114834. if (!geometry) {
  114835. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  114836. return;
  114837. }
  114838. }
  114839. this._vlsEnabled = enabled;
  114840. this._buildPipeline();
  114841. },
  114842. enumerable: true,
  114843. configurable: true
  114844. });
  114845. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  114846. /**
  114847. * @ignore
  114848. * Specifies if the motion blur effect is enabled
  114849. */
  114850. get: function () {
  114851. return this._motionBlurEnabled;
  114852. },
  114853. set: function (enabled) {
  114854. if (this._motionBlurEnabled === enabled) {
  114855. return;
  114856. }
  114857. this._motionBlurEnabled = enabled;
  114858. this._buildPipeline();
  114859. },
  114860. enumerable: true,
  114861. configurable: true
  114862. });
  114863. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  114864. /**
  114865. * Specifies if anti-aliasing is enabled
  114866. */
  114867. get: function () {
  114868. return this._fxaaEnabled;
  114869. },
  114870. set: function (enabled) {
  114871. if (this._fxaaEnabled === enabled) {
  114872. return;
  114873. }
  114874. this._fxaaEnabled = enabled;
  114875. this._buildPipeline();
  114876. },
  114877. enumerable: true,
  114878. configurable: true
  114879. });
  114880. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  114881. /**
  114882. * Specifies the number of steps used to calculate the volumetric lights
  114883. * Typically in interval [50, 200]
  114884. */
  114885. get: function () {
  114886. return this._volumetricLightStepsCount;
  114887. },
  114888. set: function (count) {
  114889. if (this.volumetricLightPostProcess) {
  114890. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  114891. }
  114892. this._volumetricLightStepsCount = count;
  114893. },
  114894. enumerable: true,
  114895. configurable: true
  114896. });
  114897. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  114898. /**
  114899. * Specifies the number of samples used for the motion blur effect
  114900. * Typically in interval [16, 64]
  114901. */
  114902. get: function () {
  114903. return this._motionBlurSamples;
  114904. },
  114905. set: function (samples) {
  114906. if (this.motionBlurPostProcess) {
  114907. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  114908. }
  114909. this._motionBlurSamples = samples;
  114910. },
  114911. enumerable: true,
  114912. configurable: true
  114913. });
  114914. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  114915. /**
  114916. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114917. */
  114918. get: function () {
  114919. return this._samples;
  114920. },
  114921. set: function (sampleCount) {
  114922. if (this._samples === sampleCount) {
  114923. return;
  114924. }
  114925. this._samples = sampleCount;
  114926. this._buildPipeline();
  114927. },
  114928. enumerable: true,
  114929. configurable: true
  114930. });
  114931. StandardRenderingPipeline.prototype._buildPipeline = function () {
  114932. var _this = this;
  114933. var ratio = this._ratio;
  114934. var scene = this._scene;
  114935. this._disposePostProcesses();
  114936. this._reset();
  114937. // Create pass post-process
  114938. if (!this._basePostProcess) {
  114939. 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);
  114940. this.originalPostProcess.onApply = function () {
  114941. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  114942. };
  114943. }
  114944. else {
  114945. this.originalPostProcess = this._basePostProcess;
  114946. }
  114947. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  114948. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  114949. }
  114950. this._currentDepthOfFieldSource = this.originalPostProcess;
  114951. if (this._bloomEnabled) {
  114952. // Create down sample X4 post-process
  114953. this._createDownSampleX4PostProcess(scene, ratio / 2);
  114954. // Create bright pass post-process
  114955. this._createBrightPassPostProcess(scene, ratio / 2);
  114956. // Create gaussian blur post-processes (down sampling blurs)
  114957. this._createBlurPostProcesses(scene, ratio / 4, 1);
  114958. // Create texture adder post-process
  114959. this._createTextureAdderPostProcess(scene, ratio);
  114960. // Create depth-of-field source post-process
  114961. 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);
  114962. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  114963. }
  114964. if (this._vlsEnabled) {
  114965. // Create volumetric light
  114966. this._createVolumetricLightPostProcess(scene, ratio);
  114967. // Create volumetric light final post-process
  114968. 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);
  114969. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  114970. }
  114971. if (this._lensFlareEnabled) {
  114972. // Create lens flare post-process
  114973. this._createLensFlarePostProcess(scene, ratio);
  114974. // Create depth-of-field source post-process post lens-flare and disable it now
  114975. 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);
  114976. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  114977. }
  114978. if (this._hdrEnabled) {
  114979. // Create luminance
  114980. this._createLuminancePostProcesses(scene, this._floatTextureType);
  114981. // Create HDR
  114982. this._createHdrPostProcess(scene, ratio);
  114983. // Create depth-of-field source post-process post hdr and disable it now
  114984. 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);
  114985. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  114986. }
  114987. if (this._depthOfFieldEnabled) {
  114988. // Create gaussian blur used by depth-of-field
  114989. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  114990. // Create depth-of-field post-process
  114991. this._createDepthOfFieldPostProcess(scene, ratio);
  114992. }
  114993. if (this._motionBlurEnabled) {
  114994. // Create motion blur post-process
  114995. this._createMotionBlurPostProcess(scene, ratio);
  114996. }
  114997. if (this._fxaaEnabled) {
  114998. // Create fxaa post-process
  114999. 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);
  115000. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  115001. }
  115002. if (this._cameras !== null) {
  115003. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115004. }
  115005. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  115006. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115007. }
  115008. };
  115009. // Down Sample X4 Post-Processs
  115010. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  115011. var _this = this;
  115012. var downSampleX4Offsets = new Array(32);
  115013. 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);
  115014. this.downSampleX4PostProcess.onApply = function (effect) {
  115015. var id = 0;
  115016. var width = _this.downSampleX4PostProcess.width;
  115017. var height = _this.downSampleX4PostProcess.height;
  115018. for (var i = -2; i < 2; i++) {
  115019. for (var j = -2; j < 2; j++) {
  115020. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  115021. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  115022. id += 2;
  115023. }
  115024. }
  115025. effect.setArray2("dsOffsets", downSampleX4Offsets);
  115026. };
  115027. // Add to pipeline
  115028. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  115029. };
  115030. // Brightpass Post-Process
  115031. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  115032. var _this = this;
  115033. var brightOffsets = new Array(8);
  115034. 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);
  115035. this.brightPassPostProcess.onApply = function (effect) {
  115036. var sU = (1.0 / _this.brightPassPostProcess.width);
  115037. var sV = (1.0 / _this.brightPassPostProcess.height);
  115038. brightOffsets[0] = -0.5 * sU;
  115039. brightOffsets[1] = 0.5 * sV;
  115040. brightOffsets[2] = 0.5 * sU;
  115041. brightOffsets[3] = 0.5 * sV;
  115042. brightOffsets[4] = -0.5 * sU;
  115043. brightOffsets[5] = -0.5 * sV;
  115044. brightOffsets[6] = 0.5 * sU;
  115045. brightOffsets[7] = -0.5 * sV;
  115046. effect.setArray2("dsOffsets", brightOffsets);
  115047. effect.setFloat("brightThreshold", _this.brightThreshold);
  115048. };
  115049. // Add to pipeline
  115050. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  115051. };
  115052. // Create blur H&V post-processes
  115053. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  115054. var _this = this;
  115055. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  115056. var engine = scene.getEngine();
  115057. var blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurH" + "_" + indice, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0), this[blurWidthKey], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  115058. var blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurV" + "_" + indice, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1), this[blurWidthKey], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  115059. blurX.onActivateObservable.add(function () {
  115060. var dw = blurX.width / engine.getRenderWidth();
  115061. blurX.kernel = _this[blurWidthKey] * dw;
  115062. });
  115063. blurY.onActivateObservable.add(function () {
  115064. var dw = blurY.height / engine.getRenderHeight();
  115065. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  115066. });
  115067. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  115068. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  115069. this.blurHPostProcesses.push(blurX);
  115070. this.blurVPostProcesses.push(blurY);
  115071. };
  115072. // Create texture adder post-process
  115073. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  115074. var _this = this;
  115075. 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);
  115076. this.textureAdderPostProcess.onApply = function (effect) {
  115077. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  115078. effect.setTexture("lensSampler", _this.lensTexture);
  115079. effect.setFloat("exposure", _this.exposure);
  115080. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  115081. };
  115082. // Add to pipeline
  115083. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  115084. };
  115085. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  115086. var _this = this;
  115087. var geometryRenderer = scene.enableGeometryBufferRenderer();
  115088. geometryRenderer.enablePosition = true;
  115089. var geometry = geometryRenderer.getGBuffer();
  115090. // Base post-process
  115091. 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));
  115092. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115093. this.volumetricLightPostProcess.onApply = function (effect) {
  115094. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  115095. var generator = _this.sourceLight.getShadowGenerator();
  115096. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  115097. effect.setTexture("positionSampler", geometry.textures[2]);
  115098. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  115099. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  115100. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  115101. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  115102. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  115103. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  115104. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  115105. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  115106. effect.setVector2("depthValues", depthValues);
  115107. }
  115108. };
  115109. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  115110. // Smooth
  115111. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  115112. // Merge
  115113. 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");
  115114. this.volumetricLightMergePostProces.onApply = function (effect) {
  115115. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  115116. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  115117. };
  115118. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  115119. };
  115120. // Create luminance
  115121. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  115122. var _this = this;
  115123. // Create luminance
  115124. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  115125. 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);
  115126. var offsets = [];
  115127. this.luminancePostProcess.onApply = function (effect) {
  115128. var sU = (1.0 / _this.luminancePostProcess.width);
  115129. var sV = (1.0 / _this.luminancePostProcess.height);
  115130. offsets[0] = -0.5 * sU;
  115131. offsets[1] = 0.5 * sV;
  115132. offsets[2] = 0.5 * sU;
  115133. offsets[3] = 0.5 * sV;
  115134. offsets[4] = -0.5 * sU;
  115135. offsets[5] = -0.5 * sV;
  115136. offsets[6] = 0.5 * sU;
  115137. offsets[7] = -0.5 * sV;
  115138. effect.setArray2("lumOffsets", offsets);
  115139. };
  115140. // Add to pipeline
  115141. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  115142. // Create down sample luminance
  115143. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  115144. var size = Math.pow(3, i);
  115145. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  115146. if (i === 0) {
  115147. defines += "#define FINAL_DOWN_SAMPLER";
  115148. }
  115149. 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);
  115150. this.luminanceDownSamplePostProcesses.push(postProcess);
  115151. }
  115152. // Create callbacks and add effects
  115153. var lastLuminance = this.luminancePostProcess;
  115154. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  115155. var downSampleOffsets = new Array(18);
  115156. pp.onApply = function (effect) {
  115157. if (!lastLuminance) {
  115158. return;
  115159. }
  115160. var id = 0;
  115161. for (var x = -1; x < 2; x++) {
  115162. for (var y = -1; y < 2; y++) {
  115163. downSampleOffsets[id] = x / lastLuminance.width;
  115164. downSampleOffsets[id + 1] = y / lastLuminance.height;
  115165. id += 2;
  115166. }
  115167. }
  115168. effect.setArray2("dsOffsets", downSampleOffsets);
  115169. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  115170. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115171. lastLuminance = _this.luminancePostProcess;
  115172. }
  115173. else {
  115174. lastLuminance = pp;
  115175. }
  115176. };
  115177. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115178. pp.onAfterRender = function () {
  115179. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  115180. var bit_shift = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
  115181. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  115182. };
  115183. }
  115184. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  115185. });
  115186. };
  115187. // Create HDR post-process
  115188. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  115189. var _this = this;
  115190. this.hdrPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define HDR", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  115191. var outputLiminance = 1;
  115192. var time = 0;
  115193. var lastTime = 0;
  115194. this.hdrPostProcess.onApply = function (effect) {
  115195. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  115196. time += scene.getEngine().getDeltaTime();
  115197. if (outputLiminance < 0) {
  115198. outputLiminance = _this._hdrCurrentLuminance;
  115199. }
  115200. else {
  115201. var dt = (lastTime - time) / 1000.0;
  115202. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  115203. outputLiminance += _this.hdrDecreaseRate * dt;
  115204. }
  115205. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  115206. outputLiminance -= _this.hdrIncreaseRate * dt;
  115207. }
  115208. else {
  115209. outputLiminance = _this._hdrCurrentLuminance;
  115210. }
  115211. }
  115212. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  115213. effect.setFloat("averageLuminance", outputLiminance);
  115214. lastTime = time;
  115215. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  115216. };
  115217. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  115218. };
  115219. // Create lens flare post-process
  115220. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  115221. var _this = this;
  115222. 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);
  115223. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  115224. this._createBlurPostProcesses(scene, ratio / 4, 2);
  115225. 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);
  115226. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  115227. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  115228. // Lens flare
  115229. this.lensFlarePostProcess.onApply = function (effect) {
  115230. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  115231. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  115232. effect.setFloat("strength", _this.lensFlareStrength);
  115233. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  115234. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  115235. // Shift
  115236. resolution.x = _this.lensFlarePostProcess.width;
  115237. resolution.y = _this.lensFlarePostProcess.height;
  115238. effect.setVector2("resolution", resolution);
  115239. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  115240. };
  115241. // Compose
  115242. var scaleBias1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(2.0, 0.0, -1.0, 0.0, 0.0, 2.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  115243. var scaleBias2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  115244. this.lensFlareComposePostProcess.onApply = function (effect) {
  115245. if (!_this._scene.activeCamera) {
  115246. return;
  115247. }
  115248. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115249. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  115250. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  115251. // Lens start rotation matrix
  115252. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  115253. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  115254. var camRot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(camerax.toVector3(), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1.0, 0.0, 0.0)) + _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(cameraz.toVector3(), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.0, 0.0, 1.0));
  115255. camRot *= 4.0;
  115256. var starRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(Math.cos(camRot) * 0.5, -Math.sin(camRot), 0.0, 0.0, Math.sin(camRot), Math.cos(camRot) * 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  115257. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  115258. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  115259. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  115260. };
  115261. };
  115262. // Create depth-of-field post-process
  115263. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  115264. var _this = this;
  115265. 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);
  115266. this.depthOfFieldPostProcess.onApply = function (effect) {
  115267. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115268. effect.setTexture("depthSampler", _this._getDepthTexture());
  115269. effect.setFloat("distance", _this.depthOfFieldDistance);
  115270. };
  115271. // Add to pipeline
  115272. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  115273. };
  115274. // Create motion blur post-process
  115275. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  115276. var _this = this;
  115277. 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);
  115278. var motionScale = 0;
  115279. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115280. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115281. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115282. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115283. this.motionBlurPostProcess.onApply = function (effect) {
  115284. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  115285. viewProjection.invertToRef(invViewProjection);
  115286. effect.setMatrix("inverseViewProjection", invViewProjection);
  115287. effect.setMatrix("prevViewProjection", prevViewProjection);
  115288. prevViewProjection = viewProjection;
  115289. screenSize.x = _this.motionBlurPostProcess.width;
  115290. screenSize.y = _this.motionBlurPostProcess.height;
  115291. effect.setVector2("screenSize", screenSize);
  115292. motionScale = scene.getEngine().getFps() / 60.0;
  115293. effect.setFloat("motionScale", motionScale);
  115294. effect.setFloat("motionStrength", _this.motionStrength);
  115295. effect.setTexture("depthSampler", _this._getDepthTexture());
  115296. };
  115297. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  115298. };
  115299. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  115300. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  115301. var renderer = this._scene.enableGeometryBufferRenderer();
  115302. return renderer.getGBuffer().textures[0];
  115303. }
  115304. return this._scene.enableDepthRenderer().getDepthMap();
  115305. };
  115306. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  115307. for (var i = 0; i < this._cameras.length; i++) {
  115308. var camera = this._cameras[i];
  115309. if (this.originalPostProcess) {
  115310. this.originalPostProcess.dispose(camera);
  115311. }
  115312. if (this.downSampleX4PostProcess) {
  115313. this.downSampleX4PostProcess.dispose(camera);
  115314. }
  115315. if (this.brightPassPostProcess) {
  115316. this.brightPassPostProcess.dispose(camera);
  115317. }
  115318. if (this.textureAdderPostProcess) {
  115319. this.textureAdderPostProcess.dispose(camera);
  115320. }
  115321. if (this.textureAdderFinalPostProcess) {
  115322. this.textureAdderFinalPostProcess.dispose(camera);
  115323. }
  115324. if (this.volumetricLightPostProcess) {
  115325. this.volumetricLightPostProcess.dispose(camera);
  115326. }
  115327. if (this.volumetricLightSmoothXPostProcess) {
  115328. this.volumetricLightSmoothXPostProcess.dispose(camera);
  115329. }
  115330. if (this.volumetricLightSmoothYPostProcess) {
  115331. this.volumetricLightSmoothYPostProcess.dispose(camera);
  115332. }
  115333. if (this.volumetricLightMergePostProces) {
  115334. this.volumetricLightMergePostProces.dispose(camera);
  115335. }
  115336. if (this.volumetricLightFinalPostProcess) {
  115337. this.volumetricLightFinalPostProcess.dispose(camera);
  115338. }
  115339. if (this.lensFlarePostProcess) {
  115340. this.lensFlarePostProcess.dispose(camera);
  115341. }
  115342. if (this.lensFlareComposePostProcess) {
  115343. this.lensFlareComposePostProcess.dispose(camera);
  115344. }
  115345. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  115346. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  115347. }
  115348. if (this.luminancePostProcess) {
  115349. this.luminancePostProcess.dispose(camera);
  115350. }
  115351. if (this.hdrPostProcess) {
  115352. this.hdrPostProcess.dispose(camera);
  115353. }
  115354. if (this.hdrFinalPostProcess) {
  115355. this.hdrFinalPostProcess.dispose(camera);
  115356. }
  115357. if (this.depthOfFieldPostProcess) {
  115358. this.depthOfFieldPostProcess.dispose(camera);
  115359. }
  115360. if (this.motionBlurPostProcess) {
  115361. this.motionBlurPostProcess.dispose(camera);
  115362. }
  115363. if (this.fxaaPostProcess) {
  115364. this.fxaaPostProcess.dispose(camera);
  115365. }
  115366. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  115367. this.blurHPostProcesses[j].dispose(camera);
  115368. }
  115369. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  115370. this.blurVPostProcesses[j].dispose(camera);
  115371. }
  115372. }
  115373. this.originalPostProcess = null;
  115374. this.downSampleX4PostProcess = null;
  115375. this.brightPassPostProcess = null;
  115376. this.textureAdderPostProcess = null;
  115377. this.textureAdderFinalPostProcess = null;
  115378. this.volumetricLightPostProcess = null;
  115379. this.volumetricLightSmoothXPostProcess = null;
  115380. this.volumetricLightSmoothYPostProcess = null;
  115381. this.volumetricLightMergePostProces = null;
  115382. this.volumetricLightFinalPostProcess = null;
  115383. this.lensFlarePostProcess = null;
  115384. this.lensFlareComposePostProcess = null;
  115385. this.luminancePostProcess = null;
  115386. this.hdrPostProcess = null;
  115387. this.hdrFinalPostProcess = null;
  115388. this.depthOfFieldPostProcess = null;
  115389. this.motionBlurPostProcess = null;
  115390. this.fxaaPostProcess = null;
  115391. this.luminanceDownSamplePostProcesses = [];
  115392. this.blurHPostProcesses = [];
  115393. this.blurVPostProcesses = [];
  115394. };
  115395. /**
  115396. * Dispose of the pipeline and stop all post processes
  115397. */
  115398. StandardRenderingPipeline.prototype.dispose = function () {
  115399. this._disposePostProcesses();
  115400. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115401. _super.prototype.dispose.call(this);
  115402. };
  115403. /**
  115404. * Serialize the rendering pipeline (Used when exporting)
  115405. * @returns the serialized object
  115406. */
  115407. StandardRenderingPipeline.prototype.serialize = function () {
  115408. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115409. if (this.sourceLight) {
  115410. serializationObject.sourceLightId = this.sourceLight.id;
  115411. }
  115412. serializationObject.customType = "StandardRenderingPipeline";
  115413. return serializationObject;
  115414. };
  115415. /**
  115416. * Parse the serialized pipeline
  115417. * @param source Source pipeline.
  115418. * @param scene The scene to load the pipeline to.
  115419. * @param rootUrl The URL of the serialized pipeline.
  115420. * @returns An instantiated pipeline from the serialized object.
  115421. */
  115422. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115423. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115424. if (source.sourceLightId) {
  115425. p.sourceLight = scene.getLightByID(source.sourceLightId);
  115426. }
  115427. return p;
  115428. };
  115429. /**
  115430. * Luminance steps
  115431. */
  115432. StandardRenderingPipeline.LuminanceSteps = 6;
  115433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115435. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  115436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115438. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  115439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115441. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  115442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115444. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  115445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  115447. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  115448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115450. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  115451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115453. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  115454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115456. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  115457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115459. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  115460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115462. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  115463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115465. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  115466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  115468. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  115469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115471. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  115472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115474. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  115475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115477. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  115478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115480. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  115481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  115483. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  115484. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115485. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  115486. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  115487. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115488. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115489. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  115490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115492. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  115493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115495. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  115496. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115497. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115498. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  115499. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115500. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115501. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  115502. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115504. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  115505. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115506. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115507. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  115508. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115509. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115510. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  115511. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115512. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115513. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  115514. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115516. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  115517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115519. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  115520. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115521. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115522. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  115523. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115524. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115525. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  115526. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115528. ], StandardRenderingPipeline.prototype, "samples", null);
  115529. return StandardRenderingPipeline;
  115530. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115531. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  115532. /***/ }),
  115533. /***/ "./PostProcesses/RenderPipeline/index.ts":
  115534. /*!***********************************************!*\
  115535. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  115536. \***********************************************/
  115537. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115539. "use strict";
  115540. __webpack_require__.r(__webpack_exports__);
  115541. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  115542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  115544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  115545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  115546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  115547. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  115549. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  115551. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  115553. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  115555. /***/ }),
  115556. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  115557. /*!*****************************************************************!*\
  115558. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  115559. \*****************************************************************/
  115560. /*! exports provided: PostProcessRenderEffect */
  115561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115562. "use strict";
  115563. __webpack_require__.r(__webpack_exports__);
  115564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  115565. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115566. /**
  115567. * This represents a set of one or more post processes in Babylon.
  115568. * A post process can be used to apply a shader to a texture after it is rendered.
  115569. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115570. */
  115571. var PostProcessRenderEffect = /** @class */ (function () {
  115572. /**
  115573. * Instantiates a post process render effect.
  115574. * A post process can be used to apply a shader to a texture after it is rendered.
  115575. * @param engine The engine the effect is tied to
  115576. * @param name The name of the effect
  115577. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  115578. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  115579. */
  115580. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  115581. this._name = name;
  115582. this._singleInstance = singleInstance || true;
  115583. this._getPostProcesses = getPostProcesses;
  115584. this._cameras = {};
  115585. this._indicesForCamera = {};
  115586. this._postProcesses = {};
  115587. }
  115588. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  115589. /**
  115590. * Checks if all the post processes in the effect are supported.
  115591. */
  115592. get: function () {
  115593. for (var index in this._postProcesses) {
  115594. if (this._postProcesses.hasOwnProperty(index)) {
  115595. var pps = this._postProcesses[index];
  115596. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  115597. if (!pps[ppIndex].isSupported) {
  115598. return false;
  115599. }
  115600. }
  115601. }
  115602. }
  115603. return true;
  115604. },
  115605. enumerable: true,
  115606. configurable: true
  115607. });
  115608. /**
  115609. * Updates the current state of the effect
  115610. * @hidden
  115611. */
  115612. PostProcessRenderEffect.prototype._update = function () {
  115613. };
  115614. /**
  115615. * Attaches the effect on cameras
  115616. * @param cameras The camera to attach to.
  115617. * @hidden
  115618. */
  115619. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  115620. var _this = this;
  115621. var cameraKey;
  115622. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115623. if (!cams) {
  115624. return;
  115625. }
  115626. for (var i = 0; i < cams.length; i++) {
  115627. var camera = cams[i];
  115628. var cameraName = camera.name;
  115629. if (this._singleInstance) {
  115630. cameraKey = 0;
  115631. }
  115632. else {
  115633. cameraKey = cameraName;
  115634. }
  115635. if (!this._postProcesses[cameraKey]) {
  115636. var postProcess = this._getPostProcesses();
  115637. if (postProcess) {
  115638. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  115639. }
  115640. }
  115641. if (!this._indicesForCamera[cameraName]) {
  115642. this._indicesForCamera[cameraName] = [];
  115643. }
  115644. this._postProcesses[cameraKey].forEach(function (postProcess) {
  115645. var index = camera.attachPostProcess(postProcess);
  115646. _this._indicesForCamera[cameraName].push(index);
  115647. });
  115648. if (!this._cameras[cameraName]) {
  115649. this._cameras[cameraName] = camera;
  115650. }
  115651. }
  115652. };
  115653. /**
  115654. * Detatches the effect on cameras
  115655. * @param cameras The camera to detatch from.
  115656. * @hidden
  115657. */
  115658. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  115659. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115660. if (!cams) {
  115661. return;
  115662. }
  115663. for (var i = 0; i < cams.length; i++) {
  115664. var camera = cams[i];
  115665. var cameraName = camera.name;
  115666. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  115667. if (postProcesses) {
  115668. postProcesses.forEach(function (postProcess) {
  115669. camera.detachPostProcess(postProcess);
  115670. });
  115671. }
  115672. if (this._cameras[cameraName]) {
  115673. this._cameras[cameraName] = null;
  115674. }
  115675. }
  115676. };
  115677. /**
  115678. * Enables the effect on given cameras
  115679. * @param cameras The camera to enable.
  115680. * @hidden
  115681. */
  115682. PostProcessRenderEffect.prototype._enable = function (cameras) {
  115683. var _this = this;
  115684. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115685. if (!cams) {
  115686. return;
  115687. }
  115688. for (var i = 0; i < cams.length; i++) {
  115689. var camera = cams[i];
  115690. var cameraName = camera.name;
  115691. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  115692. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  115693. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115694. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  115695. });
  115696. }
  115697. }
  115698. }
  115699. };
  115700. /**
  115701. * Disables the effect on the given cameras
  115702. * @param cameras The camera to disable.
  115703. * @hidden
  115704. */
  115705. PostProcessRenderEffect.prototype._disable = function (cameras) {
  115706. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115707. if (!cams) {
  115708. return;
  115709. }
  115710. for (var i = 0; i < cams.length; i++) {
  115711. var camera = cams[i];
  115712. var cameraName = camera.name;
  115713. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115714. camera.detachPostProcess(postProcess);
  115715. });
  115716. }
  115717. };
  115718. /**
  115719. * Gets a list of the post processes contained in the effect.
  115720. * @param camera The camera to get the post processes on.
  115721. * @returns The list of the post processes in the effect.
  115722. */
  115723. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  115724. if (this._singleInstance) {
  115725. return this._postProcesses[0];
  115726. }
  115727. else {
  115728. if (!camera) {
  115729. return null;
  115730. }
  115731. return this._postProcesses[camera.name];
  115732. }
  115733. };
  115734. return PostProcessRenderEffect;
  115735. }());
  115736. /***/ }),
  115737. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  115738. /*!*******************************************************************!*\
  115739. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  115740. \*******************************************************************/
  115741. /*! exports provided: PostProcessRenderPipeline */
  115742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115743. "use strict";
  115744. __webpack_require__.r(__webpack_exports__);
  115745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  115746. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115747. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115748. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  115749. /**
  115750. * PostProcessRenderPipeline
  115751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115752. */
  115753. var PostProcessRenderPipeline = /** @class */ (function () {
  115754. /**
  115755. * Initializes a PostProcessRenderPipeline
  115756. * @param engine engine to add the pipeline to
  115757. * @param name name of the pipeline
  115758. */
  115759. function PostProcessRenderPipeline(engine, name) {
  115760. this.engine = engine;
  115761. this._name = name;
  115762. this._renderEffects = {};
  115763. this._renderEffectsForIsolatedPass = new Array();
  115764. this._cameras = [];
  115765. }
  115766. /**
  115767. * "PostProcessRenderPipeline"
  115768. * @returns "PostProcessRenderPipeline"
  115769. */
  115770. PostProcessRenderPipeline.prototype.getClassName = function () {
  115771. return "PostProcessRenderPipeline";
  115772. };
  115773. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  115774. /**
  115775. * If all the render effects in the pipeline are support
  115776. */
  115777. get: function () {
  115778. for (var renderEffectName in this._renderEffects) {
  115779. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115780. if (!this._renderEffects[renderEffectName].isSupported) {
  115781. return false;
  115782. }
  115783. }
  115784. }
  115785. return true;
  115786. },
  115787. enumerable: true,
  115788. configurable: true
  115789. });
  115790. /**
  115791. * Adds an effect to the pipeline
  115792. * @param renderEffect the effect to add
  115793. */
  115794. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  115795. this._renderEffects[renderEffect._name] = renderEffect;
  115796. };
  115797. // private
  115798. /** @hidden */
  115799. PostProcessRenderPipeline.prototype._rebuild = function () {
  115800. };
  115801. /** @hidden */
  115802. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  115803. var renderEffects = this._renderEffects[renderEffectName];
  115804. if (!renderEffects) {
  115805. return;
  115806. }
  115807. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115808. };
  115809. /** @hidden */
  115810. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  115811. var renderEffects = this._renderEffects[renderEffectName];
  115812. if (!renderEffects) {
  115813. return;
  115814. }
  115815. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115816. };
  115817. /** @hidden */
  115818. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  115819. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115820. if (!cams) {
  115821. return;
  115822. }
  115823. var indicesToDelete = [];
  115824. var i;
  115825. for (i = 0; i < cams.length; i++) {
  115826. var camera = cams[i];
  115827. var cameraName = camera.name;
  115828. if (this._cameras.indexOf(camera) === -1) {
  115829. this._cameras[cameraName] = camera;
  115830. }
  115831. else if (unique) {
  115832. indicesToDelete.push(i);
  115833. }
  115834. }
  115835. for (i = 0; i < indicesToDelete.length; i++) {
  115836. cameras.splice(indicesToDelete[i], 1);
  115837. }
  115838. for (var renderEffectName in this._renderEffects) {
  115839. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115840. this._renderEffects[renderEffectName]._attachCameras(cams);
  115841. }
  115842. }
  115843. };
  115844. /** @hidden */
  115845. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  115846. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115847. if (!cams) {
  115848. return;
  115849. }
  115850. for (var renderEffectName in this._renderEffects) {
  115851. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115852. this._renderEffects[renderEffectName]._detachCameras(cams);
  115853. }
  115854. }
  115855. for (var i = 0; i < cams.length; i++) {
  115856. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  115857. }
  115858. };
  115859. /** @hidden */
  115860. PostProcessRenderPipeline.prototype._update = function () {
  115861. for (var renderEffectName in this._renderEffects) {
  115862. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115863. this._renderEffects[renderEffectName]._update();
  115864. }
  115865. }
  115866. for (var i = 0; i < this._cameras.length; i++) {
  115867. var cameraName = this._cameras[i].name;
  115868. if (this._renderEffectsForIsolatedPass[cameraName]) {
  115869. this._renderEffectsForIsolatedPass[cameraName]._update();
  115870. }
  115871. }
  115872. };
  115873. /** @hidden */
  115874. PostProcessRenderPipeline.prototype._reset = function () {
  115875. this._renderEffects = {};
  115876. this._renderEffectsForIsolatedPass = new Array();
  115877. };
  115878. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  115879. // 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)
  115880. var effectKeys = Object.keys(this._renderEffects);
  115881. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  115882. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  115883. if (postProcesses) {
  115884. postProcesses[0].samples = sampleCount;
  115885. return true;
  115886. }
  115887. }
  115888. return false;
  115889. };
  115890. /**
  115891. * Disposes of the pipeline
  115892. */
  115893. PostProcessRenderPipeline.prototype.dispose = function () {
  115894. // Must be implemented by children
  115895. };
  115896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115898. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  115899. return PostProcessRenderPipeline;
  115900. }());
  115901. /***/ }),
  115902. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  115903. /*!**************************************************************************!*\
  115904. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  115905. \**************************************************************************/
  115906. /*! exports provided: PostProcessRenderPipelineManager */
  115907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115908. "use strict";
  115909. __webpack_require__.r(__webpack_exports__);
  115910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  115911. /**
  115912. * PostProcessRenderPipelineManager class
  115913. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115914. */
  115915. var PostProcessRenderPipelineManager = /** @class */ (function () {
  115916. /**
  115917. * Initializes a PostProcessRenderPipelineManager
  115918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115919. */
  115920. function PostProcessRenderPipelineManager() {
  115921. this._renderPipelines = {};
  115922. }
  115923. /**
  115924. * Adds a pipeline to the manager
  115925. * @param renderPipeline The pipeline to add
  115926. */
  115927. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  115928. this._renderPipelines[renderPipeline._name] = renderPipeline;
  115929. };
  115930. /**
  115931. * Attaches a camera to the pipeline
  115932. * @param renderPipelineName The name of the pipeline to attach to
  115933. * @param cameras the camera to attach
  115934. * @param unique if the camera can be attached multiple times to the pipeline
  115935. */
  115936. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  115937. if (unique === void 0) { unique = false; }
  115938. var renderPipeline = this._renderPipelines[renderPipelineName];
  115939. if (!renderPipeline) {
  115940. return;
  115941. }
  115942. renderPipeline._attachCameras(cameras, unique);
  115943. };
  115944. /**
  115945. * Detaches a camera from the pipeline
  115946. * @param renderPipelineName The name of the pipeline to detach from
  115947. * @param cameras the camera to detach
  115948. */
  115949. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  115950. var renderPipeline = this._renderPipelines[renderPipelineName];
  115951. if (!renderPipeline) {
  115952. return;
  115953. }
  115954. renderPipeline._detachCameras(cameras);
  115955. };
  115956. /**
  115957. * Enables an effect by name on a pipeline
  115958. * @param renderPipelineName the name of the pipeline to enable the effect in
  115959. * @param renderEffectName the name of the effect to enable
  115960. * @param cameras the cameras that the effect should be enabled on
  115961. */
  115962. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115963. var renderPipeline = this._renderPipelines[renderPipelineName];
  115964. if (!renderPipeline) {
  115965. return;
  115966. }
  115967. renderPipeline._enableEffect(renderEffectName, cameras);
  115968. };
  115969. /**
  115970. * Disables an effect by name on a pipeline
  115971. * @param renderPipelineName the name of the pipeline to disable the effect in
  115972. * @param renderEffectName the name of the effect to disable
  115973. * @param cameras the cameras that the effect should be disabled on
  115974. */
  115975. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115976. var renderPipeline = this._renderPipelines[renderPipelineName];
  115977. if (!renderPipeline) {
  115978. return;
  115979. }
  115980. renderPipeline._disableEffect(renderEffectName, cameras);
  115981. };
  115982. /**
  115983. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  115984. */
  115985. PostProcessRenderPipelineManager.prototype.update = function () {
  115986. for (var renderPipelineName in this._renderPipelines) {
  115987. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115988. var pipeline = this._renderPipelines[renderPipelineName];
  115989. if (!pipeline.isSupported) {
  115990. pipeline.dispose();
  115991. delete this._renderPipelines[renderPipelineName];
  115992. }
  115993. else {
  115994. pipeline._update();
  115995. }
  115996. }
  115997. }
  115998. };
  115999. /** @hidden */
  116000. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  116001. for (var renderPipelineName in this._renderPipelines) {
  116002. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116003. var pipeline = this._renderPipelines[renderPipelineName];
  116004. pipeline._rebuild();
  116005. }
  116006. }
  116007. };
  116008. /**
  116009. * Disposes of the manager and pipelines
  116010. */
  116011. PostProcessRenderPipelineManager.prototype.dispose = function () {
  116012. for (var renderPipelineName in this._renderPipelines) {
  116013. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116014. var pipeline = this._renderPipelines[renderPipelineName];
  116015. pipeline.dispose();
  116016. }
  116017. }
  116018. };
  116019. return PostProcessRenderPipelineManager;
  116020. }());
  116021. /***/ }),
  116022. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  116023. /*!****************************************************************************************!*\
  116024. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  116025. \****************************************************************************************/
  116026. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  116027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116028. "use strict";
  116029. __webpack_require__.r(__webpack_exports__);
  116030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  116031. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  116032. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116033. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  116034. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  116035. get: function () {
  116036. if (!this._postProcessRenderPipelineManager) {
  116037. // Register the G Buffer component to the scene.
  116038. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  116039. if (!component) {
  116040. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  116041. this._addComponent(component);
  116042. }
  116043. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  116044. }
  116045. return this._postProcessRenderPipelineManager;
  116046. },
  116047. enumerable: true,
  116048. configurable: true
  116049. });
  116050. /**
  116051. * Defines the Render Pipeline scene component responsible to rendering pipelines
  116052. */
  116053. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  116054. /**
  116055. * Creates a new instance of the component for the given scene
  116056. * @param scene Defines the scene to register the component in
  116057. */
  116058. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  116059. /**
  116060. * The component name helpfull to identify the component in the list of scene components.
  116061. */
  116062. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  116063. this.scene = scene;
  116064. }
  116065. /**
  116066. * Registers the component in a given scene
  116067. */
  116068. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  116069. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  116070. };
  116071. /**
  116072. * Rebuilds the elements related to this component in case of
  116073. * context lost for instance.
  116074. */
  116075. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  116076. if (this.scene._postProcessRenderPipelineManager) {
  116077. this.scene._postProcessRenderPipelineManager._rebuild();
  116078. }
  116079. };
  116080. /**
  116081. * Disposes the component and the associated ressources
  116082. */
  116083. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  116084. if (this.scene._postProcessRenderPipelineManager) {
  116085. this.scene._postProcessRenderPipelineManager.dispose();
  116086. }
  116087. };
  116088. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  116089. if (this.scene._postProcessRenderPipelineManager) {
  116090. this.scene._postProcessRenderPipelineManager.update();
  116091. }
  116092. };
  116093. return PostProcessRenderPipelineManagerSceneComponent;
  116094. }());
  116095. /***/ }),
  116096. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  116097. /*!**********************************************!*\
  116098. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  116099. \**********************************************/
  116100. /*! exports provided: AnaglyphPostProcess */
  116101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116102. "use strict";
  116103. __webpack_require__.r(__webpack_exports__);
  116104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  116105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116106. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116107. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  116108. /**
  116109. * Postprocess used to generate anaglyphic rendering
  116110. */
  116111. var AnaglyphPostProcess = /** @class */ (function (_super) {
  116112. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  116113. /**
  116114. * Creates a new AnaglyphPostProcess
  116115. * @param name defines postprocess name
  116116. * @param options defines creation options or target ratio scale
  116117. * @param rigCameras defines cameras using this postprocess
  116118. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116119. * @param engine defines hosting engine
  116120. * @param reusable defines if the postprocess will be reused multiple times per frame
  116121. */
  116122. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  116123. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  116124. _this._passedProcess = rigCameras[0]._rigPostProcess;
  116125. _this.onApplyObservable.add(function (effect) {
  116126. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  116127. });
  116128. return _this;
  116129. }
  116130. return AnaglyphPostProcess;
  116131. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116132. /***/ }),
  116133. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  116134. /*!***************************************************!*\
  116135. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  116136. \***************************************************/
  116137. /*! exports provided: BlackAndWhitePostProcess */
  116138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116139. "use strict";
  116140. __webpack_require__.r(__webpack_exports__);
  116141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  116142. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116143. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116144. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  116145. /**
  116146. * Post process used to render in black and white
  116147. */
  116148. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  116149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  116150. /**
  116151. * Creates a black and white post process
  116152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116153. * @param name The name of the effect.
  116154. * @param options The required width/height ratio to downsize to before computing the render pass.
  116155. * @param camera The camera to apply the render pass to.
  116156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116157. * @param engine The engine which the post process will be applied. (default: current engine)
  116158. * @param reusable If the post process can be reused on the same frame. (default: false)
  116159. */
  116160. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  116161. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  116162. /**
  116163. * Linear about to convert he result to black and white (default: 1)
  116164. */
  116165. _this.degree = 1;
  116166. _this.onApplyObservable.add(function (effect) {
  116167. effect.setFloat("degree", _this.degree);
  116168. });
  116169. return _this;
  116170. }
  116171. return BlackAndWhitePostProcess;
  116172. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116173. /***/ }),
  116174. /***/ "./PostProcesses/bloomEffect.ts":
  116175. /*!**************************************!*\
  116176. !*** ./PostProcesses/bloomEffect.ts ***!
  116177. \**************************************/
  116178. /*! exports provided: BloomEffect */
  116179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116180. "use strict";
  116181. __webpack_require__.r(__webpack_exports__);
  116182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  116183. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116184. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116185. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116186. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116187. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116188. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116189. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116190. /**
  116191. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116192. */
  116193. var BloomEffect = /** @class */ (function (_super) {
  116194. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  116195. /**
  116196. * Creates a new instance of @see BloomEffect
  116197. * @param scene The scene the effect belongs to.
  116198. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116199. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116200. * @param bloomWeight The the strength of bloom.
  116201. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116202. * @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)
  116203. */
  116204. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  116205. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116206. if (blockCompilation === void 0) { blockCompilation = false; }
  116207. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  116208. return _this._effects;
  116209. }, true) || this;
  116210. _this.bloomScale = bloomScale;
  116211. /**
  116212. * @hidden Internal
  116213. */
  116214. _this._effects = [];
  116215. _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);
  116216. _this._blurX = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("horizontal blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1.0, 0), 10.0, bloomScale, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, undefined, blockCompilation);
  116217. _this._blurX.alwaysForcePOT = true;
  116218. _this._blurX.autoClear = false;
  116219. _this._blurY = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("vertical blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 1.0), 10.0, bloomScale, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, undefined, blockCompilation);
  116220. _this._blurY.alwaysForcePOT = true;
  116221. _this._blurY.autoClear = false;
  116222. _this.kernel = bloomKernel;
  116223. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  116224. _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);
  116225. _this._merge.autoClear = false;
  116226. _this._effects.push(_this._merge);
  116227. return _this;
  116228. }
  116229. Object.defineProperty(BloomEffect.prototype, "threshold", {
  116230. /**
  116231. * The luminance threshold to find bright areas of the image to bloom.
  116232. */
  116233. get: function () {
  116234. return this._downscale.threshold;
  116235. },
  116236. set: function (value) {
  116237. this._downscale.threshold = value;
  116238. },
  116239. enumerable: true,
  116240. configurable: true
  116241. });
  116242. Object.defineProperty(BloomEffect.prototype, "weight", {
  116243. /**
  116244. * The strength of the bloom.
  116245. */
  116246. get: function () {
  116247. return this._merge.weight;
  116248. },
  116249. set: function (value) {
  116250. this._merge.weight = value;
  116251. },
  116252. enumerable: true,
  116253. configurable: true
  116254. });
  116255. Object.defineProperty(BloomEffect.prototype, "kernel", {
  116256. /**
  116257. * Specifies the size of the bloom blur kernel, relative to the final output size
  116258. */
  116259. get: function () {
  116260. return this._blurX.kernel / this.bloomScale;
  116261. },
  116262. set: function (value) {
  116263. this._blurX.kernel = value * this.bloomScale;
  116264. this._blurY.kernel = value * this.bloomScale;
  116265. },
  116266. enumerable: true,
  116267. configurable: true
  116268. });
  116269. /**
  116270. * Disposes each of the internal effects for a given camera.
  116271. * @param camera The camera to dispose the effect on.
  116272. */
  116273. BloomEffect.prototype.disposeEffects = function (camera) {
  116274. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116275. this._effects[effectIndex].dispose(camera);
  116276. }
  116277. };
  116278. /**
  116279. * @hidden Internal
  116280. */
  116281. BloomEffect.prototype._updateEffects = function () {
  116282. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116283. this._effects[effectIndex].updateEffect();
  116284. }
  116285. };
  116286. /**
  116287. * Internal
  116288. * @returns if all the contained post processes are ready.
  116289. * @hidden
  116290. */
  116291. BloomEffect.prototype._isReady = function () {
  116292. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116293. if (!this._effects[effectIndex].isReady()) {
  116294. return false;
  116295. }
  116296. }
  116297. return true;
  116298. };
  116299. return BloomEffect;
  116300. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  116301. /***/ }),
  116302. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  116303. /*!************************************************!*\
  116304. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  116305. \************************************************/
  116306. /*! exports provided: BloomMergePostProcess */
  116307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116308. "use strict";
  116309. __webpack_require__.r(__webpack_exports__);
  116310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  116311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116312. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116313. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116314. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  116315. /**
  116316. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116317. */
  116318. var BloomMergePostProcess = /** @class */ (function (_super) {
  116319. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  116320. /**
  116321. * Creates a new instance of @see BloomMergePostProcess
  116322. * @param name The name of the effect.
  116323. * @param originalFromInput Post process which's input will be used for the merge.
  116324. * @param blurred Blurred highlights post process which's output will be used.
  116325. * @param weight Weight of the bloom to be added to the original input.
  116326. * @param options The required width/height ratio to downsize to before computing the render pass.
  116327. * @param camera The camera to apply the render pass to.
  116328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116329. * @param engine The engine which the post process will be applied. (default: current engine)
  116330. * @param reusable If the post process can be reused on the same frame. (default: false)
  116331. * @param textureType Type of textures used when performing the post process. (default: 0)
  116332. * @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)
  116333. */
  116334. function BloomMergePostProcess(name, originalFromInput, blurred,
  116335. /** Weight of the bloom to be added to the original input. */
  116336. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116337. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116338. if (blockCompilation === void 0) { blockCompilation = false; }
  116339. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116340. _this.weight = weight;
  116341. _this.onApplyObservable.add(function (effect) {
  116342. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116343. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  116344. effect.setFloat("bloomWeight", _this.weight);
  116345. });
  116346. if (!blockCompilation) {
  116347. _this.updateEffect();
  116348. }
  116349. return _this;
  116350. }
  116351. return BloomMergePostProcess;
  116352. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116353. /***/ }),
  116354. /***/ "./PostProcesses/blurPostProcess.ts":
  116355. /*!******************************************!*\
  116356. !*** ./PostProcesses/blurPostProcess.ts ***!
  116357. \******************************************/
  116358. /*! exports provided: BlurPostProcess */
  116359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116360. "use strict";
  116361. __webpack_require__.r(__webpack_exports__);
  116362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  116363. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116364. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116366. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116367. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  116368. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  116369. /**
  116370. * The Blur Post Process which blurs an image based on a kernel and direction.
  116371. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  116372. */
  116373. var BlurPostProcess = /** @class */ (function (_super) {
  116374. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  116375. /**
  116376. * Creates a new instance BlurPostProcess
  116377. * @param name The name of the effect.
  116378. * @param direction The direction in which to blur the image.
  116379. * @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.
  116380. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  116381. * @param camera The camera to apply the render pass to.
  116382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116383. * @param engine The engine which the post process will be applied. (default: current engine)
  116384. * @param reusable If the post process can be reused on the same frame. (default: false)
  116385. * @param textureType Type of textures used when performing the post process. (default: 0)
  116386. * @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)
  116387. */
  116388. function BlurPostProcess(name,
  116389. /** The direction in which to blur the image. */
  116390. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  116391. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  116392. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116393. if (defines === void 0) { defines = ""; }
  116394. if (blockCompilation === void 0) { blockCompilation = false; }
  116395. 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;
  116396. _this.direction = direction;
  116397. _this.blockCompilation = blockCompilation;
  116398. _this._packedFloat = false;
  116399. _this._staticDefines = "";
  116400. _this._staticDefines = defines;
  116401. _this.onApplyObservable.add(function (effect) {
  116402. if (_this._outputTexture) {
  116403. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  116404. }
  116405. else {
  116406. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  116407. }
  116408. });
  116409. _this.kernel = kernel;
  116410. return _this;
  116411. }
  116412. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  116413. /**
  116414. * Gets the length in pixels of the blur sample region
  116415. */
  116416. get: function () {
  116417. return this._idealKernel;
  116418. },
  116419. /**
  116420. * Sets the length in pixels of the blur sample region
  116421. */
  116422. set: function (v) {
  116423. if (this._idealKernel === v) {
  116424. return;
  116425. }
  116426. v = Math.max(v, 1);
  116427. this._idealKernel = v;
  116428. this._kernel = this._nearestBestKernel(v);
  116429. if (!this.blockCompilation) {
  116430. this._updateParameters();
  116431. }
  116432. },
  116433. enumerable: true,
  116434. configurable: true
  116435. });
  116436. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  116437. /**
  116438. * Gets wether or not the blur is unpacking/repacking floats
  116439. */
  116440. get: function () {
  116441. return this._packedFloat;
  116442. },
  116443. /**
  116444. * Sets wether or not the blur needs to unpack/repack floats
  116445. */
  116446. set: function (v) {
  116447. if (this._packedFloat === v) {
  116448. return;
  116449. }
  116450. this._packedFloat = v;
  116451. if (!this.blockCompilation) {
  116452. this._updateParameters();
  116453. }
  116454. },
  116455. enumerable: true,
  116456. configurable: true
  116457. });
  116458. /**
  116459. * Updates the effect with the current post process compile time values and recompiles the shader.
  116460. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116461. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116462. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116463. * @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
  116464. * @param onCompiled Called when the shader has been compiled.
  116465. * @param onError Called if there is an error when compiling a shader.
  116466. */
  116467. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116468. if (defines === void 0) { defines = null; }
  116469. if (uniforms === void 0) { uniforms = null; }
  116470. if (samplers === void 0) { samplers = null; }
  116471. this._updateParameters(onCompiled, onError);
  116472. };
  116473. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  116474. // Generate sampling offsets and weights
  116475. var N = this._kernel;
  116476. var centerIndex = (N - 1) / 2;
  116477. // Generate Gaussian sampling weights over kernel
  116478. var offsets = [];
  116479. var weights = [];
  116480. var totalWeight = 0;
  116481. for (var i = 0; i < N; i++) {
  116482. var u = i / (N - 1);
  116483. var w = this._gaussianWeight(u * 2.0 - 1);
  116484. offsets[i] = (i - centerIndex);
  116485. weights[i] = w;
  116486. totalWeight += w;
  116487. }
  116488. // Normalize weights
  116489. for (var i = 0; i < weights.length; i++) {
  116490. weights[i] /= totalWeight;
  116491. }
  116492. // Optimize: combine samples to take advantage of hardware linear sampling
  116493. // Walk from left to center, combining pairs (symmetrically)
  116494. var linearSamplingWeights = [];
  116495. var linearSamplingOffsets = [];
  116496. var linearSamplingMap = [];
  116497. for (var i = 0; i <= centerIndex; i += 2) {
  116498. var j = Math.min(i + 1, Math.floor(centerIndex));
  116499. var singleCenterSample = i === j;
  116500. if (singleCenterSample) {
  116501. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116502. }
  116503. else {
  116504. var sharedCell = j === centerIndex;
  116505. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  116506. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  116507. if (offsetLinear === 0) {
  116508. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116509. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  116510. }
  116511. else {
  116512. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  116513. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  116514. }
  116515. }
  116516. }
  116517. for (var i = 0; i < linearSamplingMap.length; i++) {
  116518. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  116519. linearSamplingWeights[i] = linearSamplingMap[i].w;
  116520. }
  116521. // Replace with optimized
  116522. offsets = linearSamplingOffsets;
  116523. weights = linearSamplingWeights;
  116524. // Generate shaders
  116525. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  116526. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  116527. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  116528. var defines = "";
  116529. defines += this._staticDefines;
  116530. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  116531. if (this._staticDefines.indexOf("DOF") != -1) {
  116532. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  116533. varyingCount--;
  116534. }
  116535. for (var i = 0; i < varyingCount; i++) {
  116536. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  116537. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  116538. }
  116539. var depCount = 0;
  116540. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  116541. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  116542. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  116543. depCount++;
  116544. }
  116545. if (this.packedFloat) {
  116546. defines += "#define PACKEDFLOAT 1";
  116547. }
  116548. this.blockCompilation = false;
  116549. _super.prototype.updateEffect.call(this, defines, null, null, {
  116550. varyingCount: varyingCount,
  116551. depCount: depCount
  116552. }, onCompiled, onError);
  116553. };
  116554. /**
  116555. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  116556. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  116557. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  116558. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  116559. * The gaps between physical kernels are compensated for in the weighting of the samples
  116560. * @param idealKernel Ideal blur kernel.
  116561. * @return Nearest best kernel.
  116562. */
  116563. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  116564. var v = Math.round(idealKernel);
  116565. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  116566. var k = _a[_i];
  116567. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  116568. return Math.max(k, 3);
  116569. }
  116570. }
  116571. return Math.max(v, 3);
  116572. };
  116573. /**
  116574. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  116575. * @param x The point on the Gaussian distribution to sample.
  116576. * @return the value of the Gaussian function at x.
  116577. */
  116578. BlurPostProcess.prototype._gaussianWeight = function (x) {
  116579. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  116580. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  116581. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  116582. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  116583. // truncated at around 1.3% of peak strength.
  116584. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  116585. var sigma = (1 / 3);
  116586. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  116587. var exponent = -((x * x) / (2.0 * sigma * sigma));
  116588. var weight = (1.0 / denominator) * Math.exp(exponent);
  116589. return weight;
  116590. };
  116591. /**
  116592. * Generates a string that can be used as a floating point number in GLSL.
  116593. * @param x Value to print.
  116594. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  116595. * @return GLSL float string.
  116596. */
  116597. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  116598. if (decimalFigures === void 0) { decimalFigures = 8; }
  116599. return x.toFixed(decimalFigures).replace(/0+$/, '');
  116600. };
  116601. return BlurPostProcess;
  116602. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116603. /***/ }),
  116604. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  116605. /*!*********************************************************!*\
  116606. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  116607. \*********************************************************/
  116608. /*! exports provided: ChromaticAberrationPostProcess */
  116609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116610. "use strict";
  116611. __webpack_require__.r(__webpack_exports__);
  116612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  116613. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116614. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116615. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116616. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116617. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  116618. /**
  116619. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116620. */
  116621. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  116622. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  116623. /**
  116624. * Creates a new instance ChromaticAberrationPostProcess
  116625. * @param name The name of the effect.
  116626. * @param screenWidth The width of the screen to apply the effect on.
  116627. * @param screenHeight The height of the screen to apply the effect on.
  116628. * @param options The required width/height ratio to downsize to before computing the render pass.
  116629. * @param camera The camera to apply the render pass to.
  116630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116631. * @param engine The engine which the post process will be applied. (default: current engine)
  116632. * @param reusable If the post process can be reused on the same frame. (default: false)
  116633. * @param textureType Type of textures used when performing the post process. (default: 0)
  116634. * @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)
  116635. */
  116636. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116637. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116638. if (blockCompilation === void 0) { blockCompilation = false; }
  116639. 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;
  116640. /**
  116641. * The amount of seperation of rgb channels (default: 30)
  116642. */
  116643. _this.aberrationAmount = 30;
  116644. /**
  116645. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116646. */
  116647. _this.radialIntensity = 0;
  116648. /**
  116649. * 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))
  116650. */
  116651. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  116652. /**
  116653. * 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))
  116654. */
  116655. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  116656. _this.onApplyObservable.add(function (effect) {
  116657. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  116658. effect.setFloat('screen_width', screenWidth);
  116659. effect.setFloat('screen_height', screenHeight);
  116660. effect.setFloat('radialIntensity', _this.radialIntensity);
  116661. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  116662. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  116663. });
  116664. return _this;
  116665. }
  116666. return ChromaticAberrationPostProcess;
  116667. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116668. /***/ }),
  116669. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  116670. /*!*******************************************************!*\
  116671. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  116672. \*******************************************************/
  116673. /*! exports provided: CircleOfConfusionPostProcess */
  116674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116675. "use strict";
  116676. __webpack_require__.r(__webpack_exports__);
  116677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  116678. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116679. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116680. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116681. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116682. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  116683. /**
  116684. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116685. */
  116686. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  116687. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  116688. /**
  116689. * Creates a new instance CircleOfConfusionPostProcess
  116690. * @param name The name of the effect.
  116691. * @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.
  116692. * @param options The required width/height ratio to downsize to before computing the render pass.
  116693. * @param camera The camera to apply the render pass to.
  116694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116695. * @param engine The engine which the post process will be applied. (default: current engine)
  116696. * @param reusable If the post process can be reused on the same frame. (default: false)
  116697. * @param textureType Type of textures used when performing the post process. (default: 0)
  116698. * @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)
  116699. */
  116700. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116701. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116702. if (blockCompilation === void 0) { blockCompilation = false; }
  116703. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116704. /**
  116705. * 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.
  116706. */
  116707. _this.lensSize = 50;
  116708. /**
  116709. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116710. */
  116711. _this.fStop = 1.4;
  116712. /**
  116713. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116714. */
  116715. _this.focusDistance = 2000;
  116716. /**
  116717. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116718. */
  116719. _this.focalLength = 50;
  116720. _this._depthTexture = null;
  116721. _this._depthTexture = depthTexture;
  116722. _this.onApplyObservable.add(function (effect) {
  116723. if (!_this._depthTexture) {
  116724. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  116725. return;
  116726. }
  116727. effect.setTexture("depthSampler", _this._depthTexture);
  116728. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  116729. var aperture = _this.lensSize / _this.fStop;
  116730. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  116731. effect.setFloat('focusDistance', _this.focusDistance);
  116732. effect.setFloat('cocPrecalculation', cocPrecalculation);
  116733. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  116734. });
  116735. return _this;
  116736. }
  116737. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  116738. /**
  116739. * 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.
  116740. */
  116741. set: function (value) {
  116742. this._depthTexture = value;
  116743. },
  116744. enumerable: true,
  116745. configurable: true
  116746. });
  116747. return CircleOfConfusionPostProcess;
  116748. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116749. /***/ }),
  116750. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  116751. /*!*****************************************************!*\
  116752. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  116753. \*****************************************************/
  116754. /*! exports provided: ColorCorrectionPostProcess */
  116755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116756. "use strict";
  116757. __webpack_require__.r(__webpack_exports__);
  116758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  116759. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116760. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116761. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116762. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  116763. /**
  116764. *
  116765. * This post-process allows the modification of rendered colors by using
  116766. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116767. *
  116768. * The object needs to be provided an url to a texture containing the color
  116769. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116770. * Use an image editing software to tweak the LUT to match your needs.
  116771. *
  116772. * For an example of a color LUT, see here:
  116773. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116774. * For explanations on color grading, see here:
  116775. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116776. *
  116777. */
  116778. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  116779. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  116780. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  116781. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  116782. _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);
  116783. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  116784. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116785. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116786. _this.onApply = function (effect) {
  116787. effect.setTexture("colorTable", _this._colorTableTexture);
  116788. };
  116789. return _this;
  116790. }
  116791. return ColorCorrectionPostProcess;
  116792. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116793. /***/ }),
  116794. /***/ "./PostProcesses/convolutionPostProcess.ts":
  116795. /*!*************************************************!*\
  116796. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  116797. \*************************************************/
  116798. /*! exports provided: ConvolutionPostProcess */
  116799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116800. "use strict";
  116801. __webpack_require__.r(__webpack_exports__);
  116802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  116803. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116804. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116805. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116806. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  116807. /**
  116808. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  116809. * input texture to perform effects such as edge detection or sharpening
  116810. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  116811. */
  116812. var ConvolutionPostProcess = /** @class */ (function (_super) {
  116813. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  116814. /**
  116815. * Creates a new instance ConvolutionPostProcess
  116816. * @param name The name of the effect.
  116817. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  116818. * @param options The required width/height ratio to downsize to before computing the render pass.
  116819. * @param camera The camera to apply the render pass to.
  116820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116821. * @param engine The engine which the post process will be applied. (default: current engine)
  116822. * @param reusable If the post process can be reused on the same frame. (default: false)
  116823. * @param textureType Type of textures used when performing the post process. (default: 0)
  116824. */
  116825. function ConvolutionPostProcess(name,
  116826. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116827. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  116828. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116829. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116830. _this.kernel = kernel;
  116831. _this.onApply = function (effect) {
  116832. effect.setFloat2("screenSize", _this.width, _this.height);
  116833. effect.setArray("kernel", _this.kernel);
  116834. };
  116835. return _this;
  116836. }
  116837. // Statics
  116838. /**
  116839. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116840. */
  116841. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  116842. /**
  116843. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116844. */
  116845. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  116846. /**
  116847. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116848. */
  116849. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  116850. /**
  116851. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116852. */
  116853. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  116854. /**
  116855. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116856. */
  116857. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  116858. /**
  116859. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116860. */
  116861. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  116862. return ConvolutionPostProcess;
  116863. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116864. /***/ }),
  116865. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  116866. /*!******************************************************!*\
  116867. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  116868. \******************************************************/
  116869. /*! exports provided: DepthOfFieldBlurPostProcess */
  116870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116871. "use strict";
  116872. __webpack_require__.r(__webpack_exports__);
  116873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  116874. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116875. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116876. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116877. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116878. /**
  116879. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  116880. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  116881. * based on samples that have a large difference in distance than the center pixel.
  116882. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116883. */
  116884. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  116885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  116886. /**
  116887. * Creates a new instance CircleOfConfusionPostProcess
  116888. * @param name The name of the effect.
  116889. * @param scene The scene the effect belongs to.
  116890. * @param direction The direction the blur should be applied.
  116891. * @param kernel The size of the kernel used to blur.
  116892. * @param options The required width/height ratio to downsize to before computing the render pass.
  116893. * @param camera The camera to apply the render pass to.
  116894. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  116895. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  116896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116897. * @param engine The engine which the post process will be applied. (default: current engine)
  116898. * @param reusable If the post process can be reused on the same frame. (default: false)
  116899. * @param textureType Type of textures used when performing the post process. (default: 0)
  116900. * @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)
  116901. */
  116902. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  116903. if (imageToBlur === void 0) { imageToBlur = null; }
  116904. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  116905. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116906. if (blockCompilation === void 0) { blockCompilation = false; }
  116907. 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;
  116908. _this.direction = direction;
  116909. _this.onApplyObservable.add(function (effect) {
  116910. if (imageToBlur != null) {
  116911. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  116912. }
  116913. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116914. if (scene.activeCamera) {
  116915. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  116916. }
  116917. });
  116918. return _this;
  116919. }
  116920. return DepthOfFieldBlurPostProcess;
  116921. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  116922. /***/ }),
  116923. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  116924. /*!*********************************************!*\
  116925. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  116926. \*********************************************/
  116927. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  116928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116929. "use strict";
  116930. __webpack_require__.r(__webpack_exports__);
  116931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  116932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  116933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116934. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116935. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116936. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116937. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  116938. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  116939. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  116940. /**
  116941. * Specifies the level of max blur that should be applied when using the depth of field effect
  116942. */
  116943. var DepthOfFieldEffectBlurLevel;
  116944. (function (DepthOfFieldEffectBlurLevel) {
  116945. /**
  116946. * Subtle blur
  116947. */
  116948. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  116949. /**
  116950. * Medium blur
  116951. */
  116952. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  116953. /**
  116954. * Large blur
  116955. */
  116956. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  116957. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  116958. /**
  116959. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  116960. */
  116961. var DepthOfFieldEffect = /** @class */ (function (_super) {
  116962. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  116963. /**
  116964. * Creates a new instance DepthOfFieldEffect
  116965. * @param scene The scene the effect belongs to.
  116966. * @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.
  116967. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116968. * @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)
  116969. */
  116970. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  116971. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  116972. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116973. if (blockCompilation === void 0) { blockCompilation = false; }
  116974. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  116975. return _this._effects;
  116976. }, true) || this;
  116977. /**
  116978. * @hidden Internal post processes in depth of field effect
  116979. */
  116980. _this._effects = [];
  116981. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  116982. _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);
  116983. // 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)
  116984. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  116985. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116986. _this._depthOfFieldBlurY = [];
  116987. _this._depthOfFieldBlurX = [];
  116988. var blurCount = 1;
  116989. var kernelSize = 15;
  116990. switch (blurLevel) {
  116991. case DepthOfFieldEffectBlurLevel.High: {
  116992. blurCount = 3;
  116993. kernelSize = 51;
  116994. break;
  116995. }
  116996. case DepthOfFieldEffectBlurLevel.Medium: {
  116997. blurCount = 2;
  116998. kernelSize = 31;
  116999. break;
  117000. }
  117001. default: {
  117002. kernelSize = 15;
  117003. blurCount = 1;
  117004. break;
  117005. }
  117006. }
  117007. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  117008. var ratio = 1.0;
  117009. for (var i = 0; i < blurCount; i++) {
  117010. var blurY = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("verticle blur", scene, new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1.0), adjustedKernelSize, ratio, null, _this._circleOfConfusion, i == 0 ? _this._circleOfConfusion : null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  117011. blurY.autoClear = false;
  117012. ratio = 0.75 / Math.pow(2, i);
  117013. var blurX = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("horizontal blur", scene, new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1.0, 0), adjustedKernelSize, ratio, null, _this._circleOfConfusion, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  117014. blurX.autoClear = false;
  117015. _this._depthOfFieldBlurY.push(blurY);
  117016. _this._depthOfFieldBlurX.push(blurX);
  117017. }
  117018. // Set all post processes on the effect.
  117019. _this._effects = [_this._circleOfConfusion];
  117020. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  117021. _this._effects.push(_this._depthOfFieldBlurY[i]);
  117022. _this._effects.push(_this._depthOfFieldBlurX[i]);
  117023. }
  117024. // Merge blurred images with original image based on circleOfConfusion
  117025. _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);
  117026. _this._dofMerge.autoClear = false;
  117027. _this._effects.push(_this._dofMerge);
  117028. return _this;
  117029. }
  117030. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  117031. get: function () {
  117032. return this._circleOfConfusion.focalLength;
  117033. },
  117034. /**
  117035. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117036. */
  117037. set: function (value) {
  117038. this._circleOfConfusion.focalLength = value;
  117039. },
  117040. enumerable: true,
  117041. configurable: true
  117042. });
  117043. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  117044. get: function () {
  117045. return this._circleOfConfusion.fStop;
  117046. },
  117047. /**
  117048. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117049. */
  117050. set: function (value) {
  117051. this._circleOfConfusion.fStop = value;
  117052. },
  117053. enumerable: true,
  117054. configurable: true
  117055. });
  117056. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  117057. get: function () {
  117058. return this._circleOfConfusion.focusDistance;
  117059. },
  117060. /**
  117061. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117062. */
  117063. set: function (value) {
  117064. this._circleOfConfusion.focusDistance = value;
  117065. },
  117066. enumerable: true,
  117067. configurable: true
  117068. });
  117069. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  117070. get: function () {
  117071. return this._circleOfConfusion.lensSize;
  117072. },
  117073. /**
  117074. * 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.
  117075. */
  117076. set: function (value) {
  117077. this._circleOfConfusion.lensSize = value;
  117078. },
  117079. enumerable: true,
  117080. configurable: true
  117081. });
  117082. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  117083. /**
  117084. * 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.
  117085. */
  117086. set: function (value) {
  117087. this._circleOfConfusion.depthTexture = value;
  117088. },
  117089. enumerable: true,
  117090. configurable: true
  117091. });
  117092. /**
  117093. * Disposes each of the internal effects for a given camera.
  117094. * @param camera The camera to dispose the effect on.
  117095. */
  117096. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  117097. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117098. this._effects[effectIndex].dispose(camera);
  117099. }
  117100. };
  117101. /**
  117102. * @hidden Internal
  117103. */
  117104. DepthOfFieldEffect.prototype._updateEffects = function () {
  117105. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117106. this._effects[effectIndex].updateEffect();
  117107. }
  117108. };
  117109. /**
  117110. * Internal
  117111. * @returns if all the contained post processes are ready.
  117112. * @hidden
  117113. */
  117114. DepthOfFieldEffect.prototype._isReady = function () {
  117115. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117116. if (!this._effects[effectIndex].isReady()) {
  117117. return false;
  117118. }
  117119. }
  117120. return true;
  117121. };
  117122. return DepthOfFieldEffect;
  117123. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  117124. /***/ }),
  117125. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  117126. /*!*******************************************************!*\
  117127. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  117128. \*******************************************************/
  117129. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  117130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117131. "use strict";
  117132. __webpack_require__.r(__webpack_exports__);
  117133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  117134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  117135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117136. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117137. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117138. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  117139. /**
  117140. * Options to be set when merging outputs from the default pipeline.
  117141. */
  117142. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  117143. function DepthOfFieldMergePostProcessOptions() {
  117144. }
  117145. return DepthOfFieldMergePostProcessOptions;
  117146. }());
  117147. /**
  117148. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117149. */
  117150. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  117151. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  117152. /**
  117153. * Creates a new instance of DepthOfFieldMergePostProcess
  117154. * @param name The name of the effect.
  117155. * @param originalFromInput Post process which's input will be used for the merge.
  117156. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117157. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117158. * @param options The required width/height ratio to downsize to before computing the render pass.
  117159. * @param camera The camera to apply the render pass to.
  117160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117161. * @param engine The engine which the post process will be applied. (default: current engine)
  117162. * @param reusable If the post process can be reused on the same frame. (default: false)
  117163. * @param textureType Type of textures used when performing the post process. (default: 0)
  117164. * @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)
  117165. */
  117166. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117167. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117168. if (blockCompilation === void 0) { blockCompilation = false; }
  117169. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  117170. _this.blurSteps = blurSteps;
  117171. _this.onApplyObservable.add(function (effect) {
  117172. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  117173. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117174. blurSteps.forEach(function (step, index) {
  117175. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  117176. });
  117177. });
  117178. if (!blockCompilation) {
  117179. _this.updateEffect();
  117180. }
  117181. return _this;
  117182. }
  117183. /**
  117184. * Updates the effect with the current post process compile time values and recompiles the shader.
  117185. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117186. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117187. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117188. * @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
  117189. * @param onCompiled Called when the shader has been compiled.
  117190. * @param onError Called if there is an error when compiling a shader.
  117191. */
  117192. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117193. if (defines === void 0) { defines = null; }
  117194. if (uniforms === void 0) { uniforms = null; }
  117195. if (samplers === void 0) { samplers = null; }
  117196. if (!defines) {
  117197. defines = "";
  117198. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  117199. }
  117200. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  117201. };
  117202. return DepthOfFieldMergePostProcess;
  117203. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117204. /***/ }),
  117205. /***/ "./PostProcesses/displayPassPostProcess.ts":
  117206. /*!*************************************************!*\
  117207. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  117208. \*************************************************/
  117209. /*! exports provided: DisplayPassPostProcess */
  117210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117211. "use strict";
  117212. __webpack_require__.r(__webpack_exports__);
  117213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  117214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117215. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117216. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  117217. /**
  117218. * DisplayPassPostProcess which produces an output the same as it's input
  117219. */
  117220. var DisplayPassPostProcess = /** @class */ (function (_super) {
  117221. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  117222. /**
  117223. * Creates the DisplayPassPostProcess
  117224. * @param name The name of the effect.
  117225. * @param options The required width/height ratio to downsize to before computing the render pass.
  117226. * @param camera The camera to apply the render pass to.
  117227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117228. * @param engine The engine which the post process will be applied. (default: current engine)
  117229. * @param reusable If the post process can be reused on the same frame. (default: false)
  117230. */
  117231. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  117232. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  117233. }
  117234. return DisplayPassPostProcess;
  117235. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117236. /***/ }),
  117237. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  117238. /*!*******************************************************!*\
  117239. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  117240. \*******************************************************/
  117241. /*! exports provided: ExtractHighlightsPostProcess */
  117242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117243. "use strict";
  117244. __webpack_require__.r(__webpack_exports__);
  117245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  117246. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117247. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117248. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117249. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117250. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  117251. /**
  117252. * 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.
  117253. */
  117254. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  117255. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  117256. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117257. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117258. if (blockCompilation === void 0) { blockCompilation = false; }
  117259. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117260. /**
  117261. * The luminance threshold, pixels below this value will be set to black.
  117262. */
  117263. _this.threshold = 0.9;
  117264. /** @hidden */
  117265. _this._exposure = 1;
  117266. /**
  117267. * Post process which has the input texture to be used when performing highlight extraction
  117268. * @hidden
  117269. */
  117270. _this._inputPostProcess = null;
  117271. _this.onApplyObservable.add(function (effect) {
  117272. if (_this._inputPostProcess) {
  117273. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  117274. }
  117275. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  117276. effect.setFloat('exposure', _this._exposure);
  117277. });
  117278. return _this;
  117279. }
  117280. return ExtractHighlightsPostProcess;
  117281. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117282. /***/ }),
  117283. /***/ "./PostProcesses/filterPostProcess.ts":
  117284. /*!********************************************!*\
  117285. !*** ./PostProcesses/filterPostProcess.ts ***!
  117286. \********************************************/
  117287. /*! exports provided: FilterPostProcess */
  117288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117289. "use strict";
  117290. __webpack_require__.r(__webpack_exports__);
  117291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  117292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117293. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117294. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  117295. /**
  117296. * Applies a kernel filter to the image
  117297. */
  117298. var FilterPostProcess = /** @class */ (function (_super) {
  117299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  117300. /**
  117301. *
  117302. * @param name The name of the effect.
  117303. * @param kernelMatrix The matrix to be applied to the image
  117304. * @param options The required width/height ratio to downsize to before computing the render pass.
  117305. * @param camera The camera to apply the render pass to.
  117306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117307. * @param engine The engine which the post process will be applied. (default: current engine)
  117308. * @param reusable If the post process can be reused on the same frame. (default: false)
  117309. */
  117310. function FilterPostProcess(name,
  117311. /** The matrix to be applied to the image */
  117312. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  117313. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  117314. _this.kernelMatrix = kernelMatrix;
  117315. _this.onApply = function (effect) {
  117316. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  117317. };
  117318. return _this;
  117319. }
  117320. return FilterPostProcess;
  117321. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117322. /***/ }),
  117323. /***/ "./PostProcesses/fxaaPostProcess.ts":
  117324. /*!******************************************!*\
  117325. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  117326. \******************************************/
  117327. /*! exports provided: FxaaPostProcess */
  117328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117329. "use strict";
  117330. __webpack_require__.r(__webpack_exports__);
  117331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  117332. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117333. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117334. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117335. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117336. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  117337. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  117338. /**
  117339. * Fxaa post process
  117340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117341. */
  117342. var FxaaPostProcess = /** @class */ (function (_super) {
  117343. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  117344. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117345. if (camera === void 0) { camera = null; }
  117346. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117347. 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;
  117348. var defines = _this._getDefines();
  117349. _this.updateEffect(defines);
  117350. _this.onApplyObservable.add(function (effect) {
  117351. var texelSize = _this.texelSize;
  117352. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  117353. });
  117354. return _this;
  117355. }
  117356. FxaaPostProcess.prototype._getDefines = function () {
  117357. var engine = this.getEngine();
  117358. if (!engine) {
  117359. return null;
  117360. }
  117361. var glInfo = engine.getGlInfo();
  117362. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  117363. return "#define MALI 1\n";
  117364. }
  117365. return null;
  117366. };
  117367. return FxaaPostProcess;
  117368. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117369. /***/ }),
  117370. /***/ "./PostProcesses/grainPostProcess.ts":
  117371. /*!*******************************************!*\
  117372. !*** ./PostProcesses/grainPostProcess.ts ***!
  117373. \*******************************************/
  117374. /*! exports provided: GrainPostProcess */
  117375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117376. "use strict";
  117377. __webpack_require__.r(__webpack_exports__);
  117378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  117379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117380. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117381. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117382. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  117383. /**
  117384. * The GrainPostProcess adds noise to the image at mid luminance levels
  117385. */
  117386. var GrainPostProcess = /** @class */ (function (_super) {
  117387. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  117388. /**
  117389. * Creates a new instance of @see GrainPostProcess
  117390. * @param name The name of the effect.
  117391. * @param options The required width/height ratio to downsize to before computing the render pass.
  117392. * @param camera The camera to apply the render pass to.
  117393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117394. * @param engine The engine which the post process will be applied. (default: current engine)
  117395. * @param reusable If the post process can be reused on the same frame. (default: false)
  117396. * @param textureType Type of textures used when performing the post process. (default: 0)
  117397. * @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)
  117398. */
  117399. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117400. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117401. if (blockCompilation === void 0) { blockCompilation = false; }
  117402. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117403. /**
  117404. * The intensity of the grain added (default: 30)
  117405. */
  117406. _this.intensity = 30;
  117407. /**
  117408. * If the grain should be randomized on every frame
  117409. */
  117410. _this.animated = false;
  117411. _this.onApplyObservable.add(function (effect) {
  117412. effect.setFloat('intensity', _this.intensity);
  117413. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  117414. });
  117415. return _this;
  117416. }
  117417. return GrainPostProcess;
  117418. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117419. /***/ }),
  117420. /***/ "./PostProcesses/highlightsPostProcess.ts":
  117421. /*!************************************************!*\
  117422. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  117423. \************************************************/
  117424. /*! exports provided: HighlightsPostProcess */
  117425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117426. "use strict";
  117427. __webpack_require__.r(__webpack_exports__);
  117428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  117429. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117430. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117431. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117432. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  117433. /**
  117434. * Extracts highlights from the image
  117435. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117436. */
  117437. var HighlightsPostProcess = /** @class */ (function (_super) {
  117438. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  117439. /**
  117440. * Extracts highlights from the image
  117441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117442. * @param name The name of the effect.
  117443. * @param options The required width/height ratio to downsize to before computing the render pass.
  117444. * @param camera The camera to apply the render pass to.
  117445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117446. * @param engine The engine which the post process will be applied. (default: current engine)
  117447. * @param reusable If the post process can be reused on the same frame. (default: false)
  117448. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117449. */
  117450. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117451. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117452. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117453. }
  117454. return HighlightsPostProcess;
  117455. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117456. /***/ }),
  117457. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  117458. /*!*****************************************************!*\
  117459. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  117460. \*****************************************************/
  117461. /*! exports provided: ImageProcessingPostProcess */
  117462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117463. "use strict";
  117464. __webpack_require__.r(__webpack_exports__);
  117465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  117466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117467. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117468. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  117469. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117470. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117471. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117472. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  117473. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117474. /**
  117475. * ImageProcessingPostProcess
  117476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117477. */
  117478. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  117479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  117480. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  117481. if (camera === void 0) { camera = null; }
  117482. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117483. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  117484. _this._fromLinearSpace = true;
  117485. /**
  117486. * Defines cache preventing GC.
  117487. */
  117488. _this._defines = {
  117489. IMAGEPROCESSING: false,
  117490. VIGNETTE: false,
  117491. VIGNETTEBLENDMODEMULTIPLY: false,
  117492. VIGNETTEBLENDMODEOPAQUE: false,
  117493. TONEMAPPING: false,
  117494. TONEMAPPING_ACES: false,
  117495. CONTRAST: false,
  117496. COLORCURVES: false,
  117497. COLORGRADING: false,
  117498. COLORGRADING3D: false,
  117499. FROMLINEARSPACE: false,
  117500. SAMPLER3DGREENDEPTH: false,
  117501. SAMPLER3DBGRMAP: false,
  117502. IMAGEPROCESSINGPOSTPROCESS: false,
  117503. EXPOSURE: false,
  117504. };
  117505. // Setup the configuration as forced by the constructor. This would then not force the
  117506. // scene materials output in linear space and let untouched the default forward pass.
  117507. if (imageProcessingConfiguration) {
  117508. imageProcessingConfiguration.applyByPostProcess = true;
  117509. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  117510. // This will cause the shader to be compiled
  117511. _this.fromLinearSpace = false;
  117512. }
  117513. // Setup the default processing configuration to the scene.
  117514. else {
  117515. _this._attachImageProcessingConfiguration(null, true);
  117516. _this.imageProcessingConfiguration.applyByPostProcess = true;
  117517. }
  117518. _this.onApply = function (effect) {
  117519. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  117520. };
  117521. return _this;
  117522. }
  117523. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  117524. /**
  117525. * Gets the image processing configuration used either in this material.
  117526. */
  117527. get: function () {
  117528. return this._imageProcessingConfiguration;
  117529. },
  117530. /**
  117531. * Sets the Default image processing configuration used either in the this material.
  117532. *
  117533. * If sets to null, the scene one is in use.
  117534. */
  117535. set: function (value) {
  117536. this._attachImageProcessingConfiguration(value);
  117537. },
  117538. enumerable: true,
  117539. configurable: true
  117540. });
  117541. /**
  117542. * Attaches a new image processing configuration to the PBR Material.
  117543. * @param configuration
  117544. */
  117545. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  117546. var _this = this;
  117547. if (doNotBuild === void 0) { doNotBuild = false; }
  117548. if (configuration === this._imageProcessingConfiguration) {
  117549. return;
  117550. }
  117551. // Detaches observer.
  117552. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117553. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117554. }
  117555. // Pick the scene configuration if needed.
  117556. if (!configuration) {
  117557. var scene = null;
  117558. var engine = this.getEngine();
  117559. var camera = this.getCamera();
  117560. if (camera) {
  117561. scene = camera.getScene();
  117562. }
  117563. else if (engine && engine.scenes) {
  117564. var scenes = engine.scenes;
  117565. scene = scenes[scenes.length - 1];
  117566. }
  117567. else {
  117568. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  117569. }
  117570. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  117571. }
  117572. else {
  117573. this._imageProcessingConfiguration = configuration;
  117574. }
  117575. // Attaches observer.
  117576. if (this._imageProcessingConfiguration) {
  117577. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  117578. _this._updateParameters();
  117579. });
  117580. }
  117581. // Ensure the effect will be rebuilt.
  117582. if (!doNotBuild) {
  117583. this._updateParameters();
  117584. }
  117585. };
  117586. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  117587. /**
  117588. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117589. */
  117590. get: function () {
  117591. return this.imageProcessingConfiguration.colorCurves;
  117592. },
  117593. /**
  117594. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117595. */
  117596. set: function (value) {
  117597. this.imageProcessingConfiguration.colorCurves = value;
  117598. },
  117599. enumerable: true,
  117600. configurable: true
  117601. });
  117602. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  117603. /**
  117604. * Gets wether the color curves effect is enabled.
  117605. */
  117606. get: function () {
  117607. return this.imageProcessingConfiguration.colorCurvesEnabled;
  117608. },
  117609. /**
  117610. * Sets wether the color curves effect is enabled.
  117611. */
  117612. set: function (value) {
  117613. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  117614. },
  117615. enumerable: true,
  117616. configurable: true
  117617. });
  117618. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  117619. /**
  117620. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117621. */
  117622. get: function () {
  117623. return this.imageProcessingConfiguration.colorGradingTexture;
  117624. },
  117625. /**
  117626. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117627. */
  117628. set: function (value) {
  117629. this.imageProcessingConfiguration.colorGradingTexture = value;
  117630. },
  117631. enumerable: true,
  117632. configurable: true
  117633. });
  117634. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  117635. /**
  117636. * Gets wether the color grading effect is enabled.
  117637. */
  117638. get: function () {
  117639. return this.imageProcessingConfiguration.colorGradingEnabled;
  117640. },
  117641. /**
  117642. * Gets wether the color grading effect is enabled.
  117643. */
  117644. set: function (value) {
  117645. this.imageProcessingConfiguration.colorGradingEnabled = value;
  117646. },
  117647. enumerable: true,
  117648. configurable: true
  117649. });
  117650. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  117651. /**
  117652. * Gets exposure used in the effect.
  117653. */
  117654. get: function () {
  117655. return this.imageProcessingConfiguration.exposure;
  117656. },
  117657. /**
  117658. * Sets exposure used in the effect.
  117659. */
  117660. set: function (value) {
  117661. this.imageProcessingConfiguration.exposure = value;
  117662. },
  117663. enumerable: true,
  117664. configurable: true
  117665. });
  117666. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  117667. /**
  117668. * Gets wether tonemapping is enabled or not.
  117669. */
  117670. get: function () {
  117671. return this._imageProcessingConfiguration.toneMappingEnabled;
  117672. },
  117673. /**
  117674. * Sets wether tonemapping is enabled or not
  117675. */
  117676. set: function (value) {
  117677. this._imageProcessingConfiguration.toneMappingEnabled = value;
  117678. },
  117679. enumerable: true,
  117680. configurable: true
  117681. });
  117682. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  117683. /**
  117684. * Gets contrast used in the effect.
  117685. */
  117686. get: function () {
  117687. return this.imageProcessingConfiguration.contrast;
  117688. },
  117689. /**
  117690. * Sets contrast used in the effect.
  117691. */
  117692. set: function (value) {
  117693. this.imageProcessingConfiguration.contrast = value;
  117694. },
  117695. enumerable: true,
  117696. configurable: true
  117697. });
  117698. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  117699. /**
  117700. * Gets Vignette stretch size.
  117701. */
  117702. get: function () {
  117703. return this.imageProcessingConfiguration.vignetteStretch;
  117704. },
  117705. /**
  117706. * Sets Vignette stretch size.
  117707. */
  117708. set: function (value) {
  117709. this.imageProcessingConfiguration.vignetteStretch = value;
  117710. },
  117711. enumerable: true,
  117712. configurable: true
  117713. });
  117714. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  117715. /**
  117716. * Gets Vignette centre X Offset.
  117717. */
  117718. get: function () {
  117719. return this.imageProcessingConfiguration.vignetteCentreX;
  117720. },
  117721. /**
  117722. * Sets Vignette centre X Offset.
  117723. */
  117724. set: function (value) {
  117725. this.imageProcessingConfiguration.vignetteCentreX = value;
  117726. },
  117727. enumerable: true,
  117728. configurable: true
  117729. });
  117730. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  117731. /**
  117732. * Gets Vignette centre Y Offset.
  117733. */
  117734. get: function () {
  117735. return this.imageProcessingConfiguration.vignetteCentreY;
  117736. },
  117737. /**
  117738. * Sets Vignette centre Y Offset.
  117739. */
  117740. set: function (value) {
  117741. this.imageProcessingConfiguration.vignetteCentreY = value;
  117742. },
  117743. enumerable: true,
  117744. configurable: true
  117745. });
  117746. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  117747. /**
  117748. * Gets Vignette weight or intensity of the vignette effect.
  117749. */
  117750. get: function () {
  117751. return this.imageProcessingConfiguration.vignetteWeight;
  117752. },
  117753. /**
  117754. * Sets Vignette weight or intensity of the vignette effect.
  117755. */
  117756. set: function (value) {
  117757. this.imageProcessingConfiguration.vignetteWeight = value;
  117758. },
  117759. enumerable: true,
  117760. configurable: true
  117761. });
  117762. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  117763. /**
  117764. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117765. * if vignetteEnabled is set to true.
  117766. */
  117767. get: function () {
  117768. return this.imageProcessingConfiguration.vignetteColor;
  117769. },
  117770. /**
  117771. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117772. * if vignetteEnabled is set to true.
  117773. */
  117774. set: function (value) {
  117775. this.imageProcessingConfiguration.vignetteColor = value;
  117776. },
  117777. enumerable: true,
  117778. configurable: true
  117779. });
  117780. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  117781. /**
  117782. * Gets Camera field of view used by the Vignette effect.
  117783. */
  117784. get: function () {
  117785. return this.imageProcessingConfiguration.vignetteCameraFov;
  117786. },
  117787. /**
  117788. * Sets Camera field of view used by the Vignette effect.
  117789. */
  117790. set: function (value) {
  117791. this.imageProcessingConfiguration.vignetteCameraFov = value;
  117792. },
  117793. enumerable: true,
  117794. configurable: true
  117795. });
  117796. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  117797. /**
  117798. * Gets the vignette blend mode allowing different kind of effect.
  117799. */
  117800. get: function () {
  117801. return this.imageProcessingConfiguration.vignetteBlendMode;
  117802. },
  117803. /**
  117804. * Sets the vignette blend mode allowing different kind of effect.
  117805. */
  117806. set: function (value) {
  117807. this.imageProcessingConfiguration.vignetteBlendMode = value;
  117808. },
  117809. enumerable: true,
  117810. configurable: true
  117811. });
  117812. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  117813. /**
  117814. * Gets wether the vignette effect is enabled.
  117815. */
  117816. get: function () {
  117817. return this.imageProcessingConfiguration.vignetteEnabled;
  117818. },
  117819. /**
  117820. * Sets wether the vignette effect is enabled.
  117821. */
  117822. set: function (value) {
  117823. this.imageProcessingConfiguration.vignetteEnabled = value;
  117824. },
  117825. enumerable: true,
  117826. configurable: true
  117827. });
  117828. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  117829. /**
  117830. * Gets wether the input of the processing is in Gamma or Linear Space.
  117831. */
  117832. get: function () {
  117833. return this._fromLinearSpace;
  117834. },
  117835. /**
  117836. * Sets wether the input of the processing is in Gamma or Linear Space.
  117837. */
  117838. set: function (value) {
  117839. if (this._fromLinearSpace === value) {
  117840. return;
  117841. }
  117842. this._fromLinearSpace = value;
  117843. this._updateParameters();
  117844. },
  117845. enumerable: true,
  117846. configurable: true
  117847. });
  117848. /**
  117849. * "ImageProcessingPostProcess"
  117850. * @returns "ImageProcessingPostProcess"
  117851. */
  117852. ImageProcessingPostProcess.prototype.getClassName = function () {
  117853. return "ImageProcessingPostProcess";
  117854. };
  117855. ImageProcessingPostProcess.prototype._updateParameters = function () {
  117856. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  117857. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  117858. var defines = "";
  117859. for (var define in this._defines) {
  117860. if (this._defines[define]) {
  117861. defines += "#define " + define + ";\r\n";
  117862. }
  117863. }
  117864. var samplers = ["textureSampler"];
  117865. var uniforms = ["scale"];
  117866. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  117867. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  117868. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  117869. }
  117870. this.updateEffect(defines, uniforms, samplers);
  117871. };
  117872. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  117873. _super.prototype.dispose.call(this, camera);
  117874. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117875. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117876. }
  117877. if (this._imageProcessingConfiguration) {
  117878. this.imageProcessingConfiguration.applyByPostProcess = false;
  117879. }
  117880. };
  117881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117883. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  117884. return ImageProcessingPostProcess;
  117885. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117886. /***/ }),
  117887. /***/ "./PostProcesses/index.ts":
  117888. /*!********************************!*\
  117889. !*** ./PostProcesses/index.ts ***!
  117890. \********************************/
  117891. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  117892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117893. "use strict";
  117894. __webpack_require__.r(__webpack_exports__);
  117895. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  117896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  117897. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  117898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  117899. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  117901. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  117902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  117903. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  117905. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  117907. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  117909. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  117910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  117911. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  117912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  117913. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  117915. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  117917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  117918. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  117920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  117921. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  117922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  117923. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  117924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  117925. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  117926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  117927. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  117929. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  117931. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  117932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  117933. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  117934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  117935. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  117936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  117937. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  117938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  117939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  117940. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  117942. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  117943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  117944. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  117945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  117946. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  117947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  117948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  117949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  117950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  117951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  117952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  117953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  117954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  117955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  117956. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  117957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  117958. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  117959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  117960. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  117961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  117962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  117963. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  117964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  117965. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  117966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  117967. /***/ }),
  117968. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  117969. /*!************************************************!*\
  117970. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  117971. \************************************************/
  117972. /*! exports provided: MotionBlurPostProcess */
  117973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117974. "use strict";
  117975. __webpack_require__.r(__webpack_exports__);
  117976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  117977. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117978. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117980. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117981. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117982. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  117983. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  117984. /**
  117985. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117986. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117987. * As an example, all you have to do is to create the post-process:
  117988. * var mb = new BABYLON.MotionBlurPostProcess(
  117989. * 'mb', // The name of the effect.
  117990. * scene, // The scene containing the objects to blur according to their velocity.
  117991. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117992. * camera // The camera to apply the render pass to.
  117993. * );
  117994. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117995. */
  117996. var MotionBlurPostProcess = /** @class */ (function (_super) {
  117997. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  117998. /**
  117999. * Creates a new instance MotionBlurPostProcess
  118000. * @param name The name of the effect.
  118001. * @param scene The scene containing the objects to blur according to their velocity.
  118002. * @param options The required width/height ratio to downsize to before computing the render pass.
  118003. * @param camera The camera to apply the render pass to.
  118004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118005. * @param engine The engine which the post process will be applied. (default: current engine)
  118006. * @param reusable If the post process can be reused on the same frame. (default: false)
  118007. * @param textureType Type of textures used when performing the post process. (default: 0)
  118008. * @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)
  118009. */
  118010. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118011. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118012. if (blockCompilation === void 0) { blockCompilation = false; }
  118013. 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;
  118014. /**
  118015. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118016. */
  118017. _this.motionStrength = 1;
  118018. _this._motionBlurSamples = 32;
  118019. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118020. if (!_this._geometryBufferRenderer) {
  118021. // Geometry buffer renderer is not supported. So, work as a passthrough.
  118022. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  118023. _this.updateEffect();
  118024. }
  118025. else {
  118026. // Geometry buffer renderer is supported.
  118027. _this._geometryBufferRenderer.enableVelocity = true;
  118028. _this.onApply = function (effect) {
  118029. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  118030. effect.setFloat("motionScale", scene.getAnimationRatio());
  118031. effect.setFloat("motionStrength", _this.motionStrength);
  118032. if (_this._geometryBufferRenderer) {
  118033. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  118034. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  118035. }
  118036. };
  118037. }
  118038. return _this;
  118039. }
  118040. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  118041. /**
  118042. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118043. */
  118044. get: function () {
  118045. return this._motionBlurSamples;
  118046. },
  118047. /**
  118048. * Sets the number of iterations to be used for motion blur quality
  118049. */
  118050. set: function (samples) {
  118051. this._motionBlurSamples = samples;
  118052. if (this._geometryBufferRenderer) {
  118053. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  118054. }
  118055. },
  118056. enumerable: true,
  118057. configurable: true
  118058. });
  118059. /**
  118060. * Disposes the post process.
  118061. * @param camera The camera to dispose the post process on.
  118062. */
  118063. MotionBlurPostProcess.prototype.dispose = function (camera) {
  118064. if (this._geometryBufferRenderer) {
  118065. // Clear previous transformation matrices dictionary used to compute objects velocities
  118066. this._geometryBufferRenderer._previousTransformationMatrices = {};
  118067. }
  118068. _super.prototype.dispose.call(this, camera);
  118069. };
  118070. return MotionBlurPostProcess;
  118071. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118072. /***/ }),
  118073. /***/ "./PostProcesses/passPostProcess.ts":
  118074. /*!******************************************!*\
  118075. !*** ./PostProcesses/passPostProcess.ts ***!
  118076. \******************************************/
  118077. /*! exports provided: PassPostProcess, PassCubePostProcess */
  118078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118079. "use strict";
  118080. __webpack_require__.r(__webpack_exports__);
  118081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  118082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  118083. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118084. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118085. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118086. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118087. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  118088. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  118089. /**
  118090. * PassPostProcess which produces an output the same as it's input
  118091. */
  118092. var PassPostProcess = /** @class */ (function (_super) {
  118093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  118094. /**
  118095. * Creates the PassPostProcess
  118096. * @param name The name of the effect.
  118097. * @param options The required width/height ratio to downsize to before computing the render pass.
  118098. * @param camera The camera to apply the render pass to.
  118099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118100. * @param engine The engine which the post process will be applied. (default: current engine)
  118101. * @param reusable If the post process can be reused on the same frame. (default: false)
  118102. * @param textureType The type of texture to be used when performing the post processing.
  118103. * @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)
  118104. */
  118105. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118106. if (camera === void 0) { camera = null; }
  118107. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118108. if (blockCompilation === void 0) { blockCompilation = false; }
  118109. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  118110. }
  118111. return PassPostProcess;
  118112. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118113. /**
  118114. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118115. */
  118116. var PassCubePostProcess = /** @class */ (function (_super) {
  118117. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  118118. /**
  118119. * Creates the PassCubePostProcess
  118120. * @param name The name of the effect.
  118121. * @param options The required width/height ratio to downsize to before computing the render pass.
  118122. * @param camera The camera to apply the render pass to.
  118123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118124. * @param engine The engine which the post process will be applied. (default: current engine)
  118125. * @param reusable If the post process can be reused on the same frame. (default: false)
  118126. * @param textureType The type of texture to be used when performing the post processing.
  118127. * @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)
  118128. */
  118129. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118130. if (camera === void 0) { camera = null; }
  118131. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118132. if (blockCompilation === void 0) { blockCompilation = false; }
  118133. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  118134. _this._face = 0;
  118135. return _this;
  118136. }
  118137. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  118138. /**
  118139. * Gets or sets the cube face to display.
  118140. * * 0 is +X
  118141. * * 1 is -X
  118142. * * 2 is +Y
  118143. * * 3 is -Y
  118144. * * 4 is +Z
  118145. * * 5 is -Z
  118146. */
  118147. get: function () {
  118148. return this._face;
  118149. },
  118150. set: function (value) {
  118151. if (value < 0 || value > 5) {
  118152. return;
  118153. }
  118154. this._face = value;
  118155. switch (this._face) {
  118156. case 0:
  118157. this.updateEffect("#define POSITIVEX");
  118158. break;
  118159. case 1:
  118160. this.updateEffect("#define NEGATIVEX");
  118161. break;
  118162. case 2:
  118163. this.updateEffect("#define POSITIVEY");
  118164. break;
  118165. case 3:
  118166. this.updateEffect("#define NEGATIVEY");
  118167. break;
  118168. case 4:
  118169. this.updateEffect("#define POSITIVEZ");
  118170. break;
  118171. case 5:
  118172. this.updateEffect("#define NEGATIVEZ");
  118173. break;
  118174. }
  118175. },
  118176. enumerable: true,
  118177. configurable: true
  118178. });
  118179. return PassCubePostProcess;
  118180. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118181. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  118182. 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);
  118183. };
  118184. /***/ }),
  118185. /***/ "./PostProcesses/postProcess.ts":
  118186. /*!**************************************!*\
  118187. !*** ./PostProcesses/postProcess.ts ***!
  118188. \**************************************/
  118189. /*! exports provided: PostProcess */
  118190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118191. "use strict";
  118192. __webpack_require__.r(__webpack_exports__);
  118193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  118194. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  118195. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118196. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  118197. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118198. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118199. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  118200. /**
  118201. * PostProcess can be used to apply a shader to a texture after it has been rendered
  118202. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118203. */
  118204. var PostProcess = /** @class */ (function () {
  118205. /**
  118206. * Creates a new instance PostProcess
  118207. * @param name The name of the PostProcess.
  118208. * @param fragmentUrl The url of the fragment shader to be used.
  118209. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  118210. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  118211. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118212. * @param camera The camera to apply the render pass to.
  118213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118214. * @param engine The engine which the post process will be applied. (default: current engine)
  118215. * @param reusable If the post process can be reused on the same frame. (default: false)
  118216. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  118217. * @param textureType Type of textures used when performing the post process. (default: 0)
  118218. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  118219. * @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
  118220. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  118221. */
  118222. function PostProcess(
  118223. /** Name of the PostProcess. */
  118224. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  118225. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  118226. if (defines === void 0) { defines = null; }
  118227. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118228. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  118229. if (blockCompilation === void 0) { blockCompilation = false; }
  118230. this.name = name;
  118231. /**
  118232. * Width of the texture to apply the post process on
  118233. */
  118234. this.width = -1;
  118235. /**
  118236. * Height of the texture to apply the post process on
  118237. */
  118238. this.height = -1;
  118239. /**
  118240. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  118241. * @hidden
  118242. */
  118243. this._outputTexture = null;
  118244. /**
  118245. * If the buffer needs to be cleared before applying the post process. (default: true)
  118246. * Should be set to false if shader will overwrite all previous pixels.
  118247. */
  118248. this.autoClear = true;
  118249. /**
  118250. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  118251. */
  118252. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  118253. /**
  118254. * Animations to be used for the post processing
  118255. */
  118256. this.animations = new Array();
  118257. /**
  118258. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  118259. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  118260. */
  118261. this.enablePixelPerfectMode = false;
  118262. /**
  118263. * Force the postprocess to be applied without taking in account viewport
  118264. */
  118265. this.forceFullscreenViewport = true;
  118266. /**
  118267. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  118268. *
  118269. * | Value | Type | Description |
  118270. * | ----- | ----------------------------------- | ----------- |
  118271. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  118272. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  118273. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  118274. *
  118275. */
  118276. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  118277. /**
  118278. * Force textures to be a power of two (default: false)
  118279. */
  118280. this.alwaysForcePOT = false;
  118281. this._samples = 1;
  118282. /**
  118283. * Modify the scale of the post process to be the same as the viewport (default: false)
  118284. */
  118285. this.adaptScaleToCurrentViewport = false;
  118286. this._reusable = false;
  118287. /**
  118288. * Smart array of input and output textures for the post process.
  118289. * @hidden
  118290. */
  118291. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118292. /**
  118293. * The index in _textures that corresponds to the output texture.
  118294. * @hidden
  118295. */
  118296. this._currentRenderTextureInd = 0;
  118297. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  118298. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118299. // Events
  118300. /**
  118301. * An event triggered when the postprocess is activated.
  118302. */
  118303. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118304. /**
  118305. * An event triggered when the postprocess changes its size.
  118306. */
  118307. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118308. /**
  118309. * An event triggered when the postprocess applies its effect.
  118310. */
  118311. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118312. /**
  118313. * An event triggered before rendering the postprocess
  118314. */
  118315. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118316. /**
  118317. * An event triggered after rendering the postprocess
  118318. */
  118319. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118320. if (camera != null) {
  118321. this._camera = camera;
  118322. this._scene = camera.getScene();
  118323. camera.attachPostProcess(this);
  118324. this._engine = this._scene.getEngine();
  118325. this._scene.postProcesses.push(this);
  118326. }
  118327. else if (engine) {
  118328. this._engine = engine;
  118329. this._engine.postProcesses.push(this);
  118330. }
  118331. this._options = options;
  118332. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  118333. this._reusable = reusable || false;
  118334. this._textureType = textureType;
  118335. this._samplers = samplers || [];
  118336. this._samplers.push("textureSampler");
  118337. this._fragmentUrl = fragmentUrl;
  118338. this._vertexUrl = vertexUrl;
  118339. this._parameters = parameters || [];
  118340. this._parameters.push("scale");
  118341. this._indexParameters = indexParameters;
  118342. if (!blockCompilation) {
  118343. this.updateEffect(defines);
  118344. }
  118345. }
  118346. Object.defineProperty(PostProcess.prototype, "samples", {
  118347. /**
  118348. * Number of sample textures (default: 1)
  118349. */
  118350. get: function () {
  118351. return this._samples;
  118352. },
  118353. set: function (n) {
  118354. var _this = this;
  118355. this._samples = n;
  118356. this._textures.forEach(function (texture) {
  118357. if (texture.samples !== _this._samples) {
  118358. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  118359. }
  118360. });
  118361. },
  118362. enumerable: true,
  118363. configurable: true
  118364. });
  118365. /**
  118366. * Returns the fragment url or shader name used in the post process.
  118367. * @returns the fragment url or name in the shader store.
  118368. */
  118369. PostProcess.prototype.getEffectName = function () {
  118370. return this._fragmentUrl;
  118371. };
  118372. Object.defineProperty(PostProcess.prototype, "onActivate", {
  118373. /**
  118374. * A function that is added to the onActivateObservable
  118375. */
  118376. set: function (callback) {
  118377. if (this._onActivateObserver) {
  118378. this.onActivateObservable.remove(this._onActivateObserver);
  118379. }
  118380. if (callback) {
  118381. this._onActivateObserver = this.onActivateObservable.add(callback);
  118382. }
  118383. },
  118384. enumerable: true,
  118385. configurable: true
  118386. });
  118387. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  118388. /**
  118389. * A function that is added to the onSizeChangedObservable
  118390. */
  118391. set: function (callback) {
  118392. if (this._onSizeChangedObserver) {
  118393. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  118394. }
  118395. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  118396. },
  118397. enumerable: true,
  118398. configurable: true
  118399. });
  118400. Object.defineProperty(PostProcess.prototype, "onApply", {
  118401. /**
  118402. * A function that is added to the onApplyObservable
  118403. */
  118404. set: function (callback) {
  118405. if (this._onApplyObserver) {
  118406. this.onApplyObservable.remove(this._onApplyObserver);
  118407. }
  118408. this._onApplyObserver = this.onApplyObservable.add(callback);
  118409. },
  118410. enumerable: true,
  118411. configurable: true
  118412. });
  118413. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  118414. /**
  118415. * A function that is added to the onBeforeRenderObservable
  118416. */
  118417. set: function (callback) {
  118418. if (this._onBeforeRenderObserver) {
  118419. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  118420. }
  118421. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  118422. },
  118423. enumerable: true,
  118424. configurable: true
  118425. });
  118426. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  118427. /**
  118428. * A function that is added to the onAfterRenderObservable
  118429. */
  118430. set: function (callback) {
  118431. if (this._onAfterRenderObserver) {
  118432. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  118433. }
  118434. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  118435. },
  118436. enumerable: true,
  118437. configurable: true
  118438. });
  118439. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  118440. /**
  118441. * 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
  118442. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  118443. */
  118444. get: function () {
  118445. return this._textures.data[this._currentRenderTextureInd];
  118446. },
  118447. set: function (value) {
  118448. this._forcedOutputTexture = value;
  118449. },
  118450. enumerable: true,
  118451. configurable: true
  118452. });
  118453. /**
  118454. * Gets the camera which post process is applied to.
  118455. * @returns The camera the post process is applied to.
  118456. */
  118457. PostProcess.prototype.getCamera = function () {
  118458. return this._camera;
  118459. };
  118460. Object.defineProperty(PostProcess.prototype, "texelSize", {
  118461. /**
  118462. * Gets the texel size of the postprocess.
  118463. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  118464. */
  118465. get: function () {
  118466. if (this._shareOutputWithPostProcess) {
  118467. return this._shareOutputWithPostProcess.texelSize;
  118468. }
  118469. if (this._forcedOutputTexture) {
  118470. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  118471. }
  118472. return this._texelSize;
  118473. },
  118474. enumerable: true,
  118475. configurable: true
  118476. });
  118477. /**
  118478. * Gets the engine which this post process belongs to.
  118479. * @returns The engine the post process was enabled with.
  118480. */
  118481. PostProcess.prototype.getEngine = function () {
  118482. return this._engine;
  118483. };
  118484. /**
  118485. * The effect that is created when initializing the post process.
  118486. * @returns The created effect corrisponding the the postprocess.
  118487. */
  118488. PostProcess.prototype.getEffect = function () {
  118489. return this._effect;
  118490. };
  118491. /**
  118492. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  118493. * @param postProcess The post process to share the output with.
  118494. * @returns This post process.
  118495. */
  118496. PostProcess.prototype.shareOutputWith = function (postProcess) {
  118497. this._disposeTextures();
  118498. this._shareOutputWithPostProcess = postProcess;
  118499. return this;
  118500. };
  118501. /**
  118502. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  118503. * This should be called if the post process that shares output with this post process is disabled/disposed.
  118504. */
  118505. PostProcess.prototype.useOwnOutput = function () {
  118506. if (this._textures.length == 0) {
  118507. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118508. }
  118509. this._shareOutputWithPostProcess = null;
  118510. };
  118511. /**
  118512. * Updates the effect with the current post process compile time values and recompiles the shader.
  118513. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118514. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118515. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118516. * @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
  118517. * @param onCompiled Called when the shader has been compiled.
  118518. * @param onError Called if there is an error when compiling a shader.
  118519. */
  118520. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118521. if (defines === void 0) { defines = null; }
  118522. if (uniforms === void 0) { uniforms = null; }
  118523. if (samplers === void 0) { samplers = null; }
  118524. 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);
  118525. };
  118526. /**
  118527. * The post process is reusable if it can be used multiple times within one frame.
  118528. * @returns If the post process is reusable
  118529. */
  118530. PostProcess.prototype.isReusable = function () {
  118531. return this._reusable;
  118532. };
  118533. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  118534. PostProcess.prototype.markTextureDirty = function () {
  118535. this.width = -1;
  118536. };
  118537. /**
  118538. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  118539. * 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.
  118540. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  118541. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  118542. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  118543. * @returns The target texture that was bound to be written to.
  118544. */
  118545. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  118546. var _this = this;
  118547. if (sourceTexture === void 0) { sourceTexture = null; }
  118548. camera = camera || this._camera;
  118549. var scene = camera.getScene();
  118550. var engine = scene.getEngine();
  118551. var maxSize = engine.getCaps().maxTextureSize;
  118552. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  118553. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  118554. // 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
  118555. var webVRCamera = camera.parent;
  118556. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  118557. requiredWidth /= 2;
  118558. }
  118559. var desiredWidth = (this._options.width || requiredWidth);
  118560. var desiredHeight = this._options.height || requiredHeight;
  118561. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  118562. if (this.adaptScaleToCurrentViewport) {
  118563. var currentViewport = engine.currentViewport;
  118564. if (currentViewport) {
  118565. desiredWidth *= currentViewport.width;
  118566. desiredHeight *= currentViewport.height;
  118567. }
  118568. }
  118569. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  118570. if (!this._options.width) {
  118571. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  118572. }
  118573. if (!this._options.height) {
  118574. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  118575. }
  118576. }
  118577. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  118578. if (this._textures.length > 0) {
  118579. for (var i = 0; i < this._textures.length; i++) {
  118580. this._engine._releaseTexture(this._textures.data[i]);
  118581. }
  118582. this._textures.reset();
  118583. }
  118584. this.width = desiredWidth;
  118585. this.height = desiredHeight;
  118586. var textureSize = { width: this.width, height: this.height };
  118587. var textureOptions = {
  118588. generateMipMaps: false,
  118589. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  118590. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  118591. samplingMode: this.renderTargetSamplingMode,
  118592. type: this._textureType
  118593. };
  118594. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118595. if (this._reusable) {
  118596. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118597. }
  118598. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  118599. this.onSizeChangedObservable.notifyObservers(this);
  118600. }
  118601. this._textures.forEach(function (texture) {
  118602. if (texture.samples !== _this.samples) {
  118603. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  118604. }
  118605. });
  118606. }
  118607. var target;
  118608. if (this._shareOutputWithPostProcess) {
  118609. target = this._shareOutputWithPostProcess.inputTexture;
  118610. }
  118611. else if (this._forcedOutputTexture) {
  118612. target = this._forcedOutputTexture;
  118613. this.width = this._forcedOutputTexture.width;
  118614. this.height = this._forcedOutputTexture.height;
  118615. }
  118616. else {
  118617. target = this.inputTexture;
  118618. }
  118619. // Bind the input of this post process to be used as the output of the previous post process.
  118620. if (this.enablePixelPerfectMode) {
  118621. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  118622. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  118623. }
  118624. else {
  118625. this._scaleRatio.copyFromFloats(1, 1);
  118626. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  118627. }
  118628. this.onActivateObservable.notifyObservers(camera);
  118629. // Clear
  118630. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  118631. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  118632. }
  118633. if (this._reusable) {
  118634. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  118635. }
  118636. return target;
  118637. };
  118638. Object.defineProperty(PostProcess.prototype, "isSupported", {
  118639. /**
  118640. * If the post process is supported.
  118641. */
  118642. get: function () {
  118643. return this._effect.isSupported;
  118644. },
  118645. enumerable: true,
  118646. configurable: true
  118647. });
  118648. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  118649. /**
  118650. * The aspect ratio of the output texture.
  118651. */
  118652. get: function () {
  118653. if (this._shareOutputWithPostProcess) {
  118654. return this._shareOutputWithPostProcess.aspectRatio;
  118655. }
  118656. if (this._forcedOutputTexture) {
  118657. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  118658. }
  118659. return this.width / this.height;
  118660. },
  118661. enumerable: true,
  118662. configurable: true
  118663. });
  118664. /**
  118665. * Get a value indicating if the post-process is ready to be used
  118666. * @returns true if the post-process is ready (shader is compiled)
  118667. */
  118668. PostProcess.prototype.isReady = function () {
  118669. return this._effect && this._effect.isReady();
  118670. };
  118671. /**
  118672. * Binds all textures and uniforms to the shader, this will be run on every pass.
  118673. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  118674. */
  118675. PostProcess.prototype.apply = function () {
  118676. // Check
  118677. if (!this._effect || !this._effect.isReady()) {
  118678. return null;
  118679. }
  118680. // States
  118681. this._engine.enableEffect(this._effect);
  118682. this._engine.setState(false);
  118683. this._engine.setDepthBuffer(false);
  118684. this._engine.setDepthWrite(false);
  118685. // Alpha
  118686. this._engine.setAlphaMode(this.alphaMode);
  118687. if (this.alphaConstants) {
  118688. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  118689. }
  118690. // Bind the output texture of the preivous post process as the input to this post process.
  118691. var source;
  118692. if (this._shareOutputWithPostProcess) {
  118693. source = this._shareOutputWithPostProcess.inputTexture;
  118694. }
  118695. else if (this._forcedOutputTexture) {
  118696. source = this._forcedOutputTexture;
  118697. }
  118698. else {
  118699. source = this.inputTexture;
  118700. }
  118701. this._effect._bindTexture("textureSampler", source);
  118702. // Parameters
  118703. this._effect.setVector2("scale", this._scaleRatio);
  118704. this.onApplyObservable.notifyObservers(this._effect);
  118705. return this._effect;
  118706. };
  118707. PostProcess.prototype._disposeTextures = function () {
  118708. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  118709. return;
  118710. }
  118711. if (this._textures.length > 0) {
  118712. for (var i = 0; i < this._textures.length; i++) {
  118713. this._engine._releaseTexture(this._textures.data[i]);
  118714. }
  118715. }
  118716. this._textures.dispose();
  118717. };
  118718. /**
  118719. * Disposes the post process.
  118720. * @param camera The camera to dispose the post process on.
  118721. */
  118722. PostProcess.prototype.dispose = function (camera) {
  118723. camera = camera || this._camera;
  118724. this._disposeTextures();
  118725. if (this._scene) {
  118726. var index_1 = this._scene.postProcesses.indexOf(this);
  118727. if (index_1 !== -1) {
  118728. this._scene.postProcesses.splice(index_1, 1);
  118729. }
  118730. }
  118731. else {
  118732. var index_2 = this._engine.postProcesses.indexOf(this);
  118733. if (index_2 !== -1) {
  118734. this._engine.postProcesses.splice(index_2, 1);
  118735. }
  118736. }
  118737. if (!camera) {
  118738. return;
  118739. }
  118740. camera.detachPostProcess(this);
  118741. var index = camera._postProcesses.indexOf(this);
  118742. if (index === 0 && camera._postProcesses.length > 0) {
  118743. var firstPostProcess = this._camera._getFirstPostProcess();
  118744. if (firstPostProcess) {
  118745. firstPostProcess.markTextureDirty();
  118746. }
  118747. }
  118748. this.onActivateObservable.clear();
  118749. this.onAfterRenderObservable.clear();
  118750. this.onApplyObservable.clear();
  118751. this.onBeforeRenderObservable.clear();
  118752. this.onSizeChangedObservable.clear();
  118753. };
  118754. return PostProcess;
  118755. }());
  118756. /***/ }),
  118757. /***/ "./PostProcesses/postProcessManager.ts":
  118758. /*!*********************************************!*\
  118759. !*** ./PostProcesses/postProcessManager.ts ***!
  118760. \*********************************************/
  118761. /*! exports provided: PostProcessManager */
  118762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118763. "use strict";
  118764. __webpack_require__.r(__webpack_exports__);
  118765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  118766. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118767. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118768. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118769. /**
  118770. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118771. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118772. */
  118773. var PostProcessManager = /** @class */ (function () {
  118774. /**
  118775. * Creates a new instance PostProcess
  118776. * @param scene The scene that the post process is associated with.
  118777. */
  118778. function PostProcessManager(scene) {
  118779. this._vertexBuffers = {};
  118780. this._scene = scene;
  118781. }
  118782. PostProcessManager.prototype._prepareBuffers = function () {
  118783. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  118784. return;
  118785. }
  118786. // VBO
  118787. var vertices = [];
  118788. vertices.push(1, 1);
  118789. vertices.push(-1, 1);
  118790. vertices.push(-1, -1);
  118791. vertices.push(1, -1);
  118792. 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);
  118793. this._buildIndexBuffer();
  118794. };
  118795. PostProcessManager.prototype._buildIndexBuffer = function () {
  118796. // Indices
  118797. var indices = [];
  118798. indices.push(0);
  118799. indices.push(1);
  118800. indices.push(2);
  118801. indices.push(0);
  118802. indices.push(2);
  118803. indices.push(3);
  118804. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  118805. };
  118806. /**
  118807. * Rebuilds the vertex buffers of the manager.
  118808. * @hidden
  118809. */
  118810. PostProcessManager.prototype._rebuild = function () {
  118811. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118812. if (!vb) {
  118813. return;
  118814. }
  118815. vb._rebuild();
  118816. this._buildIndexBuffer();
  118817. };
  118818. // Methods
  118819. /**
  118820. * Prepares a frame to be run through a post process.
  118821. * @param sourceTexture The input texture to the post procesess. (default: null)
  118822. * @param postProcesses An array of post processes to be run. (default: null)
  118823. * @returns True if the post processes were able to be run.
  118824. * @hidden
  118825. */
  118826. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  118827. if (sourceTexture === void 0) { sourceTexture = null; }
  118828. if (postProcesses === void 0) { postProcesses = null; }
  118829. var camera = this._scene.activeCamera;
  118830. if (!camera) {
  118831. return false;
  118832. }
  118833. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118834. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118835. return false;
  118836. }
  118837. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  118838. return true;
  118839. };
  118840. /**
  118841. * Manually render a set of post processes to a texture.
  118842. * @param postProcesses An array of post processes to be run.
  118843. * @param targetTexture The target texture to render to.
  118844. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  118845. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  118846. * @param lodLevel defines which lod of the texture to render to
  118847. */
  118848. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  118849. if (targetTexture === void 0) { targetTexture = null; }
  118850. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118851. if (faceIndex === void 0) { faceIndex = 0; }
  118852. if (lodLevel === void 0) { lodLevel = 0; }
  118853. var engine = this._scene.getEngine();
  118854. for (var index = 0; index < postProcesses.length; index++) {
  118855. if (index < postProcesses.length - 1) {
  118856. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  118857. }
  118858. else {
  118859. if (targetTexture) {
  118860. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  118861. }
  118862. else {
  118863. engine.restoreDefaultFramebuffer();
  118864. }
  118865. }
  118866. var pp = postProcesses[index];
  118867. var effect = pp.apply();
  118868. if (effect) {
  118869. pp.onBeforeRenderObservable.notifyObservers(effect);
  118870. // VBOs
  118871. this._prepareBuffers();
  118872. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118873. // Draw order
  118874. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118875. pp.onAfterRenderObservable.notifyObservers(effect);
  118876. }
  118877. }
  118878. // Restore depth buffer
  118879. engine.setDepthBuffer(true);
  118880. engine.setDepthWrite(true);
  118881. };
  118882. /**
  118883. * Finalize the result of the output of the postprocesses.
  118884. * @param doNotPresent If true the result will not be displayed to the screen.
  118885. * @param targetTexture The target texture to render to.
  118886. * @param faceIndex The index of the face to bind the target texture to.
  118887. * @param postProcesses The array of post processes to render.
  118888. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  118889. * @hidden
  118890. */
  118891. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  118892. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118893. var camera = this._scene.activeCamera;
  118894. if (!camera) {
  118895. return;
  118896. }
  118897. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118898. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118899. return;
  118900. }
  118901. var engine = this._scene.getEngine();
  118902. for (var index = 0, len = postProcesses.length; index < len; index++) {
  118903. var pp = postProcesses[index];
  118904. if (index < len - 1) {
  118905. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  118906. }
  118907. else {
  118908. if (targetTexture) {
  118909. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  118910. pp._outputTexture = targetTexture;
  118911. }
  118912. else {
  118913. engine.restoreDefaultFramebuffer();
  118914. pp._outputTexture = null;
  118915. }
  118916. }
  118917. if (doNotPresent) {
  118918. break;
  118919. }
  118920. var effect = pp.apply();
  118921. if (effect) {
  118922. pp.onBeforeRenderObservable.notifyObservers(effect);
  118923. // VBOs
  118924. this._prepareBuffers();
  118925. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118926. // Draw order
  118927. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118928. pp.onAfterRenderObservable.notifyObservers(effect);
  118929. }
  118930. }
  118931. // Restore states
  118932. engine.setDepthBuffer(true);
  118933. engine.setDepthWrite(true);
  118934. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  118935. };
  118936. /**
  118937. * Disposes of the post process manager.
  118938. */
  118939. PostProcessManager.prototype.dispose = function () {
  118940. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118941. if (buffer) {
  118942. buffer.dispose();
  118943. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  118944. }
  118945. if (this._indexBuffer) {
  118946. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  118947. this._indexBuffer = null;
  118948. }
  118949. };
  118950. return PostProcessManager;
  118951. }());
  118952. /***/ }),
  118953. /***/ "./PostProcesses/refractionPostProcess.ts":
  118954. /*!************************************************!*\
  118955. !*** ./PostProcesses/refractionPostProcess.ts ***!
  118956. \************************************************/
  118957. /*! exports provided: RefractionPostProcess */
  118958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118959. "use strict";
  118960. __webpack_require__.r(__webpack_exports__);
  118961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  118962. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118963. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118964. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118965. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  118966. /**
  118967. * Post process which applies a refractin texture
  118968. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118969. */
  118970. var RefractionPostProcess = /** @class */ (function (_super) {
  118971. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  118972. /**
  118973. * Initializes the RefractionPostProcess
  118974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118975. * @param name The name of the effect.
  118976. * @param refractionTextureUrl Url of the refraction texture to use
  118977. * @param color the base color of the refraction (used to taint the rendering)
  118978. * @param depth simulated refraction depth
  118979. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118980. * @param camera The camera to apply the render pass to.
  118981. * @param options The required width/height ratio to downsize to before computing the render pass.
  118982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118983. * @param engine The engine which the post process will be applied. (default: current engine)
  118984. * @param reusable If the post process can be reused on the same frame. (default: false)
  118985. */
  118986. function RefractionPostProcess(name, refractionTextureUrl,
  118987. /** the base color of the refraction (used to taint the rendering) */
  118988. color,
  118989. /** simulated refraction depth */
  118990. depth,
  118991. /** the coefficient of the base color (0 to remove base color tainting) */
  118992. colorLevel, options, camera, samplingMode, engine, reusable) {
  118993. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  118994. _this.color = color;
  118995. _this.depth = depth;
  118996. _this.colorLevel = colorLevel;
  118997. _this._ownRefractionTexture = true;
  118998. _this.onActivateObservable.add(function (cam) {
  118999. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  119000. });
  119001. _this.onApplyObservable.add(function (effect) {
  119002. effect.setColor3("baseColor", _this.color);
  119003. effect.setFloat("depth", _this.depth);
  119004. effect.setFloat("colorLevel", _this.colorLevel);
  119005. effect.setTexture("refractionSampler", _this._refTexture);
  119006. });
  119007. return _this;
  119008. }
  119009. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  119010. /**
  119011. * Gets or sets the refraction texture
  119012. * Please note that you are responsible for disposing the texture if you set it manually
  119013. */
  119014. get: function () {
  119015. return this._refTexture;
  119016. },
  119017. set: function (value) {
  119018. if (this._refTexture && this._ownRefractionTexture) {
  119019. this._refTexture.dispose();
  119020. }
  119021. this._refTexture = value;
  119022. this._ownRefractionTexture = false;
  119023. },
  119024. enumerable: true,
  119025. configurable: true
  119026. });
  119027. // Methods
  119028. /**
  119029. * Disposes of the post process
  119030. * @param camera Camera to dispose post process on
  119031. */
  119032. RefractionPostProcess.prototype.dispose = function (camera) {
  119033. if (this._refTexture && this._ownRefractionTexture) {
  119034. this._refTexture.dispose();
  119035. this._refTexture = null;
  119036. }
  119037. _super.prototype.dispose.call(this, camera);
  119038. };
  119039. return RefractionPostProcess;
  119040. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119041. /***/ }),
  119042. /***/ "./PostProcesses/sharpenPostProcess.ts":
  119043. /*!*********************************************!*\
  119044. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  119045. \*********************************************/
  119046. /*! exports provided: SharpenPostProcess */
  119047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119048. "use strict";
  119049. __webpack_require__.r(__webpack_exports__);
  119050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  119051. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119052. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119053. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119054. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  119055. /**
  119056. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119058. */
  119059. var SharpenPostProcess = /** @class */ (function (_super) {
  119060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  119061. /**
  119062. * Creates a new instance ConvolutionPostProcess
  119063. * @param name The name of the effect.
  119064. * @param options The required width/height ratio to downsize to before computing the render pass.
  119065. * @param camera The camera to apply the render pass to.
  119066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119067. * @param engine The engine which the post process will be applied. (default: current engine)
  119068. * @param reusable If the post process can be reused on the same frame. (default: false)
  119069. * @param textureType Type of textures used when performing the post process. (default: 0)
  119070. * @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)
  119071. */
  119072. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119073. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119074. if (blockCompilation === void 0) { blockCompilation = false; }
  119075. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119076. /**
  119077. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119078. */
  119079. _this.colorAmount = 1.0;
  119080. /**
  119081. * How much sharpness should be applied (default: 0.3)
  119082. */
  119083. _this.edgeAmount = 0.3;
  119084. _this.onApply = function (effect) {
  119085. effect.setFloat2("screenSize", _this.width, _this.height);
  119086. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  119087. };
  119088. return _this;
  119089. }
  119090. return SharpenPostProcess;
  119091. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119092. /***/ }),
  119093. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  119094. /*!***********************************************************!*\
  119095. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  119096. \***********************************************************/
  119097. /*! exports provided: StereoscopicInterlacePostProcess */
  119098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119099. "use strict";
  119100. __webpack_require__.r(__webpack_exports__);
  119101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  119102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119104. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119105. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  119106. /**
  119107. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  119108. */
  119109. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  119110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  119111. /**
  119112. * Initializes a StereoscopicInterlacePostProcess
  119113. * @param name The name of the effect.
  119114. * @param rigCameras The rig cameras to be appled to the post process
  119115. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  119116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119117. * @param engine The engine which the post process will be applied. (default: current engine)
  119118. * @param reusable If the post process can be reused on the same frame. (default: false)
  119119. */
  119120. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  119121. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  119122. _this._passedProcess = rigCameras[0]._rigPostProcess;
  119123. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119124. _this.onSizeChangedObservable.add(function () {
  119125. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119126. });
  119127. _this.onApplyObservable.add(function (effect) {
  119128. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  119129. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  119130. });
  119131. return _this;
  119132. }
  119133. return StereoscopicInterlacePostProcess;
  119134. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119135. /***/ }),
  119136. /***/ "./PostProcesses/tonemapPostProcess.ts":
  119137. /*!*********************************************!*\
  119138. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  119139. \*********************************************/
  119140. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  119141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119142. "use strict";
  119143. __webpack_require__.r(__webpack_exports__);
  119144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  119145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  119146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119147. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119148. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119149. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  119150. /** Defines operator used for tonemapping */
  119151. var TonemappingOperator;
  119152. (function (TonemappingOperator) {
  119153. /** Hable */
  119154. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  119155. /** Reinhard */
  119156. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  119157. /** HejiDawson */
  119158. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  119159. /** Photographic */
  119160. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  119161. })(TonemappingOperator || (TonemappingOperator = {}));
  119162. /**
  119163. * Defines a post process to apply tone mapping
  119164. */
  119165. var TonemapPostProcess = /** @class */ (function (_super) {
  119166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  119167. /**
  119168. * Creates a new TonemapPostProcess
  119169. * @param name defines the name of the postprocess
  119170. * @param _operator defines the operator to use
  119171. * @param exposureAdjustment defines the required exposure adjustement
  119172. * @param camera defines the camera to use (can be null)
  119173. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119174. * @param engine defines the hosting engine (can be ignore if camera is set)
  119175. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119176. */
  119177. function TonemapPostProcess(name, _operator,
  119178. /** Defines the required exposure adjustement */
  119179. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  119180. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  119181. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119182. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  119183. _this._operator = _operator;
  119184. _this.exposureAdjustment = exposureAdjustment;
  119185. var defines = "#define ";
  119186. if (_this._operator === TonemappingOperator.Hable) {
  119187. defines += "HABLE_TONEMAPPING";
  119188. }
  119189. else if (_this._operator === TonemappingOperator.Reinhard) {
  119190. defines += "REINHARD_TONEMAPPING";
  119191. }
  119192. else if (_this._operator === TonemappingOperator.HejiDawson) {
  119193. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  119194. }
  119195. else if (_this._operator === TonemappingOperator.Photographic) {
  119196. defines += "PHOTOGRAPHIC_TONEMAPPING";
  119197. }
  119198. //sadly a second call to create the effect.
  119199. _this.updateEffect(defines);
  119200. _this.onApply = function (effect) {
  119201. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  119202. };
  119203. return _this;
  119204. }
  119205. return TonemapPostProcess;
  119206. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119207. /***/ }),
  119208. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  119209. /*!***************************************************************!*\
  119210. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  119211. \***************************************************************/
  119212. /*! exports provided: VolumetricLightScatteringPostProcess */
  119213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119214. "use strict";
  119215. __webpack_require__.r(__webpack_exports__);
  119216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  119217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119218. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119219. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119221. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119222. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119223. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119224. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119225. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  119226. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119227. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119228. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119229. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119230. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  119231. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119232. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  119233. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  119234. /**
  119235. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119236. */
  119237. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  119238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  119239. /**
  119240. * @constructor
  119241. * @param name The post-process name
  119242. * @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)
  119243. * @param camera The camera that the post-process will be attached to
  119244. * @param mesh The mesh used to create the light scattering
  119245. * @param samples The post-process quality, default 100
  119246. * @param samplingModeThe post-process filtering mode
  119247. * @param engine The babylon engine
  119248. * @param reusable If the post-process is reusable
  119249. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119250. */
  119251. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  119252. if (samples === void 0) { samples = 100; }
  119253. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  119254. 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;
  119255. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119256. /**
  119257. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119258. */
  119259. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119260. /**
  119261. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119262. */
  119263. _this.useCustomMeshPosition = false;
  119264. /**
  119265. * If the post-process should inverse the light scattering direction
  119266. */
  119267. _this.invert = true;
  119268. /**
  119269. * Array containing the excluded meshes not rendered in the internal pass
  119270. */
  119271. _this.excludedMeshes = new Array();
  119272. /**
  119273. * Controls the overall intensity of the post-process
  119274. */
  119275. _this.exposure = 0.3;
  119276. /**
  119277. * Dissipates each sample's contribution in range [0, 1]
  119278. */
  119279. _this.decay = 0.96815;
  119280. /**
  119281. * Controls the overall intensity of each sample
  119282. */
  119283. _this.weight = 0.58767;
  119284. /**
  119285. * Controls the density of each sample
  119286. */
  119287. _this.density = 0.926;
  119288. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  119289. engine = scene.getEngine();
  119290. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  119291. // Configure mesh
  119292. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  119293. // Configure
  119294. _this._createPass(scene, ratio.passRatio || ratio);
  119295. _this.onActivate = function (camera) {
  119296. if (!_this.isSupported) {
  119297. _this.dispose(camera);
  119298. }
  119299. _this.onActivate = null;
  119300. };
  119301. _this.onApplyObservable.add(function (effect) {
  119302. _this._updateMeshScreenCoordinates(scene);
  119303. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  119304. effect.setFloat("exposure", _this.exposure);
  119305. effect.setFloat("decay", _this.decay);
  119306. effect.setFloat("weight", _this.weight);
  119307. effect.setFloat("density", _this.density);
  119308. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  119309. });
  119310. return _this;
  119311. }
  119312. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  119313. /**
  119314. * @hidden
  119315. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119316. */
  119317. get: function () {
  119318. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119319. return false;
  119320. },
  119321. set: function (useDiffuseColor) {
  119322. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119323. },
  119324. enumerable: true,
  119325. configurable: true
  119326. });
  119327. /**
  119328. * Returns the string "VolumetricLightScatteringPostProcess"
  119329. * @returns "VolumetricLightScatteringPostProcess"
  119330. */
  119331. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  119332. return "VolumetricLightScatteringPostProcess";
  119333. };
  119334. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  119335. var mesh = subMesh.getMesh();
  119336. // Render this.mesh as default
  119337. if (mesh === this.mesh && mesh.material) {
  119338. return mesh.material.isReady(mesh);
  119339. }
  119340. var defines = [];
  119341. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  119342. var material = subMesh.getMaterial();
  119343. // Alpha test
  119344. if (material) {
  119345. if (material.needAlphaTesting()) {
  119346. defines.push("#define ALPHATEST");
  119347. }
  119348. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  119349. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  119350. defines.push("#define UV1");
  119351. }
  119352. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  119353. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  119354. defines.push("#define UV2");
  119355. }
  119356. }
  119357. // Bones
  119358. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119359. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  119360. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  119361. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119362. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  119363. }
  119364. else {
  119365. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119366. }
  119367. // Instances
  119368. if (useInstances) {
  119369. defines.push("#define INSTANCES");
  119370. attribs.push("world0");
  119371. attribs.push("world1");
  119372. attribs.push("world2");
  119373. attribs.push("world3");
  119374. }
  119375. // Get correct effect
  119376. var join = defines.join("\n");
  119377. if (this._cachedDefines !== join) {
  119378. this._cachedDefines = join;
  119379. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  119380. }
  119381. return this._volumetricLightScatteringPass.isReady();
  119382. };
  119383. /**
  119384. * Sets the new light position for light scattering effect
  119385. * @param position The new custom light position
  119386. */
  119387. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  119388. this.customMeshPosition = position;
  119389. };
  119390. /**
  119391. * Returns the light position for light scattering effect
  119392. * @return Vector3 The custom light position
  119393. */
  119394. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  119395. return this.customMeshPosition;
  119396. };
  119397. /**
  119398. * Disposes the internal assets and detaches the post-process from the camera
  119399. */
  119400. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  119401. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  119402. if (rttIndex !== -1) {
  119403. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  119404. }
  119405. this._volumetricLightScatteringRTT.dispose();
  119406. _super.prototype.dispose.call(this, camera);
  119407. };
  119408. /**
  119409. * Returns the render target texture used by the post-process
  119410. * @return the render target texture used by the post-process
  119411. */
  119412. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  119413. return this._volumetricLightScatteringRTT;
  119414. };
  119415. // Private methods
  119416. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  119417. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  119418. return true;
  119419. }
  119420. return false;
  119421. };
  119422. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  119423. var _this = this;
  119424. var engine = scene.getEngine();
  119425. this._volumetricLightScatteringRTT = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__["RenderTargetTexture"]("volumetricLightScatteringMap", { width: engine.getRenderWidth() * ratio, height: engine.getRenderHeight() * ratio }, scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  119426. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119427. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119428. this._volumetricLightScatteringRTT.renderList = null;
  119429. this._volumetricLightScatteringRTT.renderParticles = false;
  119430. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  119431. var camera = this.getCamera();
  119432. if (camera) {
  119433. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119434. }
  119435. else {
  119436. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119437. }
  119438. // Custom render function for submeshes
  119439. var renderSubMesh = function (subMesh) {
  119440. var mesh = subMesh.getRenderingMesh();
  119441. if (_this._meshExcluded(mesh)) {
  119442. return;
  119443. }
  119444. var material = subMesh.getMaterial();
  119445. if (!material) {
  119446. return;
  119447. }
  119448. var scene = mesh.getScene();
  119449. var engine = scene.getEngine();
  119450. // Culling
  119451. engine.setState(material.backFaceCulling);
  119452. // Managing instances
  119453. var batch = mesh._getInstancesRenderList(subMesh._id);
  119454. if (batch.mustReturn) {
  119455. return;
  119456. }
  119457. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119458. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  119459. var effect = _this._volumetricLightScatteringPass;
  119460. if (mesh === _this.mesh) {
  119461. if (subMesh.effect) {
  119462. effect = subMesh.effect;
  119463. }
  119464. else {
  119465. effect = material.getEffect();
  119466. }
  119467. }
  119468. engine.enableEffect(effect);
  119469. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  119470. if (mesh === _this.mesh) {
  119471. material.bind(mesh.getWorldMatrix(), mesh);
  119472. }
  119473. else {
  119474. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  119475. // Alpha test
  119476. if (material && material.needAlphaTesting()) {
  119477. var alphaTexture = material.getAlphaTestTexture();
  119478. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  119479. if (alphaTexture) {
  119480. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119481. }
  119482. }
  119483. // Bones
  119484. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119485. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119486. }
  119487. }
  119488. // Draw
  119489. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  119490. }
  119491. };
  119492. // Render target texture callbacks
  119493. var savedSceneClearColor;
  119494. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  119495. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  119496. savedSceneClearColor = scene.clearColor;
  119497. scene.clearColor = sceneClearColor;
  119498. });
  119499. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  119500. scene.clearColor = savedSceneClearColor;
  119501. });
  119502. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119503. var engine = scene.getEngine();
  119504. var index;
  119505. if (depthOnlySubMeshes.length) {
  119506. engine.setColorWrite(false);
  119507. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119508. renderSubMesh(depthOnlySubMeshes.data[index]);
  119509. }
  119510. engine.setColorWrite(true);
  119511. }
  119512. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119513. renderSubMesh(opaqueSubMeshes.data[index]);
  119514. }
  119515. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119516. renderSubMesh(alphaTestSubMeshes.data[index]);
  119517. }
  119518. if (transparentSubMeshes.length) {
  119519. // Sort sub meshes
  119520. for (index = 0; index < transparentSubMeshes.length; index++) {
  119521. var submesh = transparentSubMeshes.data[index];
  119522. var boundingInfo = submesh.getBoundingInfo();
  119523. if (boundingInfo && scene.activeCamera) {
  119524. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  119525. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  119526. }
  119527. }
  119528. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  119529. sortedArray.sort(function (a, b) {
  119530. // Alpha index first
  119531. if (a._alphaIndex > b._alphaIndex) {
  119532. return 1;
  119533. }
  119534. if (a._alphaIndex < b._alphaIndex) {
  119535. return -1;
  119536. }
  119537. // Then distance to camera
  119538. if (a._distanceToCamera < b._distanceToCamera) {
  119539. return 1;
  119540. }
  119541. if (a._distanceToCamera > b._distanceToCamera) {
  119542. return -1;
  119543. }
  119544. return 0;
  119545. });
  119546. // Render sub meshes
  119547. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  119548. for (index = 0; index < sortedArray.length; index++) {
  119549. renderSubMesh(sortedArray[index]);
  119550. }
  119551. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  119552. }
  119553. };
  119554. };
  119555. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  119556. var transform = scene.getTransformMatrix();
  119557. var meshPosition;
  119558. if (this.useCustomMeshPosition) {
  119559. meshPosition = this.customMeshPosition;
  119560. }
  119561. else if (this.attachedNode) {
  119562. meshPosition = this.attachedNode.position;
  119563. }
  119564. else {
  119565. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  119566. }
  119567. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  119568. this._screenCoordinates.x = pos.x / this._viewPort.width;
  119569. this._screenCoordinates.y = pos.y / this._viewPort.height;
  119570. if (this.invert) {
  119571. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  119572. }
  119573. };
  119574. // Static methods
  119575. /**
  119576. * Creates a default mesh for the Volumeric Light Scattering post-process
  119577. * @param name The mesh name
  119578. * @param scene The scene where to create the mesh
  119579. * @return the default mesh
  119580. */
  119581. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  119582. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  119583. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  119584. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  119585. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  119586. mesh.material = material;
  119587. return mesh;
  119588. };
  119589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119591. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  119592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119594. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  119595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119597. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  119598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119600. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  119601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119603. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  119604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119606. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  119607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119609. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  119610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119612. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  119613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119615. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  119616. return VolumetricLightScatteringPostProcess;
  119617. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  119618. /***/ }),
  119619. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  119620. /*!************************************************************!*\
  119621. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  119622. \************************************************************/
  119623. /*! exports provided: VRDistortionCorrectionPostProcess */
  119624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119625. "use strict";
  119626. __webpack_require__.r(__webpack_exports__);
  119627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  119628. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119630. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119631. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119632. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  119633. /**
  119634. * VRDistortionCorrectionPostProcess used for mobile VR
  119635. */
  119636. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  119637. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  119638. /**
  119639. * Initializes the VRDistortionCorrectionPostProcess
  119640. * @param name The name of the effect.
  119641. * @param camera The camera to apply the render pass to.
  119642. * @param isRightEye If this is for the right eye distortion
  119643. * @param vrMetrics All the required metrics for the VR camera
  119644. */
  119645. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  119646. var _this = _super.call(this, name, "vrDistortionCorrection", [
  119647. 'LensCenter',
  119648. 'Scale',
  119649. 'ScaleIn',
  119650. 'HmdWarpParam'
  119651. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  119652. _this._isRightEye = isRightEye;
  119653. _this._distortionFactors = vrMetrics.distortionK;
  119654. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  119655. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  119656. _this.adaptScaleToCurrentViewport = true;
  119657. _this.onSizeChangedObservable.add(function () {
  119658. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  119659. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  119660. _this._lensCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);
  119661. });
  119662. _this.onApplyObservable.add(function (effect) {
  119663. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  119664. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  119665. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  119666. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  119667. });
  119668. return _this;
  119669. }
  119670. return VRDistortionCorrectionPostProcess;
  119671. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119672. /***/ }),
  119673. /***/ "./Probes/index.ts":
  119674. /*!*************************!*\
  119675. !*** ./Probes/index.ts ***!
  119676. \*************************/
  119677. /*! exports provided: ReflectionProbe */
  119678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119679. "use strict";
  119680. __webpack_require__.r(__webpack_exports__);
  119681. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  119682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  119683. /***/ }),
  119684. /***/ "./Probes/reflectionProbe.ts":
  119685. /*!***********************************!*\
  119686. !*** ./Probes/reflectionProbe.ts ***!
  119687. \***********************************/
  119688. /*! exports provided: ReflectionProbe */
  119689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119690. "use strict";
  119691. __webpack_require__.r(__webpack_exports__);
  119692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  119693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119694. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119695. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119696. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119697. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  119698. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119699. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  119700. if (!this.reflectionProbes) {
  119701. return -1;
  119702. }
  119703. var index = this.reflectionProbes.indexOf(toRemove);
  119704. if (index !== -1) {
  119705. this.reflectionProbes.splice(index, 1);
  119706. }
  119707. return index;
  119708. };
  119709. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  119710. if (!this.reflectionProbes) {
  119711. this.reflectionProbes = [];
  119712. }
  119713. this.reflectionProbes.push(newReflectionProbe);
  119714. };
  119715. /**
  119716. * Class used to generate realtime reflection / refraction cube textures
  119717. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119718. */
  119719. var ReflectionProbe = /** @class */ (function () {
  119720. /**
  119721. * Creates a new reflection probe
  119722. * @param name defines the name of the probe
  119723. * @param size defines the texture resolution (for each face)
  119724. * @param scene defines the hosting scene
  119725. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119726. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119727. */
  119728. function ReflectionProbe(
  119729. /** defines the name of the probe */
  119730. name, size, scene, generateMipMaps, useFloat) {
  119731. if (generateMipMaps === void 0) { generateMipMaps = true; }
  119732. if (useFloat === void 0) { useFloat = false; }
  119733. var _this = this;
  119734. this.name = name;
  119735. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119736. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119737. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119738. this._invertYAxis = false;
  119739. /** Gets or sets probe position (center of the cube map) */
  119740. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119741. this._scene = scene;
  119742. // Create the scene field if not exist.
  119743. if (!this._scene.reflectionProbes) {
  119744. this._scene.reflectionProbes = new Array();
  119745. }
  119746. this._scene.reflectionProbes.push(this);
  119747. 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);
  119748. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  119749. switch (faceIndex) {
  119750. case 0:
  119751. _this._add.copyFromFloats(1, 0, 0);
  119752. break;
  119753. case 1:
  119754. _this._add.copyFromFloats(-1, 0, 0);
  119755. break;
  119756. case 2:
  119757. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  119758. break;
  119759. case 3:
  119760. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  119761. break;
  119762. case 4:
  119763. _this._add.copyFromFloats(0, 0, 1);
  119764. break;
  119765. case 5:
  119766. _this._add.copyFromFloats(0, 0, -1);
  119767. break;
  119768. }
  119769. if (_this._attachedMesh) {
  119770. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  119771. }
  119772. _this.position.addToRef(_this._add, _this._target);
  119773. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  119774. if (scene.activeCamera) {
  119775. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  119776. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  119777. }
  119778. scene._forcedViewPosition = _this.position;
  119779. });
  119780. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  119781. scene._forcedViewPosition = null;
  119782. scene.updateTransformMatrix(true);
  119783. });
  119784. }
  119785. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  119786. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119787. get: function () {
  119788. return this._renderTargetTexture.samples;
  119789. },
  119790. set: function (value) {
  119791. this._renderTargetTexture.samples = value;
  119792. },
  119793. enumerable: true,
  119794. configurable: true
  119795. });
  119796. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  119797. /** Gets or sets the refresh rate to use (on every frame by default) */
  119798. get: function () {
  119799. return this._renderTargetTexture.refreshRate;
  119800. },
  119801. set: function (value) {
  119802. this._renderTargetTexture.refreshRate = value;
  119803. },
  119804. enumerable: true,
  119805. configurable: true
  119806. });
  119807. /**
  119808. * Gets the hosting scene
  119809. * @returns a Scene
  119810. */
  119811. ReflectionProbe.prototype.getScene = function () {
  119812. return this._scene;
  119813. };
  119814. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  119815. /** Gets the internal CubeTexture used to render to */
  119816. get: function () {
  119817. return this._renderTargetTexture;
  119818. },
  119819. enumerable: true,
  119820. configurable: true
  119821. });
  119822. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  119823. /** Gets the list of meshes to render */
  119824. get: function () {
  119825. return this._renderTargetTexture.renderList;
  119826. },
  119827. enumerable: true,
  119828. configurable: true
  119829. });
  119830. /**
  119831. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119832. * @param mesh defines the mesh to attach to
  119833. */
  119834. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  119835. this._attachedMesh = mesh;
  119836. };
  119837. /**
  119838. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119839. * @param renderingGroupId The rendering group id corresponding to its index
  119840. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119841. */
  119842. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  119843. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  119844. };
  119845. /**
  119846. * Clean all associated resources
  119847. */
  119848. ReflectionProbe.prototype.dispose = function () {
  119849. var index = this._scene.reflectionProbes.indexOf(this);
  119850. if (index !== -1) {
  119851. // Remove from the scene if found
  119852. this._scene.reflectionProbes.splice(index, 1);
  119853. }
  119854. if (this._renderTargetTexture) {
  119855. this._renderTargetTexture.dispose();
  119856. this._renderTargetTexture = null;
  119857. }
  119858. };
  119859. /**
  119860. * Converts the reflection probe information to a readable string for debug purpose.
  119861. * @param fullDetails Supports for multiple levels of logging within scene loading
  119862. * @returns the human readable reflection probe info
  119863. */
  119864. ReflectionProbe.prototype.toString = function (fullDetails) {
  119865. var ret = "Name: " + this.name;
  119866. if (fullDetails) {
  119867. ret += ", position: " + this.position.toString();
  119868. if (this._attachedMesh) {
  119869. ret += ", attached mesh: " + this._attachedMesh.name;
  119870. }
  119871. }
  119872. return ret;
  119873. };
  119874. /**
  119875. * Get the class name of the relfection probe.
  119876. * @returns "ReflectionProbe"
  119877. */
  119878. ReflectionProbe.prototype.getClassName = function () {
  119879. return "ReflectionProbe";
  119880. };
  119881. /**
  119882. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119883. * @returns The JSON representation of the texture
  119884. */
  119885. ReflectionProbe.prototype.serialize = function () {
  119886. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  119887. serializationObject.isReflectionProbe = true;
  119888. return serializationObject;
  119889. };
  119890. /**
  119891. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119892. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119893. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119894. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119895. * @returns The parsed reflection probe if successful
  119896. */
  119897. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  119898. var reflectionProbe = null;
  119899. if (scene.reflectionProbes) {
  119900. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  119901. var rp = scene.reflectionProbes[index];
  119902. if (rp.name === parsedReflectionProbe.name) {
  119903. reflectionProbe = rp;
  119904. break;
  119905. }
  119906. }
  119907. }
  119908. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  119909. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  119910. if (parsedReflectionProbe._attachedMesh) {
  119911. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  119912. }
  119913. return reflectionProbe;
  119914. };
  119915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119917. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  119918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119920. ], ReflectionProbe.prototype, "position", void 0);
  119921. return ReflectionProbe;
  119922. }());
  119923. /***/ }),
  119924. /***/ "./Rendering/boundingBoxRenderer.ts":
  119925. /*!******************************************!*\
  119926. !*** ./Rendering/boundingBoxRenderer.ts ***!
  119927. \******************************************/
  119928. /*! exports provided: BoundingBoxRenderer */
  119929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119930. "use strict";
  119931. __webpack_require__.r(__webpack_exports__);
  119932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  119933. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119934. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119935. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119936. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  119937. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119938. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  119939. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119940. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119941. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119942. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  119943. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  119944. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  119945. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  119946. get: function () {
  119947. return this._forceShowBoundingBoxes || false;
  119948. },
  119949. set: function (value) {
  119950. this._forceShowBoundingBoxes = value;
  119951. // Lazyly creates a BB renderer if needed.
  119952. if (value) {
  119953. this.getBoundingBoxRenderer();
  119954. }
  119955. },
  119956. enumerable: true,
  119957. configurable: true
  119958. });
  119959. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  119960. if (!this._boundingBoxRenderer) {
  119961. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  119962. }
  119963. return this._boundingBoxRenderer;
  119964. };
  119965. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  119966. get: function () {
  119967. return this._showBoundingBox || false;
  119968. },
  119969. set: function (value) {
  119970. this._showBoundingBox = value;
  119971. // Lazyly creates a BB renderer if needed.
  119972. if (value) {
  119973. this.getScene().getBoundingBoxRenderer();
  119974. }
  119975. },
  119976. enumerable: true,
  119977. configurable: true
  119978. });
  119979. /**
  119980. * Component responsible of rendering the bounding box of the meshes in a scene.
  119981. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119982. */
  119983. var BoundingBoxRenderer = /** @class */ (function () {
  119984. /**
  119985. * Instantiates a new bounding box renderer in a scene.
  119986. * @param scene the scene the renderer renders in
  119987. */
  119988. function BoundingBoxRenderer(scene) {
  119989. /**
  119990. * The component name helpfull to identify the component in the list of scene components.
  119991. */
  119992. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  119993. /**
  119994. * Color of the bounding box lines placed in front of an object
  119995. */
  119996. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  119997. /**
  119998. * Color of the bounding box lines placed behind an object
  119999. */
  120000. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  120001. /**
  120002. * Defines if the renderer should show the back lines or not
  120003. */
  120004. this.showBackLines = true;
  120005. /**
  120006. * @hidden
  120007. */
  120008. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  120009. this._vertexBuffers = {};
  120010. this.scene = scene;
  120011. scene._addComponent(this);
  120012. }
  120013. /**
  120014. * Registers the component in a given scene
  120015. */
  120016. BoundingBoxRenderer.prototype.register = function () {
  120017. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  120018. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  120019. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  120020. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  120021. };
  120022. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  120023. if (mesh.showSubMeshesBoundingBox) {
  120024. var boundingInfo = subMesh.getBoundingInfo();
  120025. if (boundingInfo !== null && boundingInfo !== undefined) {
  120026. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120027. this.renderList.push(boundingInfo.boundingBox);
  120028. }
  120029. }
  120030. };
  120031. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  120032. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  120033. var boundingInfo = sourceMesh.getBoundingInfo();
  120034. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120035. this.renderList.push(boundingInfo.boundingBox);
  120036. }
  120037. };
  120038. BoundingBoxRenderer.prototype._prepareRessources = function () {
  120039. if (this._colorShader) {
  120040. return;
  120041. }
  120042. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  120043. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  120044. uniforms: ["world", "viewProjection", "color"]
  120045. });
  120046. var engine = this.scene.getEngine();
  120047. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  120048. 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);
  120049. this._createIndexBuffer();
  120050. };
  120051. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  120052. var engine = this.scene.getEngine();
  120053. 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]);
  120054. };
  120055. /**
  120056. * Rebuilds the elements related to this component in case of
  120057. * context lost for instance.
  120058. */
  120059. BoundingBoxRenderer.prototype.rebuild = function () {
  120060. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120061. if (vb) {
  120062. vb._rebuild();
  120063. }
  120064. this._createIndexBuffer();
  120065. };
  120066. /**
  120067. * @hidden
  120068. */
  120069. BoundingBoxRenderer.prototype.reset = function () {
  120070. this.renderList.reset();
  120071. };
  120072. /**
  120073. * Render the bounding boxes of a specific rendering group
  120074. * @param renderingGroupId defines the rendering group to render
  120075. */
  120076. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  120077. if (this.renderList.length === 0) {
  120078. return;
  120079. }
  120080. this._prepareRessources();
  120081. if (!this._colorShader.isReady()) {
  120082. return;
  120083. }
  120084. var engine = this.scene.getEngine();
  120085. engine.setDepthWrite(false);
  120086. this._colorShader._preBind();
  120087. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  120088. var boundingBox = this.renderList.data[boundingBoxIndex];
  120089. if (boundingBox._tag !== renderingGroupId) {
  120090. continue;
  120091. }
  120092. var min = boundingBox.minimum;
  120093. var max = boundingBox.maximum;
  120094. var diff = max.subtract(min);
  120095. var median = min.add(diff.scale(0.5));
  120096. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120097. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120098. .multiply(boundingBox.getWorldMatrix());
  120099. // VBOs
  120100. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120101. if (this.showBackLines) {
  120102. // Back
  120103. engine.setDepthFunctionToGreaterOrEqual();
  120104. this.scene.resetCachedMaterial();
  120105. this._colorShader.setColor4("color", this.backColor.toColor4());
  120106. this._colorShader.bind(worldMatrix);
  120107. // Draw order
  120108. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120109. }
  120110. // Front
  120111. engine.setDepthFunctionToLess();
  120112. this.scene.resetCachedMaterial();
  120113. this._colorShader.setColor4("color", this.frontColor.toColor4());
  120114. this._colorShader.bind(worldMatrix);
  120115. // Draw order
  120116. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120117. }
  120118. this._colorShader.unbind();
  120119. engine.setDepthFunctionToLessOrEqual();
  120120. engine.setDepthWrite(true);
  120121. };
  120122. /**
  120123. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120124. * @param mesh Define the mesh to render the occlusion bounding box for
  120125. */
  120126. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  120127. this._prepareRessources();
  120128. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  120129. return;
  120130. }
  120131. var engine = this.scene.getEngine();
  120132. engine.setDepthWrite(false);
  120133. engine.setColorWrite(false);
  120134. this._colorShader._preBind();
  120135. var boundingBox = mesh._boundingInfo.boundingBox;
  120136. var min = boundingBox.minimum;
  120137. var max = boundingBox.maximum;
  120138. var diff = max.subtract(min);
  120139. var median = min.add(diff.scale(0.5));
  120140. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120141. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120142. .multiply(boundingBox.getWorldMatrix());
  120143. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120144. engine.setDepthFunctionToLess();
  120145. this.scene.resetCachedMaterial();
  120146. this._colorShader.bind(worldMatrix);
  120147. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120148. this._colorShader.unbind();
  120149. engine.setDepthFunctionToLessOrEqual();
  120150. engine.setDepthWrite(true);
  120151. engine.setColorWrite(true);
  120152. };
  120153. /**
  120154. * Dispose and release the resources attached to this renderer.
  120155. */
  120156. BoundingBoxRenderer.prototype.dispose = function () {
  120157. if (!this._colorShader) {
  120158. return;
  120159. }
  120160. this.renderList.dispose();
  120161. this._colorShader.dispose();
  120162. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120163. if (buffer) {
  120164. buffer.dispose();
  120165. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120166. }
  120167. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  120168. };
  120169. return BoundingBoxRenderer;
  120170. }());
  120171. /***/ }),
  120172. /***/ "./Rendering/depthRenderer.ts":
  120173. /*!************************************!*\
  120174. !*** ./Rendering/depthRenderer.ts ***!
  120175. \************************************/
  120176. /*! exports provided: DepthRenderer */
  120177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120178. "use strict";
  120179. __webpack_require__.r(__webpack_exports__);
  120180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  120181. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120182. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120183. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120184. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120185. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120186. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120187. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  120188. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  120189. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  120190. /**
  120191. * This represents a depth renderer in Babylon.
  120192. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120193. */
  120194. var DepthRenderer = /** @class */ (function () {
  120195. /**
  120196. * Instantiates a depth renderer
  120197. * @param scene The scene the renderer belongs to
  120198. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120199. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120200. */
  120201. function DepthRenderer(scene, type, camera) {
  120202. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  120203. if (camera === void 0) { camera = null; }
  120204. var _this = this;
  120205. /**
  120206. * Specifiess that the depth renderer will only be used within
  120207. * the camera it is created for.
  120208. * This can help forcing its rendering during the camera processing.
  120209. */
  120210. this.useOnlyInActiveCamera = false;
  120211. this._scene = scene;
  120212. DepthRenderer._SceneComponentInitialization(this._scene);
  120213. this._camera = camera;
  120214. var engine = scene.getEngine();
  120215. // Render target
  120216. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  120217. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120218. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120219. this._depthMap.refreshRate = 1;
  120220. this._depthMap.renderParticles = false;
  120221. this._depthMap.renderList = null;
  120222. // Camera to get depth map from to support multiple concurrent cameras
  120223. this._depthMap.activeCamera = this._camera;
  120224. this._depthMap.ignoreCameraViewport = true;
  120225. this._depthMap.useCameraPostProcesses = false;
  120226. // set default depth value to 1.0 (far away)
  120227. this._depthMap.onClearObservable.add(function (engine) {
  120228. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  120229. });
  120230. // Custom render function
  120231. var renderSubMesh = function (subMesh) {
  120232. var mesh = subMesh.getRenderingMesh();
  120233. var scene = _this._scene;
  120234. var engine = scene.getEngine();
  120235. var material = subMesh.getMaterial();
  120236. if (!material) {
  120237. return;
  120238. }
  120239. // Culling and reverse (right handed system)
  120240. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120241. // Managing instances
  120242. var batch = mesh._getInstancesRenderList(subMesh._id);
  120243. if (batch.mustReturn) {
  120244. return;
  120245. }
  120246. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120247. var camera = _this._camera || scene.activeCamera;
  120248. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  120249. engine.enableEffect(_this._effect);
  120250. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  120251. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120252. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  120253. // Alpha test
  120254. if (material && material.needAlphaTesting()) {
  120255. var alphaTexture = material.getAlphaTestTexture();
  120256. if (alphaTexture) {
  120257. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120258. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120259. }
  120260. }
  120261. // Bones
  120262. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120263. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120264. }
  120265. // Draw
  120266. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120267. }
  120268. };
  120269. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120270. var index;
  120271. if (depthOnlySubMeshes.length) {
  120272. engine.setColorWrite(false);
  120273. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120274. renderSubMesh(depthOnlySubMeshes.data[index]);
  120275. }
  120276. engine.setColorWrite(true);
  120277. }
  120278. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120279. renderSubMesh(opaqueSubMeshes.data[index]);
  120280. }
  120281. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120282. renderSubMesh(alphaTestSubMeshes.data[index]);
  120283. }
  120284. };
  120285. }
  120286. /**
  120287. * Creates the depth rendering effect and checks if the effect is ready.
  120288. * @param subMesh The submesh to be used to render the depth map of
  120289. * @param useInstances If multiple world instances should be used
  120290. * @returns if the depth renderer is ready to render the depth map
  120291. */
  120292. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  120293. var material = subMesh.getMaterial();
  120294. if (material.disableDepthWrite) {
  120295. return false;
  120296. }
  120297. var defines = [];
  120298. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120299. var mesh = subMesh.getMesh();
  120300. // Alpha test
  120301. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  120302. defines.push("#define ALPHATEST");
  120303. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120304. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120305. defines.push("#define UV1");
  120306. }
  120307. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120308. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120309. defines.push("#define UV2");
  120310. }
  120311. }
  120312. // Bones
  120313. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120314. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120315. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120316. if (mesh.numBoneInfluencers > 4) {
  120317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120318. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120319. }
  120320. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120321. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120322. }
  120323. else {
  120324. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120325. }
  120326. // Instances
  120327. if (useInstances) {
  120328. defines.push("#define INSTANCES");
  120329. attribs.push("world0");
  120330. attribs.push("world1");
  120331. attribs.push("world2");
  120332. attribs.push("world3");
  120333. }
  120334. // Get correct effect
  120335. var join = defines.join("\n");
  120336. if (this._cachedDefines !== join) {
  120337. this._cachedDefines = join;
  120338. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  120339. }
  120340. return this._effect.isReady();
  120341. };
  120342. /**
  120343. * Gets the texture which the depth map will be written to.
  120344. * @returns The depth map texture
  120345. */
  120346. DepthRenderer.prototype.getDepthMap = function () {
  120347. return this._depthMap;
  120348. };
  120349. /**
  120350. * Disposes of the depth renderer.
  120351. */
  120352. DepthRenderer.prototype.dispose = function () {
  120353. this._depthMap.dispose();
  120354. };
  120355. /** @hidden */
  120356. DepthRenderer._SceneComponentInitialization = function (_) {
  120357. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  120358. };
  120359. return DepthRenderer;
  120360. }());
  120361. /***/ }),
  120362. /***/ "./Rendering/depthRendererSceneComponent.ts":
  120363. /*!**************************************************!*\
  120364. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  120365. \**************************************************/
  120366. /*! exports provided: DepthRendererSceneComponent */
  120367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120368. "use strict";
  120369. __webpack_require__.r(__webpack_exports__);
  120370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  120371. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120372. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120373. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120374. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120375. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  120376. camera = camera || this.activeCamera;
  120377. if (!camera) {
  120378. throw "No camera available to enable depth renderer";
  120379. }
  120380. if (!this._depthRenderer) {
  120381. this._depthRenderer = {};
  120382. }
  120383. if (!this._depthRenderer[camera.id]) {
  120384. var textureType = 0;
  120385. if (this.getEngine().getCaps().textureHalfFloatRender) {
  120386. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120387. }
  120388. else if (this.getEngine().getCaps().textureFloatRender) {
  120389. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  120390. }
  120391. else {
  120392. throw "Depth renderer does not support int texture type";
  120393. }
  120394. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  120395. }
  120396. return this._depthRenderer[camera.id];
  120397. };
  120398. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  120399. camera = camera || this.activeCamera;
  120400. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  120401. return;
  120402. }
  120403. this._depthRenderer[camera.id].dispose();
  120404. delete this._depthRenderer[camera.id];
  120405. };
  120406. /**
  120407. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120408. * in several rendering techniques.
  120409. */
  120410. var DepthRendererSceneComponent = /** @class */ (function () {
  120411. /**
  120412. * Creates a new instance of the component for the given scene
  120413. * @param scene Defines the scene to register the component in
  120414. */
  120415. function DepthRendererSceneComponent(scene) {
  120416. /**
  120417. * The component name helpfull to identify the component in the list of scene components.
  120418. */
  120419. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  120420. this.scene = scene;
  120421. }
  120422. /**
  120423. * Registers the component in a given scene
  120424. */
  120425. DepthRendererSceneComponent.prototype.register = function () {
  120426. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  120427. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  120428. };
  120429. /**
  120430. * Rebuilds the elements related to this component in case of
  120431. * context lost for instance.
  120432. */
  120433. DepthRendererSceneComponent.prototype.rebuild = function () {
  120434. // Nothing to do for this component
  120435. };
  120436. /**
  120437. * Disposes the component and the associated ressources
  120438. */
  120439. DepthRendererSceneComponent.prototype.dispose = function () {
  120440. for (var key in this.scene._depthRenderer) {
  120441. this.scene._depthRenderer[key].dispose();
  120442. }
  120443. };
  120444. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120445. if (this.scene._depthRenderer) {
  120446. for (var key in this.scene._depthRenderer) {
  120447. var depthRenderer = this.scene._depthRenderer[key];
  120448. if (!depthRenderer.useOnlyInActiveCamera) {
  120449. renderTargets.push(depthRenderer.getDepthMap());
  120450. }
  120451. }
  120452. }
  120453. };
  120454. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  120455. if (this.scene._depthRenderer) {
  120456. for (var key in this.scene._depthRenderer) {
  120457. var depthRenderer = this.scene._depthRenderer[key];
  120458. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  120459. renderTargets.push(depthRenderer.getDepthMap());
  120460. }
  120461. }
  120462. }
  120463. };
  120464. return DepthRendererSceneComponent;
  120465. }());
  120466. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  120467. // Register the G Buffer component to the scene.
  120468. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  120469. if (!component) {
  120470. component = new DepthRendererSceneComponent(scene);
  120471. scene._addComponent(component);
  120472. }
  120473. };
  120474. /***/ }),
  120475. /***/ "./Rendering/edgesRenderer.ts":
  120476. /*!************************************!*\
  120477. !*** ./Rendering/edgesRenderer.ts ***!
  120478. \************************************/
  120479. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  120480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120481. "use strict";
  120482. __webpack_require__.r(__webpack_exports__);
  120483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  120484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  120485. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120486. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120487. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120488. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  120489. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120490. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120491. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120492. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  120493. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120494. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  120495. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  120496. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  120497. if (this._edgesRenderer) {
  120498. this._edgesRenderer.dispose();
  120499. this._edgesRenderer = null;
  120500. }
  120501. return this;
  120502. };
  120503. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120504. if (epsilon === void 0) { epsilon = 0.95; }
  120505. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120506. this.disableEdgesRendering();
  120507. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120508. return this;
  120509. };
  120510. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  120511. get: function () {
  120512. return this._edgesRenderer;
  120513. },
  120514. enumerable: true,
  120515. configurable: true
  120516. });
  120517. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120518. if (epsilon === void 0) { epsilon = 0.95; }
  120519. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120520. this.disableEdgesRendering();
  120521. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120522. return this;
  120523. };
  120524. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120525. if (epsilon === void 0) { epsilon = 0.95; }
  120526. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120527. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  120528. return this;
  120529. };
  120530. /**
  120531. * FaceAdjacencies Helper class to generate edges
  120532. */
  120533. var FaceAdjacencies = /** @class */ (function () {
  120534. function FaceAdjacencies() {
  120535. this.edges = new Array();
  120536. this.edgesConnectedCount = 0;
  120537. }
  120538. return FaceAdjacencies;
  120539. }());
  120540. /**
  120541. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  120542. */
  120543. var EdgesRenderer = /** @class */ (function () {
  120544. /**
  120545. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  120546. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  120547. * @param source Mesh used to create edges
  120548. * @param epsilon sum of angles in adjacency to check for edge
  120549. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  120550. * @param generateEdgesLines - should generate Lines or only prepare resources.
  120551. */
  120552. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  120553. if (epsilon === void 0) { epsilon = 0.95; }
  120554. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120555. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  120556. var _this = this;
  120557. /**
  120558. * Define the size of the edges with an orthographic camera
  120559. */
  120560. this.edgesWidthScalerForOrthographic = 1000.0;
  120561. /**
  120562. * Define the size of the edges with a perspective camera
  120563. */
  120564. this.edgesWidthScalerForPerspective = 50.0;
  120565. this._linesPositions = new Array();
  120566. this._linesNormals = new Array();
  120567. this._linesIndices = new Array();
  120568. this._buffers = {};
  120569. this._checkVerticesInsteadOfIndices = false;
  120570. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  120571. this.isEnabled = true;
  120572. this._source = source;
  120573. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  120574. this._epsilon = epsilon;
  120575. this._prepareRessources();
  120576. if (generateEdgesLines) {
  120577. this._generateEdgesLines();
  120578. }
  120579. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  120580. _this._rebuild();
  120581. });
  120582. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  120583. _this.dispose();
  120584. });
  120585. }
  120586. EdgesRenderer.prototype._prepareRessources = function () {
  120587. if (this._lineShader) {
  120588. return;
  120589. }
  120590. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  120591. attributes: ["position", "normal"],
  120592. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  120593. });
  120594. this._lineShader.disableDepthWrite = true;
  120595. this._lineShader.backFaceCulling = false;
  120596. };
  120597. /** @hidden */
  120598. EdgesRenderer.prototype._rebuild = function () {
  120599. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120600. if (buffer) {
  120601. buffer._rebuild();
  120602. }
  120603. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120604. if (buffer) {
  120605. buffer._rebuild();
  120606. }
  120607. var scene = this._source.getScene();
  120608. var engine = scene.getEngine();
  120609. this._ib = engine.createIndexBuffer(this._linesIndices);
  120610. };
  120611. /**
  120612. * Releases the required resources for the edges renderer
  120613. */
  120614. EdgesRenderer.prototype.dispose = function () {
  120615. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  120616. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  120617. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120618. if (buffer) {
  120619. buffer.dispose();
  120620. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120621. }
  120622. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120623. if (buffer) {
  120624. buffer.dispose();
  120625. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  120626. }
  120627. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  120628. this._lineShader.dispose();
  120629. };
  120630. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  120631. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  120632. return 0;
  120633. }
  120634. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  120635. return 1;
  120636. }
  120637. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  120638. return 2;
  120639. }
  120640. return -1;
  120641. };
  120642. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  120643. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  120644. return 0;
  120645. }
  120646. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  120647. return 1;
  120648. }
  120649. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  120650. return 2;
  120651. }
  120652. return -1;
  120653. };
  120654. /**
  120655. * Checks if the pair of p0 and p1 is en edge
  120656. * @param faceIndex
  120657. * @param edge
  120658. * @param faceNormals
  120659. * @param p0
  120660. * @param p1
  120661. * @private
  120662. */
  120663. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  120664. var needToCreateLine;
  120665. if (edge === undefined) {
  120666. needToCreateLine = true;
  120667. }
  120668. else {
  120669. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  120670. needToCreateLine = dotProduct < this._epsilon;
  120671. }
  120672. if (needToCreateLine) {
  120673. this.createLine(p0, p1, this._linesPositions.length / 3);
  120674. }
  120675. };
  120676. /**
  120677. * push line into the position, normal and index buffer
  120678. * @protected
  120679. */
  120680. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  120681. // Positions
  120682. 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);
  120683. // Normals
  120684. 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);
  120685. // Indices
  120686. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  120687. };
  120688. /**
  120689. * Generates lines edges from adjacencjes
  120690. * @private
  120691. */
  120692. EdgesRenderer.prototype._generateEdgesLines = function () {
  120693. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120694. var indices = this._source.getIndices();
  120695. if (!indices || !positions) {
  120696. return;
  120697. }
  120698. // First let's find adjacencies
  120699. var adjacencies = new Array();
  120700. var faceNormals = new Array();
  120701. var index;
  120702. var faceAdjacencies;
  120703. // Prepare faces
  120704. for (index = 0; index < indices.length; index += 3) {
  120705. faceAdjacencies = new FaceAdjacencies();
  120706. var p0Index = indices[index];
  120707. var p1Index = indices[index + 1];
  120708. var p2Index = indices[index + 2];
  120709. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  120710. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  120711. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  120712. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  120713. faceNormal.normalize();
  120714. faceNormals.push(faceNormal);
  120715. adjacencies.push(faceAdjacencies);
  120716. }
  120717. // Scan
  120718. for (index = 0; index < adjacencies.length; index++) {
  120719. faceAdjacencies = adjacencies[index];
  120720. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  120721. var otherFaceAdjacencies = adjacencies[otherIndex];
  120722. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  120723. break;
  120724. }
  120725. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  120726. continue;
  120727. }
  120728. var otherP0 = indices[otherIndex * 3];
  120729. var otherP1 = indices[otherIndex * 3 + 1];
  120730. var otherP2 = indices[otherIndex * 3 + 2];
  120731. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  120732. var otherEdgeIndex = 0;
  120733. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  120734. continue;
  120735. }
  120736. switch (edgeIndex) {
  120737. case 0:
  120738. if (this._checkVerticesInsteadOfIndices) {
  120739. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120740. }
  120741. else {
  120742. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  120743. }
  120744. break;
  120745. case 1:
  120746. if (this._checkVerticesInsteadOfIndices) {
  120747. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120748. }
  120749. else {
  120750. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  120751. }
  120752. break;
  120753. case 2:
  120754. if (this._checkVerticesInsteadOfIndices) {
  120755. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120756. }
  120757. else {
  120758. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  120759. }
  120760. break;
  120761. }
  120762. if (otherEdgeIndex === -1) {
  120763. continue;
  120764. }
  120765. faceAdjacencies.edges[edgeIndex] = otherIndex;
  120766. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  120767. faceAdjacencies.edgesConnectedCount++;
  120768. otherFaceAdjacencies.edgesConnectedCount++;
  120769. if (faceAdjacencies.edgesConnectedCount === 3) {
  120770. break;
  120771. }
  120772. }
  120773. }
  120774. }
  120775. // Create lines
  120776. for (index = 0; index < adjacencies.length; index++) {
  120777. // 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
  120778. var current = adjacencies[index];
  120779. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  120780. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  120781. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  120782. }
  120783. // Merge into a single mesh
  120784. var engine = this._source.getScene().getEngine();
  120785. 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);
  120786. 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);
  120787. this._ib = engine.createIndexBuffer(this._linesIndices);
  120788. this._indicesCount = this._linesIndices.length;
  120789. };
  120790. /**
  120791. * Checks wether or not the edges renderer is ready to render.
  120792. * @return true if ready, otherwise false.
  120793. */
  120794. EdgesRenderer.prototype.isReady = function () {
  120795. return this._lineShader.isReady();
  120796. };
  120797. /**
  120798. * Renders the edges of the attached mesh,
  120799. */
  120800. EdgesRenderer.prototype.render = function () {
  120801. var scene = this._source.getScene();
  120802. if (!this.isReady() || !scene.activeCamera) {
  120803. return;
  120804. }
  120805. var engine = scene.getEngine();
  120806. this._lineShader._preBind();
  120807. if (this._source.edgesColor.a !== 1) {
  120808. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  120809. }
  120810. else {
  120811. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  120812. }
  120813. // VBOs
  120814. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  120815. scene.resetCachedMaterial();
  120816. this._lineShader.setColor4("color", this._source.edgesColor);
  120817. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  120818. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  120819. }
  120820. else {
  120821. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  120822. }
  120823. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  120824. this._lineShader.bind(this._source.getWorldMatrix());
  120825. // Draw order
  120826. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  120827. this._lineShader.unbind();
  120828. };
  120829. return EdgesRenderer;
  120830. }());
  120831. /**
  120832. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  120833. */
  120834. var LineEdgesRenderer = /** @class */ (function (_super) {
  120835. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  120836. /**
  120837. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  120838. * @param source LineMesh used to generate edges
  120839. * @param epsilon not important (specified angle for edge detection)
  120840. * @param checkVerticesInsteadOfIndices not important for LineMesh
  120841. */
  120842. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  120843. if (epsilon === void 0) { epsilon = 0.95; }
  120844. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120845. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  120846. _this._generateEdgesLines();
  120847. return _this;
  120848. }
  120849. /**
  120850. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  120851. */
  120852. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  120853. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120854. var indices = this._source.getIndices();
  120855. if (!indices || !positions) {
  120856. return;
  120857. }
  120858. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  120859. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  120860. var len = indices.length - 1;
  120861. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  120862. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  120863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  120864. this.createLine(p0, p1, offset);
  120865. }
  120866. // Merge into a single mesh
  120867. var engine = this._source.getScene().getEngine();
  120868. 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);
  120869. 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);
  120870. this._ib = engine.createIndexBuffer(this._linesIndices);
  120871. this._indicesCount = this._linesIndices.length;
  120872. };
  120873. return LineEdgesRenderer;
  120874. }(EdgesRenderer));
  120875. /***/ }),
  120876. /***/ "./Rendering/geometryBufferRenderer.ts":
  120877. /*!*********************************************!*\
  120878. !*** ./Rendering/geometryBufferRenderer.ts ***!
  120879. \*********************************************/
  120880. /*! exports provided: GeometryBufferRenderer */
  120881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120882. "use strict";
  120883. __webpack_require__.r(__webpack_exports__);
  120884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  120885. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120886. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120887. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120888. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120889. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  120890. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120891. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  120892. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  120893. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  120894. /**
  120895. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120896. */
  120897. var GeometryBufferRenderer = /** @class */ (function () {
  120898. /**
  120899. * Creates a new G Buffer for the scene
  120900. * @param scene The scene the buffer belongs to
  120901. * @param ratio How big is the buffer related to the main canvas.
  120902. */
  120903. function GeometryBufferRenderer(scene, ratio) {
  120904. if (ratio === void 0) { ratio = 1; }
  120905. /**
  120906. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120907. * in order to compute objects velocities when enableVelocity is set to "true"
  120908. * @hidden
  120909. */
  120910. this._previousTransformationMatrices = {};
  120911. this._enablePosition = false;
  120912. this._enableVelocity = false;
  120913. this._positionIndex = -1;
  120914. this._velocityIndex = -1;
  120915. this._scene = scene;
  120916. this._ratio = ratio;
  120917. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  120918. // Render target
  120919. this._createRenderTargets();
  120920. }
  120921. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  120922. /**
  120923. * Set the render list (meshes to be rendered) used in the G buffer.
  120924. */
  120925. set: function (meshes) {
  120926. this._multiRenderTarget.renderList = meshes;
  120927. },
  120928. enumerable: true,
  120929. configurable: true
  120930. });
  120931. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  120932. /**
  120933. * Gets wether or not G buffer are supported by the running hardware.
  120934. * This requires draw buffer supports
  120935. */
  120936. get: function () {
  120937. return this._multiRenderTarget.isSupported;
  120938. },
  120939. enumerable: true,
  120940. configurable: true
  120941. });
  120942. /**
  120943. * Returns the index of the given texture type in the G-Buffer textures array
  120944. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120945. * @returns the index of the given texture type in the G-Buffer textures array
  120946. */
  120947. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  120948. switch (textureType) {
  120949. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  120950. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  120951. default: return -1;
  120952. }
  120953. };
  120954. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  120955. /**
  120956. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120957. */
  120958. get: function () {
  120959. return this._enablePosition;
  120960. },
  120961. /**
  120962. * Sets whether or not objects positions are enabled for the G buffer.
  120963. */
  120964. set: function (enable) {
  120965. this._enablePosition = enable;
  120966. this.dispose();
  120967. this._createRenderTargets();
  120968. },
  120969. enumerable: true,
  120970. configurable: true
  120971. });
  120972. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  120973. /**
  120974. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120975. */
  120976. get: function () {
  120977. return this._enableVelocity;
  120978. },
  120979. /**
  120980. * Sets wether or not objects velocities are enabled for the G buffer.
  120981. */
  120982. set: function (enable) {
  120983. this._enableVelocity = enable;
  120984. this.dispose();
  120985. this._createRenderTargets();
  120986. },
  120987. enumerable: true,
  120988. configurable: true
  120989. });
  120990. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  120991. /**
  120992. * Gets the scene associated with the buffer.
  120993. */
  120994. get: function () {
  120995. return this._scene;
  120996. },
  120997. enumerable: true,
  120998. configurable: true
  120999. });
  121000. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  121001. /**
  121002. * Gets the ratio used by the buffer during its creation.
  121003. * How big is the buffer related to the main canvas.
  121004. */
  121005. get: function () {
  121006. return this._ratio;
  121007. },
  121008. enumerable: true,
  121009. configurable: true
  121010. });
  121011. /**
  121012. * Checks wether everything is ready to render a submesh to the G buffer.
  121013. * @param subMesh the submesh to check readiness for
  121014. * @param useInstances is the mesh drawn using instance or not
  121015. * @returns true if ready otherwise false
  121016. */
  121017. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  121018. var material = subMesh.getMaterial();
  121019. if (material && material.disableDepthWrite) {
  121020. return false;
  121021. }
  121022. var defines = [];
  121023. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121024. var mesh = subMesh.getMesh();
  121025. // Alpha test
  121026. if (material && material.needAlphaTesting()) {
  121027. defines.push("#define ALPHATEST");
  121028. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121029. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121030. defines.push("#define UV1");
  121031. }
  121032. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121033. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121034. defines.push("#define UV2");
  121035. }
  121036. }
  121037. // Buffers
  121038. if (this._enablePosition) {
  121039. defines.push("#define POSITION");
  121040. defines.push("#define POSITION_INDEX " + this._positionIndex);
  121041. }
  121042. if (this._enableVelocity) {
  121043. defines.push("#define VELOCITY");
  121044. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  121045. }
  121046. // Bones
  121047. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121048. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121049. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121050. if (mesh.numBoneInfluencers > 4) {
  121051. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121052. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121053. }
  121054. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121055. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121056. }
  121057. else {
  121058. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121059. }
  121060. // Instances
  121061. if (useInstances) {
  121062. defines.push("#define INSTANCES");
  121063. attribs.push("world0");
  121064. attribs.push("world1");
  121065. attribs.push("world2");
  121066. attribs.push("world3");
  121067. }
  121068. // Setup textures count
  121069. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  121070. // Get correct effect
  121071. var join = defines.join("\n");
  121072. if (this._cachedDefines !== join) {
  121073. this._cachedDefines = join;
  121074. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  121075. }
  121076. return this._effect.isReady();
  121077. };
  121078. /**
  121079. * Gets the current underlying G Buffer.
  121080. * @returns the buffer
  121081. */
  121082. GeometryBufferRenderer.prototype.getGBuffer = function () {
  121083. return this._multiRenderTarget;
  121084. };
  121085. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  121086. /**
  121087. * Gets the number of samples used to render the buffer (anti aliasing).
  121088. */
  121089. get: function () {
  121090. return this._multiRenderTarget.samples;
  121091. },
  121092. /**
  121093. * Sets the number of samples used to render the buffer (anti aliasing).
  121094. */
  121095. set: function (value) {
  121096. this._multiRenderTarget.samples = value;
  121097. },
  121098. enumerable: true,
  121099. configurable: true
  121100. });
  121101. /**
  121102. * Disposes the renderer and frees up associated resources.
  121103. */
  121104. GeometryBufferRenderer.prototype.dispose = function () {
  121105. this.getGBuffer().dispose();
  121106. };
  121107. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  121108. var _this = this;
  121109. var engine = this._scene.getEngine();
  121110. var count = 2;
  121111. if (this._enablePosition) {
  121112. this._positionIndex = count;
  121113. count++;
  121114. }
  121115. if (this._enableVelocity) {
  121116. this._velocityIndex = count;
  121117. count++;
  121118. }
  121119. 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 });
  121120. if (!this.isSupported) {
  121121. return;
  121122. }
  121123. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121124. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121125. this._multiRenderTarget.refreshRate = 1;
  121126. this._multiRenderTarget.renderParticles = false;
  121127. this._multiRenderTarget.renderList = null;
  121128. // set default depth value to 1.0 (far away)
  121129. this._multiRenderTarget.onClearObservable.add(function (engine) {
  121130. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  121131. });
  121132. // Custom render function
  121133. var renderSubMesh = function (subMesh) {
  121134. var mesh = subMesh.getRenderingMesh();
  121135. var scene = _this._scene;
  121136. var engine = scene.getEngine();
  121137. var material = subMesh.getMaterial();
  121138. if (!material) {
  121139. return;
  121140. }
  121141. // Velocity
  121142. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  121143. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  121144. }
  121145. // Culling
  121146. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  121147. // Managing instances
  121148. var batch = mesh._getInstancesRenderList(subMesh._id);
  121149. if (batch.mustReturn) {
  121150. return;
  121151. }
  121152. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121153. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  121154. engine.enableEffect(_this._effect);
  121155. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121156. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121157. _this._effect.setMatrix("view", scene.getViewMatrix());
  121158. // Alpha test
  121159. if (material && material.needAlphaTesting()) {
  121160. var alphaTexture = material.getAlphaTestTexture();
  121161. if (alphaTexture) {
  121162. _this._effect.setTexture("diffuseSampler", alphaTexture);
  121163. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121164. }
  121165. }
  121166. // Bones
  121167. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121168. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121169. }
  121170. // Velocity
  121171. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  121172. // Draw
  121173. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  121174. }
  121175. // Velocity
  121176. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  121177. };
  121178. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121179. var index;
  121180. if (depthOnlySubMeshes.length) {
  121181. engine.setColorWrite(false);
  121182. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121183. renderSubMesh(depthOnlySubMeshes.data[index]);
  121184. }
  121185. engine.setColorWrite(true);
  121186. }
  121187. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121188. renderSubMesh(opaqueSubMeshes.data[index]);
  121189. }
  121190. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121191. renderSubMesh(alphaTestSubMeshes.data[index]);
  121192. }
  121193. };
  121194. };
  121195. /**
  121196. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121197. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121198. */
  121199. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  121200. /**
  121201. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121202. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121203. */
  121204. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  121205. /** @hidden */
  121206. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  121207. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  121208. };
  121209. return GeometryBufferRenderer;
  121210. }());
  121211. /***/ }),
  121212. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  121213. /*!***********************************************************!*\
  121214. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  121215. \***********************************************************/
  121216. /*! exports provided: GeometryBufferRendererSceneComponent */
  121217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121218. "use strict";
  121219. __webpack_require__.r(__webpack_exports__);
  121220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  121221. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121222. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121223. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121224. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  121225. get: function () {
  121226. this._geometryBufferRenderer;
  121227. },
  121228. set: function (value) {
  121229. if (value && value.isSupported) {
  121230. this._geometryBufferRenderer = value;
  121231. }
  121232. },
  121233. enumerable: true,
  121234. configurable: true
  121235. });
  121236. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  121237. if (ratio === void 0) { ratio = 1; }
  121238. if (this._geometryBufferRenderer) {
  121239. return this._geometryBufferRenderer;
  121240. }
  121241. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  121242. if (!this._geometryBufferRenderer.isSupported) {
  121243. this._geometryBufferRenderer = null;
  121244. }
  121245. return this._geometryBufferRenderer;
  121246. };
  121247. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  121248. if (!this._geometryBufferRenderer) {
  121249. return;
  121250. }
  121251. this._geometryBufferRenderer.dispose();
  121252. this._geometryBufferRenderer = null;
  121253. };
  121254. /**
  121255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121256. * in several rendering techniques.
  121257. */
  121258. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  121259. /**
  121260. * Creates a new instance of the component for the given scene
  121261. * @param scene Defines the scene to register the component in
  121262. */
  121263. function GeometryBufferRendererSceneComponent(scene) {
  121264. /**
  121265. * The component name helpful to identify the component in the list of scene components.
  121266. */
  121267. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  121268. this.scene = scene;
  121269. }
  121270. /**
  121271. * Registers the component in a given scene
  121272. */
  121273. GeometryBufferRendererSceneComponent.prototype.register = function () {
  121274. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  121275. };
  121276. /**
  121277. * Rebuilds the elements related to this component in case of
  121278. * context lost for instance.
  121279. */
  121280. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  121281. // Nothing to do for this component
  121282. };
  121283. /**
  121284. * Disposes the component and the associated ressources
  121285. */
  121286. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  121287. // Nothing to do for this component
  121288. };
  121289. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121290. if (this.scene._geometryBufferRenderer) {
  121291. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  121292. }
  121293. };
  121294. return GeometryBufferRendererSceneComponent;
  121295. }());
  121296. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  121297. // Register the G Buffer component to the scene.
  121298. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  121299. if (!component) {
  121300. component = new GeometryBufferRendererSceneComponent(scene);
  121301. scene._addComponent(component);
  121302. }
  121303. };
  121304. /***/ }),
  121305. /***/ "./Rendering/index.ts":
  121306. /*!****************************!*\
  121307. !*** ./Rendering/index.ts ***!
  121308. \****************************/
  121309. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  121310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121311. "use strict";
  121312. __webpack_require__.r(__webpack_exports__);
  121313. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  121314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  121315. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  121317. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  121318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  121319. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  121320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  121321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  121322. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  121324. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  121325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  121326. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  121327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  121328. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  121330. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  121331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  121332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  121333. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  121334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  121335. /***/ }),
  121336. /***/ "./Rendering/outlineRenderer.ts":
  121337. /*!**************************************!*\
  121338. !*** ./Rendering/outlineRenderer.ts ***!
  121339. \**************************************/
  121340. /*! exports provided: OutlineRenderer */
  121341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121342. "use strict";
  121343. __webpack_require__.r(__webpack_exports__);
  121344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  121345. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121346. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121347. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121348. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121349. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121350. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121351. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  121352. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  121353. /**
  121354. * Gets the outline renderer associated with the scene
  121355. * @returns a OutlineRenderer
  121356. */
  121357. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  121358. if (!this._outlineRenderer) {
  121359. this._outlineRenderer = new OutlineRenderer(this);
  121360. }
  121361. return this._outlineRenderer;
  121362. };
  121363. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  121364. get: function () {
  121365. return this._renderOutline;
  121366. },
  121367. set: function (value) {
  121368. if (value) {
  121369. // Lazy Load the component.
  121370. this.getScene().getOutlineRenderer();
  121371. }
  121372. this._renderOutline = value;
  121373. },
  121374. enumerable: true,
  121375. configurable: true
  121376. });
  121377. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  121378. get: function () {
  121379. return this._renderOverlay;
  121380. },
  121381. set: function (value) {
  121382. if (value) {
  121383. // Lazy Load the component.
  121384. this.getScene().getOutlineRenderer();
  121385. }
  121386. this._renderOverlay = value;
  121387. },
  121388. enumerable: true,
  121389. configurable: true
  121390. });
  121391. /**
  121392. * This class is responsible to draw bothe outline/overlay of meshes.
  121393. * It should not be used directly but through the available method on mesh.
  121394. */
  121395. var OutlineRenderer = /** @class */ (function () {
  121396. /**
  121397. * Instantiates a new outline renderer. (There could be only one per scene).
  121398. * @param scene Defines the scene it belongs to
  121399. */
  121400. function OutlineRenderer(scene) {
  121401. /**
  121402. * The name of the component. Each component must have a unique name.
  121403. */
  121404. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  121405. /**
  121406. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121407. */
  121408. this.zOffset = 1;
  121409. this.scene = scene;
  121410. this._engine = scene.getEngine();
  121411. this.scene._addComponent(this);
  121412. }
  121413. /**
  121414. * Register the component to one instance of a scene.
  121415. */
  121416. OutlineRenderer.prototype.register = function () {
  121417. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  121418. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  121419. };
  121420. /**
  121421. * Rebuilds the elements related to this component in case of
  121422. * context lost for instance.
  121423. */
  121424. OutlineRenderer.prototype.rebuild = function () {
  121425. // Nothing to do here.
  121426. };
  121427. /**
  121428. * Disposes the component and the associated ressources.
  121429. */
  121430. OutlineRenderer.prototype.dispose = function () {
  121431. // Nothing to do here.
  121432. };
  121433. /**
  121434. * Renders the outline in the canvas.
  121435. * @param subMesh Defines the sumesh to render
  121436. * @param batch Defines the batch of meshes in case of instances
  121437. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121438. */
  121439. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  121440. var _this = this;
  121441. if (useOverlay === void 0) { useOverlay = false; }
  121442. var scene = this.scene;
  121443. var engine = scene.getEngine();
  121444. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  121445. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  121446. return;
  121447. }
  121448. var mesh = subMesh.getRenderingMesh();
  121449. var material = subMesh.getMaterial();
  121450. if (!material || !scene.activeCamera) {
  121451. return;
  121452. }
  121453. engine.enableEffect(this._effect);
  121454. // Logarithmic depth
  121455. if (material.useLogarithmicDepth) {
  121456. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  121457. }
  121458. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  121459. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  121460. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121461. // Bones
  121462. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121463. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121464. }
  121465. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121466. // Alpha test
  121467. if (material && material.needAlphaTesting()) {
  121468. var alphaTexture = material.getAlphaTestTexture();
  121469. if (alphaTexture) {
  121470. this._effect.setTexture("diffuseSampler", alphaTexture);
  121471. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121472. }
  121473. }
  121474. engine.setZOffset(-this.zOffset);
  121475. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  121476. engine.setZOffset(0);
  121477. };
  121478. /**
  121479. * Returns whether or not the outline renderer is ready for a given submesh.
  121480. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121481. * @param subMesh Defines the submesh to check readyness for
  121482. * @param useInstances Defines wheter wee are trying to render instances or not
  121483. * @returns true if ready otherwise false
  121484. */
  121485. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  121486. var defines = [];
  121487. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  121488. var mesh = subMesh.getMesh();
  121489. var material = subMesh.getMaterial();
  121490. if (material) {
  121491. // Alpha test
  121492. if (material.needAlphaTesting()) {
  121493. defines.push("#define ALPHATEST");
  121494. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  121495. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  121496. defines.push("#define UV1");
  121497. }
  121498. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  121499. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  121500. defines.push("#define UV2");
  121501. }
  121502. }
  121503. //Logarithmic depth
  121504. if (material.useLogarithmicDepth) {
  121505. defines.push("#define LOGARITHMICDEPTH");
  121506. }
  121507. }
  121508. // Bones
  121509. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121510. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  121511. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  121512. if (mesh.numBoneInfluencers > 4) {
  121513. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  121514. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  121515. }
  121516. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121517. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121518. }
  121519. else {
  121520. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121521. }
  121522. // Instances
  121523. if (useInstances) {
  121524. defines.push("#define INSTANCES");
  121525. attribs.push("world0");
  121526. attribs.push("world1");
  121527. attribs.push("world2");
  121528. attribs.push("world3");
  121529. }
  121530. // Get correct effect
  121531. var join = defines.join("\n");
  121532. if (this._cachedDefines !== join) {
  121533. this._cachedDefines = join;
  121534. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  121535. }
  121536. return this._effect.isReady();
  121537. };
  121538. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  121539. // Outline - step 1
  121540. this._savedDepthWrite = this._engine.getDepthWrite();
  121541. if (mesh.renderOutline) {
  121542. this._engine.setDepthWrite(false);
  121543. this.render(subMesh, batch);
  121544. this._engine.setDepthWrite(this._savedDepthWrite);
  121545. }
  121546. };
  121547. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  121548. // Outline - step 2
  121549. if (mesh.renderOutline && this._savedDepthWrite) {
  121550. this._engine.setDepthWrite(true);
  121551. this._engine.setColorWrite(false);
  121552. this.render(subMesh, batch);
  121553. this._engine.setColorWrite(true);
  121554. }
  121555. // Overlay
  121556. if (mesh.renderOverlay) {
  121557. var currentMode = this._engine.getAlphaMode();
  121558. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  121559. this.render(subMesh, batch, true);
  121560. this._engine.setAlphaMode(currentMode);
  121561. }
  121562. };
  121563. return OutlineRenderer;
  121564. }());
  121565. /***/ }),
  121566. /***/ "./Rendering/renderingGroup.ts":
  121567. /*!*************************************!*\
  121568. !*** ./Rendering/renderingGroup.ts ***!
  121569. \*************************************/
  121570. /*! exports provided: RenderingGroup */
  121571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121572. "use strict";
  121573. __webpack_require__.r(__webpack_exports__);
  121574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  121575. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121576. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121577. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121578. /**
  121579. * This represents the object necessary to create a rendering group.
  121580. * This is exclusively used and created by the rendering manager.
  121581. * To modify the behavior, you use the available helpers in your scene or meshes.
  121582. * @hidden
  121583. */
  121584. var RenderingGroup = /** @class */ (function () {
  121585. /**
  121586. * Creates a new rendering group.
  121587. * @param index The rendering group index
  121588. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  121589. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  121590. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  121591. */
  121592. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121593. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121594. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121595. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121596. this.index = index;
  121597. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121598. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121599. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121600. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121601. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121602. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121603. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  121604. this._scene = scene;
  121605. this.opaqueSortCompareFn = opaqueSortCompareFn;
  121606. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  121607. this.transparentSortCompareFn = transparentSortCompareFn;
  121608. }
  121609. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  121610. /**
  121611. * Set the opaque sort comparison function.
  121612. * If null the sub meshes will be render in the order they were created
  121613. */
  121614. set: function (value) {
  121615. this._opaqueSortCompareFn = value;
  121616. if (value) {
  121617. this._renderOpaque = this.renderOpaqueSorted;
  121618. }
  121619. else {
  121620. this._renderOpaque = RenderingGroup.renderUnsorted;
  121621. }
  121622. },
  121623. enumerable: true,
  121624. configurable: true
  121625. });
  121626. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  121627. /**
  121628. * Set the alpha test sort comparison function.
  121629. * If null the sub meshes will be render in the order they were created
  121630. */
  121631. set: function (value) {
  121632. this._alphaTestSortCompareFn = value;
  121633. if (value) {
  121634. this._renderAlphaTest = this.renderAlphaTestSorted;
  121635. }
  121636. else {
  121637. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  121638. }
  121639. },
  121640. enumerable: true,
  121641. configurable: true
  121642. });
  121643. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  121644. /**
  121645. * Set the transparent sort comparison function.
  121646. * If null the sub meshes will be render in the order they were created
  121647. */
  121648. set: function (value) {
  121649. if (value) {
  121650. this._transparentSortCompareFn = value;
  121651. }
  121652. else {
  121653. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  121654. }
  121655. this._renderTransparent = this.renderTransparentSorted;
  121656. },
  121657. enumerable: true,
  121658. configurable: true
  121659. });
  121660. /**
  121661. * Render all the sub meshes contained in the group.
  121662. * @param customRenderFunction Used to override the default render behaviour of the group.
  121663. * @returns true if rendered some submeshes.
  121664. */
  121665. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  121666. if (customRenderFunction) {
  121667. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  121668. return;
  121669. }
  121670. var engine = this._scene.getEngine();
  121671. // Depth only
  121672. if (this._depthOnlySubMeshes.length !== 0) {
  121673. engine.setColorWrite(false);
  121674. this._renderAlphaTest(this._depthOnlySubMeshes);
  121675. engine.setColorWrite(true);
  121676. }
  121677. // Opaque
  121678. if (this._opaqueSubMeshes.length !== 0) {
  121679. this._renderOpaque(this._opaqueSubMeshes);
  121680. }
  121681. // Alpha test
  121682. if (this._alphaTestSubMeshes.length !== 0) {
  121683. this._renderAlphaTest(this._alphaTestSubMeshes);
  121684. }
  121685. var stencilState = engine.getStencilBuffer();
  121686. engine.setStencilBuffer(false);
  121687. // Sprites
  121688. if (renderSprites) {
  121689. this._renderSprites();
  121690. }
  121691. // Particles
  121692. if (renderParticles) {
  121693. this._renderParticles(activeMeshes);
  121694. }
  121695. if (this.onBeforeTransparentRendering) {
  121696. this.onBeforeTransparentRendering();
  121697. }
  121698. // Transparent
  121699. if (this._transparentSubMeshes.length !== 0) {
  121700. this._renderTransparent(this._transparentSubMeshes);
  121701. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121702. }
  121703. // Set back stencil to false in case it changes before the edge renderer.
  121704. engine.setStencilBuffer(false);
  121705. // Edges
  121706. if (this._edgesRenderers.length) {
  121707. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  121708. this._edgesRenderers.data[edgesRendererIndex].render();
  121709. }
  121710. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121711. }
  121712. // Restore Stencil state.
  121713. engine.setStencilBuffer(stencilState);
  121714. };
  121715. /**
  121716. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  121717. * @param subMeshes The submeshes to render
  121718. */
  121719. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  121720. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  121721. };
  121722. /**
  121723. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  121724. * @param subMeshes The submeshes to render
  121725. */
  121726. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  121727. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  121728. };
  121729. /**
  121730. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  121731. * @param subMeshes The submeshes to render
  121732. */
  121733. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  121734. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  121735. };
  121736. /**
  121737. * Renders the submeshes in a specified order.
  121738. * @param subMeshes The submeshes to sort before render
  121739. * @param sortCompareFn The comparison function use to sort
  121740. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  121741. * @param transparent Specifies to activate blending if true
  121742. */
  121743. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  121744. var subIndex = 0;
  121745. var subMesh;
  121746. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  121747. for (; subIndex < subMeshes.length; subIndex++) {
  121748. subMesh = subMeshes.data[subIndex];
  121749. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  121750. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  121751. }
  121752. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  121753. if (sortCompareFn) {
  121754. sortedArray.sort(sortCompareFn);
  121755. }
  121756. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  121757. subMesh = sortedArray[subIndex];
  121758. if (transparent) {
  121759. var material = subMesh.getMaterial();
  121760. if (material && material.needDepthPrePass) {
  121761. var engine = material.getScene().getEngine();
  121762. engine.setColorWrite(false);
  121763. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121764. subMesh.render(false);
  121765. engine.setColorWrite(true);
  121766. }
  121767. }
  121768. subMesh.render(transparent);
  121769. }
  121770. };
  121771. /**
  121772. * Renders the submeshes in the order they were dispatched (no sort applied).
  121773. * @param subMeshes The submeshes to render
  121774. */
  121775. RenderingGroup.renderUnsorted = function (subMeshes) {
  121776. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  121777. var submesh = subMeshes.data[subIndex];
  121778. submesh.render(false);
  121779. }
  121780. };
  121781. /**
  121782. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121783. * are rendered back to front if in the same alpha index.
  121784. *
  121785. * @param a The first submesh
  121786. * @param b The second submesh
  121787. * @returns The result of the comparison
  121788. */
  121789. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  121790. // Alpha index first
  121791. if (a._alphaIndex > b._alphaIndex) {
  121792. return 1;
  121793. }
  121794. if (a._alphaIndex < b._alphaIndex) {
  121795. return -1;
  121796. }
  121797. // Then distance to camera
  121798. return RenderingGroup.backToFrontSortCompare(a, b);
  121799. };
  121800. /**
  121801. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121802. * are rendered back to front.
  121803. *
  121804. * @param a The first submesh
  121805. * @param b The second submesh
  121806. * @returns The result of the comparison
  121807. */
  121808. RenderingGroup.backToFrontSortCompare = function (a, b) {
  121809. // Then distance to camera
  121810. if (a._distanceToCamera < b._distanceToCamera) {
  121811. return 1;
  121812. }
  121813. if (a._distanceToCamera > b._distanceToCamera) {
  121814. return -1;
  121815. }
  121816. return 0;
  121817. };
  121818. /**
  121819. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121820. * are rendered front to back (prevent overdraw).
  121821. *
  121822. * @param a The first submesh
  121823. * @param b The second submesh
  121824. * @returns The result of the comparison
  121825. */
  121826. RenderingGroup.frontToBackSortCompare = function (a, b) {
  121827. // Then distance to camera
  121828. if (a._distanceToCamera < b._distanceToCamera) {
  121829. return -1;
  121830. }
  121831. if (a._distanceToCamera > b._distanceToCamera) {
  121832. return 1;
  121833. }
  121834. return 0;
  121835. };
  121836. /**
  121837. * Resets the different lists of submeshes to prepare a new frame.
  121838. */
  121839. RenderingGroup.prototype.prepare = function () {
  121840. this._opaqueSubMeshes.reset();
  121841. this._transparentSubMeshes.reset();
  121842. this._alphaTestSubMeshes.reset();
  121843. this._depthOnlySubMeshes.reset();
  121844. this._particleSystems.reset();
  121845. this._spriteManagers.reset();
  121846. this._edgesRenderers.reset();
  121847. };
  121848. RenderingGroup.prototype.dispose = function () {
  121849. this._opaqueSubMeshes.dispose();
  121850. this._transparentSubMeshes.dispose();
  121851. this._alphaTestSubMeshes.dispose();
  121852. this._depthOnlySubMeshes.dispose();
  121853. this._particleSystems.dispose();
  121854. this._spriteManagers.dispose();
  121855. this._edgesRenderers.dispose();
  121856. };
  121857. /**
  121858. * Inserts the submesh in its correct queue depending on its material.
  121859. * @param subMesh The submesh to dispatch
  121860. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121861. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121862. */
  121863. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  121864. // Get mesh and materials if not provided
  121865. if (mesh === undefined) {
  121866. mesh = subMesh.getMesh();
  121867. }
  121868. if (material === undefined) {
  121869. material = subMesh.getMaterial();
  121870. }
  121871. if (material === null || material === undefined) {
  121872. return;
  121873. }
  121874. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  121875. this._transparentSubMeshes.push(subMesh);
  121876. }
  121877. else if (material.needAlphaTesting()) { // Alpha test
  121878. if (material.needDepthPrePass) {
  121879. this._depthOnlySubMeshes.push(subMesh);
  121880. }
  121881. this._alphaTestSubMeshes.push(subMesh);
  121882. }
  121883. else {
  121884. if (material.needDepthPrePass) {
  121885. this._depthOnlySubMeshes.push(subMesh);
  121886. }
  121887. this._opaqueSubMeshes.push(subMesh); // Opaque
  121888. }
  121889. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  121890. this._edgesRenderers.push(mesh._edgesRenderer);
  121891. }
  121892. };
  121893. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  121894. this._spriteManagers.push(spriteManager);
  121895. };
  121896. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  121897. this._particleSystems.push(particleSystem);
  121898. };
  121899. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  121900. if (this._particleSystems.length === 0) {
  121901. return;
  121902. }
  121903. // Particles
  121904. var activeCamera = this._scene.activeCamera;
  121905. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  121906. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  121907. var particleSystem = this._particleSystems.data[particleIndex];
  121908. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  121909. continue;
  121910. }
  121911. var emitter = particleSystem.emitter;
  121912. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  121913. this._scene._activeParticles.addCount(particleSystem.render(), false);
  121914. }
  121915. }
  121916. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  121917. };
  121918. RenderingGroup.prototype._renderSprites = function () {
  121919. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  121920. return;
  121921. }
  121922. // Sprites
  121923. var activeCamera = this._scene.activeCamera;
  121924. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  121925. for (var id = 0; id < this._spriteManagers.length; id++) {
  121926. var spriteManager = this._spriteManagers.data[id];
  121927. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  121928. spriteManager.render();
  121929. }
  121930. }
  121931. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  121932. };
  121933. return RenderingGroup;
  121934. }());
  121935. /***/ }),
  121936. /***/ "./Rendering/renderingManager.ts":
  121937. /*!***************************************!*\
  121938. !*** ./Rendering/renderingManager.ts ***!
  121939. \***************************************/
  121940. /*! exports provided: RenderingGroupInfo, RenderingManager */
  121941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121942. "use strict";
  121943. __webpack_require__.r(__webpack_exports__);
  121944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  121945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  121946. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121947. /**
  121948. * This class is used by the onRenderingGroupObservable
  121949. */
  121950. var RenderingGroupInfo = /** @class */ (function () {
  121951. function RenderingGroupInfo() {
  121952. }
  121953. return RenderingGroupInfo;
  121954. }());
  121955. /**
  121956. * This is the manager responsible of all the rendering for meshes sprites and particles.
  121957. * It is enable to manage the different groups as well as the different necessary sort functions.
  121958. * This should not be used directly aside of the few static configurations
  121959. */
  121960. var RenderingManager = /** @class */ (function () {
  121961. /**
  121962. * Instantiates a new rendering group for a particular scene
  121963. * @param scene Defines the scene the groups belongs to
  121964. */
  121965. function RenderingManager(scene) {
  121966. /**
  121967. * @hidden
  121968. */
  121969. this._useSceneAutoClearSetup = false;
  121970. this._renderingGroups = new Array();
  121971. this._autoClearDepthStencil = {};
  121972. this._customOpaqueSortCompareFn = {};
  121973. this._customAlphaTestSortCompareFn = {};
  121974. this._customTransparentSortCompareFn = {};
  121975. this._renderingGroupInfo = new RenderingGroupInfo();
  121976. this._scene = scene;
  121977. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  121978. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  121979. }
  121980. }
  121981. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  121982. if (depth === void 0) { depth = true; }
  121983. if (stencil === void 0) { stencil = true; }
  121984. if (this._depthStencilBufferAlreadyCleaned) {
  121985. return;
  121986. }
  121987. this._scene.getEngine().clear(null, false, depth, stencil);
  121988. this._depthStencilBufferAlreadyCleaned = true;
  121989. };
  121990. /**
  121991. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  121992. * @hidden
  121993. */
  121994. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  121995. // Update the observable context (not null as it only goes away on dispose)
  121996. var info = this._renderingGroupInfo;
  121997. info.scene = this._scene;
  121998. info.camera = this._scene.activeCamera;
  121999. // Dispatch sprites
  122000. if (this._scene.spriteManagers && renderSprites) {
  122001. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  122002. var manager = this._scene.spriteManagers[index];
  122003. this.dispatchSprites(manager);
  122004. }
  122005. }
  122006. // Render
  122007. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122008. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  122009. var renderingGroup = this._renderingGroups[index];
  122010. if (!renderingGroup) {
  122011. continue;
  122012. }
  122013. var renderingGroupMask = Math.pow(2, index);
  122014. info.renderingGroupId = index;
  122015. // Before Observable
  122016. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122017. // Clear depth/stencil if needed
  122018. if (RenderingManager.AUTOCLEAR) {
  122019. var autoClear = this._useSceneAutoClearSetup ?
  122020. this._scene.getAutoClearDepthStencilSetup(index) :
  122021. this._autoClearDepthStencil[index];
  122022. if (autoClear && autoClear.autoClear) {
  122023. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  122024. }
  122025. }
  122026. // Render
  122027. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  122028. var step = _a[_i];
  122029. step.action(index);
  122030. }
  122031. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  122032. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  122033. var step = _c[_b];
  122034. step.action(index);
  122035. }
  122036. // After Observable
  122037. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122038. }
  122039. };
  122040. /**
  122041. * Resets the different information of the group to prepare a new frame
  122042. * @hidden
  122043. */
  122044. RenderingManager.prototype.reset = function () {
  122045. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122046. var renderingGroup = this._renderingGroups[index];
  122047. if (renderingGroup) {
  122048. renderingGroup.prepare();
  122049. }
  122050. }
  122051. };
  122052. /**
  122053. * Dispose and release the group and its associated resources.
  122054. * @hidden
  122055. */
  122056. RenderingManager.prototype.dispose = function () {
  122057. this.freeRenderingGroups();
  122058. this._renderingGroups.length = 0;
  122059. this._renderingGroupInfo = null;
  122060. };
  122061. /**
  122062. * Clear the info related to rendering groups preventing retention points during dispose.
  122063. */
  122064. RenderingManager.prototype.freeRenderingGroups = function () {
  122065. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122066. var renderingGroup = this._renderingGroups[index];
  122067. if (renderingGroup) {
  122068. renderingGroup.dispose();
  122069. }
  122070. }
  122071. };
  122072. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  122073. if (this._renderingGroups[renderingGroupId] === undefined) {
  122074. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  122075. }
  122076. };
  122077. /**
  122078. * Add a sprite manager to the rendering manager in order to render it this frame.
  122079. * @param spriteManager Define the sprite manager to render
  122080. */
  122081. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  122082. var renderingGroupId = spriteManager.renderingGroupId || 0;
  122083. this._prepareRenderingGroup(renderingGroupId);
  122084. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  122085. };
  122086. /**
  122087. * Add a particle system to the rendering manager in order to render it this frame.
  122088. * @param particleSystem Define the particle system to render
  122089. */
  122090. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  122091. var renderingGroupId = particleSystem.renderingGroupId || 0;
  122092. this._prepareRenderingGroup(renderingGroupId);
  122093. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  122094. };
  122095. /**
  122096. * Add a submesh to the manager in order to render it this frame
  122097. * @param subMesh The submesh to dispatch
  122098. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122099. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122100. */
  122101. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  122102. if (mesh === undefined) {
  122103. mesh = subMesh.getMesh();
  122104. }
  122105. var renderingGroupId = mesh.renderingGroupId || 0;
  122106. this._prepareRenderingGroup(renderingGroupId);
  122107. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  122108. };
  122109. /**
  122110. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  122111. * This allowed control for front to back rendering or reversly depending of the special needs.
  122112. *
  122113. * @param renderingGroupId The rendering group id corresponding to its index
  122114. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  122115. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  122116. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  122117. */
  122118. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  122119. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  122120. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  122121. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  122122. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  122123. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  122124. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  122125. if (this._renderingGroups[renderingGroupId]) {
  122126. var group = this._renderingGroups[renderingGroupId];
  122127. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  122128. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  122129. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  122130. }
  122131. };
  122132. /**
  122133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  122134. *
  122135. * @param renderingGroupId The rendering group id corresponding to its index
  122136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122137. * @param depth Automatically clears depth between groups if true and autoClear is true.
  122138. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  122139. */
  122140. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  122141. if (depth === void 0) { depth = true; }
  122142. if (stencil === void 0) { stencil = true; }
  122143. this._autoClearDepthStencil[renderingGroupId] = {
  122144. autoClear: autoClearDepthStencil,
  122145. depth: depth,
  122146. stencil: stencil
  122147. };
  122148. };
  122149. /**
  122150. * Gets the current auto clear configuration for one rendering group of the rendering
  122151. * manager.
  122152. * @param index the rendering group index to get the information for
  122153. * @returns The auto clear setup for the requested rendering group
  122154. */
  122155. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  122156. return this._autoClearDepthStencil[index];
  122157. };
  122158. /**
  122159. * The max id used for rendering groups (not included)
  122160. */
  122161. RenderingManager.MAX_RENDERINGGROUPS = 4;
  122162. /**
  122163. * The min id used for rendering groups (included)
  122164. */
  122165. RenderingManager.MIN_RENDERINGGROUPS = 0;
  122166. /**
  122167. * Used to globally prevent autoclearing scenes.
  122168. */
  122169. RenderingManager.AUTOCLEAR = true;
  122170. return RenderingManager;
  122171. }());
  122172. /***/ }),
  122173. /***/ "./Rendering/utilityLayerRenderer.ts":
  122174. /*!*******************************************!*\
  122175. !*** ./Rendering/utilityLayerRenderer.ts ***!
  122176. \*******************************************/
  122177. /*! exports provided: UtilityLayerRenderer */
  122178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122179. "use strict";
  122180. __webpack_require__.r(__webpack_exports__);
  122181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  122182. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122183. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122184. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  122185. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122186. /**
  122187. * Renders a layer on top of an existing scene
  122188. */
  122189. var UtilityLayerRenderer = /** @class */ (function () {
  122190. /**
  122191. * Instantiates a UtilityLayerRenderer
  122192. * @param originalScene the original scene that will be rendered on top of
  122193. * @param handleEvents boolean indicating if the utility layer should handle events
  122194. */
  122195. function UtilityLayerRenderer(
  122196. /** the original scene that will be rendered on top of */
  122197. originalScene, handleEvents) {
  122198. if (handleEvents === void 0) { handleEvents = true; }
  122199. var _this = this;
  122200. this.originalScene = originalScene;
  122201. this._pointerCaptures = {};
  122202. this._lastPointerEvents = {};
  122203. /**
  122204. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  122205. */
  122206. this.pickUtilitySceneFirst = true;
  122207. /**
  122208. * If the utility layer should automatically be rendered on top of existing scene
  122209. */
  122210. this.shouldRender = true;
  122211. /**
  122212. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  122213. */
  122214. this.onlyCheckPointerDownEvents = true;
  122215. /**
  122216. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  122217. */
  122218. this.processAllEvents = false;
  122219. /**
  122220. * Observable raised when the pointer move from the utility layer scene to the main scene
  122221. */
  122222. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  122223. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  122224. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  122225. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  122226. this.utilityLayerScene._allowPostProcessClearColor = false;
  122227. originalScene.getEngine().scenes.pop();
  122228. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  122229. this.utilityLayerScene.detachControl();
  122230. if (handleEvents) {
  122231. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  122232. if (!_this.utilityLayerScene.activeCamera) {
  122233. return;
  122234. }
  122235. if (!_this.processAllEvents) {
  122236. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  122237. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  122238. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122239. return;
  122240. }
  122241. }
  122242. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  122243. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  122244. var pointerEvent = (prePointerInfo.event);
  122245. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  122246. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122247. return;
  122248. }
  122249. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  122250. if (!prePointerInfo.ray && utilityScenePick) {
  122251. prePointerInfo.ray = utilityScenePick.ray;
  122252. }
  122253. // always fire the prepointer oversvable
  122254. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  122255. // allow every non pointer down event to flow to the utility layer
  122256. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122257. if (!prePointerInfo.skipOnPointerObservable) {
  122258. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122259. }
  122260. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  122261. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122262. }
  122263. return;
  122264. }
  122265. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  122266. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  122267. if (utilityScenePick && utilityScenePick.hit) {
  122268. if (!prePointerInfo.skipOnPointerObservable) {
  122269. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122270. }
  122271. prePointerInfo.skipOnPointerObservable = true;
  122272. }
  122273. }
  122274. else {
  122275. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  122276. var pointerEvent_1 = (prePointerInfo.event);
  122277. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  122278. if (originalScenePick && utilityScenePick) {
  122279. // No pick in utility scene
  122280. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  122281. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122282. // We touched an utility mesh present in the main scene
  122283. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122284. prePointerInfo.skipOnPointerObservable = true;
  122285. }
  122286. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122287. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  122288. }
  122289. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122290. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122291. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122292. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122293. }
  122294. }
  122295. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  122296. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  122297. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  122298. // If a previous utility layer set this, do not unset this
  122299. if (!prePointerInfo.skipOnPointerObservable) {
  122300. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  122301. }
  122302. }
  122303. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  122304. // We have a pick in both scenes but main is closer than utility
  122305. // We touched an utility mesh present in the main scene
  122306. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122307. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122308. prePointerInfo.skipOnPointerObservable = true;
  122309. }
  122310. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122311. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122312. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122313. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122314. }
  122315. }
  122316. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  122317. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  122318. }
  122319. }
  122320. }
  122321. });
  122322. }
  122323. // Render directly on top of existing scene without clearing
  122324. this.utilityLayerScene.autoClear = false;
  122325. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  122326. if (_this.shouldRender) {
  122327. _this.render();
  122328. }
  122329. });
  122330. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  122331. _this.dispose();
  122332. });
  122333. this._updateCamera();
  122334. }
  122335. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  122336. /**
  122337. * 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)
  122338. */
  122339. get: function () {
  122340. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  122341. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122342. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122343. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122344. });
  122345. }
  122346. return UtilityLayerRenderer._DefaultUtilityLayer;
  122347. },
  122348. enumerable: true,
  122349. configurable: true
  122350. });
  122351. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  122352. /**
  122353. * 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)
  122354. */
  122355. get: function () {
  122356. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  122357. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122358. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  122359. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122360. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122361. });
  122362. }
  122363. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  122364. },
  122365. enumerable: true,
  122366. configurable: true
  122367. });
  122368. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  122369. if (!prePointerInfo.skipOnPointerObservable) {
  122370. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  122371. this._lastPointerEvents[pointerEvent.pointerId] = true;
  122372. }
  122373. };
  122374. /**
  122375. * Renders the utility layers scene on top of the original scene
  122376. */
  122377. UtilityLayerRenderer.prototype.render = function () {
  122378. this._updateCamera();
  122379. if (this.utilityLayerScene.activeCamera) {
  122380. // Set the camera's scene to utility layers scene
  122381. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  122382. var camera = this.utilityLayerScene.activeCamera;
  122383. camera._scene = this.utilityLayerScene;
  122384. if (camera.leftCamera) {
  122385. camera.leftCamera._scene = this.utilityLayerScene;
  122386. }
  122387. if (camera.rightCamera) {
  122388. camera.rightCamera._scene = this.utilityLayerScene;
  122389. }
  122390. this.utilityLayerScene.render(false);
  122391. // Reset camera's scene back to original
  122392. camera._scene = oldScene;
  122393. if (camera.leftCamera) {
  122394. camera.leftCamera._scene = oldScene;
  122395. }
  122396. if (camera.rightCamera) {
  122397. camera.rightCamera._scene = oldScene;
  122398. }
  122399. }
  122400. };
  122401. /**
  122402. * Disposes of the renderer
  122403. */
  122404. UtilityLayerRenderer.prototype.dispose = function () {
  122405. this.onPointerOutObservable.clear();
  122406. if (this._afterRenderObserver) {
  122407. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  122408. }
  122409. if (this._sceneDisposeObserver) {
  122410. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  122411. }
  122412. if (this._originalPointerObserver) {
  122413. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  122414. }
  122415. this.utilityLayerScene.dispose();
  122416. };
  122417. UtilityLayerRenderer.prototype._updateCamera = function () {
  122418. if (this.originalScene.activeCameras.length > 1) {
  122419. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  122420. }
  122421. else {
  122422. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  122423. }
  122424. };
  122425. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122426. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122427. return UtilityLayerRenderer;
  122428. }());
  122429. /***/ }),
  122430. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  122431. /*!*****************************************************************!*\
  122432. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  122433. \*****************************************************************/
  122434. /*! exports provided: backgroundFragmentDeclaration */
  122435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122436. "use strict";
  122437. __webpack_require__.r(__webpack_exports__);
  122438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  122439. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122440. var name = 'backgroundFragmentDeclaration';
  122441. 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";
  122442. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122443. /** @hidden */
  122444. var backgroundFragmentDeclaration = { name: name, shader: shader };
  122445. /***/ }),
  122446. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  122447. /*!************************************************************!*\
  122448. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  122449. \************************************************************/
  122450. /*! exports provided: backgroundUboDeclaration */
  122451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122452. "use strict";
  122453. __webpack_require__.r(__webpack_exports__);
  122454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  122455. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122456. var name = 'backgroundUboDeclaration';
  122457. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  122458. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122459. /** @hidden */
  122460. var backgroundUboDeclaration = { name: name, shader: shader };
  122461. /***/ }),
  122462. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  122463. /*!***************************************************************!*\
  122464. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  122465. \***************************************************************/
  122466. /*! exports provided: backgroundVertexDeclaration */
  122467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122468. "use strict";
  122469. __webpack_require__.r(__webpack_exports__);
  122470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  122471. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122472. var name = 'backgroundVertexDeclaration';
  122473. 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";
  122474. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122475. /** @hidden */
  122476. var backgroundVertexDeclaration = { name: name, shader: shader };
  122477. /***/ }),
  122478. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  122479. /*!****************************************************!*\
  122480. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  122481. \****************************************************/
  122482. /*! exports provided: bonesDeclaration */
  122483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122484. "use strict";
  122485. __webpack_require__.r(__webpack_exports__);
  122486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  122487. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122488. var name = 'bonesDeclaration';
  122489. 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";
  122490. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122491. /** @hidden */
  122492. var bonesDeclaration = { name: name, shader: shader };
  122493. /***/ }),
  122494. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  122495. /*!***********************************************!*\
  122496. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  122497. \***********************************************/
  122498. /*! exports provided: bonesVertex */
  122499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122500. "use strict";
  122501. __webpack_require__.r(__webpack_exports__);
  122502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  122503. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122504. var name = 'bonesVertex';
  122505. 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";
  122506. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122507. /** @hidden */
  122508. var bonesVertex = { name: name, shader: shader };
  122509. /***/ }),
  122510. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  122511. /*!************************************************!*\
  122512. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  122513. \************************************************/
  122514. /*! exports provided: bumpFragment */
  122515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122516. "use strict";
  122517. __webpack_require__.r(__webpack_exports__);
  122518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  122519. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122520. var name = 'bumpFragment';
  122521. 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#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";
  122522. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122523. /** @hidden */
  122524. var bumpFragment = { name: name, shader: shader };
  122525. /***/ }),
  122526. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  122527. /*!*********************************************************!*\
  122528. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  122529. \*********************************************************/
  122530. /*! exports provided: bumpFragmentFunctions */
  122531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122532. "use strict";
  122533. __webpack_require__.r(__webpack_exports__);
  122534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  122535. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122536. var name = 'bumpFragmentFunctions';
  122537. var shader = "#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;\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\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*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef 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\n#endif";
  122538. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122539. /** @hidden */
  122540. var bumpFragmentFunctions = { name: name, shader: shader };
  122541. /***/ }),
  122542. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  122543. /*!**********************************************!*\
  122544. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  122545. \**********************************************/
  122546. /*! exports provided: bumpVertex */
  122547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122548. "use strict";
  122549. __webpack_require__.r(__webpack_exports__);
  122550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  122551. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122552. var name = 'bumpVertex';
  122553. var shader = "#if defined(BUMP) || defined(PARALLAX)\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";
  122554. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122555. /** @hidden */
  122556. var bumpVertex = { name: name, shader: shader };
  122557. /***/ }),
  122558. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  122559. /*!*********************************************************!*\
  122560. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  122561. \*********************************************************/
  122562. /*! exports provided: bumpVertexDeclaration */
  122563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122564. "use strict";
  122565. __webpack_require__.r(__webpack_exports__);
  122566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  122567. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122568. var name = 'bumpVertexDeclaration';
  122569. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  122570. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122571. /** @hidden */
  122572. var bumpVertexDeclaration = { name: name, shader: shader };
  122573. /***/ }),
  122574. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  122575. /*!*****************************************************!*\
  122576. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  122577. \*****************************************************/
  122578. /*! exports provided: clipPlaneFragment */
  122579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122580. "use strict";
  122581. __webpack_require__.r(__webpack_exports__);
  122582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  122583. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122584. var name = 'clipPlaneFragment';
  122585. 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";
  122586. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122587. /** @hidden */
  122588. var clipPlaneFragment = { name: name, shader: shader };
  122589. /***/ }),
  122590. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  122591. /*!****************************************************************!*\
  122592. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  122593. \****************************************************************/
  122594. /*! exports provided: clipPlaneFragmentDeclaration */
  122595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122596. "use strict";
  122597. __webpack_require__.r(__webpack_exports__);
  122598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  122599. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122600. var name = 'clipPlaneFragmentDeclaration';
  122601. 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";
  122602. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122603. /** @hidden */
  122604. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  122605. /***/ }),
  122606. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  122607. /*!*****************************************************************!*\
  122608. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  122609. \*****************************************************************/
  122610. /*! exports provided: clipPlaneFragmentDeclaration2 */
  122611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122612. "use strict";
  122613. __webpack_require__.r(__webpack_exports__);
  122614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  122615. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122616. var name = 'clipPlaneFragmentDeclaration2';
  122617. 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";
  122618. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122619. /** @hidden */
  122620. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  122621. /***/ }),
  122622. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  122623. /*!***************************************************!*\
  122624. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  122625. \***************************************************/
  122626. /*! exports provided: clipPlaneVertex */
  122627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122628. "use strict";
  122629. __webpack_require__.r(__webpack_exports__);
  122630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  122631. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122632. var name = 'clipPlaneVertex';
  122633. 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";
  122634. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122635. /** @hidden */
  122636. var clipPlaneVertex = { name: name, shader: shader };
  122637. /***/ }),
  122638. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  122639. /*!**************************************************************!*\
  122640. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  122641. \**************************************************************/
  122642. /*! exports provided: clipPlaneVertexDeclaration */
  122643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122644. "use strict";
  122645. __webpack_require__.r(__webpack_exports__);
  122646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  122647. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122648. var name = 'clipPlaneVertexDeclaration';
  122649. 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";
  122650. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122651. /** @hidden */
  122652. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  122653. /***/ }),
  122654. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  122655. /*!***************************************************************!*\
  122656. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  122657. \***************************************************************/
  122658. /*! exports provided: clipPlaneVertexDeclaration2 */
  122659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122660. "use strict";
  122661. __webpack_require__.r(__webpack_exports__);
  122662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  122663. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122664. var name = 'clipPlaneVertexDeclaration2';
  122665. 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";
  122666. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122667. /** @hidden */
  122668. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  122669. /***/ }),
  122670. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  122671. /*!**************************************************************!*\
  122672. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  122673. \**************************************************************/
  122674. /*! exports provided: defaultFragmentDeclaration */
  122675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122676. "use strict";
  122677. __webpack_require__.r(__webpack_exports__);
  122678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  122679. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122680. var name = 'defaultFragmentDeclaration';
  122681. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  122682. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122683. /** @hidden */
  122684. var defaultFragmentDeclaration = { name: name, shader: shader };
  122685. /***/ }),
  122686. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  122687. /*!*********************************************************!*\
  122688. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  122689. \*********************************************************/
  122690. /*! exports provided: defaultUboDeclaration */
  122691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122692. "use strict";
  122693. __webpack_require__.r(__webpack_exports__);
  122694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  122695. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122696. var name = 'defaultUboDeclaration';
  122697. 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;\nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  122698. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122699. /** @hidden */
  122700. var defaultUboDeclaration = { name: name, shader: shader };
  122701. /***/ }),
  122702. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  122703. /*!************************************************************!*\
  122704. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  122705. \************************************************************/
  122706. /*! exports provided: defaultVertexDeclaration */
  122707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122708. "use strict";
  122709. __webpack_require__.r(__webpack_exports__);
  122710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  122711. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122712. var name = 'defaultVertexDeclaration';
  122713. 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";
  122714. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122715. /** @hidden */
  122716. var defaultVertexDeclaration = { name: name, shader: shader };
  122717. /***/ }),
  122718. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  122719. /*!************************************************!*\
  122720. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  122721. \************************************************/
  122722. /*! exports provided: depthPrePass */
  122723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122724. "use strict";
  122725. __webpack_require__.r(__webpack_exports__);
  122726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  122727. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122728. var name = 'depthPrePass';
  122729. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  122730. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122731. /** @hidden */
  122732. var depthPrePass = { name: name, shader: shader };
  122733. /***/ }),
  122734. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  122735. /*!***********************************************!*\
  122736. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  122737. \***********************************************/
  122738. /*! exports provided: fogFragment */
  122739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122740. "use strict";
  122741. __webpack_require__.r(__webpack_exports__);
  122742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  122743. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122744. var name = 'fogFragment';
  122745. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  122746. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122747. /** @hidden */
  122748. var fogFragment = { name: name, shader: shader };
  122749. /***/ }),
  122750. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  122751. /*!**********************************************************!*\
  122752. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  122753. \**********************************************************/
  122754. /*! exports provided: fogFragmentDeclaration */
  122755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122756. "use strict";
  122757. __webpack_require__.r(__webpack_exports__);
  122758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  122759. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122760. var name = 'fogFragmentDeclaration';
  122761. 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";
  122762. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122763. /** @hidden */
  122764. var fogFragmentDeclaration = { name: name, shader: shader };
  122765. /***/ }),
  122766. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  122767. /*!*********************************************!*\
  122768. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  122769. \*********************************************/
  122770. /*! exports provided: fogVertex */
  122771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122772. "use strict";
  122773. __webpack_require__.r(__webpack_exports__);
  122774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  122775. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122776. var name = 'fogVertex';
  122777. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  122778. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122779. /** @hidden */
  122780. var fogVertex = { name: name, shader: shader };
  122781. /***/ }),
  122782. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  122783. /*!********************************************************!*\
  122784. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  122785. \********************************************************/
  122786. /*! exports provided: fogVertexDeclaration */
  122787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122788. "use strict";
  122789. __webpack_require__.r(__webpack_exports__);
  122790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  122791. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122792. var name = 'fogVertexDeclaration';
  122793. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  122794. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122795. /** @hidden */
  122796. var fogVertexDeclaration = { name: name, shader: shader };
  122797. /***/ }),
  122798. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  122799. /*!***************************************************!*\
  122800. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  122801. \***************************************************/
  122802. /*! exports provided: fresnelFunction */
  122803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122804. "use strict";
  122805. __webpack_require__.r(__webpack_exports__);
  122806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  122807. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122808. var name = 'fresnelFunction';
  122809. 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";
  122810. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122811. /** @hidden */
  122812. var fresnelFunction = { name: name, shader: shader };
  122813. /***/ }),
  122814. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  122815. /*!******************************************************!*\
  122816. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  122817. \******************************************************/
  122818. /*! exports provided: harmonicsFunctions */
  122819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122820. "use strict";
  122821. __webpack_require__.r(__webpack_exports__);
  122822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  122823. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122824. var name = 'harmonicsFunctions';
  122825. var shader = "#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif";
  122826. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122827. /** @hidden */
  122828. var harmonicsFunctions = { name: name, shader: shader };
  122829. /***/ }),
  122830. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  122831. /*!***************************************************!*\
  122832. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  122833. \***************************************************/
  122834. /*! exports provided: helperFunctions */
  122835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122836. "use strict";
  122837. __webpack_require__.r(__webpack_exports__);
  122838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  122839. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122840. var name = 'helperFunctions';
  122841. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  122842. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122843. /** @hidden */
  122844. var helperFunctions = { name: name, shader: shader };
  122845. /***/ }),
  122846. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  122847. /*!**************************************************************!*\
  122848. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  122849. \**************************************************************/
  122850. /*! exports provided: imageProcessingDeclaration */
  122851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122852. "use strict";
  122853. __webpack_require__.r(__webpack_exports__);
  122854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  122855. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122856. var name = 'imageProcessingDeclaration';
  122857. 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";
  122858. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122859. /** @hidden */
  122860. var imageProcessingDeclaration = { name: name, shader: shader };
  122861. /***/ }),
  122862. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  122863. /*!************************************************************!*\
  122864. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  122865. \************************************************************/
  122866. /*! exports provided: imageProcessingFunctions */
  122867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122868. "use strict";
  122869. __webpack_require__.r(__webpack_exports__);
  122870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  122871. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122872. var name = 'imageProcessingFunctions';
  122873. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  122874. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122875. /** @hidden */
  122876. var imageProcessingFunctions = { name: name, shader: shader };
  122877. /***/ }),
  122878. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  122879. /*!********************************************************!*\
  122880. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  122881. \********************************************************/
  122882. /*! exports provided: instancesDeclaration */
  122883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122884. "use strict";
  122885. __webpack_require__.r(__webpack_exports__);
  122886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  122887. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122888. var name = 'instancesDeclaration';
  122889. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  122890. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122891. /** @hidden */
  122892. var instancesDeclaration = { name: name, shader: shader };
  122893. /***/ }),
  122894. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  122895. /*!***************************************************!*\
  122896. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  122897. \***************************************************/
  122898. /*! exports provided: instancesVertex */
  122899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122900. "use strict";
  122901. __webpack_require__.r(__webpack_exports__);
  122902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  122903. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122904. var name = 'instancesVertex';
  122905. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  122906. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122907. /** @hidden */
  122908. var instancesVertex = { name: name, shader: shader };
  122909. /***/ }),
  122910. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  122911. /*!******************************************************!*\
  122912. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  122913. \******************************************************/
  122914. /*! exports provided: kernelBlurFragment */
  122915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122916. "use strict";
  122917. __webpack_require__.r(__webpack_exports__);
  122918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  122919. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122920. var name = 'kernelBlurFragment';
  122921. 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";
  122922. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122923. /** @hidden */
  122924. var kernelBlurFragment = { name: name, shader: shader };
  122925. /***/ }),
  122926. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  122927. /*!*******************************************************!*\
  122928. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  122929. \*******************************************************/
  122930. /*! exports provided: kernelBlurFragment2 */
  122931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122932. "use strict";
  122933. __webpack_require__.r(__webpack_exports__);
  122934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  122935. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122936. var name = 'kernelBlurFragment2';
  122937. 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";
  122938. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122939. /** @hidden */
  122940. var kernelBlurFragment2 = { name: name, shader: shader };
  122941. /***/ }),
  122942. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  122943. /*!****************************************************************!*\
  122944. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  122945. \****************************************************************/
  122946. /*! exports provided: kernelBlurVaryingDeclaration */
  122947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122948. "use strict";
  122949. __webpack_require__.r(__webpack_exports__);
  122950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  122951. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122952. var name = 'kernelBlurVaryingDeclaration';
  122953. var shader = "varying vec2 sampleCoord{X};";
  122954. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122955. /** @hidden */
  122956. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  122957. /***/ }),
  122958. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  122959. /*!****************************************************!*\
  122960. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  122961. \****************************************************/
  122962. /*! exports provided: kernelBlurVertex */
  122963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122964. "use strict";
  122965. __webpack_require__.r(__webpack_exports__);
  122966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  122967. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122968. var name = 'kernelBlurVertex';
  122969. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  122970. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122971. /** @hidden */
  122972. var kernelBlurVertex = { name: name, shader: shader };
  122973. /***/ }),
  122974. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  122975. /*!*************************************************!*\
  122976. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  122977. \*************************************************/
  122978. /*! exports provided: lightFragment */
  122979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122980. "use strict";
  122981. __webpack_require__.r(__webpack_exports__);
  122982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  122983. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122984. var name = 'lightFragment';
  122985. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\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#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  122986. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122987. /** @hidden */
  122988. var lightFragment = { name: name, shader: shader };
  122989. /***/ }),
  122990. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  122991. /*!************************************************************!*\
  122992. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  122993. \************************************************************/
  122994. /*! exports provided: lightFragmentDeclaration */
  122995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122996. "use strict";
  122997. __webpack_require__.r(__webpack_exports__);
  122998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  122999. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123000. var name = 'lightFragmentDeclaration';
  123001. 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";
  123002. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123003. /** @hidden */
  123004. var lightFragmentDeclaration = { name: name, shader: shader };
  123005. /***/ }),
  123006. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  123007. /*!*******************************************************!*\
  123008. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  123009. \*******************************************************/
  123010. /*! exports provided: lightUboDeclaration */
  123011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123012. "use strict";
  123013. __webpack_require__.r(__webpack_exports__);
  123014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  123015. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123016. var name = 'lightUboDeclaration';
  123017. 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";
  123018. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123019. /** @hidden */
  123020. var lightUboDeclaration = { name: name, shader: shader };
  123021. /***/ }),
  123022. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  123023. /*!***********************************************************!*\
  123024. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  123025. \***********************************************************/
  123026. /*! exports provided: lightsFragmentFunctions */
  123027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123028. "use strict";
  123029. __webpack_require__.r(__webpack_exports__);
  123030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  123031. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123032. var name = 'lightsFragmentFunctions';
  123033. 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}";
  123034. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123035. /** @hidden */
  123036. var lightsFragmentFunctions = { name: name, shader: shader };
  123037. /***/ }),
  123038. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  123039. /*!*******************************************************!*\
  123040. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  123041. \*******************************************************/
  123042. /*! exports provided: logDepthDeclaration */
  123043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123044. "use strict";
  123045. __webpack_require__.r(__webpack_exports__);
  123046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  123047. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123048. var name = 'logDepthDeclaration';
  123049. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  123050. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123051. /** @hidden */
  123052. var logDepthDeclaration = { name: name, shader: shader };
  123053. /***/ }),
  123054. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  123055. /*!****************************************************!*\
  123056. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  123057. \****************************************************/
  123058. /*! exports provided: logDepthFragment */
  123059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123060. "use strict";
  123061. __webpack_require__.r(__webpack_exports__);
  123062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  123063. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123064. var name = 'logDepthFragment';
  123065. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  123066. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123067. /** @hidden */
  123068. var logDepthFragment = { name: name, shader: shader };
  123069. /***/ }),
  123070. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  123071. /*!**************************************************!*\
  123072. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  123073. \**************************************************/
  123074. /*! exports provided: logDepthVertex */
  123075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123076. "use strict";
  123077. __webpack_require__.r(__webpack_exports__);
  123078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  123079. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123080. var name = 'logDepthVertex';
  123081. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  123082. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123083. /** @hidden */
  123084. var logDepthVertex = { name: name, shader: shader };
  123085. /***/ }),
  123086. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  123087. /*!******************************************************!*\
  123088. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  123089. \******************************************************/
  123090. /*! exports provided: morphTargetsVertex */
  123091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123092. "use strict";
  123093. __webpack_require__.r(__webpack_exports__);
  123094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  123095. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123096. var name = 'morphTargetsVertex';
  123097. var shader = "#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif";
  123098. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123099. /** @hidden */
  123100. var morphTargetsVertex = { name: name, shader: shader };
  123101. /***/ }),
  123102. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  123103. /*!*****************************************************************!*\
  123104. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  123105. \*****************************************************************/
  123106. /*! exports provided: morphTargetsVertexDeclaration */
  123107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123108. "use strict";
  123109. __webpack_require__.r(__webpack_exports__);
  123110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  123111. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123112. var name = 'morphTargetsVertexDeclaration';
  123113. var shader = "#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif";
  123114. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123115. /** @hidden */
  123116. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  123117. /***/ }),
  123118. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  123119. /*!***********************************************************************!*\
  123120. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  123121. \***********************************************************************/
  123122. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  123123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123124. "use strict";
  123125. __webpack_require__.r(__webpack_exports__);
  123126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  123127. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123128. var name = 'morphTargetsVertexGlobalDeclaration';
  123129. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  123130. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123131. /** @hidden */
  123132. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  123133. /***/ }),
  123134. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  123135. /*!**********************************************************!*\
  123136. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  123137. \**********************************************************/
  123138. /*! exports provided: mrtFragmentDeclaration */
  123139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123140. "use strict";
  123141. __webpack_require__.r(__webpack_exports__);
  123142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  123143. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123144. var name = 'mrtFragmentDeclaration';
  123145. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  123146. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123147. /** @hidden */
  123148. var mrtFragmentDeclaration = { name: name, shader: shader };
  123149. /***/ }),
  123150. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  123151. /*!**********************************************************!*\
  123152. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  123153. \**********************************************************/
  123154. /*! exports provided: pbrFragmentDeclaration */
  123155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123156. "use strict";
  123157. __webpack_require__.r(__webpack_exports__);
  123158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  123159. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123160. var name = 'pbrFragmentDeclaration';
  123161. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif";
  123162. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123163. /** @hidden */
  123164. var pbrFragmentDeclaration = { name: name, shader: shader };
  123165. /***/ }),
  123166. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  123167. /*!************************************************!*\
  123168. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  123169. \************************************************/
  123170. /*! exports provided: pbrFunctions */
  123171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123172. "use strict";
  123173. __webpack_require__.r(__webpack_exports__);
  123174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  123175. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123176. var name = 'pbrFunctions';
  123177. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\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}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  123178. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123179. /** @hidden */
  123180. var pbrFunctions = { name: name, shader: shader };
  123181. /***/ }),
  123182. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  123183. /*!*****************************************************!*\
  123184. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  123185. \*****************************************************/
  123186. /*! exports provided: pbrLightFunctions */
  123187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123188. "use strict";
  123189. __webpack_require__.r(__webpack_exports__);
  123190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  123191. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123192. var name = 'pbrLightFunctions';
  123193. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\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 toLinearSpace(textureColor);\n}";
  123194. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123195. /** @hidden */
  123196. var pbrLightFunctions = { name: name, shader: shader };
  123197. /***/ }),
  123198. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  123199. /*!*****************************************************!*\
  123200. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  123201. \*****************************************************/
  123202. /*! exports provided: pbrUboDeclaration */
  123203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123204. "use strict";
  123205. __webpack_require__.r(__webpack_exports__);
  123206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  123207. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123208. var name = 'pbrUboDeclaration';
  123209. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  123210. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123211. /** @hidden */
  123212. var pbrUboDeclaration = { name: name, shader: shader };
  123213. /***/ }),
  123214. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  123215. /*!********************************************************!*\
  123216. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  123217. \********************************************************/
  123218. /*! exports provided: pbrVertexDeclaration */
  123219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123220. "use strict";
  123221. __webpack_require__.r(__webpack_exports__);
  123222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  123223. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123224. var name = 'pbrVertexDeclaration';
  123225. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n";
  123226. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123227. /** @hidden */
  123228. var pbrVertexDeclaration = { name: name, shader: shader };
  123229. /***/ }),
  123230. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  123231. /*!****************************************************!*\
  123232. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  123233. \****************************************************/
  123234. /*! exports provided: pointCloudVertex */
  123235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123236. "use strict";
  123237. __webpack_require__.r(__webpack_exports__);
  123238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  123239. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123240. var name = 'pointCloudVertex';
  123241. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  123242. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123243. /** @hidden */
  123244. var pointCloudVertex = { name: name, shader: shader };
  123245. /***/ }),
  123246. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  123247. /*!******************************************************!*\
  123248. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  123249. \******************************************************/
  123250. /*! exports provided: reflectionFunction */
  123251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123252. "use strict";
  123253. __webpack_require__.r(__webpack_exports__);
  123254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  123255. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123256. var name = 'reflectionFunction';
  123257. var shader = "#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  123258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123259. /** @hidden */
  123260. var reflectionFunction = { name: name, shader: shader };
  123261. /***/ }),
  123262. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  123263. /*!************************************************************!*\
  123264. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  123265. \************************************************************/
  123266. /*! exports provided: shadowsFragmentFunctions */
  123267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123268. "use strict";
  123269. __webpack_require__.r(__webpack_exports__);
  123270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  123271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123272. var name = 'shadowsFragmentFunctions';
  123273. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  123274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123275. /** @hidden */
  123276. var shadowsFragmentFunctions = { name: name, shader: shader };
  123277. /***/ }),
  123278. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  123279. /*!*************************************************!*\
  123280. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  123281. \*************************************************/
  123282. /*! exports provided: shadowsVertex */
  123283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123284. "use strict";
  123285. __webpack_require__.r(__webpack_exports__);
  123286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  123287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123288. var name = 'shadowsVertex';
  123289. 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";
  123290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123291. /** @hidden */
  123292. var shadowsVertex = { name: name, shader: shader };
  123293. /***/ }),
  123294. /***/ "./Shaders/anaglyph.fragment.ts":
  123295. /*!**************************************!*\
  123296. !*** ./Shaders/anaglyph.fragment.ts ***!
  123297. \**************************************/
  123298. /*! exports provided: anaglyphPixelShader */
  123299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123300. "use strict";
  123301. __webpack_require__.r(__webpack_exports__);
  123302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  123303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123304. var name = 'anaglyphPixelShader';
  123305. 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}";
  123306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123307. /** @hidden */
  123308. var anaglyphPixelShader = { name: name, shader: shader };
  123309. /***/ }),
  123310. /***/ "./Shaders/background.fragment.ts":
  123311. /*!****************************************!*\
  123312. !*** ./Shaders/background.fragment.ts ***!
  123313. \****************************************/
  123314. /*! exports provided: backgroundPixelShader */
  123315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123316. "use strict";
  123317. __webpack_require__.r(__webpack_exports__);
  123318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  123319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123320. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  123321. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123322. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123323. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123324. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123325. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123326. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123327. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123328. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123329. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123330. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123331. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123332. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123333. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123334. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123335. var name = 'backgroundPixelShader';
  123336. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  123337. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123338. /** @hidden */
  123339. var backgroundPixelShader = { name: name, shader: shader };
  123340. /***/ }),
  123341. /***/ "./Shaders/background.vertex.ts":
  123342. /*!**************************************!*\
  123343. !*** ./Shaders/background.vertex.ts ***!
  123344. \**************************************/
  123345. /*! exports provided: backgroundVertexShader */
  123346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123347. "use strict";
  123348. __webpack_require__.r(__webpack_exports__);
  123349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  123350. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123351. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  123352. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123353. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123354. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123355. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123356. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123357. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123358. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123359. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123360. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123361. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123362. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123363. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123364. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123365. var name = 'backgroundVertexShader';
  123366. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  123367. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123368. /** @hidden */
  123369. var backgroundVertexShader = { name: name, shader: shader };
  123370. /***/ }),
  123371. /***/ "./Shaders/blackAndWhite.fragment.ts":
  123372. /*!*******************************************!*\
  123373. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  123374. \*******************************************/
  123375. /*! exports provided: blackAndWhitePixelShader */
  123376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123377. "use strict";
  123378. __webpack_require__.r(__webpack_exports__);
  123379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  123380. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123381. var name = 'blackAndWhitePixelShader';
  123382. 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}";
  123383. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123384. /** @hidden */
  123385. var blackAndWhitePixelShader = { name: name, shader: shader };
  123386. /***/ }),
  123387. /***/ "./Shaders/bloomMerge.fragment.ts":
  123388. /*!****************************************!*\
  123389. !*** ./Shaders/bloomMerge.fragment.ts ***!
  123390. \****************************************/
  123391. /*! exports provided: bloomMergePixelShader */
  123392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123393. "use strict";
  123394. __webpack_require__.r(__webpack_exports__);
  123395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  123396. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123397. var name = 'bloomMergePixelShader';
  123398. 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";
  123399. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123400. /** @hidden */
  123401. var bloomMergePixelShader = { name: name, shader: shader };
  123402. /***/ }),
  123403. /***/ "./Shaders/chromaticAberration.fragment.ts":
  123404. /*!*************************************************!*\
  123405. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  123406. \*************************************************/
  123407. /*! exports provided: chromaticAberrationPixelShader */
  123408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123409. "use strict";
  123410. __webpack_require__.r(__webpack_exports__);
  123411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  123412. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123413. var name = 'chromaticAberrationPixelShader';
  123414. 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}";
  123415. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123416. /** @hidden */
  123417. var chromaticAberrationPixelShader = { name: name, shader: shader };
  123418. /***/ }),
  123419. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  123420. /*!***********************************************!*\
  123421. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  123422. \***********************************************/
  123423. /*! exports provided: circleOfConfusionPixelShader */
  123424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123425. "use strict";
  123426. __webpack_require__.r(__webpack_exports__);
  123427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  123428. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123429. var name = 'circleOfConfusionPixelShader';
  123430. 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";
  123431. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123432. /** @hidden */
  123433. var circleOfConfusionPixelShader = { name: name, shader: shader };
  123434. /***/ }),
  123435. /***/ "./Shaders/color.fragment.ts":
  123436. /*!***********************************!*\
  123437. !*** ./Shaders/color.fragment.ts ***!
  123438. \***********************************/
  123439. /*! exports provided: colorPixelShader */
  123440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123441. "use strict";
  123442. __webpack_require__.r(__webpack_exports__);
  123443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  123444. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123445. var name = 'colorPixelShader';
  123446. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  123447. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123448. /** @hidden */
  123449. var colorPixelShader = { name: name, shader: shader };
  123450. /***/ }),
  123451. /***/ "./Shaders/color.vertex.ts":
  123452. /*!*********************************!*\
  123453. !*** ./Shaders/color.vertex.ts ***!
  123454. \*********************************/
  123455. /*! exports provided: colorVertexShader */
  123456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123457. "use strict";
  123458. __webpack_require__.r(__webpack_exports__);
  123459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  123460. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123461. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123462. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123463. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123464. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123465. var name = 'colorVertexShader';
  123466. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  123467. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123468. /** @hidden */
  123469. var colorVertexShader = { name: name, shader: shader };
  123470. /***/ }),
  123471. /***/ "./Shaders/colorCorrection.fragment.ts":
  123472. /*!*********************************************!*\
  123473. !*** ./Shaders/colorCorrection.fragment.ts ***!
  123474. \*********************************************/
  123475. /*! exports provided: colorCorrectionPixelShader */
  123476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123477. "use strict";
  123478. __webpack_require__.r(__webpack_exports__);
  123479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  123480. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123481. var name = 'colorCorrectionPixelShader';
  123482. 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}";
  123483. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123484. /** @hidden */
  123485. var colorCorrectionPixelShader = { name: name, shader: shader };
  123486. /***/ }),
  123487. /***/ "./Shaders/convolution.fragment.ts":
  123488. /*!*****************************************!*\
  123489. !*** ./Shaders/convolution.fragment.ts ***!
  123490. \*****************************************/
  123491. /*! exports provided: convolutionPixelShader */
  123492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123493. "use strict";
  123494. __webpack_require__.r(__webpack_exports__);
  123495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  123496. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123497. var name = 'convolutionPixelShader';
  123498. 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}";
  123499. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123500. /** @hidden */
  123501. var convolutionPixelShader = { name: name, shader: shader };
  123502. /***/ }),
  123503. /***/ "./Shaders/default.fragment.ts":
  123504. /*!*************************************!*\
  123505. !*** ./Shaders/default.fragment.ts ***!
  123506. \*************************************/
  123507. /*! exports provided: defaultPixelShader */
  123508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123509. "use strict";
  123510. __webpack_require__.r(__webpack_exports__);
  123511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  123512. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123513. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  123514. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123515. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123516. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123517. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123518. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123519. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123520. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  123521. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123522. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123523. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123524. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123525. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123526. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123527. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123528. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123529. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123530. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123531. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123532. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123533. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123534. var name = 'defaultPixelShader';
  123535. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  123536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123537. /** @hidden */
  123538. var defaultPixelShader = { name: name, shader: shader };
  123539. /***/ }),
  123540. /***/ "./Shaders/default.vertex.ts":
  123541. /*!***********************************!*\
  123542. !*** ./Shaders/default.vertex.ts ***!
  123543. \***********************************/
  123544. /*! exports provided: defaultVertexShader */
  123545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123546. "use strict";
  123547. __webpack_require__.r(__webpack_exports__);
  123548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  123549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123550. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  123551. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123552. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123553. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123554. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123555. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123556. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123557. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123558. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123559. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123560. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123561. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123562. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123563. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123564. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123565. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123566. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123567. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123568. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123569. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123570. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  123571. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123572. var name = 'defaultVertexShader';
  123573. var shader = "#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  123574. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123575. /** @hidden */
  123576. var defaultVertexShader = { name: name, shader: shader };
  123577. /***/ }),
  123578. /***/ "./Shaders/depth.fragment.ts":
  123579. /*!***********************************!*\
  123580. !*** ./Shaders/depth.fragment.ts ***!
  123581. \***********************************/
  123582. /*! exports provided: depthPixelShader */
  123583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123584. "use strict";
  123585. __webpack_require__.r(__webpack_exports__);
  123586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  123587. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123588. var name = 'depthPixelShader';
  123589. var shader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}";
  123590. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123591. /** @hidden */
  123592. var depthPixelShader = { name: name, shader: shader };
  123593. /***/ }),
  123594. /***/ "./Shaders/depth.vertex.ts":
  123595. /*!*********************************!*\
  123596. !*** ./Shaders/depth.vertex.ts ***!
  123597. \*********************************/
  123598. /*! exports provided: depthVertexShader */
  123599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123600. "use strict";
  123601. __webpack_require__.r(__webpack_exports__);
  123602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  123603. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123604. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123605. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123606. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123607. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123608. var name = 'depthVertexShader';
  123609. var shader = "\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  123610. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123611. /** @hidden */
  123612. var depthVertexShader = { name: name, shader: shader };
  123613. /***/ }),
  123614. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  123615. /*!******************************************!*\
  123616. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  123617. \******************************************/
  123618. /*! exports provided: depthBoxBlurPixelShader */
  123619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123620. "use strict";
  123621. __webpack_require__.r(__webpack_exports__);
  123622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  123623. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123624. var name = 'depthBoxBlurPixelShader';
  123625. 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}";
  123626. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123627. /** @hidden */
  123628. var depthBoxBlurPixelShader = { name: name, shader: shader };
  123629. /***/ }),
  123630. /***/ "./Shaders/depthOfField.fragment.ts":
  123631. /*!******************************************!*\
  123632. !*** ./Shaders/depthOfField.fragment.ts ***!
  123633. \******************************************/
  123634. /*! exports provided: depthOfFieldPixelShader */
  123635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123636. "use strict";
  123637. __webpack_require__.r(__webpack_exports__);
  123638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  123639. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123640. var name = 'depthOfFieldPixelShader';
  123641. 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";
  123642. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123643. /** @hidden */
  123644. var depthOfFieldPixelShader = { name: name, shader: shader };
  123645. /***/ }),
  123646. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  123647. /*!***********************************************!*\
  123648. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  123649. \***********************************************/
  123650. /*! exports provided: depthOfFieldMergePixelShader */
  123651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123652. "use strict";
  123653. __webpack_require__.r(__webpack_exports__);
  123654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  123655. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123656. var name = 'depthOfFieldMergePixelShader';
  123657. 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";
  123658. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123659. /** @hidden */
  123660. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  123661. /***/ }),
  123662. /***/ "./Shaders/displayPass.fragment.ts":
  123663. /*!*****************************************!*\
  123664. !*** ./Shaders/displayPass.fragment.ts ***!
  123665. \*****************************************/
  123666. /*! exports provided: displayPassPixelShader */
  123667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123668. "use strict";
  123669. __webpack_require__.r(__webpack_exports__);
  123670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  123671. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123672. var name = 'displayPassPixelShader';
  123673. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  123674. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123675. /** @hidden */
  123676. var displayPassPixelShader = { name: name, shader: shader };
  123677. /***/ }),
  123678. /***/ "./Shaders/extractHighlights.fragment.ts":
  123679. /*!***********************************************!*\
  123680. !*** ./Shaders/extractHighlights.fragment.ts ***!
  123681. \***********************************************/
  123682. /*! exports provided: extractHighlightsPixelShader */
  123683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123684. "use strict";
  123685. __webpack_require__.r(__webpack_exports__);
  123686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  123687. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123688. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123689. var name = 'extractHighlightsPixelShader';
  123690. 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}";
  123691. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123692. /** @hidden */
  123693. var extractHighlightsPixelShader = { name: name, shader: shader };
  123694. /***/ }),
  123695. /***/ "./Shaders/filter.fragment.ts":
  123696. /*!************************************!*\
  123697. !*** ./Shaders/filter.fragment.ts ***!
  123698. \************************************/
  123699. /*! exports provided: filterPixelShader */
  123700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123701. "use strict";
  123702. __webpack_require__.r(__webpack_exports__);
  123703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  123704. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123705. var name = 'filterPixelShader';
  123706. 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}";
  123707. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123708. /** @hidden */
  123709. var filterPixelShader = { name: name, shader: shader };
  123710. /***/ }),
  123711. /***/ "./Shaders/fxaa.fragment.ts":
  123712. /*!**********************************!*\
  123713. !*** ./Shaders/fxaa.fragment.ts ***!
  123714. \**********************************/
  123715. /*! exports provided: fxaaPixelShader */
  123716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123717. "use strict";
  123718. __webpack_require__.r(__webpack_exports__);
  123719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  123720. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123721. var name = 'fxaaPixelShader';
  123722. 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}";
  123723. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123724. /** @hidden */
  123725. var fxaaPixelShader = { name: name, shader: shader };
  123726. /***/ }),
  123727. /***/ "./Shaders/fxaa.vertex.ts":
  123728. /*!********************************!*\
  123729. !*** ./Shaders/fxaa.vertex.ts ***!
  123730. \********************************/
  123731. /*! exports provided: fxaaVertexShader */
  123732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123733. "use strict";
  123734. __webpack_require__.r(__webpack_exports__);
  123735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  123736. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123737. var name = 'fxaaVertexShader';
  123738. 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}";
  123739. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123740. /** @hidden */
  123741. var fxaaVertexShader = { name: name, shader: shader };
  123742. /***/ }),
  123743. /***/ "./Shaders/geometry.fragment.ts":
  123744. /*!**************************************!*\
  123745. !*** ./Shaders/geometry.fragment.ts ***!
  123746. \**************************************/
  123747. /*! exports provided: geometryPixelShader */
  123748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123749. "use strict";
  123750. __webpack_require__.r(__webpack_exports__);
  123751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  123752. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123753. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  123754. var name = 'geometryPixelShader';
  123755. var shader = "#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPosition,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=(a-b)*0.5+0.5;\nvelocity*=0.5+0.5;\nvelocity=vec2(pow(velocity.x,3.0),pow(velocity.y,3.0));\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";
  123756. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123757. /** @hidden */
  123758. var geometryPixelShader = { name: name, shader: shader };
  123759. /***/ }),
  123760. /***/ "./Shaders/geometry.vertex.ts":
  123761. /*!************************************!*\
  123762. !*** ./Shaders/geometry.vertex.ts ***!
  123763. \************************************/
  123764. /*! exports provided: geometryVertexShader */
  123765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123766. "use strict";
  123767. __webpack_require__.r(__webpack_exports__);
  123768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  123769. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123770. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123771. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123772. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123773. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123774. var name = 'geometryVertexShader';
  123775. var shader = "precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorldViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\n#ifdef VELOCITY\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousWorldViewProjection*vec4(position,1.0);\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  123776. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123777. /** @hidden */
  123778. var geometryVertexShader = { name: name, shader: shader };
  123779. /***/ }),
  123780. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  123781. /*!*************************************************!*\
  123782. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  123783. \*************************************************/
  123784. /*! exports provided: glowBlurPostProcessPixelShader */
  123785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123786. "use strict";
  123787. __webpack_require__.r(__webpack_exports__);
  123788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  123789. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123790. var name = 'glowBlurPostProcessPixelShader';
  123791. 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}";
  123792. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123793. /** @hidden */
  123794. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  123795. /***/ }),
  123796. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  123797. /*!***********************************************!*\
  123798. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  123799. \***********************************************/
  123800. /*! exports provided: glowMapGenerationPixelShader */
  123801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123802. "use strict";
  123803. __webpack_require__.r(__webpack_exports__);
  123804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  123805. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123806. var name = 'glowMapGenerationPixelShader';
  123807. var shader = "#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\nvec4 finalColor=color;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef GLOW\ngl_FragColor.rgb*=gl_FragColor.a;\ngl_FragColor.a=1.0;\n#endif\n}";
  123808. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123809. /** @hidden */
  123810. var glowMapGenerationPixelShader = { name: name, shader: shader };
  123811. /***/ }),
  123812. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  123813. /*!*********************************************!*\
  123814. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  123815. \*********************************************/
  123816. /*! exports provided: glowMapGenerationVertexShader */
  123817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123818. "use strict";
  123819. __webpack_require__.r(__webpack_exports__);
  123820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  123821. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123822. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123823. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123824. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123825. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123826. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123827. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123828. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123829. var name = 'glowMapGenerationVertexShader';
  123830. var shader = "\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;\nvarying vec4 vColor;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n}";
  123831. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123832. /** @hidden */
  123833. var glowMapGenerationVertexShader = { name: name, shader: shader };
  123834. /***/ }),
  123835. /***/ "./Shaders/glowMapMerge.fragment.ts":
  123836. /*!******************************************!*\
  123837. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  123838. \******************************************/
  123839. /*! exports provided: glowMapMergePixelShader */
  123840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123841. "use strict";
  123842. __webpack_require__.r(__webpack_exports__);
  123843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  123844. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123845. var name = 'glowMapMergePixelShader';
  123846. 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}";
  123847. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123848. /** @hidden */
  123849. var glowMapMergePixelShader = { name: name, shader: shader };
  123850. /***/ }),
  123851. /***/ "./Shaders/glowMapMerge.vertex.ts":
  123852. /*!****************************************!*\
  123853. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  123854. \****************************************/
  123855. /*! exports provided: glowMapMergeVertexShader */
  123856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123857. "use strict";
  123858. __webpack_require__.r(__webpack_exports__);
  123859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  123860. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123861. var name = 'glowMapMergeVertexShader';
  123862. 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}";
  123863. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123864. /** @hidden */
  123865. var glowMapMergeVertexShader = { name: name, shader: shader };
  123866. /***/ }),
  123867. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  123868. /*!************************************************!*\
  123869. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  123870. \************************************************/
  123871. /*! exports provided: gpuRenderParticlesPixelShader */
  123872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123873. "use strict";
  123874. __webpack_require__.r(__webpack_exports__);
  123875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  123876. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123877. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  123878. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123879. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123880. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123881. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123882. var name = 'gpuRenderParticlesPixelShader';
  123883. 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";
  123884. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123885. /** @hidden */
  123886. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  123887. /***/ }),
  123888. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  123889. /*!**********************************************!*\
  123890. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  123891. \**********************************************/
  123892. /*! exports provided: gpuRenderParticlesVertexShader */
  123893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123894. "use strict";
  123895. __webpack_require__.r(__webpack_exports__);
  123896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  123897. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123898. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  123899. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123900. var name = 'gpuRenderParticlesVertexShader';
  123901. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  123902. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123903. /** @hidden */
  123904. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  123905. /***/ }),
  123906. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  123907. /*!************************************************!*\
  123908. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  123909. \************************************************/
  123910. /*! exports provided: gpuUpdateParticlesPixelShader */
  123911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123912. "use strict";
  123913. __webpack_require__.r(__webpack_exports__);
  123914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  123915. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123916. var name = 'gpuUpdateParticlesPixelShader';
  123917. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  123918. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123919. /** @hidden */
  123920. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  123921. /***/ }),
  123922. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  123923. /*!**********************************************!*\
  123924. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  123925. \**********************************************/
  123926. /*! exports provided: gpuUpdateParticlesVertexShader */
  123927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123928. "use strict";
  123929. __webpack_require__.r(__webpack_exports__);
  123930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  123931. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123932. var name = 'gpuUpdateParticlesVertexShader';
  123933. var shader = "#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\nuniform mat4 emitterWM;\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\n\nin vec3 position;\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\n\nout vec3 outPosition;\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif\n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta;\n\nif (newAge>=life && stopFactor != 0.) {\nvec3 position;\nvec3 direction;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=mod(newAge,outLife);\n\noutSeed=seed;\n\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;\n#ifndef COLORGRADIENTS\n\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n\n#ifndef ANGULARSPEEDGRADIENTS\noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif\n\n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=vec3(0,0,0);\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\ndirection=position+directionRandomizer*randoms3;\n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\ndirection=position+directionRandomizer*randoms3;\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nposition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\ndirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\ndirection=normalize(direction);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.00001;\n#else\nfloat h=randoms2.y*height.y;\n\nh=1.-h*h;\n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h*height.x;\nposition=vec3(randX,randY,randZ);\n\nif (abs(cos(coneAngle)) == 1.0) {\ndirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\ndirection=position+directionRandomizer*randoms3;\n}\n#else\n\nposition=vec3(0.,0.,0.);\n\ndirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\noutPosition=(emitterWM*vec4(position,1.)).xyz;\nvec3 initial=(emitterWM*vec4(direction,0.)).xyz;\noutDirection=initial*power;\n#ifndef BILLBOARD\noutInitialDirection=initial;\n#endif\n#ifdef ANIMATESHEET\noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif\n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\noutPosition=position+direction*directionScale;\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS\noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif\n#ifndef BILLBOARD\noutInitialDirection=initialDirection;\n#endif\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nvec3 localPosition=outPosition-emitterWM[3].xyz;\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET\nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#endif\nfloat ratio=clamp(mod(offsetAge*cellInfos.z,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";
  123934. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123935. /** @hidden */
  123936. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  123937. /***/ }),
  123938. /***/ "./Shaders/grain.fragment.ts":
  123939. /*!***********************************!*\
  123940. !*** ./Shaders/grain.fragment.ts ***!
  123941. \***********************************/
  123942. /*! exports provided: grainPixelShader */
  123943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123944. "use strict";
  123945. __webpack_require__.r(__webpack_exports__);
  123946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  123947. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123948. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123949. var name = 'grainPixelShader';
  123950. 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}";
  123951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123952. /** @hidden */
  123953. var grainPixelShader = { name: name, shader: shader };
  123954. /***/ }),
  123955. /***/ "./Shaders/highlights.fragment.ts":
  123956. /*!****************************************!*\
  123957. !*** ./Shaders/highlights.fragment.ts ***!
  123958. \****************************************/
  123959. /*! exports provided: highlightsPixelShader */
  123960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123961. "use strict";
  123962. __webpack_require__.r(__webpack_exports__);
  123963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  123964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123965. var name = 'highlightsPixelShader';
  123966. 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}";
  123967. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123968. /** @hidden */
  123969. var highlightsPixelShader = { name: name, shader: shader };
  123970. /***/ }),
  123971. /***/ "./Shaders/imageProcessing.fragment.ts":
  123972. /*!*********************************************!*\
  123973. !*** ./Shaders/imageProcessing.fragment.ts ***!
  123974. \*********************************************/
  123975. /*! exports provided: imageProcessingPixelShader */
  123976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123977. "use strict";
  123978. __webpack_require__.r(__webpack_exports__);
  123979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  123980. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123981. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123982. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123983. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123984. var name = 'imageProcessingPixelShader';
  123985. 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}";
  123986. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123987. /** @hidden */
  123988. var imageProcessingPixelShader = { name: name, shader: shader };
  123989. /***/ }),
  123990. /***/ "./Shaders/kernelBlur.fragment.ts":
  123991. /*!****************************************!*\
  123992. !*** ./Shaders/kernelBlur.fragment.ts ***!
  123993. \****************************************/
  123994. /*! exports provided: kernelBlurPixelShader */
  123995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123996. "use strict";
  123997. __webpack_require__.r(__webpack_exports__);
  123998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  123999. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124000. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124001. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  124002. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  124003. var name = 'kernelBlurPixelShader';
  124004. var shader = "\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT;\nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";
  124005. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124006. /** @hidden */
  124007. var kernelBlurPixelShader = { name: name, shader: shader };
  124008. /***/ }),
  124009. /***/ "./Shaders/kernelBlur.vertex.ts":
  124010. /*!**************************************!*\
  124011. !*** ./Shaders/kernelBlur.vertex.ts ***!
  124012. \**************************************/
  124013. /*! exports provided: kernelBlurVertexShader */
  124014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124015. "use strict";
  124016. __webpack_require__.r(__webpack_exports__);
  124017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  124018. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124019. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124020. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  124021. var name = 'kernelBlurVertexShader';
  124022. 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}";
  124023. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124024. /** @hidden */
  124025. var kernelBlurVertexShader = { name: name, shader: shader };
  124026. /***/ }),
  124027. /***/ "./Shaders/layer.fragment.ts":
  124028. /*!***********************************!*\
  124029. !*** ./Shaders/layer.fragment.ts ***!
  124030. \***********************************/
  124031. /*! exports provided: layerPixelShader */
  124032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124033. "use strict";
  124034. __webpack_require__.r(__webpack_exports__);
  124035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  124036. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124037. var name = 'layerPixelShader';
  124038. 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}";
  124039. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124040. /** @hidden */
  124041. var layerPixelShader = { name: name, shader: shader };
  124042. /***/ }),
  124043. /***/ "./Shaders/layer.vertex.ts":
  124044. /*!*********************************!*\
  124045. !*** ./Shaders/layer.vertex.ts ***!
  124046. \*********************************/
  124047. /*! exports provided: layerVertexShader */
  124048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124049. "use strict";
  124050. __webpack_require__.r(__webpack_exports__);
  124051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  124052. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124053. var name = 'layerVertexShader';
  124054. 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}";
  124055. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124056. /** @hidden */
  124057. var layerVertexShader = { name: name, shader: shader };
  124058. /***/ }),
  124059. /***/ "./Shaders/lensFlare.fragment.ts":
  124060. /*!***************************************!*\
  124061. !*** ./Shaders/lensFlare.fragment.ts ***!
  124062. \***************************************/
  124063. /*! exports provided: lensFlarePixelShader */
  124064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124065. "use strict";
  124066. __webpack_require__.r(__webpack_exports__);
  124067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  124068. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124069. var name = 'lensFlarePixelShader';
  124070. 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}";
  124071. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124072. /** @hidden */
  124073. var lensFlarePixelShader = { name: name, shader: shader };
  124074. /***/ }),
  124075. /***/ "./Shaders/lensFlare.vertex.ts":
  124076. /*!*************************************!*\
  124077. !*** ./Shaders/lensFlare.vertex.ts ***!
  124078. \*************************************/
  124079. /*! exports provided: lensFlareVertexShader */
  124080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124081. "use strict";
  124082. __webpack_require__.r(__webpack_exports__);
  124083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  124084. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124085. var name = 'lensFlareVertexShader';
  124086. 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}";
  124087. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124088. /** @hidden */
  124089. var lensFlareVertexShader = { name: name, shader: shader };
  124090. /***/ }),
  124091. /***/ "./Shaders/lensHighlights.fragment.ts":
  124092. /*!********************************************!*\
  124093. !*** ./Shaders/lensHighlights.fragment.ts ***!
  124094. \********************************************/
  124095. /*! exports provided: lensHighlightsPixelShader */
  124096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124097. "use strict";
  124098. __webpack_require__.r(__webpack_exports__);
  124099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  124100. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124101. var name = 'lensHighlightsPixelShader';
  124102. 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}";
  124103. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124104. /** @hidden */
  124105. var lensHighlightsPixelShader = { name: name, shader: shader };
  124106. /***/ }),
  124107. /***/ "./Shaders/line.fragment.ts":
  124108. /*!**********************************!*\
  124109. !*** ./Shaders/line.fragment.ts ***!
  124110. \**********************************/
  124111. /*! exports provided: linePixelShader */
  124112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124113. "use strict";
  124114. __webpack_require__.r(__webpack_exports__);
  124115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  124116. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124117. var name = 'linePixelShader';
  124118. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  124119. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124120. /** @hidden */
  124121. var linePixelShader = { name: name, shader: shader };
  124122. /***/ }),
  124123. /***/ "./Shaders/line.vertex.ts":
  124124. /*!********************************!*\
  124125. !*** ./Shaders/line.vertex.ts ***!
  124126. \********************************/
  124127. /*! exports provided: lineVertexShader */
  124128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124129. "use strict";
  124130. __webpack_require__.r(__webpack_exports__);
  124131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  124132. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124133. var name = 'lineVertexShader';
  124134. 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}";
  124135. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124136. /** @hidden */
  124137. var lineVertexShader = { name: name, shader: shader };
  124138. /***/ }),
  124139. /***/ "./Shaders/motionBlur.fragment.ts":
  124140. /*!****************************************!*\
  124141. !*** ./Shaders/motionBlur.fragment.ts ***!
  124142. \****************************************/
  124143. /*! exports provided: motionBlurPixelShader */
  124144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124145. "use strict";
  124146. __webpack_require__.r(__webpack_exports__);
  124147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  124148. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124149. var name = 'motionBlurPixelShader';
  124150. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D velocitySampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\nvec2 texelSize=1.0/screenSize;\nvec2 velocityColor=texture2D(velocitySampler,vUV).rg;\nvec2 velocity=vec2(pow(velocityColor.r,1.0/3.0),pow(velocityColor.g,1.0/3.0))*2.0-1.0;\nvelocity*=motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint samplesCount=int(clamp(speed,1.0,SAMPLES));\nvelocity=normalize(velocity)*texelSize;\nfloat hlim=float(-samplesCount)*0.5+0.5;\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i)\n{\nif (i>=samplesCount)\nbreak;\nvec2 offset=vUV+velocity*(hlim+float(i));\nresult+=texture2D(textureSampler,offset);\n}\ngl_FragColor=result/float(samplesCount);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  124151. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124152. /** @hidden */
  124153. var motionBlurPixelShader = { name: name, shader: shader };
  124154. /***/ }),
  124155. /***/ "./Shaders/noise.fragment.ts":
  124156. /*!***********************************!*\
  124157. !*** ./Shaders/noise.fragment.ts ***!
  124158. \***********************************/
  124159. /*! exports provided: noisePixelShader */
  124160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124161. "use strict";
  124162. __webpack_require__.r(__webpack_exports__);
  124163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  124164. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124165. var name = 'noisePixelShader';
  124166. 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";
  124167. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124168. /** @hidden */
  124169. var noisePixelShader = { name: name, shader: shader };
  124170. /***/ }),
  124171. /***/ "./Shaders/outline.fragment.ts":
  124172. /*!*************************************!*\
  124173. !*** ./Shaders/outline.fragment.ts ***!
  124174. \*************************************/
  124175. /*! exports provided: outlinePixelShader */
  124176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124177. "use strict";
  124178. __webpack_require__.r(__webpack_exports__);
  124179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  124180. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124181. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124182. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124183. var name = 'outlinePixelShader';
  124184. 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}";
  124185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124186. /** @hidden */
  124187. var outlinePixelShader = { name: name, shader: shader };
  124188. /***/ }),
  124189. /***/ "./Shaders/outline.vertex.ts":
  124190. /*!***********************************!*\
  124191. !*** ./Shaders/outline.vertex.ts ***!
  124192. \***********************************/
  124193. /*! exports provided: outlineVertexShader */
  124194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124195. "use strict";
  124196. __webpack_require__.r(__webpack_exports__);
  124197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  124198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124199. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124200. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124201. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124202. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124203. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124204. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124205. var name = 'outlineVertexShader';
  124206. var shader = "\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<logDepthVertex>\n}\n";
  124207. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124208. /** @hidden */
  124209. var outlineVertexShader = { name: name, shader: shader };
  124210. /***/ }),
  124211. /***/ "./Shaders/particles.fragment.ts":
  124212. /*!***************************************!*\
  124213. !*** ./Shaders/particles.fragment.ts ***!
  124214. \***************************************/
  124215. /*! exports provided: particlesPixelShader */
  124216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124217. "use strict";
  124218. __webpack_require__.r(__webpack_exports__);
  124219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  124220. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124221. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124222. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124223. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124224. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124225. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124226. var name = 'particlesPixelShader';
  124227. 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}";
  124228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124229. /** @hidden */
  124230. var particlesPixelShader = { name: name, shader: shader };
  124231. /***/ }),
  124232. /***/ "./Shaders/particles.vertex.ts":
  124233. /*!*************************************!*\
  124234. !*** ./Shaders/particles.vertex.ts ***!
  124235. \*************************************/
  124236. /*! exports provided: particlesVertexShader */
  124237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124238. "use strict";
  124239. __webpack_require__.r(__webpack_exports__);
  124240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  124241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124242. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124243. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124244. var name = 'particlesVertexShader';
  124245. 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}";
  124246. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124247. /** @hidden */
  124248. var particlesVertexShader = { name: name, shader: shader };
  124249. /***/ }),
  124250. /***/ "./Shaders/pass.fragment.ts":
  124251. /*!**********************************!*\
  124252. !*** ./Shaders/pass.fragment.ts ***!
  124253. \**********************************/
  124254. /*! exports provided: passPixelShader */
  124255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124256. "use strict";
  124257. __webpack_require__.r(__webpack_exports__);
  124258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  124259. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124260. var name = 'passPixelShader';
  124261. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  124262. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124263. /** @hidden */
  124264. var passPixelShader = { name: name, shader: shader };
  124265. /***/ }),
  124266. /***/ "./Shaders/passCube.fragment.ts":
  124267. /*!**************************************!*\
  124268. !*** ./Shaders/passCube.fragment.ts ***!
  124269. \**************************************/
  124270. /*! exports provided: passCubePixelShader */
  124271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124272. "use strict";
  124273. __webpack_require__.r(__webpack_exports__);
  124274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  124275. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124276. var name = 'passCubePixelShader';
  124277. 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}";
  124278. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124279. /** @hidden */
  124280. var passCubePixelShader = { name: name, shader: shader };
  124281. /***/ }),
  124282. /***/ "./Shaders/pbr.fragment.ts":
  124283. /*!*********************************!*\
  124284. !*** ./Shaders/pbr.fragment.ts ***!
  124285. \*********************************/
  124286. /*! exports provided: pbrPixelShader */
  124287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124288. "use strict";
  124289. __webpack_require__.r(__webpack_exports__);
  124290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  124291. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124292. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  124293. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124294. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124295. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124296. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124297. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124298. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124299. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124300. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124301. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  124302. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124303. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  124304. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124305. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124306. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124307. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124308. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124309. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124310. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124311. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124312. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124313. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124314. var name = 'pbrPixelShader';
  124315. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\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\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\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#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\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#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\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\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=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\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.;\nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\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 REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";
  124316. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124317. /** @hidden */
  124318. var pbrPixelShader = { name: name, shader: shader };
  124319. /***/ }),
  124320. /***/ "./Shaders/pbr.vertex.ts":
  124321. /*!*******************************!*\
  124322. !*** ./Shaders/pbr.vertex.ts ***!
  124323. \*******************************/
  124324. /*! exports provided: pbrVertexShader */
  124325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124326. "use strict";
  124327. __webpack_require__.r(__webpack_exports__);
  124328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  124329. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124330. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  124331. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124332. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124333. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124334. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124335. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124336. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124337. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124338. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124339. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124340. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124341. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124342. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124343. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124344. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124345. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124346. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124347. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124348. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124349. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124350. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124351. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124352. var name = 'pbrVertexShader';
  124353. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\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}";
  124354. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124355. /** @hidden */
  124356. var pbrVertexShader = { name: name, shader: shader };
  124357. /***/ }),
  124358. /***/ "./Shaders/postprocess.vertex.ts":
  124359. /*!***************************************!*\
  124360. !*** ./Shaders/postprocess.vertex.ts ***!
  124361. \***************************************/
  124362. /*! exports provided: postprocessVertexShader */
  124363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124364. "use strict";
  124365. __webpack_require__.r(__webpack_exports__);
  124366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  124367. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124368. var name = 'postprocessVertexShader';
  124369. 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}";
  124370. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124371. /** @hidden */
  124372. var postprocessVertexShader = { name: name, shader: shader };
  124373. /***/ }),
  124374. /***/ "./Shaders/procedural.vertex.ts":
  124375. /*!**************************************!*\
  124376. !*** ./Shaders/procedural.vertex.ts ***!
  124377. \**************************************/
  124378. /*! exports provided: proceduralVertexShader */
  124379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124380. "use strict";
  124381. __webpack_require__.r(__webpack_exports__);
  124382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  124383. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124384. var name = 'proceduralVertexShader';
  124385. 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}";
  124386. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124387. /** @hidden */
  124388. var proceduralVertexShader = { name: name, shader: shader };
  124389. /***/ }),
  124390. /***/ "./Shaders/refraction.fragment.ts":
  124391. /*!****************************************!*\
  124392. !*** ./Shaders/refraction.fragment.ts ***!
  124393. \****************************************/
  124394. /*! exports provided: refractionPixelShader */
  124395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124396. "use strict";
  124397. __webpack_require__.r(__webpack_exports__);
  124398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  124399. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124400. var name = 'refractionPixelShader';
  124401. 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}";
  124402. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124403. /** @hidden */
  124404. var refractionPixelShader = { name: name, shader: shader };
  124405. /***/ }),
  124406. /***/ "./Shaders/rgbdDecode.fragment.ts":
  124407. /*!****************************************!*\
  124408. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  124409. \****************************************/
  124410. /*! exports provided: rgbdDecodePixelShader */
  124411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124412. "use strict";
  124413. __webpack_require__.r(__webpack_exports__);
  124414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  124415. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124416. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124417. var name = 'rgbdDecodePixelShader';
  124418. 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}";
  124419. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124420. /** @hidden */
  124421. var rgbdDecodePixelShader = { name: name, shader: shader };
  124422. /***/ }),
  124423. /***/ "./Shaders/rgbdEncode.fragment.ts":
  124424. /*!****************************************!*\
  124425. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  124426. \****************************************/
  124427. /*! exports provided: rgbdEncodePixelShader */
  124428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124429. "use strict";
  124430. __webpack_require__.r(__webpack_exports__);
  124431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  124432. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124433. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124434. var name = 'rgbdEncodePixelShader';
  124435. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  124436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124437. /** @hidden */
  124438. var rgbdEncodePixelShader = { name: name, shader: shader };
  124439. /***/ }),
  124440. /***/ "./Shaders/shadowMap.fragment.ts":
  124441. /*!***************************************!*\
  124442. !*** ./Shaders/shadowMap.fragment.ts ***!
  124443. \***************************************/
  124444. /*! exports provided: shadowMapPixelShader */
  124445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124446. "use strict";
  124447. __webpack_require__.r(__webpack_exports__);
  124448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  124449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124450. var name = 'shadowMapPixelShader';
  124451. var shader = "#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";
  124452. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124453. /** @hidden */
  124454. var shadowMapPixelShader = { name: name, shader: shader };
  124455. /***/ }),
  124456. /***/ "./Shaders/shadowMap.vertex.ts":
  124457. /*!*************************************!*\
  124458. !*** ./Shaders/shadowMap.vertex.ts ***!
  124459. \*************************************/
  124460. /*! exports provided: shadowMapVertexShader */
  124461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124462. "use strict";
  124463. __webpack_require__.r(__webpack_exports__);
  124464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  124465. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124466. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124467. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124468. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124469. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124470. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124471. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124472. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124473. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124474. var name = 'shadowMapVertexShader';
  124475. var shader = "\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  124476. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124477. /** @hidden */
  124478. var shadowMapVertexShader = { name: name, shader: shader };
  124479. /***/ }),
  124480. /***/ "./Shaders/sharpen.fragment.ts":
  124481. /*!*************************************!*\
  124482. !*** ./Shaders/sharpen.fragment.ts ***!
  124483. \*************************************/
  124484. /*! exports provided: sharpenPixelShader */
  124485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124486. "use strict";
  124487. __webpack_require__.r(__webpack_exports__);
  124488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  124489. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124490. var name = 'sharpenPixelShader';
  124491. 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}";
  124492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124493. /** @hidden */
  124494. var sharpenPixelShader = { name: name, shader: shader };
  124495. /***/ }),
  124496. /***/ "./Shaders/sprites.fragment.ts":
  124497. /*!*************************************!*\
  124498. !*** ./Shaders/sprites.fragment.ts ***!
  124499. \*************************************/
  124500. /*! exports provided: spritesPixelShader */
  124501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124502. "use strict";
  124503. __webpack_require__.r(__webpack_exports__);
  124504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  124505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124506. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124507. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124508. var name = 'spritesPixelShader';
  124509. 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}";
  124510. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124511. /** @hidden */
  124512. var spritesPixelShader = { name: name, shader: shader };
  124513. /***/ }),
  124514. /***/ "./Shaders/sprites.vertex.ts":
  124515. /*!***********************************!*\
  124516. !*** ./Shaders/sprites.vertex.ts ***!
  124517. \***********************************/
  124518. /*! exports provided: spritesVertexShader */
  124519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124520. "use strict";
  124521. __webpack_require__.r(__webpack_exports__);
  124522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  124523. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124524. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124525. var name = 'spritesVertexShader';
  124526. 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}";
  124527. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124528. /** @hidden */
  124529. var spritesVertexShader = { name: name, shader: shader };
  124530. /***/ }),
  124531. /***/ "./Shaders/ssao.fragment.ts":
  124532. /*!**********************************!*\
  124533. !*** ./Shaders/ssao.fragment.ts ***!
  124534. \**********************************/
  124535. /*! exports provided: ssaoPixelShader */
  124536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124537. "use strict";
  124538. __webpack_require__.r(__webpack_exports__);
  124539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  124540. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124541. var name = 'ssaoPixelShader';
  124542. 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";
  124543. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124544. /** @hidden */
  124545. var ssaoPixelShader = { name: name, shader: shader };
  124546. /***/ }),
  124547. /***/ "./Shaders/ssao2.fragment.ts":
  124548. /*!***********************************!*\
  124549. !*** ./Shaders/ssao2.fragment.ts ***!
  124550. \***********************************/
  124551. /*! exports provided: ssao2PixelShader */
  124552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124553. "use strict";
  124554. __webpack_require__.r(__webpack_exports__);
  124555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  124556. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124557. var name = 'ssao2PixelShader';
  124558. 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";
  124559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124560. /** @hidden */
  124561. var ssao2PixelShader = { name: name, shader: shader };
  124562. /***/ }),
  124563. /***/ "./Shaders/ssaoCombine.fragment.ts":
  124564. /*!*****************************************!*\
  124565. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  124566. \*****************************************/
  124567. /*! exports provided: ssaoCombinePixelShader */
  124568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124569. "use strict";
  124570. __webpack_require__.r(__webpack_exports__);
  124571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  124572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124573. var name = 'ssaoCombinePixelShader';
  124574. 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";
  124575. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124576. /** @hidden */
  124577. var ssaoCombinePixelShader = { name: name, shader: shader };
  124578. /***/ }),
  124579. /***/ "./Shaders/standard.fragment.ts":
  124580. /*!**************************************!*\
  124581. !*** ./Shaders/standard.fragment.ts ***!
  124582. \**************************************/
  124583. /*! exports provided: standardPixelShader */
  124584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124585. "use strict";
  124586. __webpack_require__.r(__webpack_exports__);
  124587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  124588. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124589. var name = 'standardPixelShader';
  124590. var shader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
  124591. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124592. /** @hidden */
  124593. var standardPixelShader = { name: name, shader: shader };
  124594. /***/ }),
  124595. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  124596. /*!***************************************************!*\
  124597. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  124598. \***************************************************/
  124599. /*! exports provided: stereoscopicInterlacePixelShader */
  124600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124601. "use strict";
  124602. __webpack_require__.r(__webpack_exports__);
  124603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  124604. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124605. var name = 'stereoscopicInterlacePixelShader';
  124606. 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}";
  124607. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124608. /** @hidden */
  124609. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  124610. /***/ }),
  124611. /***/ "./Shaders/tonemap.fragment.ts":
  124612. /*!*************************************!*\
  124613. !*** ./Shaders/tonemap.fragment.ts ***!
  124614. \*************************************/
  124615. /*! exports provided: tonemapPixelShader */
  124616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124617. "use strict";
  124618. __webpack_require__.r(__webpack_exports__);
  124619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  124620. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124621. var name = 'tonemapPixelShader';
  124622. 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}";
  124623. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124624. /** @hidden */
  124625. var tonemapPixelShader = { name: name, shader: shader };
  124626. /***/ }),
  124627. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  124628. /*!*******************************************************!*\
  124629. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  124630. \*******************************************************/
  124631. /*! exports provided: volumetricLightScatteringPixelShader */
  124632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124633. "use strict";
  124634. __webpack_require__.r(__webpack_exports__);
  124635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  124636. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124637. var name = 'volumetricLightScatteringPixelShader';
  124638. 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";
  124639. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124640. /** @hidden */
  124641. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  124642. /***/ }),
  124643. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  124644. /*!***********************************************************!*\
  124645. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  124646. \***********************************************************/
  124647. /*! exports provided: volumetricLightScatteringPassPixelShader */
  124648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124649. "use strict";
  124650. __webpack_require__.r(__webpack_exports__);
  124651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  124652. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124653. var name = 'volumetricLightScatteringPassPixelShader';
  124654. 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";
  124655. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124656. /** @hidden */
  124657. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  124658. /***/ }),
  124659. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  124660. /*!****************************************************!*\
  124661. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  124662. \****************************************************/
  124663. /*! exports provided: vrDistortionCorrectionPixelShader */
  124664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124665. "use strict";
  124666. __webpack_require__.r(__webpack_exports__);
  124667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  124668. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124669. var name = 'vrDistortionCorrectionPixelShader';
  124670. 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}";
  124671. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124672. /** @hidden */
  124673. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  124674. /***/ }),
  124675. /***/ "./Sprites/index.ts":
  124676. /*!**************************!*\
  124677. !*** ./Sprites/index.ts ***!
  124678. \**************************/
  124679. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  124680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124681. "use strict";
  124682. __webpack_require__.r(__webpack_exports__);
  124683. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  124684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  124685. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  124686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  124687. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  124689. /***/ }),
  124690. /***/ "./Sprites/sprite.ts":
  124691. /*!***************************!*\
  124692. !*** ./Sprites/sprite.ts ***!
  124693. \***************************/
  124694. /*! exports provided: Sprite */
  124695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124696. "use strict";
  124697. __webpack_require__.r(__webpack_exports__);
  124698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  124699. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124700. /**
  124701. * Class used to represent a sprite
  124702. * @see http://doc.babylonjs.com/babylon101/sprites
  124703. */
  124704. var Sprite = /** @class */ (function () {
  124705. /**
  124706. * Creates a new Sprite
  124707. * @param name defines the name
  124708. * @param manager defines the manager
  124709. */
  124710. function Sprite(
  124711. /** defines the name */
  124712. name, manager) {
  124713. this.name = name;
  124714. /** Gets or sets the main color */
  124715. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  124716. /** Gets or sets the width */
  124717. this.width = 1.0;
  124718. /** Gets or sets the height */
  124719. this.height = 1.0;
  124720. /** Gets or sets rotation angle */
  124721. this.angle = 0;
  124722. /** Gets or sets the cell index in the sprite sheet */
  124723. this.cellIndex = 0;
  124724. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  124725. this.invertU = 0;
  124726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  124727. this.invertV = 0;
  124728. /** Gets the list of attached animations */
  124729. this.animations = new Array();
  124730. /** Gets or sets a boolean indicating if the sprite can be picked */
  124731. this.isPickable = false;
  124732. this._animationStarted = false;
  124733. this._loopAnimation = false;
  124734. this._fromIndex = 0;
  124735. this._toIndex = 0;
  124736. this._delay = 0;
  124737. this._direction = 1;
  124738. this._time = 0;
  124739. /**
  124740. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  124741. */
  124742. this.isVisible = true;
  124743. this._manager = manager;
  124744. this._manager.sprites.push(this);
  124745. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124746. }
  124747. Object.defineProperty(Sprite.prototype, "size", {
  124748. /**
  124749. * Gets or sets the sprite size
  124750. */
  124751. get: function () {
  124752. return this.width;
  124753. },
  124754. set: function (value) {
  124755. this.width = value;
  124756. this.height = value;
  124757. },
  124758. enumerable: true,
  124759. configurable: true
  124760. });
  124761. /**
  124762. * Starts an animation
  124763. * @param from defines the initial key
  124764. * @param to defines the end key
  124765. * @param loop defines if the animation must loop
  124766. * @param delay defines the start delay (in ms)
  124767. * @param onAnimationEnd defines a callback to call when animation ends
  124768. */
  124769. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  124770. this._fromIndex = from;
  124771. this._toIndex = to;
  124772. this._loopAnimation = loop;
  124773. this._delay = delay;
  124774. this._animationStarted = true;
  124775. this._direction = from < to ? 1 : -1;
  124776. this.cellIndex = from;
  124777. this._time = 0;
  124778. this._onAnimationEnd = onAnimationEnd;
  124779. };
  124780. /** Stops current animation (if any) */
  124781. Sprite.prototype.stopAnimation = function () {
  124782. this._animationStarted = false;
  124783. };
  124784. /** @hidden */
  124785. Sprite.prototype._animate = function (deltaTime) {
  124786. if (!this._animationStarted) {
  124787. return;
  124788. }
  124789. this._time += deltaTime;
  124790. if (this._time > this._delay) {
  124791. this._time = this._time % this._delay;
  124792. this.cellIndex += this._direction;
  124793. if (this.cellIndex > this._toIndex) {
  124794. if (this._loopAnimation) {
  124795. this.cellIndex = this._fromIndex;
  124796. }
  124797. else {
  124798. this.cellIndex = this._toIndex;
  124799. this._animationStarted = false;
  124800. if (this._onAnimationEnd) {
  124801. this._onAnimationEnd();
  124802. }
  124803. if (this.disposeWhenFinishedAnimating) {
  124804. this.dispose();
  124805. }
  124806. }
  124807. }
  124808. }
  124809. };
  124810. /** Release associated resources */
  124811. Sprite.prototype.dispose = function () {
  124812. for (var i = 0; i < this._manager.sprites.length; i++) {
  124813. if (this._manager.sprites[i] == this) {
  124814. this._manager.sprites.splice(i, 1);
  124815. }
  124816. }
  124817. };
  124818. return Sprite;
  124819. }());
  124820. /***/ }),
  124821. /***/ "./Sprites/spriteManager.ts":
  124822. /*!**********************************!*\
  124823. !*** ./Sprites/spriteManager.ts ***!
  124824. \**********************************/
  124825. /*! exports provided: SpriteManager */
  124826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124827. "use strict";
  124828. __webpack_require__.r(__webpack_exports__);
  124829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  124830. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124831. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124832. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124834. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124835. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124836. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124837. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124838. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124839. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124840. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  124841. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  124842. /**
  124843. * Class used to manage multiple sprites on the same spritesheet
  124844. * @see http://doc.babylonjs.com/babylon101/sprites
  124845. */
  124846. var SpriteManager = /** @class */ (function () {
  124847. /**
  124848. * Creates a new sprite manager
  124849. * @param name defines the manager's name
  124850. * @param imgUrl defines the sprite sheet url
  124851. * @param capacity defines the maximum allowed number of sprites
  124852. * @param cellSize defines the size of a sprite cell
  124853. * @param scene defines the hosting scene
  124854. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124855. * @param samplingMode defines the smapling mode to use with spritesheet
  124856. */
  124857. function SpriteManager(
  124858. /** defines the manager's name */
  124859. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  124860. if (epsilon === void 0) { epsilon = 0.01; }
  124861. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  124862. this.name = name;
  124863. /** Gets the list of sprites */
  124864. this.sprites = new Array();
  124865. /** Gets or sets the rendering group id (0 by default) */
  124866. this.renderingGroupId = 0;
  124867. /** Gets or sets camera layer mask */
  124868. this.layerMask = 0x0FFFFFFF;
  124869. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  124870. this.fogEnabled = true;
  124871. /** Gets or sets a boolean indicating if the sprites are pickable */
  124872. this.isPickable = false;
  124873. /**
  124874. * An event triggered when the manager is disposed.
  124875. */
  124876. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  124877. this._vertexBuffers = {};
  124878. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  124879. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  124880. }
  124881. this._capacity = capacity;
  124882. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  124883. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124884. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124885. if (cellSize.width && cellSize.height) {
  124886. this.cellWidth = cellSize.width;
  124887. this.cellHeight = cellSize.height;
  124888. }
  124889. else if (cellSize !== undefined) {
  124890. this.cellWidth = cellSize;
  124891. this.cellHeight = cellSize;
  124892. }
  124893. else {
  124894. return;
  124895. }
  124896. this._epsilon = epsilon;
  124897. this._scene = scene;
  124898. this._scene.spriteManagers.push(this);
  124899. var indices = [];
  124900. var index = 0;
  124901. for (var count = 0; count < capacity; count++) {
  124902. indices.push(index);
  124903. indices.push(index + 1);
  124904. indices.push(index + 2);
  124905. indices.push(index);
  124906. indices.push(index + 2);
  124907. indices.push(index + 3);
  124908. index += 4;
  124909. }
  124910. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  124911. // VBO
  124912. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  124913. this._vertexData = new Float32Array(capacity * 16 * 4);
  124914. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  124915. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  124916. var options = this._buffer.createVertexBuffer("options", 4, 4);
  124917. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  124918. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  124919. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  124920. this._vertexBuffers["options"] = options;
  124921. this._vertexBuffers["cellInfo"] = cellInfo;
  124922. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  124923. // Effects
  124924. 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"], "");
  124925. 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");
  124926. }
  124927. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  124928. /**
  124929. * Callback called when the manager is disposed
  124930. */
  124931. set: function (callback) {
  124932. if (this._onDisposeObserver) {
  124933. this.onDisposeObservable.remove(this._onDisposeObserver);
  124934. }
  124935. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  124936. },
  124937. enumerable: true,
  124938. configurable: true
  124939. });
  124940. Object.defineProperty(SpriteManager.prototype, "texture", {
  124941. /**
  124942. * Gets or sets the spritesheet texture
  124943. */
  124944. get: function () {
  124945. return this._spriteTexture;
  124946. },
  124947. set: function (value) {
  124948. this._spriteTexture = value;
  124949. },
  124950. enumerable: true,
  124951. configurable: true
  124952. });
  124953. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  124954. var arrayOffset = index * 16;
  124955. if (offsetX === 0) {
  124956. offsetX = this._epsilon;
  124957. }
  124958. else if (offsetX === 1) {
  124959. offsetX = 1 - this._epsilon;
  124960. }
  124961. if (offsetY === 0) {
  124962. offsetY = this._epsilon;
  124963. }
  124964. else if (offsetY === 1) {
  124965. offsetY = 1 - this._epsilon;
  124966. }
  124967. this._vertexData[arrayOffset] = sprite.position.x;
  124968. this._vertexData[arrayOffset + 1] = sprite.position.y;
  124969. this._vertexData[arrayOffset + 2] = sprite.position.z;
  124970. this._vertexData[arrayOffset + 3] = sprite.angle;
  124971. this._vertexData[arrayOffset + 4] = sprite.width;
  124972. this._vertexData[arrayOffset + 5] = sprite.height;
  124973. this._vertexData[arrayOffset + 6] = offsetX;
  124974. this._vertexData[arrayOffset + 7] = offsetY;
  124975. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  124976. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  124977. var offset = (sprite.cellIndex / rowSize) >> 0;
  124978. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  124979. this._vertexData[arrayOffset + 11] = offset;
  124980. // Color
  124981. this._vertexData[arrayOffset + 12] = sprite.color.r;
  124982. this._vertexData[arrayOffset + 13] = sprite.color.g;
  124983. this._vertexData[arrayOffset + 14] = sprite.color.b;
  124984. this._vertexData[arrayOffset + 15] = sprite.color.a;
  124985. };
  124986. /**
  124987. * Intersects the sprites with a ray
  124988. * @param ray defines the ray to intersect with
  124989. * @param camera defines the current active camera
  124990. * @param predicate defines a predicate used to select candidate sprites
  124991. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  124992. * @returns null if no hit or a PickingInfo
  124993. */
  124994. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  124995. var count = Math.min(this._capacity, this.sprites.length);
  124996. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124997. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124998. var distance = Number.MAX_VALUE;
  124999. var currentSprite = null;
  125000. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125001. var cameraView = camera.getViewMatrix();
  125002. for (var index = 0; index < count; index++) {
  125003. var sprite = this.sprites[index];
  125004. if (!sprite) {
  125005. continue;
  125006. }
  125007. if (predicate) {
  125008. if (!predicate(sprite)) {
  125009. continue;
  125010. }
  125011. }
  125012. else if (!sprite.isPickable) {
  125013. continue;
  125014. }
  125015. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  125016. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  125017. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  125018. if (ray.intersectsBoxMinMax(min, max)) {
  125019. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  125020. if (distance > currentDistance) {
  125021. distance = currentDistance;
  125022. currentSprite = sprite;
  125023. if (fastCheck) {
  125024. break;
  125025. }
  125026. }
  125027. }
  125028. }
  125029. if (currentSprite) {
  125030. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  125031. result.hit = true;
  125032. result.pickedSprite = currentSprite;
  125033. result.distance = distance;
  125034. return result;
  125035. }
  125036. return null;
  125037. };
  125038. /**
  125039. * Render all child sprites
  125040. */
  125041. SpriteManager.prototype.render = function () {
  125042. // Check
  125043. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  125044. || !this._spriteTexture.isReady() || !this.sprites.length) {
  125045. return;
  125046. }
  125047. var engine = this._scene.getEngine();
  125048. var baseSize = this._spriteTexture.getBaseSize();
  125049. // Sprites
  125050. var deltaTime = engine.getDeltaTime();
  125051. var max = Math.min(this._capacity, this.sprites.length);
  125052. var rowSize = baseSize.width / this.cellWidth;
  125053. var offset = 0;
  125054. for (var index = 0; index < max; index++) {
  125055. var sprite = this.sprites[index];
  125056. if (!sprite || !sprite.isVisible) {
  125057. continue;
  125058. }
  125059. sprite._animate(deltaTime);
  125060. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  125061. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  125062. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  125063. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  125064. }
  125065. this._buffer.update(this._vertexData);
  125066. // Render
  125067. var effect = this._effectBase;
  125068. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125069. effect = this._effectFog;
  125070. }
  125071. engine.enableEffect(effect);
  125072. var viewMatrix = this._scene.getViewMatrix();
  125073. effect.setTexture("diffuseSampler", this._spriteTexture);
  125074. effect.setMatrix("view", viewMatrix);
  125075. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  125076. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  125077. // Fog
  125078. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125079. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  125080. effect.setColor3("vFogColor", this._scene.fogColor);
  125081. }
  125082. // VBOs
  125083. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125084. // Draw order
  125085. engine.setDepthFunctionToLessOrEqual();
  125086. effect.setBool("alphaTest", true);
  125087. engine.setColorWrite(false);
  125088. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125089. engine.setColorWrite(true);
  125090. effect.setBool("alphaTest", false);
  125091. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  125092. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125093. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  125094. };
  125095. /**
  125096. * Release associated resources
  125097. */
  125098. SpriteManager.prototype.dispose = function () {
  125099. if (this._buffer) {
  125100. this._buffer.dispose();
  125101. this._buffer = null;
  125102. }
  125103. if (this._indexBuffer) {
  125104. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125105. this._indexBuffer = null;
  125106. }
  125107. if (this._spriteTexture) {
  125108. this._spriteTexture.dispose();
  125109. this._spriteTexture = null;
  125110. }
  125111. // Remove from scene
  125112. var index = this._scene.spriteManagers.indexOf(this);
  125113. this._scene.spriteManagers.splice(index, 1);
  125114. // Callback
  125115. this.onDisposeObservable.notifyObservers(this);
  125116. this.onDisposeObservable.clear();
  125117. };
  125118. return SpriteManager;
  125119. }());
  125120. /***/ }),
  125121. /***/ "./Sprites/spriteSceneComponent.ts":
  125122. /*!*****************************************!*\
  125123. !*** ./Sprites/spriteSceneComponent.ts ***!
  125124. \*****************************************/
  125125. /*! exports provided: SpriteSceneComponent */
  125126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125127. "use strict";
  125128. __webpack_require__.r(__webpack_exports__);
  125129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  125130. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125131. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125132. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  125133. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125134. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125135. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  125136. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125137. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  125138. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  125139. return null;
  125140. }
  125141. var pickingInfo = null;
  125142. if (!camera) {
  125143. if (!this.activeCamera) {
  125144. return null;
  125145. }
  125146. camera = this.activeCamera;
  125147. }
  125148. if (this.spriteManagers.length > 0) {
  125149. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  125150. var spriteManager = this.spriteManagers[spriteIndex];
  125151. if (!spriteManager.isPickable) {
  125152. continue;
  125153. }
  125154. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  125155. if (!result || !result.hit) {
  125156. continue;
  125157. }
  125158. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  125159. continue;
  125160. }
  125161. pickingInfo = result;
  125162. if (fastCheck) {
  125163. break;
  125164. }
  125165. }
  125166. }
  125167. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  125168. };
  125169. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  125170. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  125171. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125172. };
  125173. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  125174. if (!this._tempSpritePickingRay) {
  125175. return null;
  125176. }
  125177. if (!camera) {
  125178. if (!this.activeCamera) {
  125179. return null;
  125180. }
  125181. camera = this.activeCamera;
  125182. }
  125183. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  125184. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125185. };
  125186. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  125187. if (this._pointerOverSprite === sprite) {
  125188. return;
  125189. }
  125190. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125191. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125192. }
  125193. this._pointerOverSprite = sprite;
  125194. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125195. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125196. }
  125197. };
  125198. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  125199. return this._pointerOverSprite;
  125200. };
  125201. /**
  125202. * Defines the sprite scene component responsible to manage sprites
  125203. * in a given scene.
  125204. */
  125205. var SpriteSceneComponent = /** @class */ (function () {
  125206. /**
  125207. * Creates a new instance of the component for the given scene
  125208. * @param scene Defines the scene to register the component in
  125209. */
  125210. function SpriteSceneComponent(scene) {
  125211. /**
  125212. * The component name helpfull to identify the component in the list of scene components.
  125213. */
  125214. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  125215. this.scene = scene;
  125216. this.scene.spriteManagers = new Array();
  125217. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  125218. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125219. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125220. this._spritePredicate = function (sprite) {
  125221. if (!sprite.actionManager) {
  125222. return false;
  125223. }
  125224. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  125225. };
  125226. }
  125227. /**
  125228. * Registers the component in a given scene
  125229. */
  125230. SpriteSceneComponent.prototype.register = function () {
  125231. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  125232. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  125233. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  125234. };
  125235. /**
  125236. * Rebuilds the elements related to this component in case of
  125237. * context lost for instance.
  125238. */
  125239. SpriteSceneComponent.prototype.rebuild = function () {
  125240. /** Nothing to do for sprites */
  125241. };
  125242. /**
  125243. * Disposes the component and the associated ressources.
  125244. */
  125245. SpriteSceneComponent.prototype.dispose = function () {
  125246. this.scene.onBeforeSpritesRenderingObservable.clear();
  125247. this.scene.onAfterSpritesRenderingObservable.clear();
  125248. var spriteManagers = this.scene.spriteManagers;
  125249. while (spriteManagers.length) {
  125250. spriteManagers[0].dispose();
  125251. }
  125252. };
  125253. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  125254. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  125255. if (result) {
  125256. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  125257. }
  125258. return result;
  125259. };
  125260. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  125261. var scene = this.scene;
  125262. if (isMeshPicked) {
  125263. scene.setPointerOverSprite(null);
  125264. }
  125265. else {
  125266. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  125267. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125268. scene.setPointerOverSprite(pickResult.pickedSprite);
  125269. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  125270. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  125271. }
  125272. else {
  125273. canvas.style.cursor = scene.hoverCursor;
  125274. }
  125275. }
  125276. else {
  125277. scene.setPointerOverSprite(null);
  125278. }
  125279. }
  125280. return pickResult;
  125281. };
  125282. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125283. var scene = this.scene;
  125284. scene._pickedDownSprite = null;
  125285. if (scene.spriteManagers.length > 0) {
  125286. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125287. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125288. if (pickResult.pickedSprite.actionManager) {
  125289. scene._pickedDownSprite = pickResult.pickedSprite;
  125290. switch (evt.button) {
  125291. case 0:
  125292. 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));
  125293. break;
  125294. case 1:
  125295. 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));
  125296. break;
  125297. case 2:
  125298. 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));
  125299. break;
  125300. }
  125301. if (pickResult.pickedSprite.actionManager) {
  125302. 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));
  125303. }
  125304. }
  125305. }
  125306. }
  125307. return pickResult;
  125308. };
  125309. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125310. var scene = this.scene;
  125311. if (scene.spriteManagers.length > 0) {
  125312. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125313. if (spritePickResult) {
  125314. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  125315. if (spritePickResult.pickedSprite.actionManager) {
  125316. 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));
  125317. if (spritePickResult.pickedSprite.actionManager) {
  125318. if (!this.scene._isPointerSwiping()) {
  125319. 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));
  125320. }
  125321. }
  125322. }
  125323. }
  125324. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  125325. 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));
  125326. }
  125327. }
  125328. }
  125329. return pickResult;
  125330. };
  125331. return SpriteSceneComponent;
  125332. }());
  125333. /***/ }),
  125334. /***/ "./States/alphaCullingState.ts":
  125335. /*!*************************************!*\
  125336. !*** ./States/alphaCullingState.ts ***!
  125337. \*************************************/
  125338. /*! exports provided: _AlphaState */
  125339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125340. "use strict";
  125341. __webpack_require__.r(__webpack_exports__);
  125342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  125343. /**
  125344. * @hidden
  125345. **/
  125346. var _AlphaState = /** @class */ (function () {
  125347. /**
  125348. * Initializes the state.
  125349. */
  125350. function _AlphaState() {
  125351. this._isAlphaBlendDirty = false;
  125352. this._isBlendFunctionParametersDirty = false;
  125353. this._isBlendEquationParametersDirty = false;
  125354. this._isBlendConstantsDirty = false;
  125355. this._alphaBlend = false;
  125356. this._blendFunctionParameters = new Array(4);
  125357. this._blendEquationParameters = new Array(2);
  125358. this._blendConstants = new Array(4);
  125359. this.reset();
  125360. }
  125361. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  125362. get: function () {
  125363. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  125364. },
  125365. enumerable: true,
  125366. configurable: true
  125367. });
  125368. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  125369. get: function () {
  125370. return this._alphaBlend;
  125371. },
  125372. set: function (value) {
  125373. if (this._alphaBlend === value) {
  125374. return;
  125375. }
  125376. this._alphaBlend = value;
  125377. this._isAlphaBlendDirty = true;
  125378. },
  125379. enumerable: true,
  125380. configurable: true
  125381. });
  125382. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  125383. if (this._blendConstants[0] === r &&
  125384. this._blendConstants[1] === g &&
  125385. this._blendConstants[2] === b &&
  125386. this._blendConstants[3] === a) {
  125387. return;
  125388. }
  125389. this._blendConstants[0] = r;
  125390. this._blendConstants[1] = g;
  125391. this._blendConstants[2] = b;
  125392. this._blendConstants[3] = a;
  125393. this._isBlendConstantsDirty = true;
  125394. };
  125395. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  125396. if (this._blendFunctionParameters[0] === value0 &&
  125397. this._blendFunctionParameters[1] === value1 &&
  125398. this._blendFunctionParameters[2] === value2 &&
  125399. this._blendFunctionParameters[3] === value3) {
  125400. return;
  125401. }
  125402. this._blendFunctionParameters[0] = value0;
  125403. this._blendFunctionParameters[1] = value1;
  125404. this._blendFunctionParameters[2] = value2;
  125405. this._blendFunctionParameters[3] = value3;
  125406. this._isBlendFunctionParametersDirty = true;
  125407. };
  125408. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  125409. if (this._blendEquationParameters[0] === rgb &&
  125410. this._blendEquationParameters[1] === alpha) {
  125411. return;
  125412. }
  125413. this._blendEquationParameters[0] = rgb;
  125414. this._blendEquationParameters[1] = alpha;
  125415. this._isBlendEquationParametersDirty = true;
  125416. };
  125417. _AlphaState.prototype.reset = function () {
  125418. this._alphaBlend = false;
  125419. this._blendFunctionParameters[0] = null;
  125420. this._blendFunctionParameters[1] = null;
  125421. this._blendFunctionParameters[2] = null;
  125422. this._blendFunctionParameters[3] = null;
  125423. this._blendEquationParameters[0] = null;
  125424. this._blendEquationParameters[1] = null;
  125425. this._blendConstants[0] = null;
  125426. this._blendConstants[1] = null;
  125427. this._blendConstants[2] = null;
  125428. this._blendConstants[3] = null;
  125429. this._isAlphaBlendDirty = true;
  125430. this._isBlendFunctionParametersDirty = false;
  125431. this._isBlendEquationParametersDirty = false;
  125432. this._isBlendConstantsDirty = false;
  125433. };
  125434. _AlphaState.prototype.apply = function (gl) {
  125435. if (!this.isDirty) {
  125436. return;
  125437. }
  125438. // Alpha blend
  125439. if (this._isAlphaBlendDirty) {
  125440. if (this._alphaBlend) {
  125441. gl.enable(gl.BLEND);
  125442. }
  125443. else {
  125444. gl.disable(gl.BLEND);
  125445. }
  125446. this._isAlphaBlendDirty = false;
  125447. }
  125448. // Alpha function
  125449. if (this._isBlendFunctionParametersDirty) {
  125450. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  125451. this._isBlendFunctionParametersDirty = false;
  125452. }
  125453. // Alpha equation
  125454. if (this._isBlendEquationParametersDirty) {
  125455. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  125456. this._isBlendEquationParametersDirty = false;
  125457. }
  125458. // Constants
  125459. if (this._isBlendConstantsDirty) {
  125460. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  125461. this._isBlendConstantsDirty = false;
  125462. }
  125463. };
  125464. return _AlphaState;
  125465. }());
  125466. /***/ }),
  125467. /***/ "./States/depthCullingState.ts":
  125468. /*!*************************************!*\
  125469. !*** ./States/depthCullingState.ts ***!
  125470. \*************************************/
  125471. /*! exports provided: _DepthCullingState */
  125472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125473. "use strict";
  125474. __webpack_require__.r(__webpack_exports__);
  125475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  125476. /**
  125477. * @hidden
  125478. **/
  125479. var _DepthCullingState = /** @class */ (function () {
  125480. /**
  125481. * Initializes the state.
  125482. */
  125483. function _DepthCullingState() {
  125484. this._isDepthTestDirty = false;
  125485. this._isDepthMaskDirty = false;
  125486. this._isDepthFuncDirty = false;
  125487. this._isCullFaceDirty = false;
  125488. this._isCullDirty = false;
  125489. this._isZOffsetDirty = false;
  125490. this._isFrontFaceDirty = false;
  125491. this.reset();
  125492. }
  125493. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  125494. get: function () {
  125495. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  125496. },
  125497. enumerable: true,
  125498. configurable: true
  125499. });
  125500. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  125501. get: function () {
  125502. return this._zOffset;
  125503. },
  125504. set: function (value) {
  125505. if (this._zOffset === value) {
  125506. return;
  125507. }
  125508. this._zOffset = value;
  125509. this._isZOffsetDirty = true;
  125510. },
  125511. enumerable: true,
  125512. configurable: true
  125513. });
  125514. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  125515. get: function () {
  125516. return this._cullFace;
  125517. },
  125518. set: function (value) {
  125519. if (this._cullFace === value) {
  125520. return;
  125521. }
  125522. this._cullFace = value;
  125523. this._isCullFaceDirty = true;
  125524. },
  125525. enumerable: true,
  125526. configurable: true
  125527. });
  125528. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  125529. get: function () {
  125530. return this._cull;
  125531. },
  125532. set: function (value) {
  125533. if (this._cull === value) {
  125534. return;
  125535. }
  125536. this._cull = value;
  125537. this._isCullDirty = true;
  125538. },
  125539. enumerable: true,
  125540. configurable: true
  125541. });
  125542. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  125543. get: function () {
  125544. return this._depthFunc;
  125545. },
  125546. set: function (value) {
  125547. if (this._depthFunc === value) {
  125548. return;
  125549. }
  125550. this._depthFunc = value;
  125551. this._isDepthFuncDirty = true;
  125552. },
  125553. enumerable: true,
  125554. configurable: true
  125555. });
  125556. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  125557. get: function () {
  125558. return this._depthMask;
  125559. },
  125560. set: function (value) {
  125561. if (this._depthMask === value) {
  125562. return;
  125563. }
  125564. this._depthMask = value;
  125565. this._isDepthMaskDirty = true;
  125566. },
  125567. enumerable: true,
  125568. configurable: true
  125569. });
  125570. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  125571. get: function () {
  125572. return this._depthTest;
  125573. },
  125574. set: function (value) {
  125575. if (this._depthTest === value) {
  125576. return;
  125577. }
  125578. this._depthTest = value;
  125579. this._isDepthTestDirty = true;
  125580. },
  125581. enumerable: true,
  125582. configurable: true
  125583. });
  125584. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  125585. get: function () {
  125586. return this._frontFace;
  125587. },
  125588. set: function (value) {
  125589. if (this._frontFace === value) {
  125590. return;
  125591. }
  125592. this._frontFace = value;
  125593. this._isFrontFaceDirty = true;
  125594. },
  125595. enumerable: true,
  125596. configurable: true
  125597. });
  125598. _DepthCullingState.prototype.reset = function () {
  125599. this._depthMask = true;
  125600. this._depthTest = true;
  125601. this._depthFunc = null;
  125602. this._cullFace = null;
  125603. this._cull = null;
  125604. this._zOffset = 0;
  125605. this._frontFace = null;
  125606. this._isDepthTestDirty = true;
  125607. this._isDepthMaskDirty = true;
  125608. this._isDepthFuncDirty = false;
  125609. this._isCullFaceDirty = false;
  125610. this._isCullDirty = false;
  125611. this._isZOffsetDirty = false;
  125612. this._isFrontFaceDirty = false;
  125613. };
  125614. _DepthCullingState.prototype.apply = function (gl) {
  125615. if (!this.isDirty) {
  125616. return;
  125617. }
  125618. // Cull
  125619. if (this._isCullDirty) {
  125620. if (this.cull) {
  125621. gl.enable(gl.CULL_FACE);
  125622. }
  125623. else {
  125624. gl.disable(gl.CULL_FACE);
  125625. }
  125626. this._isCullDirty = false;
  125627. }
  125628. // Cull face
  125629. if (this._isCullFaceDirty) {
  125630. gl.cullFace(this.cullFace);
  125631. this._isCullFaceDirty = false;
  125632. }
  125633. // Depth mask
  125634. if (this._isDepthMaskDirty) {
  125635. gl.depthMask(this.depthMask);
  125636. this._isDepthMaskDirty = false;
  125637. }
  125638. // Depth test
  125639. if (this._isDepthTestDirty) {
  125640. if (this.depthTest) {
  125641. gl.enable(gl.DEPTH_TEST);
  125642. }
  125643. else {
  125644. gl.disable(gl.DEPTH_TEST);
  125645. }
  125646. this._isDepthTestDirty = false;
  125647. }
  125648. // Depth func
  125649. if (this._isDepthFuncDirty) {
  125650. gl.depthFunc(this.depthFunc);
  125651. this._isDepthFuncDirty = false;
  125652. }
  125653. // zOffset
  125654. if (this._isZOffsetDirty) {
  125655. if (this.zOffset) {
  125656. gl.enable(gl.POLYGON_OFFSET_FILL);
  125657. gl.polygonOffset(this.zOffset, 0);
  125658. }
  125659. else {
  125660. gl.disable(gl.POLYGON_OFFSET_FILL);
  125661. }
  125662. this._isZOffsetDirty = false;
  125663. }
  125664. // Front face
  125665. if (this._isFrontFaceDirty) {
  125666. gl.frontFace(this.frontFace);
  125667. this._isFrontFaceDirty = false;
  125668. }
  125669. };
  125670. return _DepthCullingState;
  125671. }());
  125672. /***/ }),
  125673. /***/ "./States/index.ts":
  125674. /*!*************************!*\
  125675. !*** ./States/index.ts ***!
  125676. \*************************/
  125677. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  125678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125679. "use strict";
  125680. __webpack_require__.r(__webpack_exports__);
  125681. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  125682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  125683. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  125684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  125685. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  125686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  125687. /***/ }),
  125688. /***/ "./States/stencilState.ts":
  125689. /*!********************************!*\
  125690. !*** ./States/stencilState.ts ***!
  125691. \********************************/
  125692. /*! exports provided: _StencilState */
  125693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125694. "use strict";
  125695. __webpack_require__.r(__webpack_exports__);
  125696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  125697. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125698. /**
  125699. * @hidden
  125700. **/
  125701. var _StencilState = /** @class */ (function () {
  125702. function _StencilState() {
  125703. this._isStencilTestDirty = false;
  125704. this._isStencilMaskDirty = false;
  125705. this._isStencilFuncDirty = false;
  125706. this._isStencilOpDirty = false;
  125707. this.reset();
  125708. }
  125709. Object.defineProperty(_StencilState.prototype, "isDirty", {
  125710. get: function () {
  125711. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  125712. },
  125713. enumerable: true,
  125714. configurable: true
  125715. });
  125716. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  125717. get: function () {
  125718. return this._stencilFunc;
  125719. },
  125720. set: function (value) {
  125721. if (this._stencilFunc === value) {
  125722. return;
  125723. }
  125724. this._stencilFunc = value;
  125725. this._isStencilFuncDirty = true;
  125726. },
  125727. enumerable: true,
  125728. configurable: true
  125729. });
  125730. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  125731. get: function () {
  125732. return this._stencilFuncRef;
  125733. },
  125734. set: function (value) {
  125735. if (this._stencilFuncRef === value) {
  125736. return;
  125737. }
  125738. this._stencilFuncRef = value;
  125739. this._isStencilFuncDirty = true;
  125740. },
  125741. enumerable: true,
  125742. configurable: true
  125743. });
  125744. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  125745. get: function () {
  125746. return this._stencilFuncMask;
  125747. },
  125748. set: function (value) {
  125749. if (this._stencilFuncMask === value) {
  125750. return;
  125751. }
  125752. this._stencilFuncMask = value;
  125753. this._isStencilFuncDirty = true;
  125754. },
  125755. enumerable: true,
  125756. configurable: true
  125757. });
  125758. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  125759. get: function () {
  125760. return this._stencilOpStencilFail;
  125761. },
  125762. set: function (value) {
  125763. if (this._stencilOpStencilFail === value) {
  125764. return;
  125765. }
  125766. this._stencilOpStencilFail = value;
  125767. this._isStencilOpDirty = true;
  125768. },
  125769. enumerable: true,
  125770. configurable: true
  125771. });
  125772. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  125773. get: function () {
  125774. return this._stencilOpDepthFail;
  125775. },
  125776. set: function (value) {
  125777. if (this._stencilOpDepthFail === value) {
  125778. return;
  125779. }
  125780. this._stencilOpDepthFail = value;
  125781. this._isStencilOpDirty = true;
  125782. },
  125783. enumerable: true,
  125784. configurable: true
  125785. });
  125786. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  125787. get: function () {
  125788. return this._stencilOpStencilDepthPass;
  125789. },
  125790. set: function (value) {
  125791. if (this._stencilOpStencilDepthPass === value) {
  125792. return;
  125793. }
  125794. this._stencilOpStencilDepthPass = value;
  125795. this._isStencilOpDirty = true;
  125796. },
  125797. enumerable: true,
  125798. configurable: true
  125799. });
  125800. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  125801. get: function () {
  125802. return this._stencilMask;
  125803. },
  125804. set: function (value) {
  125805. if (this._stencilMask === value) {
  125806. return;
  125807. }
  125808. this._stencilMask = value;
  125809. this._isStencilMaskDirty = true;
  125810. },
  125811. enumerable: true,
  125812. configurable: true
  125813. });
  125814. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  125815. get: function () {
  125816. return this._stencilTest;
  125817. },
  125818. set: function (value) {
  125819. if (this._stencilTest === value) {
  125820. return;
  125821. }
  125822. this._stencilTest = value;
  125823. this._isStencilTestDirty = true;
  125824. },
  125825. enumerable: true,
  125826. configurable: true
  125827. });
  125828. _StencilState.prototype.reset = function () {
  125829. this._stencilTest = false;
  125830. this._stencilMask = 0xFF;
  125831. this._stencilFunc = _StencilState.ALWAYS;
  125832. this._stencilFuncRef = 1;
  125833. this._stencilFuncMask = 0xFF;
  125834. this._stencilOpStencilFail = _StencilState.KEEP;
  125835. this._stencilOpDepthFail = _StencilState.KEEP;
  125836. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  125837. this._isStencilTestDirty = true;
  125838. this._isStencilMaskDirty = true;
  125839. this._isStencilFuncDirty = true;
  125840. this._isStencilOpDirty = true;
  125841. };
  125842. _StencilState.prototype.apply = function (gl) {
  125843. if (!this.isDirty) {
  125844. return;
  125845. }
  125846. // Stencil test
  125847. if (this._isStencilTestDirty) {
  125848. if (this.stencilTest) {
  125849. gl.enable(gl.STENCIL_TEST);
  125850. }
  125851. else {
  125852. gl.disable(gl.STENCIL_TEST);
  125853. }
  125854. this._isStencilTestDirty = false;
  125855. }
  125856. // Stencil mask
  125857. if (this._isStencilMaskDirty) {
  125858. gl.stencilMask(this.stencilMask);
  125859. this._isStencilMaskDirty = false;
  125860. }
  125861. // Stencil func
  125862. if (this._isStencilFuncDirty) {
  125863. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  125864. this._isStencilFuncDirty = false;
  125865. }
  125866. // Stencil op
  125867. if (this._isStencilOpDirty) {
  125868. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  125869. this._isStencilOpDirty = false;
  125870. }
  125871. };
  125872. /** 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 */
  125873. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  125874. /** Passed to stencilOperation to specify that stencil value must be kept */
  125875. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  125876. /** Passed to stencilOperation to specify that stencil value must be replaced */
  125877. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  125878. return _StencilState;
  125879. }());
  125880. /***/ }),
  125881. /***/ "./abstractScene.ts":
  125882. /*!**************************!*\
  125883. !*** ./abstractScene.ts ***!
  125884. \**************************/
  125885. /*! exports provided: AbstractScene */
  125886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125887. "use strict";
  125888. __webpack_require__.r(__webpack_exports__);
  125889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  125890. /**
  125891. * Base class of the scene acting as a container for the different elements composing a scene.
  125892. * This class is dynamically extended by the different components of the scene increasing
  125893. * flexibility and reducing coupling
  125894. */
  125895. var AbstractScene = /** @class */ (function () {
  125896. function AbstractScene() {
  125897. /**
  125898. * Gets the list of root nodes (ie. nodes with no parent)
  125899. */
  125900. this.rootNodes = new Array();
  125901. /** All of the cameras added to this scene
  125902. * @see http://doc.babylonjs.com/babylon101/cameras
  125903. */
  125904. this.cameras = new Array();
  125905. /**
  125906. * All of the lights added to this scene
  125907. * @see http://doc.babylonjs.com/babylon101/lights
  125908. */
  125909. this.lights = new Array();
  125910. /**
  125911. * All of the (abstract) meshes added to this scene
  125912. */
  125913. this.meshes = new Array();
  125914. /**
  125915. * The list of skeletons added to the scene
  125916. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125917. */
  125918. this.skeletons = new Array();
  125919. /**
  125920. * All of the particle systems added to this scene
  125921. * @see http://doc.babylonjs.com/babylon101/particles
  125922. */
  125923. this.particleSystems = new Array();
  125924. /**
  125925. * Gets a list of Animations associated with the scene
  125926. */
  125927. this.animations = [];
  125928. /**
  125929. * All of the animation groups added to this scene
  125930. * @see http://doc.babylonjs.com/how_to/group
  125931. */
  125932. this.animationGroups = new Array();
  125933. /**
  125934. * All of the multi-materials added to this scene
  125935. * @see http://doc.babylonjs.com/how_to/multi_materials
  125936. */
  125937. this.multiMaterials = new Array();
  125938. /**
  125939. * All of the materials added to this scene
  125940. * In the context of a Scene, it is not supposed to be modified manually.
  125941. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  125942. * Note also that the order of the Material wihin the array is not significant and might change.
  125943. * @see http://doc.babylonjs.com/babylon101/materials
  125944. */
  125945. this.materials = new Array();
  125946. /**
  125947. * The list of morph target managers added to the scene
  125948. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125949. */
  125950. this.morphTargetManagers = new Array();
  125951. /**
  125952. * The list of geometries used in the scene.
  125953. */
  125954. this.geometries = new Array();
  125955. /**
  125956. * All of the tranform nodes added to this scene
  125957. * In the context of a Scene, it is not supposed to be modified manually.
  125958. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125959. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125960. * @see http://doc.babylonjs.com/how_to/transformnode
  125961. */
  125962. this.transformNodes = new Array();
  125963. /**
  125964. * ActionManagers available on the scene.
  125965. */
  125966. this.actionManagers = new Array();
  125967. /**
  125968. * Textures to keep.
  125969. */
  125970. this.textures = new Array();
  125971. }
  125972. /**
  125973. * Adds a parser in the list of available ones
  125974. * @param name Defines the name of the parser
  125975. * @param parser Defines the parser to add
  125976. */
  125977. AbstractScene.AddParser = function (name, parser) {
  125978. this._BabylonFileParsers[name] = parser;
  125979. };
  125980. /**
  125981. * Gets a general parser from the list of avaialble ones
  125982. * @param name Defines the name of the parser
  125983. * @returns the requested parser or null
  125984. */
  125985. AbstractScene.GetParser = function (name) {
  125986. if (this._BabylonFileParsers[name]) {
  125987. return this._BabylonFileParsers[name];
  125988. }
  125989. return null;
  125990. };
  125991. /**
  125992. * Adds n individual parser in the list of available ones
  125993. * @param name Defines the name of the parser
  125994. * @param parser Defines the parser to add
  125995. */
  125996. AbstractScene.AddIndividualParser = function (name, parser) {
  125997. this._IndividualBabylonFileParsers[name] = parser;
  125998. };
  125999. /**
  126000. * Gets an individual parser from the list of avaialble ones
  126001. * @param name Defines the name of the parser
  126002. * @returns the requested parser or null
  126003. */
  126004. AbstractScene.GetIndividualParser = function (name) {
  126005. if (this._IndividualBabylonFileParsers[name]) {
  126006. return this._IndividualBabylonFileParsers[name];
  126007. }
  126008. return null;
  126009. };
  126010. /**
  126011. * Parser json data and populate both a scene and its associated container object
  126012. * @param jsonData Defines the data to parse
  126013. * @param scene Defines the scene to parse the data for
  126014. * @param container Defines the container attached to the parsing sequence
  126015. * @param rootUrl Defines the root url of the data
  126016. */
  126017. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  126018. for (var parserName in this._BabylonFileParsers) {
  126019. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  126020. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  126021. }
  126022. }
  126023. };
  126024. /**
  126025. * Stores the list of available parsers in the application.
  126026. */
  126027. AbstractScene._BabylonFileParsers = {};
  126028. /**
  126029. * Stores the list of available individual parsers in the application.
  126030. */
  126031. AbstractScene._IndividualBabylonFileParsers = {};
  126032. return AbstractScene;
  126033. }());
  126034. /***/ }),
  126035. /***/ "./assetContainer.ts":
  126036. /*!***************************!*\
  126037. !*** ./assetContainer.ts ***!
  126038. \***************************/
  126039. /*! exports provided: KeepAssets, AssetContainer */
  126040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126041. "use strict";
  126042. __webpack_require__.r(__webpack_exports__);
  126043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  126044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  126045. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126046. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126047. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  126048. /**
  126049. * Set of assets to keep when moving a scene into an asset container.
  126050. */
  126051. var KeepAssets = /** @class */ (function (_super) {
  126052. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  126053. function KeepAssets() {
  126054. return _super !== null && _super.apply(this, arguments) || this;
  126055. }
  126056. return KeepAssets;
  126057. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126058. /**
  126059. * Container with a set of assets that can be added or removed from a scene.
  126060. */
  126061. var AssetContainer = /** @class */ (function (_super) {
  126062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  126063. /**
  126064. * Instantiates an AssetContainer.
  126065. * @param scene The scene the AssetContainer belongs to.
  126066. */
  126067. function AssetContainer(scene) {
  126068. var _this = _super.call(this) || this;
  126069. _this.scene = scene;
  126070. _this["sounds"] = [];
  126071. _this["effectLayers"] = [];
  126072. _this["layers"] = [];
  126073. _this["lensFlareSystems"] = [];
  126074. _this["proceduralTextures"] = [];
  126075. _this["reflectionProbes"] = [];
  126076. return _this;
  126077. }
  126078. /**
  126079. * Adds all the assets from the container to the scene.
  126080. */
  126081. AssetContainer.prototype.addAllToScene = function () {
  126082. var _this = this;
  126083. this.cameras.forEach(function (o) {
  126084. _this.scene.addCamera(o);
  126085. });
  126086. this.lights.forEach(function (o) {
  126087. _this.scene.addLight(o);
  126088. });
  126089. this.meshes.forEach(function (o) {
  126090. _this.scene.addMesh(o);
  126091. });
  126092. this.skeletons.forEach(function (o) {
  126093. _this.scene.addSkeleton(o);
  126094. });
  126095. this.animations.forEach(function (o) {
  126096. _this.scene.addAnimation(o);
  126097. });
  126098. this.animationGroups.forEach(function (o) {
  126099. _this.scene.addAnimationGroup(o);
  126100. });
  126101. this.multiMaterials.forEach(function (o) {
  126102. _this.scene.addMultiMaterial(o);
  126103. });
  126104. this.materials.forEach(function (o) {
  126105. _this.scene.addMaterial(o);
  126106. });
  126107. this.morphTargetManagers.forEach(function (o) {
  126108. _this.scene.addMorphTargetManager(o);
  126109. });
  126110. this.geometries.forEach(function (o) {
  126111. _this.scene.addGeometry(o);
  126112. });
  126113. this.transformNodes.forEach(function (o) {
  126114. _this.scene.addTransformNode(o);
  126115. });
  126116. this.actionManagers.forEach(function (o) {
  126117. _this.scene.addActionManager(o);
  126118. });
  126119. this.textures.forEach(function (o) {
  126120. _this.scene.addTexture(o);
  126121. });
  126122. this.reflectionProbes.forEach(function (o) {
  126123. _this.scene.addReflectionProbe(o);
  126124. });
  126125. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126126. var component = _a[_i];
  126127. component.addFromContainer(this);
  126128. }
  126129. };
  126130. /**
  126131. * Removes all the assets in the container from the scene
  126132. */
  126133. AssetContainer.prototype.removeAllFromScene = function () {
  126134. var _this = this;
  126135. this.cameras.forEach(function (o) {
  126136. _this.scene.removeCamera(o);
  126137. });
  126138. this.lights.forEach(function (o) {
  126139. _this.scene.removeLight(o);
  126140. });
  126141. this.meshes.forEach(function (o) {
  126142. _this.scene.removeMesh(o);
  126143. });
  126144. this.skeletons.forEach(function (o) {
  126145. _this.scene.removeSkeleton(o);
  126146. });
  126147. this.animations.forEach(function (o) {
  126148. _this.scene.removeAnimation(o);
  126149. });
  126150. this.animationGroups.forEach(function (o) {
  126151. _this.scene.removeAnimationGroup(o);
  126152. });
  126153. this.multiMaterials.forEach(function (o) {
  126154. _this.scene.removeMultiMaterial(o);
  126155. });
  126156. this.materials.forEach(function (o) {
  126157. _this.scene.removeMaterial(o);
  126158. });
  126159. this.morphTargetManagers.forEach(function (o) {
  126160. _this.scene.removeMorphTargetManager(o);
  126161. });
  126162. this.geometries.forEach(function (o) {
  126163. _this.scene.removeGeometry(o);
  126164. });
  126165. this.transformNodes.forEach(function (o) {
  126166. _this.scene.removeTransformNode(o);
  126167. });
  126168. this.actionManagers.forEach(function (o) {
  126169. _this.scene.removeActionManager(o);
  126170. });
  126171. this.textures.forEach(function (o) {
  126172. _this.scene.removeTexture(o);
  126173. });
  126174. this.reflectionProbes.forEach(function (o) {
  126175. _this.scene.removeReflectionProbe(o);
  126176. });
  126177. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126178. var component = _a[_i];
  126179. component.removeFromContainer(this);
  126180. }
  126181. };
  126182. /**
  126183. * Disposes all the assets in the container
  126184. */
  126185. AssetContainer.prototype.dispose = function () {
  126186. this.cameras.forEach(function (o) {
  126187. o.dispose();
  126188. });
  126189. this.lights.forEach(function (o) {
  126190. o.dispose();
  126191. });
  126192. this.meshes.forEach(function (o) {
  126193. o.dispose();
  126194. });
  126195. this.skeletons.forEach(function (o) {
  126196. o.dispose();
  126197. });
  126198. this.animationGroups.forEach(function (o) {
  126199. o.dispose();
  126200. });
  126201. this.multiMaterials.forEach(function (o) {
  126202. o.dispose();
  126203. });
  126204. this.materials.forEach(function (o) {
  126205. o.dispose();
  126206. });
  126207. this.geometries.forEach(function (o) {
  126208. o.dispose();
  126209. });
  126210. this.transformNodes.forEach(function (o) {
  126211. o.dispose();
  126212. });
  126213. this.actionManagers.forEach(function (o) {
  126214. o.dispose();
  126215. });
  126216. this.textures.forEach(function (o) {
  126217. o.dispose();
  126218. });
  126219. this.reflectionProbes.forEach(function (o) {
  126220. o.dispose();
  126221. });
  126222. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126223. var component = _a[_i];
  126224. component.dispose();
  126225. }
  126226. };
  126227. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  126228. if (!sourceAssets) {
  126229. return;
  126230. }
  126231. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  126232. var asset = sourceAssets_1[_i];
  126233. var move = true;
  126234. if (keepAssets) {
  126235. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  126236. var keepAsset = keepAssets_1[_a];
  126237. if (asset === keepAsset) {
  126238. move = false;
  126239. break;
  126240. }
  126241. }
  126242. }
  126243. if (move) {
  126244. targetAssets.push(asset);
  126245. }
  126246. }
  126247. };
  126248. /**
  126249. * Removes all the assets contained in the scene and adds them to the container.
  126250. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126251. */
  126252. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  126253. if (keepAssets === undefined) {
  126254. keepAssets = new KeepAssets();
  126255. }
  126256. for (var key in this) {
  126257. if (this.hasOwnProperty(key)) {
  126258. this[key] = this[key] || [];
  126259. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  126260. }
  126261. }
  126262. this.removeAllFromScene();
  126263. };
  126264. /**
  126265. * 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.
  126266. * @returns the root mesh
  126267. */
  126268. AssetContainer.prototype.createRootMesh = function () {
  126269. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  126270. this.meshes.forEach(function (m) {
  126271. if (!m.parent) {
  126272. rootMesh.addChild(m);
  126273. }
  126274. });
  126275. this.meshes.unshift(rootMesh);
  126276. return rootMesh;
  126277. };
  126278. return AssetContainer;
  126279. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126280. /***/ }),
  126281. /***/ "./index.ts":
  126282. /*!******************!*\
  126283. !*** ./index.ts ***!
  126284. \******************/
  126285. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  126286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126287. "use strict";
  126288. __webpack_require__.r(__webpack_exports__);
  126289. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  126291. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  126292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  126293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  126294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  126295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  126296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  126297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  126298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  126299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  126300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  126301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  126302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  126303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  126304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  126305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  126306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  126307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  126308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  126309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  126310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  126311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  126312. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  126313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  126314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  126315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  126316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  126317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  126318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  126319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  126320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  126321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  126322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  126323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  126324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  126325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  126326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  126327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  126328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  126329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  126330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  126331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  126332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  126333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  126334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  126335. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  126336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  126337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  126338. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  126339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  126340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  126341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  126342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  126343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  126344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  126345. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  126346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  126347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  126348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  126349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  126350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  126351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  126352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  126353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  126354. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  126355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  126356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  126357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  126358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  126359. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  126360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  126361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  126362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  126363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  126364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  126365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  126366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  126367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  126368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  126369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  126370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  126371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  126372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  126373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  126374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  126375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  126376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  126377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  126378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  126379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  126380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  126381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  126382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  126383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  126384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  126385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  126386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  126387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  126388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  126389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  126390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  126391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  126392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  126393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  126394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  126395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  126396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  126397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  126398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  126399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  126400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  126401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  126402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  126403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  126404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  126405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  126406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  126407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  126408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  126409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  126410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  126411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  126412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  126413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  126414. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  126415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  126416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  126417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  126418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  126419. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  126420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  126421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  126422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  126423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  126424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  126425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  126426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  126427. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  126428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  126429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  126430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  126431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  126432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  126433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  126434. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  126435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  126436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  126437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  126438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  126439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  126440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  126441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  126442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  126443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  126444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  126445. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  126446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  126447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  126448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  126449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  126450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  126451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  126452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  126453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  126454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  126455. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  126456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  126457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  126458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  126459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  126460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  126461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  126462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  126463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  126464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  126465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  126466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  126467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  126468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  126469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  126470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  126471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  126472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  126473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  126474. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  126475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  126476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  126477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  126478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  126479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  126480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  126481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  126482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  126483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  126484. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  126485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  126486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  126487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  126488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  126489. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  126490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  126491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  126492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  126493. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  126494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  126495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  126496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  126497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  126498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  126499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  126500. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  126501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  126502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  126503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  126504. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  126505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  126506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  126507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  126508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  126509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  126510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  126511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  126512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  126513. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  126514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  126515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  126516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  126517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  126518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  126519. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  126520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  126521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  126522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  126523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  126524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  126525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  126526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  126527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  126528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  126529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  126530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  126531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  126532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  126533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  126534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  126535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  126536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  126537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  126538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  126539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  126540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  126541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  126542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  126543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  126544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  126545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  126546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  126547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  126548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  126549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  126550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  126551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  126552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  126553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  126554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  126555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  126556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  126557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  126558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  126559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  126560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  126561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  126562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  126563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  126564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  126565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  126566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  126567. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  126568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  126569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  126570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  126571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  126572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  126573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  126574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  126575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  126576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  126577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  126579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  126581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  126583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  126584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  126585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  126586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  126587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  126588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  126589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  126590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  126591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  126592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  126593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  126594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  126595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  126596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  126597. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  126598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  126599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  126600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  126601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  126602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  126603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  126604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  126605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  126606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  126607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  126608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  126609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  126610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  126611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  126612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  126613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  126614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  126615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  126616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  126617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  126618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  126619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  126620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  126621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  126622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  126623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  126624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  126625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  126626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  126627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  126628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  126629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  126631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  126633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  126635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  126636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  126637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  126638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  126639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  126640. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  126641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  126642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  126643. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  126644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  126645. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  126646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  126647. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  126648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  126649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  126650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  126651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  126652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  126653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  126654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  126655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  126656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  126657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  126658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  126659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  126660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  126661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  126662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  126663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  126664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  126665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  126666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  126667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  126668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  126669. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  126670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  126671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  126672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  126673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  126674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  126675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  126676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  126677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  126678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  126679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  126680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  126681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  126682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  126683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  126684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  126685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  126686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  126687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  126688. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  126689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  126690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  126691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  126692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  126693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  126694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  126695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  126696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  126697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  126698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  126699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  126700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  126701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  126702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  126703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  126704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  126705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  126706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  126707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  126708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  126709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  126710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  126711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  126712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  126713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  126714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  126715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  126716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  126717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  126718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  126719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  126720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  126721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  126723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  126724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  126725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  126727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  126728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  126729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  126730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  126731. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  126732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  126733. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  126734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  126735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  126736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  126737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  126738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  126739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  126740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  126741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  126742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  126743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  126744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  126745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  126746. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  126747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  126748. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  126750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  126751. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  126752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  126753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  126754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  126755. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  126756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  126757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  126758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  126759. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  126760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  126761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  126762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  126763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  126764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  126765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  126766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  126767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  126768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  126769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  126770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  126771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  126772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  126773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  126774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  126775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  126776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  126777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  126778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  126779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  126780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  126781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  126782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  126783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  126784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  126785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  126786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  126787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  126788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  126789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  126790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  126791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  126792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  126793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  126794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  126795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  126796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  126797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  126798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  126799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  126800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  126801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  126802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  126803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  126804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  126805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  126806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  126807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  126808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  126809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  126810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  126811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  126812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  126813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  126814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  126815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  126816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  126817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  126818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  126819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  126820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  126821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  126822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  126823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  126824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  126825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  126826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  126827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  126828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  126829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  126830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  126831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  126832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  126833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  126834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  126835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  126836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  126837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  126838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  126839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  126840. /***/ }),
  126841. /***/ "./node.ts":
  126842. /*!*****************!*\
  126843. !*** ./node.ts ***!
  126844. \*****************/
  126845. /*! exports provided: Node */
  126846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126847. "use strict";
  126848. __webpack_require__.r(__webpack_exports__);
  126849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  126850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126851. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126852. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  126853. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126854. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126855. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  126856. /**
  126857. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  126858. */
  126859. var Node = /** @class */ (function () {
  126860. /**
  126861. * Creates a new Node
  126862. * @param name the name and id to be given to this node
  126863. * @param scene the scene this node will be added to
  126864. * @param addToRootNodes the node will be added to scene.rootNodes
  126865. */
  126866. function Node(name, scene, addToRootNodes) {
  126867. if (scene === void 0) { scene = null; }
  126868. if (addToRootNodes === void 0) { addToRootNodes = true; }
  126869. /**
  126870. * Gets or sets a string used to store user defined state for the node
  126871. */
  126872. this.state = "";
  126873. /**
  126874. * Gets or sets an object used to store user defined information for the node
  126875. */
  126876. this.metadata = null;
  126877. /**
  126878. * For internal use only. Please do not use.
  126879. */
  126880. this.reservedDataStore = null;
  126881. /**
  126882. * Gets or sets a boolean used to define if the node must be serialized
  126883. */
  126884. this.doNotSerialize = false;
  126885. /** @hidden */
  126886. this._isDisposed = false;
  126887. /**
  126888. * Gets a list of Animations associated with the node
  126889. */
  126890. this.animations = new Array();
  126891. this._ranges = {};
  126892. this._isEnabled = true;
  126893. this._isParentEnabled = true;
  126894. this._isReady = true;
  126895. /** @hidden */
  126896. this._currentRenderId = -1;
  126897. this._parentRenderId = -1;
  126898. this._childRenderId = -1;
  126899. /** @hidden */
  126900. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126901. /** @hidden */
  126902. this._worldMatrixDeterminant = 0;
  126903. /** @hidden */
  126904. this._sceneRootNodesIndex = -1;
  126905. this._animationPropertiesOverride = null;
  126906. /** @hidden */
  126907. this._isNode = true;
  126908. /**
  126909. * An event triggered when the mesh is disposed
  126910. */
  126911. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126912. // Behaviors
  126913. this._behaviors = new Array();
  126914. this.name = name;
  126915. this.id = name;
  126916. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  126917. this.uniqueId = this._scene.getUniqueId();
  126918. this._initCache();
  126919. if (addToRootNodes) {
  126920. this.addToSceneRootNodes();
  126921. }
  126922. }
  126923. /**
  126924. * Add a new node constructor
  126925. * @param type defines the type name of the node to construct
  126926. * @param constructorFunc defines the constructor function
  126927. */
  126928. Node.AddNodeConstructor = function (type, constructorFunc) {
  126929. this._NodeConstructors[type] = constructorFunc;
  126930. };
  126931. /**
  126932. * Returns a node constructor based on type name
  126933. * @param type defines the type name
  126934. * @param name defines the new node name
  126935. * @param scene defines the hosting scene
  126936. * @param options defines optional options to transmit to constructors
  126937. * @returns the new constructor or null
  126938. */
  126939. Node.Construct = function (type, name, scene, options) {
  126940. var constructorFunc = this._NodeConstructors[type];
  126941. if (!constructorFunc) {
  126942. return null;
  126943. }
  126944. return constructorFunc(name, scene, options);
  126945. };
  126946. /**
  126947. * Gets a boolean indicating if the node has been disposed
  126948. * @returns true if the node was disposed
  126949. */
  126950. Node.prototype.isDisposed = function () {
  126951. return this._isDisposed;
  126952. };
  126953. Object.defineProperty(Node.prototype, "parent", {
  126954. get: function () {
  126955. return this._parentNode;
  126956. },
  126957. /**
  126958. * Gets or sets the parent of the node
  126959. */
  126960. set: function (parent) {
  126961. if (this._parentNode === parent) {
  126962. return;
  126963. }
  126964. var previousParentNode = this._parentNode;
  126965. // Remove self from list of children of parent
  126966. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  126967. var index = this._parentNode._children.indexOf(this);
  126968. if (index !== -1) {
  126969. this._parentNode._children.splice(index, 1);
  126970. }
  126971. if (!parent && !this._isDisposed) {
  126972. this.addToSceneRootNodes();
  126973. }
  126974. }
  126975. // Store new parent
  126976. this._parentNode = parent;
  126977. // Add as child to new parent
  126978. if (this._parentNode) {
  126979. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  126980. this._parentNode._children = new Array();
  126981. }
  126982. this._parentNode._children.push(this);
  126983. if (!previousParentNode) {
  126984. this.removeFromSceneRootNodes();
  126985. }
  126986. }
  126987. // Enabled state
  126988. this._syncParentEnabledState();
  126989. },
  126990. enumerable: true,
  126991. configurable: true
  126992. });
  126993. Node.prototype.addToSceneRootNodes = function () {
  126994. if (this._sceneRootNodesIndex === -1) {
  126995. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  126996. this._scene.rootNodes.push(this);
  126997. }
  126998. };
  126999. Node.prototype.removeFromSceneRootNodes = function () {
  127000. if (this._sceneRootNodesIndex !== -1) {
  127001. var rootNodes = this._scene.rootNodes;
  127002. var lastIdx = rootNodes.length - 1;
  127003. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  127004. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  127005. this._scene.rootNodes.pop();
  127006. this._sceneRootNodesIndex = -1;
  127007. }
  127008. };
  127009. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  127010. /**
  127011. * Gets or sets the animation properties override
  127012. */
  127013. get: function () {
  127014. if (!this._animationPropertiesOverride) {
  127015. return this._scene.animationPropertiesOverride;
  127016. }
  127017. return this._animationPropertiesOverride;
  127018. },
  127019. set: function (value) {
  127020. this._animationPropertiesOverride = value;
  127021. },
  127022. enumerable: true,
  127023. configurable: true
  127024. });
  127025. /**
  127026. * Gets a string idenfifying the name of the class
  127027. * @returns "Node" string
  127028. */
  127029. Node.prototype.getClassName = function () {
  127030. return "Node";
  127031. };
  127032. Object.defineProperty(Node.prototype, "onDispose", {
  127033. /**
  127034. * Sets a callback that will be raised when the node will be disposed
  127035. */
  127036. set: function (callback) {
  127037. if (this._onDisposeObserver) {
  127038. this.onDisposeObservable.remove(this._onDisposeObserver);
  127039. }
  127040. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127041. },
  127042. enumerable: true,
  127043. configurable: true
  127044. });
  127045. /**
  127046. * Gets the scene of the node
  127047. * @returns a scene
  127048. */
  127049. Node.prototype.getScene = function () {
  127050. return this._scene;
  127051. };
  127052. /**
  127053. * Gets the engine of the node
  127054. * @returns a Engine
  127055. */
  127056. Node.prototype.getEngine = function () {
  127057. return this._scene.getEngine();
  127058. };
  127059. /**
  127060. * Attach a behavior to the node
  127061. * @see http://doc.babylonjs.com/features/behaviour
  127062. * @param behavior defines the behavior to attach
  127063. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  127064. * @returns the current Node
  127065. */
  127066. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  127067. var _this = this;
  127068. if (attachImmediately === void 0) { attachImmediately = false; }
  127069. var index = this._behaviors.indexOf(behavior);
  127070. if (index !== -1) {
  127071. return this;
  127072. }
  127073. behavior.init();
  127074. if (this._scene.isLoading && !attachImmediately) {
  127075. // We defer the attach when the scene will be loaded
  127076. this._scene.onDataLoadedObservable.addOnce(function () {
  127077. behavior.attach(_this);
  127078. });
  127079. }
  127080. else {
  127081. behavior.attach(this);
  127082. }
  127083. this._behaviors.push(behavior);
  127084. return this;
  127085. };
  127086. /**
  127087. * Remove an attached behavior
  127088. * @see http://doc.babylonjs.com/features/behaviour
  127089. * @param behavior defines the behavior to attach
  127090. * @returns the current Node
  127091. */
  127092. Node.prototype.removeBehavior = function (behavior) {
  127093. var index = this._behaviors.indexOf(behavior);
  127094. if (index === -1) {
  127095. return this;
  127096. }
  127097. this._behaviors[index].detach();
  127098. this._behaviors.splice(index, 1);
  127099. return this;
  127100. };
  127101. Object.defineProperty(Node.prototype, "behaviors", {
  127102. /**
  127103. * Gets the list of attached behaviors
  127104. * @see http://doc.babylonjs.com/features/behaviour
  127105. */
  127106. get: function () {
  127107. return this._behaviors;
  127108. },
  127109. enumerable: true,
  127110. configurable: true
  127111. });
  127112. /**
  127113. * Gets an attached behavior by name
  127114. * @param name defines the name of the behavior to look for
  127115. * @see http://doc.babylonjs.com/features/behaviour
  127116. * @returns null if behavior was not found else the requested behavior
  127117. */
  127118. Node.prototype.getBehaviorByName = function (name) {
  127119. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  127120. var behavior = _a[_i];
  127121. if (behavior.name === name) {
  127122. return behavior;
  127123. }
  127124. }
  127125. return null;
  127126. };
  127127. /**
  127128. * Returns the latest update of the World matrix
  127129. * @returns a Matrix
  127130. */
  127131. Node.prototype.getWorldMatrix = function () {
  127132. if (this._currentRenderId !== this._scene.getRenderId()) {
  127133. this.computeWorldMatrix();
  127134. }
  127135. return this._worldMatrix;
  127136. };
  127137. /** @hidden */
  127138. Node.prototype._getWorldMatrixDeterminant = function () {
  127139. return this._worldMatrixDeterminant;
  127140. };
  127141. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  127142. /**
  127143. * Returns directly the latest state of the mesh World matrix.
  127144. * A Matrix is returned.
  127145. */
  127146. get: function () {
  127147. return this._worldMatrix;
  127148. },
  127149. enumerable: true,
  127150. configurable: true
  127151. });
  127152. // override it in derived class if you add new variables to the cache
  127153. // and call the parent class method
  127154. /** @hidden */
  127155. Node.prototype._initCache = function () {
  127156. this._cache = {};
  127157. this._cache.parent = undefined;
  127158. };
  127159. /** @hidden */
  127160. Node.prototype.updateCache = function (force) {
  127161. if (!force && this.isSynchronized()) {
  127162. return;
  127163. }
  127164. this._cache.parent = this.parent;
  127165. this._updateCache();
  127166. };
  127167. // override it in derived class if you add new variables to the cache
  127168. // and call the parent class method if !ignoreParentClass
  127169. /** @hidden */
  127170. Node.prototype._updateCache = function (ignoreParentClass) {
  127171. };
  127172. // override it in derived class if you add new variables to the cache
  127173. /** @hidden */
  127174. Node.prototype._isSynchronized = function () {
  127175. return true;
  127176. };
  127177. /** @hidden */
  127178. Node.prototype._markSyncedWithParent = function () {
  127179. if (this._parentNode) {
  127180. this._parentRenderId = this._parentNode._childRenderId;
  127181. }
  127182. };
  127183. /** @hidden */
  127184. Node.prototype.isSynchronizedWithParent = function () {
  127185. if (!this._parentNode) {
  127186. return true;
  127187. }
  127188. if (this._parentRenderId !== this._parentNode._childRenderId) {
  127189. return false;
  127190. }
  127191. return this._parentNode.isSynchronized();
  127192. };
  127193. /** @hidden */
  127194. Node.prototype.isSynchronized = function () {
  127195. if (this._cache.parent != this._parentNode) {
  127196. this._cache.parent = this._parentNode;
  127197. return false;
  127198. }
  127199. if (this._parentNode && !this.isSynchronizedWithParent()) {
  127200. return false;
  127201. }
  127202. return this._isSynchronized();
  127203. };
  127204. /**
  127205. * Is this node ready to be used/rendered
  127206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  127207. * @return true if the node is ready
  127208. */
  127209. Node.prototype.isReady = function (completeCheck) {
  127210. if (completeCheck === void 0) { completeCheck = false; }
  127211. return this._isReady;
  127212. };
  127213. /**
  127214. * Is this node enabled?
  127215. * 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
  127216. * @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
  127217. * @return whether this node (and its parent) is enabled
  127218. */
  127219. Node.prototype.isEnabled = function (checkAncestors) {
  127220. if (checkAncestors === void 0) { checkAncestors = true; }
  127221. if (checkAncestors === false) {
  127222. return this._isEnabled;
  127223. }
  127224. if (!this._isEnabled) {
  127225. return false;
  127226. }
  127227. return this._isParentEnabled;
  127228. };
  127229. /** @hidden */
  127230. Node.prototype._syncParentEnabledState = function () {
  127231. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  127232. if (this._children) {
  127233. this._children.forEach(function (c) {
  127234. c._syncParentEnabledState(); // Force children to update accordingly
  127235. });
  127236. }
  127237. };
  127238. /**
  127239. * Set the enabled state of this node
  127240. * @param value defines the new enabled state
  127241. */
  127242. Node.prototype.setEnabled = function (value) {
  127243. this._isEnabled = value;
  127244. this._syncParentEnabledState();
  127245. };
  127246. /**
  127247. * Is this node a descendant of the given node?
  127248. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  127249. * @param ancestor defines the parent node to inspect
  127250. * @returns a boolean indicating if this node is a descendant of the given node
  127251. */
  127252. Node.prototype.isDescendantOf = function (ancestor) {
  127253. if (this.parent) {
  127254. if (this.parent === ancestor) {
  127255. return true;
  127256. }
  127257. return this.parent.isDescendantOf(ancestor);
  127258. }
  127259. return false;
  127260. };
  127261. /** @hidden */
  127262. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  127263. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  127264. if (!this._children) {
  127265. return;
  127266. }
  127267. for (var index = 0; index < this._children.length; index++) {
  127268. var item = this._children[index];
  127269. if (!predicate || predicate(item)) {
  127270. results.push(item);
  127271. }
  127272. if (!directDescendantsOnly) {
  127273. item._getDescendants(results, false, predicate);
  127274. }
  127275. }
  127276. };
  127277. /**
  127278. * Will return all nodes that have this node as ascendant
  127279. * @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
  127280. * @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
  127281. * @return all children nodes of all types
  127282. */
  127283. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  127284. var results = new Array();
  127285. this._getDescendants(results, directDescendantsOnly, predicate);
  127286. return results;
  127287. };
  127288. /**
  127289. * Get all child-meshes of this node
  127290. * @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
  127291. * @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
  127292. * @returns an array of AbstractMesh
  127293. */
  127294. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  127295. var results = [];
  127296. this._getDescendants(results, directDescendantsOnly, function (node) {
  127297. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  127298. });
  127299. return results;
  127300. };
  127301. /**
  127302. * Get all direct children of this node
  127303. * @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
  127304. * @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)
  127305. * @returns an array of Node
  127306. */
  127307. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  127308. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  127309. return this.getDescendants(directDescendantsOnly, predicate);
  127310. };
  127311. /** @hidden */
  127312. Node.prototype._setReady = function (state) {
  127313. if (state === this._isReady) {
  127314. return;
  127315. }
  127316. if (!state) {
  127317. this._isReady = false;
  127318. return;
  127319. }
  127320. if (this.onReady) {
  127321. this.onReady(this);
  127322. }
  127323. this._isReady = true;
  127324. };
  127325. /**
  127326. * Get an animation by name
  127327. * @param name defines the name of the animation to look for
  127328. * @returns null if not found else the requested animation
  127329. */
  127330. Node.prototype.getAnimationByName = function (name) {
  127331. for (var i = 0; i < this.animations.length; i++) {
  127332. var animation = this.animations[i];
  127333. if (animation.name === name) {
  127334. return animation;
  127335. }
  127336. }
  127337. return null;
  127338. };
  127339. /**
  127340. * Creates an animation range for this node
  127341. * @param name defines the name of the range
  127342. * @param from defines the starting key
  127343. * @param to defines the end key
  127344. */
  127345. Node.prototype.createAnimationRange = function (name, from, to) {
  127346. // check name not already in use
  127347. if (!this._ranges[name]) {
  127348. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  127349. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127350. if (this.animations[i]) {
  127351. this.animations[i].createRange(name, from, to);
  127352. }
  127353. }
  127354. }
  127355. };
  127356. /**
  127357. * Delete a specific animation range
  127358. * @param name defines the name of the range to delete
  127359. * @param deleteFrames defines if animation frames from the range must be deleted as well
  127360. */
  127361. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  127362. if (deleteFrames === void 0) { deleteFrames = true; }
  127363. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127364. if (this.animations[i]) {
  127365. this.animations[i].deleteRange(name, deleteFrames);
  127366. }
  127367. }
  127368. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  127369. };
  127370. /**
  127371. * Get an animation range by name
  127372. * @param name defines the name of the animation range to look for
  127373. * @returns null if not found else the requested animation range
  127374. */
  127375. Node.prototype.getAnimationRange = function (name) {
  127376. return this._ranges[name];
  127377. };
  127378. /**
  127379. * Will start the animation sequence
  127380. * @param name defines the range frames for animation sequence
  127381. * @param loop defines if the animation should loop (false by default)
  127382. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  127383. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  127384. * @returns the object created for this animation. If range does not exist, it will return null
  127385. */
  127386. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  127387. var range = this.getAnimationRange(name);
  127388. if (!range) {
  127389. return null;
  127390. }
  127391. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  127392. };
  127393. /**
  127394. * Serialize animation ranges into a JSON compatible object
  127395. * @returns serialization object
  127396. */
  127397. Node.prototype.serializeAnimationRanges = function () {
  127398. var serializationRanges = [];
  127399. for (var name in this._ranges) {
  127400. var localRange = this._ranges[name];
  127401. if (!localRange) {
  127402. continue;
  127403. }
  127404. var range = {};
  127405. range.name = name;
  127406. range.from = localRange.from;
  127407. range.to = localRange.to;
  127408. serializationRanges.push(range);
  127409. }
  127410. return serializationRanges;
  127411. };
  127412. /**
  127413. * Computes the world matrix of the node
  127414. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  127415. * @returns the world matrix
  127416. */
  127417. Node.prototype.computeWorldMatrix = function (force) {
  127418. if (!this._worldMatrix) {
  127419. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127420. }
  127421. return this._worldMatrix;
  127422. };
  127423. /**
  127424. * Releases resources associated with this node.
  127425. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127426. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127427. */
  127428. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  127429. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  127430. this._isDisposed = true;
  127431. if (!doNotRecurse) {
  127432. var nodes = this.getDescendants(true);
  127433. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  127434. var node = nodes_1[_i];
  127435. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  127436. }
  127437. }
  127438. if (!this.parent) {
  127439. this.removeFromSceneRootNodes();
  127440. }
  127441. else {
  127442. this.parent = null;
  127443. }
  127444. // Callback
  127445. this.onDisposeObservable.notifyObservers(this);
  127446. this.onDisposeObservable.clear();
  127447. // Behaviors
  127448. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  127449. var behavior = _b[_a];
  127450. behavior.detach();
  127451. }
  127452. this._behaviors = [];
  127453. };
  127454. /**
  127455. * Parse animation range data from a serialization object and store them into a given node
  127456. * @param node defines where to store the animation ranges
  127457. * @param parsedNode defines the serialization object to read data from
  127458. * @param scene defines the hosting scene
  127459. */
  127460. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  127461. if (parsedNode.ranges) {
  127462. for (var index = 0; index < parsedNode.ranges.length; index++) {
  127463. var data = parsedNode.ranges[index];
  127464. node.createAnimationRange(data.name, data.from, data.to);
  127465. }
  127466. }
  127467. };
  127468. /** @hidden */
  127469. Node._AnimationRangeFactory = function (name, from, to) {
  127470. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  127471. };
  127472. Node._NodeConstructors = {};
  127473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127475. ], Node.prototype, "name", void 0);
  127476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127478. ], Node.prototype, "id", void 0);
  127479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127481. ], Node.prototype, "uniqueId", void 0);
  127482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127484. ], Node.prototype, "state", void 0);
  127485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127487. ], Node.prototype, "metadata", void 0);
  127488. return Node;
  127489. }());
  127490. /***/ }),
  127491. /***/ "./scene.ts":
  127492. /*!******************!*\
  127493. !*** ./scene.ts ***!
  127494. \******************/
  127495. /*! exports provided: Scene */
  127496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127497. "use strict";
  127498. __webpack_require__.r(__webpack_exports__);
  127499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  127500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127501. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  127502. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  127503. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127504. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  127505. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  127506. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  127507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127508. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127509. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  127510. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127511. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  127512. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  127513. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  127514. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127515. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  127516. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  127517. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  127518. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  127519. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  127520. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127521. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  127522. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  127523. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  127524. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127525. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  127526. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127527. /** @hidden */
  127528. var ClickInfo = /** @class */ (function () {
  127529. function ClickInfo() {
  127530. this._singleClick = false;
  127531. this._doubleClick = false;
  127532. this._hasSwiped = false;
  127533. this._ignore = false;
  127534. }
  127535. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  127536. get: function () {
  127537. return this._singleClick;
  127538. },
  127539. set: function (b) {
  127540. this._singleClick = b;
  127541. },
  127542. enumerable: true,
  127543. configurable: true
  127544. });
  127545. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  127546. get: function () {
  127547. return this._doubleClick;
  127548. },
  127549. set: function (b) {
  127550. this._doubleClick = b;
  127551. },
  127552. enumerable: true,
  127553. configurable: true
  127554. });
  127555. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  127556. get: function () {
  127557. return this._hasSwiped;
  127558. },
  127559. set: function (b) {
  127560. this._hasSwiped = b;
  127561. },
  127562. enumerable: true,
  127563. configurable: true
  127564. });
  127565. Object.defineProperty(ClickInfo.prototype, "ignore", {
  127566. get: function () {
  127567. return this._ignore;
  127568. },
  127569. set: function (b) {
  127570. this._ignore = b;
  127571. },
  127572. enumerable: true,
  127573. configurable: true
  127574. });
  127575. return ClickInfo;
  127576. }());
  127577. /**
  127578. * Represents a scene to be rendered by the engine.
  127579. * @see http://doc.babylonjs.com/features/scene
  127580. */
  127581. var Scene = /** @class */ (function (_super) {
  127582. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  127583. /**
  127584. * Creates a new Scene
  127585. * @param engine defines the engine to use to render this scene
  127586. * @param options defines the scene options
  127587. */
  127588. function Scene(engine, options) {
  127589. var _this = _super.call(this) || this;
  127590. // Members
  127591. /** @hidden */
  127592. _this._isScene = true;
  127593. /**
  127594. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  127595. */
  127596. _this.autoClear = true;
  127597. /**
  127598. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  127599. */
  127600. _this.autoClearDepthAndStencil = true;
  127601. /**
  127602. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  127603. */
  127604. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  127605. /**
  127606. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  127607. */
  127608. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  127609. _this._forceWireframe = false;
  127610. _this._forcePointsCloud = false;
  127611. /**
  127612. * Gets or sets a boolean indicating if animations are enabled
  127613. */
  127614. _this.animationsEnabled = true;
  127615. _this._animationPropertiesOverride = null;
  127616. /**
  127617. * Gets or sets a boolean indicating if a constant deltatime has to be used
  127618. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  127619. */
  127620. _this.useConstantAnimationDeltaTime = false;
  127621. /**
  127622. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  127623. * Please note that it requires to run a ray cast through the scene on every frame
  127624. */
  127625. _this.constantlyUpdateMeshUnderPointer = false;
  127626. /**
  127627. * Defines the HTML cursor to use when hovering over interactive elements
  127628. */
  127629. _this.hoverCursor = "pointer";
  127630. /**
  127631. * Defines the HTML default cursor to use (empty by default)
  127632. */
  127633. _this.defaultCursor = "";
  127634. /**
  127635. * This is used to call preventDefault() on pointer down
  127636. * in order to block unwanted artifacts like system double clicks
  127637. */
  127638. _this.preventDefaultOnPointerDown = true;
  127639. /**
  127640. * This is used to call preventDefault() on pointer up
  127641. * in order to block unwanted artifacts like system double clicks
  127642. */
  127643. _this.preventDefaultOnPointerUp = true;
  127644. // Metadata
  127645. /**
  127646. * Gets or sets user defined metadata
  127647. */
  127648. _this.metadata = null;
  127649. /**
  127650. * For internal use only. Please do not use.
  127651. */
  127652. _this.reservedDataStore = null;
  127653. /**
  127654. * Use this array to add regular expressions used to disable offline support for specific urls
  127655. */
  127656. _this.disableOfflineSupportExceptionRules = new Array();
  127657. /**
  127658. * An event triggered when the scene is disposed.
  127659. */
  127660. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127661. _this._onDisposeObserver = null;
  127662. /**
  127663. * An event triggered before rendering the scene (right after animations and physics)
  127664. */
  127665. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127666. _this._onBeforeRenderObserver = null;
  127667. /**
  127668. * An event triggered after rendering the scene
  127669. */
  127670. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127671. _this._onAfterRenderObserver = null;
  127672. /**
  127673. * An event triggered before animating the scene
  127674. */
  127675. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127676. /**
  127677. * An event triggered after animations processing
  127678. */
  127679. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127680. /**
  127681. * An event triggered before draw calls are ready to be sent
  127682. */
  127683. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127684. /**
  127685. * An event triggered after draw calls have been sent
  127686. */
  127687. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127688. /**
  127689. * An event triggered when the scene is ready
  127690. */
  127691. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127692. /**
  127693. * An event triggered before rendering a camera
  127694. */
  127695. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127696. _this._onBeforeCameraRenderObserver = null;
  127697. /**
  127698. * An event triggered after rendering a camera
  127699. */
  127700. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127701. _this._onAfterCameraRenderObserver = null;
  127702. /**
  127703. * An event triggered when active meshes evaluation is about to start
  127704. */
  127705. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127706. /**
  127707. * An event triggered when active meshes evaluation is done
  127708. */
  127709. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127710. /**
  127711. * An event triggered when particles rendering is about to start
  127712. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127713. */
  127714. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127715. /**
  127716. * An event triggered when particles rendering is done
  127717. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127718. */
  127719. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127720. /**
  127721. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  127722. */
  127723. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127724. /**
  127725. * An event triggered when a camera is created
  127726. */
  127727. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127728. /**
  127729. * An event triggered when a camera is removed
  127730. */
  127731. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127732. /**
  127733. * An event triggered when a light is created
  127734. */
  127735. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127736. /**
  127737. * An event triggered when a light is removed
  127738. */
  127739. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127740. /**
  127741. * An event triggered when a geometry is created
  127742. */
  127743. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127744. /**
  127745. * An event triggered when a geometry is removed
  127746. */
  127747. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127748. /**
  127749. * An event triggered when a transform node is created
  127750. */
  127751. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127752. /**
  127753. * An event triggered when a transform node is removed
  127754. */
  127755. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127756. /**
  127757. * An event triggered when a mesh is created
  127758. */
  127759. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127760. /**
  127761. * An event triggered when a mesh is removed
  127762. */
  127763. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127764. /**
  127765. * An event triggered when a material is created
  127766. */
  127767. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127768. /**
  127769. * An event triggered when a material is removed
  127770. */
  127771. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127772. /**
  127773. * An event triggered when a texture is created
  127774. */
  127775. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127776. /**
  127777. * An event triggered when a texture is removed
  127778. */
  127779. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127780. /**
  127781. * An event triggered when render targets are about to be rendered
  127782. * Can happen multiple times per frame.
  127783. */
  127784. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127785. /**
  127786. * An event triggered when render targets were rendered.
  127787. * Can happen multiple times per frame.
  127788. */
  127789. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127790. /**
  127791. * An event triggered before calculating deterministic simulation step
  127792. */
  127793. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127794. /**
  127795. * An event triggered after calculating deterministic simulation step
  127796. */
  127797. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127798. /**
  127799. * An event triggered when the activeCamera property is updated
  127800. */
  127801. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127802. /**
  127803. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  127804. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127805. * 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)
  127806. */
  127807. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127808. /**
  127809. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  127810. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127811. * 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)
  127812. */
  127813. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127814. /**
  127815. * This Observable will when a mesh has been imported into the scene.
  127816. */
  127817. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127818. // Animations
  127819. /** @hidden */
  127820. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127821. /**
  127822. * 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).
  127823. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  127824. */
  127825. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127826. /**
  127827. * Observable event triggered each time an input event is received from the rendering canvas
  127828. */
  127829. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127830. _this._meshPickProceed = false;
  127831. _this._currentPickResult = null;
  127832. _this._previousPickResult = null;
  127833. _this._totalPointersPressed = 0;
  127834. _this._doubleClickOccured = false;
  127835. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  127836. _this.cameraToUseForPointers = null;
  127837. _this._pointerX = 0;
  127838. _this._pointerY = 0;
  127839. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127840. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127841. _this._startingPointerTime = 0;
  127842. _this._previousStartingPointerTime = 0;
  127843. _this._pointerCaptures = {};
  127844. // Deterministic lockstep
  127845. _this._timeAccumulator = 0;
  127846. _this._currentStepId = 0;
  127847. _this._currentInternalStep = 0;
  127848. // Keyboard
  127849. /**
  127850. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  127851. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  127852. */
  127853. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127854. /**
  127855. * Observable event triggered each time an keyboard event is received from the hosting window
  127856. */
  127857. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127858. // Coordinates system
  127859. _this._useRightHandedSystem = false;
  127860. // Fog
  127861. _this._fogEnabled = true;
  127862. _this._fogMode = Scene.FOGMODE_NONE;
  127863. /**
  127864. * Gets or sets the fog color to use
  127865. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127866. * (Default is Color3(0.2, 0.2, 0.3))
  127867. */
  127868. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  127869. /**
  127870. * Gets or sets the fog density to use
  127871. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127872. * (Default is 0.1)
  127873. */
  127874. _this.fogDensity = 0.1;
  127875. /**
  127876. * Gets or sets the fog start distance to use
  127877. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127878. * (Default is 0)
  127879. */
  127880. _this.fogStart = 0;
  127881. /**
  127882. * Gets or sets the fog end distance to use
  127883. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127884. * (Default is 1000)
  127885. */
  127886. _this.fogEnd = 1000.0;
  127887. // Lights
  127888. _this._shadowsEnabled = true;
  127889. _this._lightsEnabled = true;
  127890. /** All of the active cameras added to this scene. */
  127891. _this.activeCameras = new Array();
  127892. // Textures
  127893. _this._texturesEnabled = true;
  127894. // Particles
  127895. /**
  127896. * Gets or sets a boolean indicating if particles are enabled on this scene
  127897. */
  127898. _this.particlesEnabled = true;
  127899. // Sprites
  127900. /**
  127901. * Gets or sets a boolean indicating if sprites are enabled on this scene
  127902. */
  127903. _this.spritesEnabled = true;
  127904. // Skeletons
  127905. _this._skeletonsEnabled = true;
  127906. // Lens flares
  127907. /**
  127908. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  127909. */
  127910. _this.lensFlaresEnabled = true;
  127911. // Collisions
  127912. /**
  127913. * Gets or sets a boolean indicating if collisions are enabled on this scene
  127914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127915. */
  127916. _this.collisionsEnabled = true;
  127917. /**
  127918. * Defines the gravity applied to this scene (used only for collisions)
  127919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127920. */
  127921. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  127922. // Postprocesses
  127923. /**
  127924. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  127925. */
  127926. _this.postProcessesEnabled = true;
  127927. /**
  127928. * The list of postprocesses added to the scene
  127929. */
  127930. _this.postProcesses = new Array();
  127931. // Customs render targets
  127932. /**
  127933. * Gets or sets a boolean indicating if render targets are enabled on this scene
  127934. */
  127935. _this.renderTargetsEnabled = true;
  127936. /**
  127937. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  127938. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  127939. */
  127940. _this.dumpNextRenderTargets = false;
  127941. /**
  127942. * The list of user defined render targets added to the scene
  127943. */
  127944. _this.customRenderTargets = new Array();
  127945. /**
  127946. * Gets the list of meshes imported to the scene through SceneLoader
  127947. */
  127948. _this.importedMeshesFiles = new Array();
  127949. // Probes
  127950. /**
  127951. * Gets or sets a boolean indicating if probes are enabled on this scene
  127952. */
  127953. _this.probesEnabled = true;
  127954. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127955. // Procedural textures
  127956. /**
  127957. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  127958. */
  127959. _this.proceduralTexturesEnabled = true;
  127960. // Performance counters
  127961. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127962. /** @hidden */
  127963. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127964. /** @hidden */
  127965. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127966. /** @hidden */
  127967. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127968. /** @hidden */
  127969. _this._animationTime = 0;
  127970. /**
  127971. * Gets or sets a general scale for animation speed
  127972. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  127973. */
  127974. _this.animationTimeScale = 1;
  127975. _this._renderId = 0;
  127976. _this._frameId = 0;
  127977. _this._executeWhenReadyTimeoutId = -1;
  127978. _this._intermediateRendering = false;
  127979. _this._viewUpdateFlag = -1;
  127980. _this._projectionUpdateFlag = -1;
  127981. _this._alternateViewUpdateFlag = -1;
  127982. _this._alternateProjectionUpdateFlag = -1;
  127983. /** @hidden */
  127984. _this._toBeDisposed = new Array(256);
  127985. _this._activeRequests = new Array();
  127986. /** @hidden */
  127987. _this._pendingData = new Array();
  127988. _this._isDisposed = false;
  127989. /**
  127990. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  127991. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  127992. */
  127993. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  127994. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127995. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127996. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127997. /** @hidden */
  127998. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127999. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128000. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128001. /** @hidden */
  128002. _this._activeAnimatables = new Array();
  128003. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128004. _this._useAlternateCameraConfiguration = false;
  128005. _this._alternateRendering = false;
  128006. _this._wheelEventName = "";
  128007. /**
  128008. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  128009. * This is useful if there are more lights that the maximum simulteanous authorized
  128010. */
  128011. _this.requireLightSorting = false;
  128012. /**
  128013. * @hidden
  128014. * Backing store of defined scene components.
  128015. */
  128016. _this._components = [];
  128017. /**
  128018. * @hidden
  128019. * Backing store of defined scene components.
  128020. */
  128021. _this._serializableComponents = [];
  128022. /**
  128023. * List of components to register on the next registration step.
  128024. */
  128025. _this._transientComponents = [];
  128026. /**
  128027. * @hidden
  128028. * Defines the actions happening before camera updates.
  128029. */
  128030. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128031. /**
  128032. * @hidden
  128033. * Defines the actions happening before clear the canvas.
  128034. */
  128035. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128036. /**
  128037. * @hidden
  128038. * Defines the actions when collecting render targets for the frame.
  128039. */
  128040. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128041. /**
  128042. * @hidden
  128043. * Defines the actions happening for one camera in the frame.
  128044. */
  128045. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128046. /**
  128047. * @hidden
  128048. * Defines the actions happening during the per mesh ready checks.
  128049. */
  128050. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128051. /**
  128052. * @hidden
  128053. * Defines the actions happening before evaluate active mesh checks.
  128054. */
  128055. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128056. /**
  128057. * @hidden
  128058. * Defines the actions happening during the evaluate sub mesh checks.
  128059. */
  128060. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128061. /**
  128062. * @hidden
  128063. * Defines the actions happening during the active mesh stage.
  128064. */
  128065. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128066. /**
  128067. * @hidden
  128068. * Defines the actions happening during the per camera render target step.
  128069. */
  128070. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128071. /**
  128072. * @hidden
  128073. * Defines the actions happening just before the active camera is drawing.
  128074. */
  128075. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128076. /**
  128077. * @hidden
  128078. * Defines the actions happening just before a render target is drawing.
  128079. */
  128080. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128081. /**
  128082. * @hidden
  128083. * Defines the actions happening just before a rendering group is drawing.
  128084. */
  128085. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128086. /**
  128087. * @hidden
  128088. * Defines the actions happening just before a mesh is drawing.
  128089. */
  128090. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128091. /**
  128092. * @hidden
  128093. * Defines the actions happening just after a mesh has been drawn.
  128094. */
  128095. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128096. /**
  128097. * @hidden
  128098. * Defines the actions happening just after a rendering group has been drawn.
  128099. */
  128100. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128101. /**
  128102. * @hidden
  128103. * Defines the actions happening just after the active camera has been drawn.
  128104. */
  128105. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128106. /**
  128107. * @hidden
  128108. * Defines the actions happening just after a render target has been drawn.
  128109. */
  128110. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128111. /**
  128112. * @hidden
  128113. * Defines the actions happening just after rendering all cameras and computing intersections.
  128114. */
  128115. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128116. /**
  128117. * @hidden
  128118. * Defines the actions happening when a pointer move event happens.
  128119. */
  128120. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128121. /**
  128122. * @hidden
  128123. * Defines the actions happening when a pointer down event happens.
  128124. */
  128125. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128126. /**
  128127. * @hidden
  128128. * Defines the actions happening when a pointer up event happens.
  128129. */
  128130. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128131. /**
  128132. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  128133. */
  128134. _this.geometriesByUniqueId = null;
  128135. _this._defaultMeshCandidates = {
  128136. data: [],
  128137. length: 0
  128138. };
  128139. _this._defaultSubMeshCandidates = {
  128140. data: [],
  128141. length: 0
  128142. };
  128143. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  128144. _this._activeMeshesFrozen = false;
  128145. /** @hidden */
  128146. _this._allowPostProcessClearColor = true;
  128147. /**
  128148. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  128149. */
  128150. _this.getDeterministicFrameTime = function () {
  128151. return 1000.0 / 60.0; // frame time in ms
  128152. };
  128153. _this._blockMaterialDirtyMechanism = false;
  128154. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  128155. _this._engine.scenes.push(_this);
  128156. _this._uid = null;
  128157. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  128158. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  128159. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  128160. }
  128161. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  128162. _this.attachControl();
  128163. }
  128164. // Uniform Buffer
  128165. _this._createUbo();
  128166. // Default Image processing definition
  128167. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  128168. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  128169. }
  128170. _this.setDefaultCandidateProviders();
  128171. if (options && options.useGeometryUniqueIdsMap === true) {
  128172. _this.geometriesByUniqueId = {};
  128173. }
  128174. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  128175. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  128176. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  128177. return _this;
  128178. }
  128179. /**
  128180. * Factory used to create the default material.
  128181. * @param name The name of the material to create
  128182. * @param scene The scene to create the material for
  128183. * @returns The default material
  128184. */
  128185. Scene.DefaultMaterialFactory = function (scene) {
  128186. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  128187. };
  128188. /**
  128189. * Factory used to create the a collision coordinator.
  128190. * @returns The collision coordinator
  128191. */
  128192. Scene.CollisionCoordinatorFactory = function () {
  128193. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  128194. };
  128195. Object.defineProperty(Scene.prototype, "environmentTexture", {
  128196. /**
  128197. * Texture used in all pbr material as the reflection texture.
  128198. * As in the majority of the scene they are the same (exception for multi room and so on),
  128199. * this is easier to reference from here than from all the materials.
  128200. */
  128201. get: function () {
  128202. return this._environmentTexture;
  128203. },
  128204. /**
  128205. * Texture used in all pbr material as the reflection texture.
  128206. * As in the majority of the scene they are the same (exception for multi room and so on),
  128207. * this is easier to set here than in all the materials.
  128208. */
  128209. set: function (value) {
  128210. if (this._environmentTexture === value) {
  128211. return;
  128212. }
  128213. this._environmentTexture = value;
  128214. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128215. },
  128216. enumerable: true,
  128217. configurable: true
  128218. });
  128219. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  128220. /**
  128221. * Default image processing configuration used either in the rendering
  128222. * Forward main pass or through the imageProcessingPostProcess if present.
  128223. * As in the majority of the scene they are the same (exception for multi camera),
  128224. * this is easier to reference from here than from all the materials and post process.
  128225. *
  128226. * No setter as we it is a shared configuration, you can set the values instead.
  128227. */
  128228. get: function () {
  128229. return this._imageProcessingConfiguration;
  128230. },
  128231. enumerable: true,
  128232. configurable: true
  128233. });
  128234. Object.defineProperty(Scene.prototype, "forceWireframe", {
  128235. get: function () {
  128236. return this._forceWireframe;
  128237. },
  128238. /**
  128239. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  128240. */
  128241. set: function (value) {
  128242. if (this._forceWireframe === value) {
  128243. return;
  128244. }
  128245. this._forceWireframe = value;
  128246. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128247. },
  128248. enumerable: true,
  128249. configurable: true
  128250. });
  128251. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  128252. get: function () {
  128253. return this._forcePointsCloud;
  128254. },
  128255. /**
  128256. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  128257. */
  128258. set: function (value) {
  128259. if (this._forcePointsCloud === value) {
  128260. return;
  128261. }
  128262. this._forcePointsCloud = value;
  128263. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128264. },
  128265. enumerable: true,
  128266. configurable: true
  128267. });
  128268. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  128269. /**
  128270. * Gets or sets the animation properties override
  128271. */
  128272. get: function () {
  128273. return this._animationPropertiesOverride;
  128274. },
  128275. set: function (value) {
  128276. this._animationPropertiesOverride = value;
  128277. },
  128278. enumerable: true,
  128279. configurable: true
  128280. });
  128281. Object.defineProperty(Scene.prototype, "onDispose", {
  128282. /** Sets a function to be executed when this scene is disposed. */
  128283. set: function (callback) {
  128284. if (this._onDisposeObserver) {
  128285. this.onDisposeObservable.remove(this._onDisposeObserver);
  128286. }
  128287. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128288. },
  128289. enumerable: true,
  128290. configurable: true
  128291. });
  128292. Object.defineProperty(Scene.prototype, "beforeRender", {
  128293. /** Sets a function to be executed before rendering this scene */
  128294. set: function (callback) {
  128295. if (this._onBeforeRenderObserver) {
  128296. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  128297. }
  128298. if (callback) {
  128299. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  128300. }
  128301. },
  128302. enumerable: true,
  128303. configurable: true
  128304. });
  128305. Object.defineProperty(Scene.prototype, "afterRender", {
  128306. /** Sets a function to be executed after rendering this scene */
  128307. set: function (callback) {
  128308. if (this._onAfterRenderObserver) {
  128309. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  128310. }
  128311. if (callback) {
  128312. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  128313. }
  128314. },
  128315. enumerable: true,
  128316. configurable: true
  128317. });
  128318. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  128319. /** Sets a function to be executed before rendering a camera*/
  128320. set: function (callback) {
  128321. if (this._onBeforeCameraRenderObserver) {
  128322. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  128323. }
  128324. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  128325. },
  128326. enumerable: true,
  128327. configurable: true
  128328. });
  128329. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  128330. /** Sets a function to be executed after rendering a camera*/
  128331. set: function (callback) {
  128332. if (this._onAfterCameraRenderObserver) {
  128333. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  128334. }
  128335. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  128336. },
  128337. enumerable: true,
  128338. configurable: true
  128339. });
  128340. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  128341. /**
  128342. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  128343. */
  128344. get: function () {
  128345. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  128346. },
  128347. enumerable: true,
  128348. configurable: true
  128349. });
  128350. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  128351. get: function () {
  128352. return this._useRightHandedSystem;
  128353. },
  128354. /**
  128355. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  128356. */
  128357. set: function (value) {
  128358. if (this._useRightHandedSystem === value) {
  128359. return;
  128360. }
  128361. this._useRightHandedSystem = value;
  128362. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128363. },
  128364. enumerable: true,
  128365. configurable: true
  128366. });
  128367. /**
  128368. * Sets the step Id used by deterministic lock step
  128369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128370. * @param newStepId defines the step Id
  128371. */
  128372. Scene.prototype.setStepId = function (newStepId) {
  128373. this._currentStepId = newStepId;
  128374. };
  128375. /**
  128376. * Gets the step Id used by deterministic lock step
  128377. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128378. * @returns the step Id
  128379. */
  128380. Scene.prototype.getStepId = function () {
  128381. return this._currentStepId;
  128382. };
  128383. /**
  128384. * Gets the internal step used by deterministic lock step
  128385. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128386. * @returns the internal step
  128387. */
  128388. Scene.prototype.getInternalStep = function () {
  128389. return this._currentInternalStep;
  128390. };
  128391. Object.defineProperty(Scene.prototype, "fogEnabled", {
  128392. get: function () {
  128393. return this._fogEnabled;
  128394. },
  128395. /**
  128396. * Gets or sets a boolean indicating if fog is enabled on this scene
  128397. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128398. * (Default is true)
  128399. */
  128400. set: function (value) {
  128401. if (this._fogEnabled === value) {
  128402. return;
  128403. }
  128404. this._fogEnabled = value;
  128405. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128406. },
  128407. enumerable: true,
  128408. configurable: true
  128409. });
  128410. Object.defineProperty(Scene.prototype, "fogMode", {
  128411. get: function () {
  128412. return this._fogMode;
  128413. },
  128414. /**
  128415. * Gets or sets the fog mode to use
  128416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128417. * | mode | value |
  128418. * | --- | --- |
  128419. * | FOGMODE_NONE | 0 |
  128420. * | FOGMODE_EXP | 1 |
  128421. * | FOGMODE_EXP2 | 2 |
  128422. * | FOGMODE_LINEAR | 3 |
  128423. */
  128424. set: function (value) {
  128425. if (this._fogMode === value) {
  128426. return;
  128427. }
  128428. this._fogMode = value;
  128429. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128430. },
  128431. enumerable: true,
  128432. configurable: true
  128433. });
  128434. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  128435. get: function () {
  128436. return this._shadowsEnabled;
  128437. },
  128438. /**
  128439. * Gets or sets a boolean indicating if shadows are enabled on this scene
  128440. */
  128441. set: function (value) {
  128442. if (this._shadowsEnabled === value) {
  128443. return;
  128444. }
  128445. this._shadowsEnabled = value;
  128446. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128447. },
  128448. enumerable: true,
  128449. configurable: true
  128450. });
  128451. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  128452. get: function () {
  128453. return this._lightsEnabled;
  128454. },
  128455. /**
  128456. * Gets or sets a boolean indicating if lights are enabled on this scene
  128457. */
  128458. set: function (value) {
  128459. if (this._lightsEnabled === value) {
  128460. return;
  128461. }
  128462. this._lightsEnabled = value;
  128463. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128464. },
  128465. enumerable: true,
  128466. configurable: true
  128467. });
  128468. Object.defineProperty(Scene.prototype, "activeCamera", {
  128469. /** Gets or sets the current active camera */
  128470. get: function () {
  128471. return this._activeCamera;
  128472. },
  128473. set: function (value) {
  128474. if (value === this._activeCamera) {
  128475. return;
  128476. }
  128477. this._activeCamera = value;
  128478. this.onActiveCameraChanged.notifyObservers(this);
  128479. },
  128480. enumerable: true,
  128481. configurable: true
  128482. });
  128483. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  128484. /** The default material used on meshes when no material is affected */
  128485. get: function () {
  128486. if (!this._defaultMaterial) {
  128487. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  128488. }
  128489. return this._defaultMaterial;
  128490. },
  128491. /** The default material used on meshes when no material is affected */
  128492. set: function (value) {
  128493. this._defaultMaterial = value;
  128494. },
  128495. enumerable: true,
  128496. configurable: true
  128497. });
  128498. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  128499. get: function () {
  128500. return this._texturesEnabled;
  128501. },
  128502. /**
  128503. * Gets or sets a boolean indicating if textures are enabled on this scene
  128504. */
  128505. set: function (value) {
  128506. if (this._texturesEnabled === value) {
  128507. return;
  128508. }
  128509. this._texturesEnabled = value;
  128510. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128511. },
  128512. enumerable: true,
  128513. configurable: true
  128514. });
  128515. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  128516. get: function () {
  128517. return this._skeletonsEnabled;
  128518. },
  128519. /**
  128520. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  128521. */
  128522. set: function (value) {
  128523. if (this._skeletonsEnabled === value) {
  128524. return;
  128525. }
  128526. this._skeletonsEnabled = value;
  128527. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  128528. },
  128529. enumerable: true,
  128530. configurable: true
  128531. });
  128532. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  128533. /** @hidden */
  128534. get: function () {
  128535. if (!this._collisionCoordinator) {
  128536. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  128537. this._collisionCoordinator.init(this);
  128538. }
  128539. return this._collisionCoordinator;
  128540. },
  128541. enumerable: true,
  128542. configurable: true
  128543. });
  128544. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  128545. /** @hidden */
  128546. get: function () {
  128547. return this._alternateRendering;
  128548. },
  128549. enumerable: true,
  128550. configurable: true
  128551. });
  128552. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  128553. /**
  128554. * Gets the list of frustum planes (built from the active camera)
  128555. */
  128556. get: function () {
  128557. return this._frustumPlanes;
  128558. },
  128559. enumerable: true,
  128560. configurable: true
  128561. });
  128562. /**
  128563. * Registers the transient components if needed.
  128564. */
  128565. Scene.prototype._registerTransientComponents = function () {
  128566. // Register components that have been associated lately to the scene.
  128567. if (this._transientComponents.length > 0) {
  128568. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  128569. var component = _a[_i];
  128570. component.register();
  128571. }
  128572. this._transientComponents = [];
  128573. }
  128574. };
  128575. /**
  128576. * @hidden
  128577. * Add a component to the scene.
  128578. * Note that the ccomponent could be registered on th next frame if this is called after
  128579. * the register component stage.
  128580. * @param component Defines the component to add to the scene
  128581. */
  128582. Scene.prototype._addComponent = function (component) {
  128583. this._components.push(component);
  128584. this._transientComponents.push(component);
  128585. var serializableComponent = component;
  128586. if (serializableComponent.addFromContainer) {
  128587. this._serializableComponents.push(serializableComponent);
  128588. }
  128589. };
  128590. /**
  128591. * @hidden
  128592. * Gets a component from the scene.
  128593. * @param name defines the name of the component to retrieve
  128594. * @returns the component or null if not present
  128595. */
  128596. Scene.prototype._getComponent = function (name) {
  128597. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  128598. var component = _a[_i];
  128599. if (component.name === name) {
  128600. return component;
  128601. }
  128602. }
  128603. return null;
  128604. };
  128605. /**
  128606. * @hidden
  128607. */
  128608. Scene.prototype._getDefaultMeshCandidates = function () {
  128609. this._defaultMeshCandidates.data = this.meshes;
  128610. this._defaultMeshCandidates.length = this.meshes.length;
  128611. return this._defaultMeshCandidates;
  128612. };
  128613. /**
  128614. * @hidden
  128615. */
  128616. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  128617. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  128618. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  128619. return this._defaultSubMeshCandidates;
  128620. };
  128621. /**
  128622. * Sets the default candidate providers for the scene.
  128623. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  128624. * and getCollidingSubMeshCandidates to their default function
  128625. */
  128626. Scene.prototype.setDefaultCandidateProviders = function () {
  128627. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  128628. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128629. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128630. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128631. };
  128632. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  128633. /**
  128634. * Gets the mesh that is currently under the pointer
  128635. */
  128636. get: function () {
  128637. return this._pointerOverMesh;
  128638. },
  128639. enumerable: true,
  128640. configurable: true
  128641. });
  128642. Object.defineProperty(Scene.prototype, "pointerX", {
  128643. /**
  128644. * Gets or sets the current on-screen X position of the pointer
  128645. */
  128646. get: function () {
  128647. return this._pointerX;
  128648. },
  128649. set: function (value) {
  128650. this._pointerX = value;
  128651. },
  128652. enumerable: true,
  128653. configurable: true
  128654. });
  128655. Object.defineProperty(Scene.prototype, "pointerY", {
  128656. /**
  128657. * Gets or sets the current on-screen Y position of the pointer
  128658. */
  128659. get: function () {
  128660. return this._pointerY;
  128661. },
  128662. set: function (value) {
  128663. this._pointerY = value;
  128664. },
  128665. enumerable: true,
  128666. configurable: true
  128667. });
  128668. /**
  128669. * Gets the cached material (ie. the latest rendered one)
  128670. * @returns the cached material
  128671. */
  128672. Scene.prototype.getCachedMaterial = function () {
  128673. return this._cachedMaterial;
  128674. };
  128675. /**
  128676. * Gets the cached effect (ie. the latest rendered one)
  128677. * @returns the cached effect
  128678. */
  128679. Scene.prototype.getCachedEffect = function () {
  128680. return this._cachedEffect;
  128681. };
  128682. /**
  128683. * Gets the cached visibility state (ie. the latest rendered one)
  128684. * @returns the cached visibility state
  128685. */
  128686. Scene.prototype.getCachedVisibility = function () {
  128687. return this._cachedVisibility;
  128688. };
  128689. /**
  128690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  128691. * @param material defines the current material
  128692. * @param effect defines the current effect
  128693. * @param visibility defines the current visibility state
  128694. * @returns true if one parameter is not cached
  128695. */
  128696. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  128697. if (visibility === void 0) { visibility = 1; }
  128698. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  128699. };
  128700. /**
  128701. * Gets the engine associated with the scene
  128702. * @returns an Engine
  128703. */
  128704. Scene.prototype.getEngine = function () {
  128705. return this._engine;
  128706. };
  128707. /**
  128708. * Gets the total number of vertices rendered per frame
  128709. * @returns the total number of vertices rendered per frame
  128710. */
  128711. Scene.prototype.getTotalVertices = function () {
  128712. return this._totalVertices.current;
  128713. };
  128714. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  128715. /**
  128716. * Gets the performance counter for total vertices
  128717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128718. */
  128719. get: function () {
  128720. return this._totalVertices;
  128721. },
  128722. enumerable: true,
  128723. configurable: true
  128724. });
  128725. /**
  128726. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  128727. * @returns the total number of active indices rendered per frame
  128728. */
  128729. Scene.prototype.getActiveIndices = function () {
  128730. return this._activeIndices.current;
  128731. };
  128732. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  128733. /**
  128734. * Gets the performance counter for active indices
  128735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128736. */
  128737. get: function () {
  128738. return this._activeIndices;
  128739. },
  128740. enumerable: true,
  128741. configurable: true
  128742. });
  128743. /**
  128744. * Gets the total number of active particles rendered per frame
  128745. * @returns the total number of active particles rendered per frame
  128746. */
  128747. Scene.prototype.getActiveParticles = function () {
  128748. return this._activeParticles.current;
  128749. };
  128750. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  128751. /**
  128752. * Gets the performance counter for active particles
  128753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128754. */
  128755. get: function () {
  128756. return this._activeParticles;
  128757. },
  128758. enumerable: true,
  128759. configurable: true
  128760. });
  128761. /**
  128762. * Gets the total number of active bones rendered per frame
  128763. * @returns the total number of active bones rendered per frame
  128764. */
  128765. Scene.prototype.getActiveBones = function () {
  128766. return this._activeBones.current;
  128767. };
  128768. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  128769. /**
  128770. * Gets the performance counter for active bones
  128771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128772. */
  128773. get: function () {
  128774. return this._activeBones;
  128775. },
  128776. enumerable: true,
  128777. configurable: true
  128778. });
  128779. /**
  128780. * Gets the array of active meshes
  128781. * @returns an array of AbstractMesh
  128782. */
  128783. Scene.prototype.getActiveMeshes = function () {
  128784. return this._activeMeshes;
  128785. };
  128786. /**
  128787. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  128788. * @returns a number
  128789. */
  128790. Scene.prototype.getAnimationRatio = function () {
  128791. return this._animationRatio !== undefined ? this._animationRatio : 1;
  128792. };
  128793. /**
  128794. * Gets an unique Id for the current render phase
  128795. * @returns a number
  128796. */
  128797. Scene.prototype.getRenderId = function () {
  128798. return this._renderId;
  128799. };
  128800. /**
  128801. * Gets an unique Id for the current frame
  128802. * @returns a number
  128803. */
  128804. Scene.prototype.getFrameId = function () {
  128805. return this._frameId;
  128806. };
  128807. /** Call this function if you want to manually increment the render Id*/
  128808. Scene.prototype.incrementRenderId = function () {
  128809. this._renderId++;
  128810. };
  128811. Scene.prototype._updatePointerPosition = function (evt) {
  128812. var canvasRect = this._engine.getRenderingCanvasClientRect();
  128813. if (!canvasRect) {
  128814. return;
  128815. }
  128816. this._pointerX = evt.clientX - canvasRect.left;
  128817. this._pointerY = evt.clientY - canvasRect.top;
  128818. this._unTranslatedPointerX = this._pointerX;
  128819. this._unTranslatedPointerY = this._pointerY;
  128820. };
  128821. Scene.prototype._createUbo = function () {
  128822. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  128823. this._sceneUbo.addUniform("viewProjection", 16);
  128824. this._sceneUbo.addUniform("view", 16);
  128825. };
  128826. Scene.prototype._createAlternateUbo = function () {
  128827. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  128828. this._alternateSceneUbo.addUniform("viewProjection", 16);
  128829. this._alternateSceneUbo.addUniform("view", 16);
  128830. };
  128831. // Pointers handling
  128832. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  128833. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  128834. if (!pointerInfo.pickInfo.ray) {
  128835. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  128836. }
  128837. }
  128838. };
  128839. /**
  128840. * Use this method to simulate a pointer move on a mesh
  128841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128844. * @returns the current scene
  128845. */
  128846. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  128847. var evt = new PointerEvent("pointermove", pointerEventInit);
  128848. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  128849. return this;
  128850. }
  128851. return this._processPointerMove(pickResult, evt);
  128852. };
  128853. Scene.prototype._processPointerMove = function (pickResult, evt) {
  128854. var canvas = this._engine.getRenderingCanvas();
  128855. if (!canvas) {
  128856. return this;
  128857. }
  128858. // Restore pointer
  128859. canvas.style.cursor = this.defaultCursor;
  128860. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  128861. if (isMeshPicked) {
  128862. this.setPointerOverMesh(pickResult.pickedMesh);
  128863. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  128864. if (this._pointerOverMesh.actionManager.hoverCursor) {
  128865. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  128866. }
  128867. else {
  128868. canvas.style.cursor = this.hoverCursor;
  128869. }
  128870. }
  128871. }
  128872. else {
  128873. this.setPointerOverMesh(null);
  128874. }
  128875. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  128876. var step = _a[_i];
  128877. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  128878. }
  128879. if (pickResult) {
  128880. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  128881. if (this.onPointerMove) {
  128882. this.onPointerMove(evt, pickResult, type);
  128883. }
  128884. if (this.onPointerObservable.hasObservers()) {
  128885. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128886. this._setRayOnPointerInfo(pi);
  128887. this.onPointerObservable.notifyObservers(pi, type);
  128888. }
  128889. }
  128890. return this;
  128891. };
  128892. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  128893. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  128894. if (pickResult) {
  128895. pi.ray = pickResult.ray;
  128896. }
  128897. this.onPrePointerObservable.notifyObservers(pi, type);
  128898. if (pi.skipOnPointerObservable) {
  128899. return true;
  128900. }
  128901. else {
  128902. return false;
  128903. }
  128904. };
  128905. /**
  128906. * Use this method to simulate a pointer down on a mesh
  128907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128910. * @returns the current scene
  128911. */
  128912. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  128913. var evt = new PointerEvent("pointerdown", pointerEventInit);
  128914. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  128915. return this;
  128916. }
  128917. return this._processPointerDown(pickResult, evt);
  128918. };
  128919. Scene.prototype._processPointerDown = function (pickResult, evt) {
  128920. var _this = this;
  128921. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  128922. this._pickedDownMesh = pickResult.pickedMesh;
  128923. var actionManager = pickResult.pickedMesh.actionManager;
  128924. if (actionManager) {
  128925. if (actionManager.hasPickTriggers) {
  128926. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128927. switch (evt.button) {
  128928. case 0:
  128929. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128930. break;
  128931. case 1:
  128932. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128933. break;
  128934. case 2:
  128935. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128936. break;
  128937. }
  128938. }
  128939. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  128940. window.setTimeout(function () {
  128941. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  128942. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  128943. if (_this._totalPointersPressed !== 0 &&
  128944. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  128945. !_this._isPointerSwiping()) {
  128946. _this._startingPointerTime = 0;
  128947. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128948. }
  128949. }
  128950. }, Scene.LongPressDelay);
  128951. }
  128952. }
  128953. }
  128954. else {
  128955. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  128956. var step = _a[_i];
  128957. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128958. }
  128959. }
  128960. if (pickResult) {
  128961. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  128962. if (this.onPointerDown) {
  128963. this.onPointerDown(evt, pickResult, type);
  128964. }
  128965. if (this.onPointerObservable.hasObservers()) {
  128966. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128967. this._setRayOnPointerInfo(pi);
  128968. this.onPointerObservable.notifyObservers(pi, type);
  128969. }
  128970. }
  128971. return this;
  128972. };
  128973. /**
  128974. * Use this method to simulate a pointer up on a mesh
  128975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128978. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128979. * @returns the current scene
  128980. */
  128981. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  128982. var evt = new PointerEvent("pointerup", pointerEventInit);
  128983. var clickInfo = new ClickInfo();
  128984. if (doubleTap) {
  128985. clickInfo.doubleClick = true;
  128986. }
  128987. else {
  128988. clickInfo.singleClick = true;
  128989. }
  128990. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  128991. return this;
  128992. }
  128993. return this._processPointerUp(pickResult, evt, clickInfo);
  128994. };
  128995. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  128996. if (pickResult && pickResult && pickResult.pickedMesh) {
  128997. this._pickedUpMesh = pickResult.pickedMesh;
  128998. if (this._pickedDownMesh === this._pickedUpMesh) {
  128999. if (this.onPointerPick) {
  129000. this.onPointerPick(evt, pickResult);
  129001. }
  129002. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  129003. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  129004. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  129005. this._setRayOnPointerInfo(pi);
  129006. this.onPointerObservable.notifyObservers(pi, type_1);
  129007. }
  129008. }
  129009. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  129010. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129011. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  129012. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129013. }
  129014. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129015. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129016. }
  129017. }
  129018. }
  129019. else {
  129020. if (!clickInfo.ignore) {
  129021. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  129022. var step = _a[_i];
  129023. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129024. }
  129025. }
  129026. }
  129027. if (this._pickedDownMesh &&
  129028. this._pickedDownMesh.actionManager &&
  129029. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger) &&
  129030. this._pickedDownMesh !== this._pickedUpMesh) {
  129031. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  129032. }
  129033. var type = 0;
  129034. if (this.onPointerObservable.hasObservers()) {
  129035. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  129036. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129037. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  129038. }
  129039. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129040. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  129041. }
  129042. if (type) {
  129043. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129044. this._setRayOnPointerInfo(pi);
  129045. this.onPointerObservable.notifyObservers(pi, type);
  129046. }
  129047. }
  129048. if (!clickInfo.ignore) {
  129049. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  129050. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129051. this._setRayOnPointerInfo(pi);
  129052. this.onPointerObservable.notifyObservers(pi, type);
  129053. }
  129054. }
  129055. if (this.onPointerUp && !clickInfo.ignore) {
  129056. this.onPointerUp(evt, pickResult, type);
  129057. }
  129058. return this;
  129059. };
  129060. /**
  129061. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  129062. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  129063. * @returns true if the pointer was captured
  129064. */
  129065. Scene.prototype.isPointerCaptured = function (pointerId) {
  129066. if (pointerId === void 0) { pointerId = 0; }
  129067. return this._pointerCaptures[pointerId];
  129068. };
  129069. /** @hidden */
  129070. Scene.prototype._isPointerSwiping = function () {
  129071. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  129072. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  129073. };
  129074. /**
  129075. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  129076. * @param attachUp defines if you want to attach events to pointerup
  129077. * @param attachDown defines if you want to attach events to pointerdown
  129078. * @param attachMove defines if you want to attach events to pointermove
  129079. */
  129080. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  129081. var _this = this;
  129082. if (attachUp === void 0) { attachUp = true; }
  129083. if (attachDown === void 0) { attachDown = true; }
  129084. if (attachMove === void 0) { attachMove = true; }
  129085. this._initActionManager = function (act, clickInfo) {
  129086. if (!_this._meshPickProceed) {
  129087. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129088. _this._currentPickResult = pickResult;
  129089. if (pickResult) {
  129090. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  129091. }
  129092. _this._meshPickProceed = true;
  129093. }
  129094. return act;
  129095. };
  129096. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  129097. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  129098. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  129099. btn !== _this._previousButtonPressed) {
  129100. _this._doubleClickOccured = false;
  129101. clickInfo.singleClick = true;
  129102. clickInfo.ignore = false;
  129103. cb(clickInfo, _this._currentPickResult);
  129104. }
  129105. };
  129106. this._initClickEvent = function (obs1, obs2, evt, cb) {
  129107. var clickInfo = new ClickInfo();
  129108. _this._currentPickResult = null;
  129109. var act = null;
  129110. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  129111. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  129112. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129113. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  129114. act = _this._initActionManager(act, clickInfo);
  129115. if (act) {
  129116. checkPicking = act.hasPickTriggers;
  129117. }
  129118. }
  129119. var needToIgnoreNext = false;
  129120. if (checkPicking) {
  129121. var btn = evt.button;
  129122. clickInfo.hasSwiped = _this._isPointerSwiping();
  129123. if (!clickInfo.hasSwiped) {
  129124. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  129125. if (!checkSingleClickImmediately) {
  129126. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  129127. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129128. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129129. act = _this._initActionManager(act, clickInfo);
  129130. if (act) {
  129131. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129132. }
  129133. }
  129134. }
  129135. if (checkSingleClickImmediately) {
  129136. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  129137. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  129138. btn !== _this._previousButtonPressed) {
  129139. clickInfo.singleClick = true;
  129140. cb(clickInfo, _this._currentPickResult);
  129141. needToIgnoreNext = true;
  129142. }
  129143. }
  129144. // at least one double click is required to be check and exclusive double click is enabled
  129145. else {
  129146. // wait that no double click has been raised during the double click delay
  129147. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129148. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  129149. }
  129150. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  129151. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129152. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129153. act = _this._initActionManager(act, clickInfo);
  129154. if (act) {
  129155. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129156. }
  129157. }
  129158. if (checkDoubleClick) {
  129159. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  129160. if (btn === _this._previousButtonPressed &&
  129161. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  129162. !_this._doubleClickOccured) {
  129163. // pointer has not moved for 2 clicks, it's a double click
  129164. if (!clickInfo.hasSwiped &&
  129165. !_this._isPointerSwiping()) {
  129166. _this._previousStartingPointerTime = 0;
  129167. _this._doubleClickOccured = true;
  129168. clickInfo.doubleClick = true;
  129169. clickInfo.ignore = false;
  129170. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  129171. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129172. }
  129173. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129174. cb(clickInfo, _this._currentPickResult);
  129175. }
  129176. // if the two successive clicks are too far, it's just two simple clicks
  129177. else {
  129178. _this._doubleClickOccured = false;
  129179. _this._previousStartingPointerTime = _this._startingPointerTime;
  129180. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129181. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129182. _this._previousButtonPressed = btn;
  129183. if (Scene.ExclusiveDoubleClickMode) {
  129184. if (_this._previousDelayedSimpleClickTimeout) {
  129185. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129186. }
  129187. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129188. cb(clickInfo, _this._previousPickResult);
  129189. }
  129190. else {
  129191. cb(clickInfo, _this._currentPickResult);
  129192. }
  129193. }
  129194. needToIgnoreNext = true;
  129195. }
  129196. // just the first click of the double has been raised
  129197. else {
  129198. _this._doubleClickOccured = false;
  129199. _this._previousStartingPointerTime = _this._startingPointerTime;
  129200. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129201. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129202. _this._previousButtonPressed = btn;
  129203. }
  129204. }
  129205. }
  129206. }
  129207. if (!needToIgnoreNext) {
  129208. cb(clickInfo, _this._currentPickResult);
  129209. }
  129210. };
  129211. this._onPointerMove = function (evt) {
  129212. _this._updatePointerPosition(evt);
  129213. // PreObservable support
  129214. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129215. return;
  129216. }
  129217. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129218. return;
  129219. }
  129220. if (!_this.pointerMovePredicate) {
  129221. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  129222. }
  129223. // Meshes
  129224. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  129225. _this._processPointerMove(pickResult, evt);
  129226. };
  129227. this._onPointerDown = function (evt) {
  129228. _this._totalPointersPressed++;
  129229. _this._pickedDownMesh = null;
  129230. _this._meshPickProceed = false;
  129231. _this._updatePointerPosition(evt);
  129232. if (_this.preventDefaultOnPointerDown && canvas) {
  129233. evt.preventDefault();
  129234. canvas.focus();
  129235. }
  129236. _this._startingPointerPosition.x = _this._pointerX;
  129237. _this._startingPointerPosition.y = _this._pointerY;
  129238. _this._startingPointerTime = Date.now();
  129239. // PreObservable support
  129240. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129241. return;
  129242. }
  129243. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129244. return;
  129245. }
  129246. _this._pointerCaptures[evt.pointerId] = true;
  129247. if (!_this.pointerDownPredicate) {
  129248. _this.pointerDownPredicate = function (mesh) {
  129249. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129250. };
  129251. }
  129252. // Meshes
  129253. _this._pickedDownMesh = null;
  129254. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129255. _this._processPointerDown(pickResult, evt);
  129256. };
  129257. this._onPointerUp = function (evt) {
  129258. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  129259. return; // So we need to test it the pointer down was pressed before.
  129260. }
  129261. _this._totalPointersPressed--;
  129262. _this._pickedUpMesh = null;
  129263. _this._meshPickProceed = false;
  129264. _this._updatePointerPosition(evt);
  129265. if (_this.preventDefaultOnPointerUp && canvas) {
  129266. evt.preventDefault();
  129267. canvas.focus();
  129268. }
  129269. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  129270. _this._pointerCaptures[evt.pointerId] = false;
  129271. // PreObservable support
  129272. if (_this.onPrePointerObservable.hasObservers()) {
  129273. if (!clickInfo.ignore) {
  129274. if (!clickInfo.hasSwiped) {
  129275. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129276. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129277. return;
  129278. }
  129279. }
  129280. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129281. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129282. return;
  129283. }
  129284. }
  129285. }
  129286. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129287. return;
  129288. }
  129289. }
  129290. }
  129291. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129292. return;
  129293. }
  129294. if (!_this.pointerUpPredicate) {
  129295. _this.pointerUpPredicate = function (mesh) {
  129296. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129297. };
  129298. }
  129299. // Meshes
  129300. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  129301. _this._initActionManager(null, clickInfo);
  129302. }
  129303. if (!pickResult) {
  129304. pickResult = _this._currentPickResult;
  129305. }
  129306. _this._processPointerUp(pickResult, evt, clickInfo);
  129307. _this._previousPickResult = _this._currentPickResult;
  129308. });
  129309. };
  129310. this._onKeyDown = function (evt) {
  129311. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  129312. if (_this.onPreKeyboardObservable.hasObservers()) {
  129313. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129314. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129315. if (pi.skipOnPointerObservable) {
  129316. return;
  129317. }
  129318. }
  129319. if (_this.onKeyboardObservable.hasObservers()) {
  129320. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129321. _this.onKeyboardObservable.notifyObservers(pi, type);
  129322. }
  129323. if (_this.actionManager) {
  129324. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129325. }
  129326. };
  129327. this._onKeyUp = function (evt) {
  129328. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  129329. if (_this.onPreKeyboardObservable.hasObservers()) {
  129330. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129331. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129332. if (pi.skipOnPointerObservable) {
  129333. return;
  129334. }
  129335. }
  129336. if (_this.onKeyboardObservable.hasObservers()) {
  129337. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129338. _this.onKeyboardObservable.notifyObservers(pi, type);
  129339. }
  129340. if (_this.actionManager) {
  129341. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129342. }
  129343. };
  129344. var engine = this.getEngine();
  129345. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  129346. if (!canvas) {
  129347. return;
  129348. }
  129349. canvas.addEventListener("keydown", _this._onKeyDown, false);
  129350. canvas.addEventListener("keyup", _this._onKeyUp, false);
  129351. });
  129352. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  129353. if (!canvas) {
  129354. return;
  129355. }
  129356. canvas.removeEventListener("keydown", _this._onKeyDown);
  129357. canvas.removeEventListener("keyup", _this._onKeyUp);
  129358. });
  129359. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129360. var canvas = this._engine.getRenderingCanvas();
  129361. if (!canvas) {
  129362. return;
  129363. }
  129364. if (attachMove) {
  129365. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  129366. // Wheel
  129367. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  129368. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  129369. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  129370. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  129371. }
  129372. if (attachDown) {
  129373. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  129374. }
  129375. if (attachUp) {
  129376. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  129377. }
  129378. canvas.tabIndex = 1;
  129379. };
  129380. /** Detaches all event handlers*/
  129381. Scene.prototype.detachControl = function () {
  129382. var engine = this.getEngine();
  129383. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129384. var canvas = engine.getRenderingCanvas();
  129385. if (!canvas) {
  129386. return;
  129387. }
  129388. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  129389. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  129390. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  129391. if (this._onCanvasBlurObserver) {
  129392. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  129393. }
  129394. if (this._onCanvasFocusObserver) {
  129395. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  129396. }
  129397. // Wheel
  129398. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  129399. // Keyboard
  129400. canvas.removeEventListener("keydown", this._onKeyDown);
  129401. canvas.removeEventListener("keyup", this._onKeyUp);
  129402. // Observables
  129403. this.onKeyboardObservable.clear();
  129404. this.onPreKeyboardObservable.clear();
  129405. this.onPointerObservable.clear();
  129406. this.onPrePointerObservable.clear();
  129407. };
  129408. /**
  129409. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  129410. * Delay loaded resources are not taking in account
  129411. * @return true if all required resources are ready
  129412. */
  129413. Scene.prototype.isReady = function () {
  129414. if (this._isDisposed) {
  129415. return false;
  129416. }
  129417. var index;
  129418. var engine = this.getEngine();
  129419. // Effects
  129420. if (!engine.areAllEffectsReady()) {
  129421. return false;
  129422. }
  129423. // Pending data
  129424. if (this._pendingData.length > 0) {
  129425. return false;
  129426. }
  129427. // Meshes
  129428. for (index = 0; index < this.meshes.length; index++) {
  129429. var mesh = this.meshes[index];
  129430. if (!mesh.isEnabled()) {
  129431. continue;
  129432. }
  129433. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  129434. continue;
  129435. }
  129436. if (!mesh.isReady(true)) {
  129437. return false;
  129438. }
  129439. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  129440. // Is Ready For Mesh
  129441. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  129442. var step = _a[_i];
  129443. if (!step.action(mesh, hardwareInstancedRendering)) {
  129444. return false;
  129445. }
  129446. }
  129447. }
  129448. // Geometries
  129449. for (index = 0; index < this.geometries.length; index++) {
  129450. var geometry = this.geometries[index];
  129451. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  129452. return false;
  129453. }
  129454. }
  129455. // Post-processes
  129456. if (this.activeCameras && this.activeCameras.length > 0) {
  129457. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  129458. var camera = _c[_b];
  129459. if (!camera.isReady(true)) {
  129460. return false;
  129461. }
  129462. }
  129463. }
  129464. else if (this.activeCamera) {
  129465. if (!this.activeCamera.isReady(true)) {
  129466. return false;
  129467. }
  129468. }
  129469. // Particles
  129470. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  129471. var particleSystem = _e[_d];
  129472. if (!particleSystem.isReady()) {
  129473. return false;
  129474. }
  129475. }
  129476. return true;
  129477. };
  129478. /** Resets all cached information relative to material (including effect and visibility) */
  129479. Scene.prototype.resetCachedMaterial = function () {
  129480. this._cachedMaterial = null;
  129481. this._cachedEffect = null;
  129482. this._cachedVisibility = null;
  129483. };
  129484. /**
  129485. * Registers a function to be called before every frame render
  129486. * @param func defines the function to register
  129487. */
  129488. Scene.prototype.registerBeforeRender = function (func) {
  129489. this.onBeforeRenderObservable.add(func);
  129490. };
  129491. /**
  129492. * Unregisters a function called before every frame render
  129493. * @param func defines the function to unregister
  129494. */
  129495. Scene.prototype.unregisterBeforeRender = function (func) {
  129496. this.onBeforeRenderObservable.removeCallback(func);
  129497. };
  129498. /**
  129499. * Registers a function to be called after every frame render
  129500. * @param func defines the function to register
  129501. */
  129502. Scene.prototype.registerAfterRender = function (func) {
  129503. this.onAfterRenderObservable.add(func);
  129504. };
  129505. /**
  129506. * Unregisters a function called after every frame render
  129507. * @param func defines the function to unregister
  129508. */
  129509. Scene.prototype.unregisterAfterRender = function (func) {
  129510. this.onAfterRenderObservable.removeCallback(func);
  129511. };
  129512. Scene.prototype._executeOnceBeforeRender = function (func) {
  129513. var _this = this;
  129514. var execFunc = function () {
  129515. func();
  129516. setTimeout(function () {
  129517. _this.unregisterBeforeRender(execFunc);
  129518. });
  129519. };
  129520. this.registerBeforeRender(execFunc);
  129521. };
  129522. /**
  129523. * The provided function will run before render once and will be disposed afterwards.
  129524. * A timeout delay can be provided so that the function will be executed in N ms.
  129525. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  129526. * @param func The function to be executed.
  129527. * @param timeout optional delay in ms
  129528. */
  129529. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  129530. var _this = this;
  129531. if (timeout !== undefined) {
  129532. setTimeout(function () {
  129533. _this._executeOnceBeforeRender(func);
  129534. }, timeout);
  129535. }
  129536. else {
  129537. this._executeOnceBeforeRender(func);
  129538. }
  129539. };
  129540. /** @hidden */
  129541. Scene.prototype._addPendingData = function (data) {
  129542. this._pendingData.push(data);
  129543. };
  129544. /** @hidden */
  129545. Scene.prototype._removePendingData = function (data) {
  129546. var wasLoading = this.isLoading;
  129547. var index = this._pendingData.indexOf(data);
  129548. if (index !== -1) {
  129549. this._pendingData.splice(index, 1);
  129550. }
  129551. if (wasLoading && !this.isLoading) {
  129552. this.onDataLoadedObservable.notifyObservers(this);
  129553. }
  129554. };
  129555. /**
  129556. * Returns the number of items waiting to be loaded
  129557. * @returns the number of items waiting to be loaded
  129558. */
  129559. Scene.prototype.getWaitingItemsCount = function () {
  129560. return this._pendingData.length;
  129561. };
  129562. Object.defineProperty(Scene.prototype, "isLoading", {
  129563. /**
  129564. * Returns a boolean indicating if the scene is still loading data
  129565. */
  129566. get: function () {
  129567. return this._pendingData.length > 0;
  129568. },
  129569. enumerable: true,
  129570. configurable: true
  129571. });
  129572. /**
  129573. * Registers a function to be executed when the scene is ready
  129574. * @param {Function} func - the function to be executed
  129575. */
  129576. Scene.prototype.executeWhenReady = function (func) {
  129577. var _this = this;
  129578. this.onReadyObservable.add(func);
  129579. if (this._executeWhenReadyTimeoutId !== -1) {
  129580. return;
  129581. }
  129582. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129583. _this._checkIsReady();
  129584. }, 150);
  129585. };
  129586. /**
  129587. * Returns a promise that resolves when the scene is ready
  129588. * @returns A promise that resolves when the scene is ready
  129589. */
  129590. Scene.prototype.whenReadyAsync = function () {
  129591. var _this = this;
  129592. return new Promise(function (resolve) {
  129593. _this.executeWhenReady(function () {
  129594. resolve();
  129595. });
  129596. });
  129597. };
  129598. /** @hidden */
  129599. Scene.prototype._checkIsReady = function () {
  129600. var _this = this;
  129601. this._registerTransientComponents();
  129602. if (this.isReady()) {
  129603. this.onReadyObservable.notifyObservers(this);
  129604. this.onReadyObservable.clear();
  129605. this._executeWhenReadyTimeoutId = -1;
  129606. return;
  129607. }
  129608. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129609. _this._checkIsReady();
  129610. }, 150);
  129611. };
  129612. Object.defineProperty(Scene.prototype, "animatables", {
  129613. /**
  129614. * Gets all animatable attached to the scene
  129615. */
  129616. get: function () {
  129617. return this._activeAnimatables;
  129618. },
  129619. enumerable: true,
  129620. configurable: true
  129621. });
  129622. /**
  129623. * Resets the last animation time frame.
  129624. * Useful to override when animations start running when loading a scene for the first time.
  129625. */
  129626. Scene.prototype.resetLastAnimationTimeFrame = function () {
  129627. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  129628. };
  129629. // Matrix
  129630. /** @hidden */
  129631. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129632. this._useAlternateCameraConfiguration = active;
  129633. };
  129634. /**
  129635. * Gets the current view matrix
  129636. * @returns a Matrix
  129637. */
  129638. Scene.prototype.getViewMatrix = function () {
  129639. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129640. };
  129641. /**
  129642. * Gets the current projection matrix
  129643. * @returns a Matrix
  129644. */
  129645. Scene.prototype.getProjectionMatrix = function () {
  129646. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129647. };
  129648. /**
  129649. * Gets the current transform matrix
  129650. * @returns a Matrix made of View * Projection
  129651. */
  129652. Scene.prototype.getTransformMatrix = function () {
  129653. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129654. };
  129655. /**
  129656. * Sets the current transform matrix
  129657. * @param view defines the View matrix to use
  129658. * @param projection defines the Projection matrix to use
  129659. */
  129660. Scene.prototype.setTransformMatrix = function (view, projection) {
  129661. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129662. return;
  129663. }
  129664. this._viewUpdateFlag = view.updateFlag;
  129665. this._projectionUpdateFlag = projection.updateFlag;
  129666. this._viewMatrix = view;
  129667. this._projectionMatrix = projection;
  129668. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129669. // Update frustum
  129670. if (!this._frustumPlanes) {
  129671. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129672. }
  129673. else {
  129674. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129675. }
  129676. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129677. var otherCamera = this.activeCamera._alternateCamera;
  129678. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129679. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  129680. }
  129681. if (this._sceneUbo.useUbo) {
  129682. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129683. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129684. this._sceneUbo.update();
  129685. }
  129686. };
  129687. /** @hidden */
  129688. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129689. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129690. return;
  129691. }
  129692. this._alternateViewUpdateFlag = view.updateFlag;
  129693. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129694. this._alternateViewMatrix = view;
  129695. this._alternateProjectionMatrix = projection;
  129696. if (!this._alternateTransformMatrix) {
  129697. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129698. }
  129699. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129700. if (!this._alternateSceneUbo) {
  129701. this._createAlternateUbo();
  129702. }
  129703. if (this._alternateSceneUbo.useUbo) {
  129704. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129705. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129706. this._alternateSceneUbo.update();
  129707. }
  129708. };
  129709. /**
  129710. * Gets the uniform buffer used to store scene data
  129711. * @returns a UniformBuffer
  129712. */
  129713. Scene.prototype.getSceneUniformBuffer = function () {
  129714. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129715. };
  129716. /**
  129717. * Gets an unique (relatively to the current scene) Id
  129718. * @returns an unique number for the scene
  129719. */
  129720. Scene.prototype.getUniqueId = function () {
  129721. var result = Scene._uniqueIdCounter;
  129722. Scene._uniqueIdCounter++;
  129723. return result;
  129724. };
  129725. /**
  129726. * Add a mesh to the list of scene's meshes
  129727. * @param newMesh defines the mesh to add
  129728. * @param recursive if all child meshes should also be added to the scene
  129729. */
  129730. Scene.prototype.addMesh = function (newMesh, recursive) {
  129731. var _this = this;
  129732. if (recursive === void 0) { recursive = false; }
  129733. this.meshes.push(newMesh);
  129734. newMesh._resyncLightSources();
  129735. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129736. if (recursive) {
  129737. newMesh.getChildMeshes().forEach(function (m) {
  129738. _this.addMesh(m);
  129739. });
  129740. }
  129741. };
  129742. /**
  129743. * Remove a mesh for the list of scene's meshes
  129744. * @param toRemove defines the mesh to remove
  129745. * @param recursive if all child meshes should also be removed from the scene
  129746. * @returns the index where the mesh was in the mesh list
  129747. */
  129748. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129749. var _this = this;
  129750. if (recursive === void 0) { recursive = false; }
  129751. var index = this.meshes.indexOf(toRemove);
  129752. if (index !== -1) {
  129753. // Remove from the scene if mesh found
  129754. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129755. this.meshes.pop();
  129756. }
  129757. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129758. if (recursive) {
  129759. toRemove.getChildMeshes().forEach(function (m) {
  129760. _this.removeMesh(m);
  129761. });
  129762. }
  129763. return index;
  129764. };
  129765. /**
  129766. * Add a transform node to the list of scene's transform nodes
  129767. * @param newTransformNode defines the transform node to add
  129768. */
  129769. Scene.prototype.addTransformNode = function (newTransformNode) {
  129770. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129771. this.transformNodes.push(newTransformNode);
  129772. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129773. };
  129774. /**
  129775. * Remove a transform node for the list of scene's transform nodes
  129776. * @param toRemove defines the transform node to remove
  129777. * @returns the index where the transform node was in the transform node list
  129778. */
  129779. Scene.prototype.removeTransformNode = function (toRemove) {
  129780. var index = toRemove._indexInSceneTransformNodesArray;
  129781. if (index !== -1) {
  129782. if (index !== this.transformNodes.length - 1) {
  129783. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129784. this.transformNodes[index] = lastNode;
  129785. lastNode._indexInSceneTransformNodesArray = index;
  129786. }
  129787. toRemove._indexInSceneTransformNodesArray = -1;
  129788. this.transformNodes.pop();
  129789. }
  129790. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129791. return index;
  129792. };
  129793. /**
  129794. * Remove a skeleton for the list of scene's skeletons
  129795. * @param toRemove defines the skeleton to remove
  129796. * @returns the index where the skeleton was in the skeleton list
  129797. */
  129798. Scene.prototype.removeSkeleton = function (toRemove) {
  129799. var index = this.skeletons.indexOf(toRemove);
  129800. if (index !== -1) {
  129801. // Remove from the scene if found
  129802. this.skeletons.splice(index, 1);
  129803. }
  129804. return index;
  129805. };
  129806. /**
  129807. * Remove a morph target for the list of scene's morph targets
  129808. * @param toRemove defines the morph target to remove
  129809. * @returns the index where the morph target was in the morph target list
  129810. */
  129811. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129812. var index = this.morphTargetManagers.indexOf(toRemove);
  129813. if (index !== -1) {
  129814. // Remove from the scene if found
  129815. this.morphTargetManagers.splice(index, 1);
  129816. }
  129817. return index;
  129818. };
  129819. /**
  129820. * Remove a light for the list of scene's lights
  129821. * @param toRemove defines the light to remove
  129822. * @returns the index where the light was in the light list
  129823. */
  129824. Scene.prototype.removeLight = function (toRemove) {
  129825. var index = this.lights.indexOf(toRemove);
  129826. if (index !== -1) {
  129827. // Remove from meshes
  129828. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129829. var mesh = _a[_i];
  129830. mesh._removeLightSource(toRemove);
  129831. }
  129832. // Remove from the scene if mesh found
  129833. this.lights.splice(index, 1);
  129834. this.sortLightsByPriority();
  129835. }
  129836. this.onLightRemovedObservable.notifyObservers(toRemove);
  129837. return index;
  129838. };
  129839. /**
  129840. * Remove a camera for the list of scene's cameras
  129841. * @param toRemove defines the camera to remove
  129842. * @returns the index where the camera was in the camera list
  129843. */
  129844. Scene.prototype.removeCamera = function (toRemove) {
  129845. var index = this.cameras.indexOf(toRemove);
  129846. if (index !== -1) {
  129847. // Remove from the scene if mesh found
  129848. this.cameras.splice(index, 1);
  129849. }
  129850. // Remove from activeCameras
  129851. var index2 = this.activeCameras.indexOf(toRemove);
  129852. if (index2 !== -1) {
  129853. // Remove from the scene if mesh found
  129854. this.activeCameras.splice(index2, 1);
  129855. }
  129856. // Reset the activeCamera
  129857. if (this.activeCamera === toRemove) {
  129858. if (this.cameras.length > 0) {
  129859. this.activeCamera = this.cameras[0];
  129860. }
  129861. else {
  129862. this.activeCamera = null;
  129863. }
  129864. }
  129865. this.onCameraRemovedObservable.notifyObservers(toRemove);
  129866. return index;
  129867. };
  129868. /**
  129869. * Remove a particle system for the list of scene's particle systems
  129870. * @param toRemove defines the particle system to remove
  129871. * @returns the index where the particle system was in the particle system list
  129872. */
  129873. Scene.prototype.removeParticleSystem = function (toRemove) {
  129874. var index = this.particleSystems.indexOf(toRemove);
  129875. if (index !== -1) {
  129876. this.particleSystems.splice(index, 1);
  129877. }
  129878. return index;
  129879. };
  129880. /**
  129881. * Remove a animation for the list of scene's animations
  129882. * @param toRemove defines the animation to remove
  129883. * @returns the index where the animation was in the animation list
  129884. */
  129885. Scene.prototype.removeAnimation = function (toRemove) {
  129886. var index = this.animations.indexOf(toRemove);
  129887. if (index !== -1) {
  129888. this.animations.splice(index, 1);
  129889. }
  129890. return index;
  129891. };
  129892. /**
  129893. * Removes the given animation group from this scene.
  129894. * @param toRemove The animation group to remove
  129895. * @returns The index of the removed animation group
  129896. */
  129897. Scene.prototype.removeAnimationGroup = function (toRemove) {
  129898. var index = this.animationGroups.indexOf(toRemove);
  129899. if (index !== -1) {
  129900. this.animationGroups.splice(index, 1);
  129901. }
  129902. return index;
  129903. };
  129904. /**
  129905. * Removes the given multi-material from this scene.
  129906. * @param toRemove The multi-material to remove
  129907. * @returns The index of the removed multi-material
  129908. */
  129909. Scene.prototype.removeMultiMaterial = function (toRemove) {
  129910. var index = this.multiMaterials.indexOf(toRemove);
  129911. if (index !== -1) {
  129912. this.multiMaterials.splice(index, 1);
  129913. }
  129914. return index;
  129915. };
  129916. /**
  129917. * Removes the given material from this scene.
  129918. * @param toRemove The material to remove
  129919. * @returns The index of the removed material
  129920. */
  129921. Scene.prototype.removeMaterial = function (toRemove) {
  129922. var index = toRemove._indexInSceneMaterialArray;
  129923. if (index !== -1 && index < this.materials.length) {
  129924. if (index !== this.materials.length - 1) {
  129925. var lastMaterial = this.materials[this.materials.length - 1];
  129926. this.materials[index] = lastMaterial;
  129927. lastMaterial._indexInSceneMaterialArray = index;
  129928. }
  129929. toRemove._indexInSceneMaterialArray = -1;
  129930. this.materials.pop();
  129931. }
  129932. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  129933. return index;
  129934. };
  129935. /**
  129936. * Removes the given action manager from this scene.
  129937. * @param toRemove The action manager to remove
  129938. * @returns The index of the removed action manager
  129939. */
  129940. Scene.prototype.removeActionManager = function (toRemove) {
  129941. var index = this.actionManagers.indexOf(toRemove);
  129942. if (index !== -1) {
  129943. this.actionManagers.splice(index, 1);
  129944. }
  129945. return index;
  129946. };
  129947. /**
  129948. * Removes the given texture from this scene.
  129949. * @param toRemove The texture to remove
  129950. * @returns The index of the removed texture
  129951. */
  129952. Scene.prototype.removeTexture = function (toRemove) {
  129953. var index = this.textures.indexOf(toRemove);
  129954. if (index !== -1) {
  129955. this.textures.splice(index, 1);
  129956. }
  129957. this.onTextureRemovedObservable.notifyObservers(toRemove);
  129958. return index;
  129959. };
  129960. /**
  129961. * Adds the given light to this scene
  129962. * @param newLight The light to add
  129963. */
  129964. Scene.prototype.addLight = function (newLight) {
  129965. this.lights.push(newLight);
  129966. this.sortLightsByPriority();
  129967. // Add light to all meshes (To support if the light is removed and then readded)
  129968. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129969. var mesh = _a[_i];
  129970. if (mesh._lightSources.indexOf(newLight) === -1) {
  129971. mesh._lightSources.push(newLight);
  129972. mesh._resyncLightSources();
  129973. }
  129974. }
  129975. this.onNewLightAddedObservable.notifyObservers(newLight);
  129976. };
  129977. /**
  129978. * Sorts the list list based on light priorities
  129979. */
  129980. Scene.prototype.sortLightsByPriority = function () {
  129981. if (this.requireLightSorting) {
  129982. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  129983. }
  129984. };
  129985. /**
  129986. * Adds the given camera to this scene
  129987. * @param newCamera The camera to add
  129988. */
  129989. Scene.prototype.addCamera = function (newCamera) {
  129990. this.cameras.push(newCamera);
  129991. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  129992. };
  129993. /**
  129994. * Adds the given skeleton to this scene
  129995. * @param newSkeleton The skeleton to add
  129996. */
  129997. Scene.prototype.addSkeleton = function (newSkeleton) {
  129998. this.skeletons.push(newSkeleton);
  129999. };
  130000. /**
  130001. * Adds the given particle system to this scene
  130002. * @param newParticleSystem The particle system to add
  130003. */
  130004. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  130005. this.particleSystems.push(newParticleSystem);
  130006. };
  130007. /**
  130008. * Adds the given animation to this scene
  130009. * @param newAnimation The animation to add
  130010. */
  130011. Scene.prototype.addAnimation = function (newAnimation) {
  130012. this.animations.push(newAnimation);
  130013. };
  130014. /**
  130015. * Adds the given animation group to this scene.
  130016. * @param newAnimationGroup The animation group to add
  130017. */
  130018. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  130019. this.animationGroups.push(newAnimationGroup);
  130020. };
  130021. /**
  130022. * Adds the given multi-material to this scene
  130023. * @param newMultiMaterial The multi-material to add
  130024. */
  130025. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  130026. this.multiMaterials.push(newMultiMaterial);
  130027. };
  130028. /**
  130029. * Adds the given material to this scene
  130030. * @param newMaterial The material to add
  130031. */
  130032. Scene.prototype.addMaterial = function (newMaterial) {
  130033. newMaterial._indexInSceneMaterialArray = this.materials.length;
  130034. this.materials.push(newMaterial);
  130035. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  130036. };
  130037. /**
  130038. * Adds the given morph target to this scene
  130039. * @param newMorphTargetManager The morph target to add
  130040. */
  130041. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  130042. this.morphTargetManagers.push(newMorphTargetManager);
  130043. };
  130044. /**
  130045. * Adds the given geometry to this scene
  130046. * @param newGeometry The geometry to add
  130047. */
  130048. Scene.prototype.addGeometry = function (newGeometry) {
  130049. if (this.geometriesByUniqueId) {
  130050. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  130051. }
  130052. this.geometries.push(newGeometry);
  130053. };
  130054. /**
  130055. * Adds the given action manager to this scene
  130056. * @param newActionManager The action manager to add
  130057. */
  130058. Scene.prototype.addActionManager = function (newActionManager) {
  130059. this.actionManagers.push(newActionManager);
  130060. };
  130061. /**
  130062. * Adds the given texture to this scene.
  130063. * @param newTexture The texture to add
  130064. */
  130065. Scene.prototype.addTexture = function (newTexture) {
  130066. this.textures.push(newTexture);
  130067. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  130068. };
  130069. /**
  130070. * Switch active camera
  130071. * @param newCamera defines the new active camera
  130072. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  130073. */
  130074. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  130075. if (attachControl === void 0) { attachControl = true; }
  130076. var canvas = this._engine.getRenderingCanvas();
  130077. if (!canvas) {
  130078. return;
  130079. }
  130080. if (this.activeCamera) {
  130081. this.activeCamera.detachControl(canvas);
  130082. }
  130083. this.activeCamera = newCamera;
  130084. if (attachControl) {
  130085. newCamera.attachControl(canvas);
  130086. }
  130087. };
  130088. /**
  130089. * sets the active camera of the scene using its ID
  130090. * @param id defines the camera's ID
  130091. * @return the new active camera or null if none found.
  130092. */
  130093. Scene.prototype.setActiveCameraByID = function (id) {
  130094. var camera = this.getCameraByID(id);
  130095. if (camera) {
  130096. this.activeCamera = camera;
  130097. return camera;
  130098. }
  130099. return null;
  130100. };
  130101. /**
  130102. * sets the active camera of the scene using its name
  130103. * @param name defines the camera's name
  130104. * @returns the new active camera or null if none found.
  130105. */
  130106. Scene.prototype.setActiveCameraByName = function (name) {
  130107. var camera = this.getCameraByName(name);
  130108. if (camera) {
  130109. this.activeCamera = camera;
  130110. return camera;
  130111. }
  130112. return null;
  130113. };
  130114. /**
  130115. * get an animation group using its name
  130116. * @param name defines the material's name
  130117. * @return the animation group or null if none found.
  130118. */
  130119. Scene.prototype.getAnimationGroupByName = function (name) {
  130120. for (var index = 0; index < this.animationGroups.length; index++) {
  130121. if (this.animationGroups[index].name === name) {
  130122. return this.animationGroups[index];
  130123. }
  130124. }
  130125. return null;
  130126. };
  130127. /**
  130128. * get a material using its id
  130129. * @param id defines the material's ID
  130130. * @return the material or null if none found.
  130131. */
  130132. Scene.prototype.getMaterialByID = function (id) {
  130133. for (var index = 0; index < this.materials.length; index++) {
  130134. if (this.materials[index].id === id) {
  130135. return this.materials[index];
  130136. }
  130137. }
  130138. return null;
  130139. };
  130140. /**
  130141. * Gets a material using its name
  130142. * @param name defines the material's name
  130143. * @return the material or null if none found.
  130144. */
  130145. Scene.prototype.getMaterialByName = function (name) {
  130146. for (var index = 0; index < this.materials.length; index++) {
  130147. if (this.materials[index].name === name) {
  130148. return this.materials[index];
  130149. }
  130150. }
  130151. return null;
  130152. };
  130153. /**
  130154. * Gets a camera using its id
  130155. * @param id defines the id to look for
  130156. * @returns the camera or null if not found
  130157. */
  130158. Scene.prototype.getCameraByID = function (id) {
  130159. for (var index = 0; index < this.cameras.length; index++) {
  130160. if (this.cameras[index].id === id) {
  130161. return this.cameras[index];
  130162. }
  130163. }
  130164. return null;
  130165. };
  130166. /**
  130167. * Gets a camera using its unique id
  130168. * @param uniqueId defines the unique id to look for
  130169. * @returns the camera or null if not found
  130170. */
  130171. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  130172. for (var index = 0; index < this.cameras.length; index++) {
  130173. if (this.cameras[index].uniqueId === uniqueId) {
  130174. return this.cameras[index];
  130175. }
  130176. }
  130177. return null;
  130178. };
  130179. /**
  130180. * Gets a camera using its name
  130181. * @param name defines the camera's name
  130182. * @return the camera or null if none found.
  130183. */
  130184. Scene.prototype.getCameraByName = function (name) {
  130185. for (var index = 0; index < this.cameras.length; index++) {
  130186. if (this.cameras[index].name === name) {
  130187. return this.cameras[index];
  130188. }
  130189. }
  130190. return null;
  130191. };
  130192. /**
  130193. * Gets a bone using its id
  130194. * @param id defines the bone's id
  130195. * @return the bone or null if not found
  130196. */
  130197. Scene.prototype.getBoneByID = function (id) {
  130198. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130199. var skeleton = this.skeletons[skeletonIndex];
  130200. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130201. if (skeleton.bones[boneIndex].id === id) {
  130202. return skeleton.bones[boneIndex];
  130203. }
  130204. }
  130205. }
  130206. return null;
  130207. };
  130208. /**
  130209. * Gets a bone using its id
  130210. * @param name defines the bone's name
  130211. * @return the bone or null if not found
  130212. */
  130213. Scene.prototype.getBoneByName = function (name) {
  130214. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130215. var skeleton = this.skeletons[skeletonIndex];
  130216. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130217. if (skeleton.bones[boneIndex].name === name) {
  130218. return skeleton.bones[boneIndex];
  130219. }
  130220. }
  130221. }
  130222. return null;
  130223. };
  130224. /**
  130225. * Gets a light node using its name
  130226. * @param name defines the the light's name
  130227. * @return the light or null if none found.
  130228. */
  130229. Scene.prototype.getLightByName = function (name) {
  130230. for (var index = 0; index < this.lights.length; index++) {
  130231. if (this.lights[index].name === name) {
  130232. return this.lights[index];
  130233. }
  130234. }
  130235. return null;
  130236. };
  130237. /**
  130238. * Gets a light node using its id
  130239. * @param id defines the light's id
  130240. * @return the light or null if none found.
  130241. */
  130242. Scene.prototype.getLightByID = function (id) {
  130243. for (var index = 0; index < this.lights.length; index++) {
  130244. if (this.lights[index].id === id) {
  130245. return this.lights[index];
  130246. }
  130247. }
  130248. return null;
  130249. };
  130250. /**
  130251. * Gets a light node using its scene-generated unique ID
  130252. * @param uniqueId defines the light's unique id
  130253. * @return the light or null if none found.
  130254. */
  130255. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  130256. for (var index = 0; index < this.lights.length; index++) {
  130257. if (this.lights[index].uniqueId === uniqueId) {
  130258. return this.lights[index];
  130259. }
  130260. }
  130261. return null;
  130262. };
  130263. /**
  130264. * Gets a particle system by id
  130265. * @param id defines the particle system id
  130266. * @return the corresponding system or null if none found
  130267. */
  130268. Scene.prototype.getParticleSystemByID = function (id) {
  130269. for (var index = 0; index < this.particleSystems.length; index++) {
  130270. if (this.particleSystems[index].id === id) {
  130271. return this.particleSystems[index];
  130272. }
  130273. }
  130274. return null;
  130275. };
  130276. /**
  130277. * Gets a geometry using its ID
  130278. * @param id defines the geometry's id
  130279. * @return the geometry or null if none found.
  130280. */
  130281. Scene.prototype.getGeometryByID = function (id) {
  130282. for (var index = 0; index < this.geometries.length; index++) {
  130283. if (this.geometries[index].id === id) {
  130284. return this.geometries[index];
  130285. }
  130286. }
  130287. return null;
  130288. };
  130289. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  130290. if (this.geometriesByUniqueId) {
  130291. var index_1 = this.geometriesByUniqueId[uniqueId];
  130292. if (index_1 !== undefined) {
  130293. return this.geometries[index_1];
  130294. }
  130295. }
  130296. else {
  130297. for (var index = 0; index < this.geometries.length; index++) {
  130298. if (this.geometries[index].uniqueId === uniqueId) {
  130299. return this.geometries[index];
  130300. }
  130301. }
  130302. }
  130303. return null;
  130304. };
  130305. /**
  130306. * Add a new geometry to this scene
  130307. * @param geometry defines the geometry to be added to the scene.
  130308. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  130309. * @return a boolean defining if the geometry was added or not
  130310. */
  130311. Scene.prototype.pushGeometry = function (geometry, force) {
  130312. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  130313. return false;
  130314. }
  130315. this.addGeometry(geometry);
  130316. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  130317. return true;
  130318. };
  130319. /**
  130320. * Removes an existing geometry
  130321. * @param geometry defines the geometry to be removed from the scene
  130322. * @return a boolean defining if the geometry was removed or not
  130323. */
  130324. Scene.prototype.removeGeometry = function (geometry) {
  130325. var index;
  130326. if (this.geometriesByUniqueId) {
  130327. index = this.geometriesByUniqueId[geometry.uniqueId];
  130328. if (index === undefined) {
  130329. return false;
  130330. }
  130331. }
  130332. else {
  130333. index = this.geometries.indexOf(geometry);
  130334. if (index < 0) {
  130335. return false;
  130336. }
  130337. }
  130338. if (index !== this.geometries.length - 1) {
  130339. var lastGeometry = this.geometries[this.geometries.length - 1];
  130340. this.geometries[index] = lastGeometry;
  130341. if (this.geometriesByUniqueId) {
  130342. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  130343. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  130344. }
  130345. }
  130346. this.geometries.pop();
  130347. this.onGeometryRemovedObservable.notifyObservers(geometry);
  130348. return true;
  130349. };
  130350. /**
  130351. * Gets the list of geometries attached to the scene
  130352. * @returns an array of Geometry
  130353. */
  130354. Scene.prototype.getGeometries = function () {
  130355. return this.geometries;
  130356. };
  130357. /**
  130358. * Gets the first added mesh found of a given ID
  130359. * @param id defines the id to search for
  130360. * @return the mesh found or null if not found at all
  130361. */
  130362. Scene.prototype.getMeshByID = function (id) {
  130363. for (var index = 0; index < this.meshes.length; index++) {
  130364. if (this.meshes[index].id === id) {
  130365. return this.meshes[index];
  130366. }
  130367. }
  130368. return null;
  130369. };
  130370. /**
  130371. * Gets a list of meshes using their id
  130372. * @param id defines the id to search for
  130373. * @returns a list of meshes
  130374. */
  130375. Scene.prototype.getMeshesByID = function (id) {
  130376. return this.meshes.filter(function (m) {
  130377. return m.id === id;
  130378. });
  130379. };
  130380. /**
  130381. * Gets the first added transform node found of a given ID
  130382. * @param id defines the id to search for
  130383. * @return the found transform node or null if not found at all.
  130384. */
  130385. Scene.prototype.getTransformNodeByID = function (id) {
  130386. for (var index = 0; index < this.transformNodes.length; index++) {
  130387. if (this.transformNodes[index].id === id) {
  130388. return this.transformNodes[index];
  130389. }
  130390. }
  130391. return null;
  130392. };
  130393. /**
  130394. * Gets a list of transform nodes using their id
  130395. * @param id defines the id to search for
  130396. * @returns a list of transform nodes
  130397. */
  130398. Scene.prototype.getTransformNodesByID = function (id) {
  130399. return this.transformNodes.filter(function (m) {
  130400. return m.id === id;
  130401. });
  130402. };
  130403. /**
  130404. * Gets a mesh with its auto-generated unique id
  130405. * @param uniqueId defines the unique id to search for
  130406. * @return the found mesh or null if not found at all.
  130407. */
  130408. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  130409. for (var index = 0; index < this.meshes.length; index++) {
  130410. if (this.meshes[index].uniqueId === uniqueId) {
  130411. return this.meshes[index];
  130412. }
  130413. }
  130414. return null;
  130415. };
  130416. /**
  130417. * Gets a the last added mesh using a given id
  130418. * @param id defines the id to search for
  130419. * @return the found mesh or null if not found at all.
  130420. */
  130421. Scene.prototype.getLastMeshByID = function (id) {
  130422. for (var index = this.meshes.length - 1; index >= 0; index--) {
  130423. if (this.meshes[index].id === id) {
  130424. return this.meshes[index];
  130425. }
  130426. }
  130427. return null;
  130428. };
  130429. /**
  130430. * Gets a the last added node (Mesh, Camera, Light) using a given id
  130431. * @param id defines the id to search for
  130432. * @return the found node or null if not found at all
  130433. */
  130434. Scene.prototype.getLastEntryByID = function (id) {
  130435. var index;
  130436. for (index = this.meshes.length - 1; index >= 0; index--) {
  130437. if (this.meshes[index].id === id) {
  130438. return this.meshes[index];
  130439. }
  130440. }
  130441. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130442. if (this.transformNodes[index].id === id) {
  130443. return this.transformNodes[index];
  130444. }
  130445. }
  130446. for (index = this.cameras.length - 1; index >= 0; index--) {
  130447. if (this.cameras[index].id === id) {
  130448. return this.cameras[index];
  130449. }
  130450. }
  130451. for (index = this.lights.length - 1; index >= 0; index--) {
  130452. if (this.lights[index].id === id) {
  130453. return this.lights[index];
  130454. }
  130455. }
  130456. return null;
  130457. };
  130458. /**
  130459. * Gets a node (Mesh, Camera, Light) using a given id
  130460. * @param id defines the id to search for
  130461. * @return the found node or null if not found at all
  130462. */
  130463. Scene.prototype.getNodeByID = function (id) {
  130464. var mesh = this.getMeshByID(id);
  130465. if (mesh) {
  130466. return mesh;
  130467. }
  130468. var transformNode = this.getTransformNodeByID(id);
  130469. if (transformNode) {
  130470. return transformNode;
  130471. }
  130472. var light = this.getLightByID(id);
  130473. if (light) {
  130474. return light;
  130475. }
  130476. var camera = this.getCameraByID(id);
  130477. if (camera) {
  130478. return camera;
  130479. }
  130480. var bone = this.getBoneByID(id);
  130481. if (bone) {
  130482. return bone;
  130483. }
  130484. return null;
  130485. };
  130486. /**
  130487. * Gets a node (Mesh, Camera, Light) using a given name
  130488. * @param name defines the name to search for
  130489. * @return the found node or null if not found at all.
  130490. */
  130491. Scene.prototype.getNodeByName = function (name) {
  130492. var mesh = this.getMeshByName(name);
  130493. if (mesh) {
  130494. return mesh;
  130495. }
  130496. var transformNode = this.getTransformNodeByName(name);
  130497. if (transformNode) {
  130498. return transformNode;
  130499. }
  130500. var light = this.getLightByName(name);
  130501. if (light) {
  130502. return light;
  130503. }
  130504. var camera = this.getCameraByName(name);
  130505. if (camera) {
  130506. return camera;
  130507. }
  130508. var bone = this.getBoneByName(name);
  130509. if (bone) {
  130510. return bone;
  130511. }
  130512. return null;
  130513. };
  130514. /**
  130515. * Gets a mesh using a given name
  130516. * @param name defines the name to search for
  130517. * @return the found mesh or null if not found at all.
  130518. */
  130519. Scene.prototype.getMeshByName = function (name) {
  130520. for (var index = 0; index < this.meshes.length; index++) {
  130521. if (this.meshes[index].name === name) {
  130522. return this.meshes[index];
  130523. }
  130524. }
  130525. return null;
  130526. };
  130527. /**
  130528. * Gets a transform node using a given name
  130529. * @param name defines the name to search for
  130530. * @return the found transform node or null if not found at all.
  130531. */
  130532. Scene.prototype.getTransformNodeByName = function (name) {
  130533. for (var index = 0; index < this.transformNodes.length; index++) {
  130534. if (this.transformNodes[index].name === name) {
  130535. return this.transformNodes[index];
  130536. }
  130537. }
  130538. return null;
  130539. };
  130540. /**
  130541. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130542. * @param id defines the id to search for
  130543. * @return the found skeleton or null if not found at all.
  130544. */
  130545. Scene.prototype.getLastSkeletonByID = function (id) {
  130546. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130547. if (this.skeletons[index].id === id) {
  130548. return this.skeletons[index];
  130549. }
  130550. }
  130551. return null;
  130552. };
  130553. /**
  130554. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130555. * @param id defines the id to search for
  130556. * @return the found skeleton or null if not found at all.
  130557. */
  130558. Scene.prototype.getSkeletonById = function (id) {
  130559. for (var index = 0; index < this.skeletons.length; index++) {
  130560. if (this.skeletons[index].id === id) {
  130561. return this.skeletons[index];
  130562. }
  130563. }
  130564. return null;
  130565. };
  130566. /**
  130567. * Gets a skeleton using a given name
  130568. * @param name defines the name to search for
  130569. * @return the found skeleton or null if not found at all.
  130570. */
  130571. Scene.prototype.getSkeletonByName = function (name) {
  130572. for (var index = 0; index < this.skeletons.length; index++) {
  130573. if (this.skeletons[index].name === name) {
  130574. return this.skeletons[index];
  130575. }
  130576. }
  130577. return null;
  130578. };
  130579. /**
  130580. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130581. * @param id defines the id to search for
  130582. * @return the found morph target manager or null if not found at all.
  130583. */
  130584. Scene.prototype.getMorphTargetManagerById = function (id) {
  130585. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130586. if (this.morphTargetManagers[index].uniqueId === id) {
  130587. return this.morphTargetManagers[index];
  130588. }
  130589. }
  130590. return null;
  130591. };
  130592. /**
  130593. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130594. * @param id defines the id to search for
  130595. * @return the found morph target or null if not found at all.
  130596. */
  130597. Scene.prototype.getMorphTargetById = function (id) {
  130598. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130599. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130600. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130601. var target = morphTargetManager.getTarget(index);
  130602. if (target.id === id) {
  130603. return target;
  130604. }
  130605. }
  130606. }
  130607. return null;
  130608. };
  130609. /**
  130610. * Gets a boolean indicating if the given mesh is active
  130611. * @param mesh defines the mesh to look for
  130612. * @returns true if the mesh is in the active list
  130613. */
  130614. Scene.prototype.isActiveMesh = function (mesh) {
  130615. return (this._activeMeshes.indexOf(mesh) !== -1);
  130616. };
  130617. Object.defineProperty(Scene.prototype, "uid", {
  130618. /**
  130619. * Return a unique id as a string which can serve as an identifier for the scene
  130620. */
  130621. get: function () {
  130622. if (!this._uid) {
  130623. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130624. }
  130625. return this._uid;
  130626. },
  130627. enumerable: true,
  130628. configurable: true
  130629. });
  130630. /**
  130631. * Add an externaly attached data from its key.
  130632. * This method call will fail and return false, if such key already exists.
  130633. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130634. * @param key the unique key that identifies the data
  130635. * @param data the data object to associate to the key for this Engine instance
  130636. * @return true if no such key were already present and the data was added successfully, false otherwise
  130637. */
  130638. Scene.prototype.addExternalData = function (key, data) {
  130639. if (!this._externalData) {
  130640. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130641. }
  130642. return this._externalData.add(key, data);
  130643. };
  130644. /**
  130645. * Get an externaly attached data from its key
  130646. * @param key the unique key that identifies the data
  130647. * @return the associated data, if present (can be null), or undefined if not present
  130648. */
  130649. Scene.prototype.getExternalData = function (key) {
  130650. if (!this._externalData) {
  130651. return null;
  130652. }
  130653. return this._externalData.get(key);
  130654. };
  130655. /**
  130656. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130657. * @param key the unique key that identifies the data
  130658. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130659. * @return the associated data, can be null if the factory returned null.
  130660. */
  130661. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130662. if (!this._externalData) {
  130663. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130664. }
  130665. return this._externalData.getOrAddWithFactory(key, factory);
  130666. };
  130667. /**
  130668. * Remove an externaly attached data from the Engine instance
  130669. * @param key the unique key that identifies the data
  130670. * @return true if the data was successfully removed, false if it doesn't exist
  130671. */
  130672. Scene.prototype.removeExternalData = function (key) {
  130673. return this._externalData.remove(key);
  130674. };
  130675. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130676. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130677. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130678. var step = _a[_i];
  130679. step.action(mesh, subMesh);
  130680. }
  130681. var material = subMesh.getMaterial();
  130682. if (material !== null && material !== undefined) {
  130683. // Render targets
  130684. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130685. if (this._processedMaterials.indexOf(material) === -1) {
  130686. this._processedMaterials.push(material);
  130687. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130688. }
  130689. }
  130690. // Dispatch
  130691. this._activeIndices.addCount(subMesh.indexCount, false);
  130692. this._renderingManager.dispatch(subMesh, mesh, material);
  130693. }
  130694. }
  130695. };
  130696. /**
  130697. * Clear the processed materials smart array preventing retention point in material dispose.
  130698. */
  130699. Scene.prototype.freeProcessedMaterials = function () {
  130700. this._processedMaterials.dispose();
  130701. };
  130702. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130703. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130704. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130705. * when disposing several meshes in a row or a hierarchy of meshes.
  130706. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130707. */
  130708. get: function () {
  130709. return this._preventFreeActiveMeshesAndRenderingGroups;
  130710. },
  130711. set: function (value) {
  130712. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130713. return;
  130714. }
  130715. if (value) {
  130716. this.freeActiveMeshes();
  130717. this.freeRenderingGroups();
  130718. }
  130719. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130720. },
  130721. enumerable: true,
  130722. configurable: true
  130723. });
  130724. /**
  130725. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130726. */
  130727. Scene.prototype.freeActiveMeshes = function () {
  130728. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130729. return;
  130730. }
  130731. this._activeMeshes.dispose();
  130732. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130733. this.activeCamera._activeMeshes.dispose();
  130734. }
  130735. if (this.activeCameras) {
  130736. for (var i = 0; i < this.activeCameras.length; i++) {
  130737. var activeCamera = this.activeCameras[i];
  130738. if (activeCamera && activeCamera._activeMeshes) {
  130739. activeCamera._activeMeshes.dispose();
  130740. }
  130741. }
  130742. }
  130743. };
  130744. /**
  130745. * Clear the info related to rendering groups preventing retention points during dispose.
  130746. */
  130747. Scene.prototype.freeRenderingGroups = function () {
  130748. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130749. return;
  130750. }
  130751. if (this._renderingManager) {
  130752. this._renderingManager.freeRenderingGroups();
  130753. }
  130754. if (this.textures) {
  130755. for (var i = 0; i < this.textures.length; i++) {
  130756. var texture = this.textures[i];
  130757. if (texture && texture.renderList) {
  130758. texture.freeRenderingGroups();
  130759. }
  130760. }
  130761. }
  130762. };
  130763. /** @hidden */
  130764. Scene.prototype._isInIntermediateRendering = function () {
  130765. return this._intermediateRendering;
  130766. };
  130767. /**
  130768. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130769. * @returns the current scene
  130770. */
  130771. Scene.prototype.freezeActiveMeshes = function () {
  130772. if (!this.activeCamera) {
  130773. return this;
  130774. }
  130775. if (!this._frustumPlanes) {
  130776. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130777. }
  130778. this._evaluateActiveMeshes();
  130779. this._activeMeshesFrozen = true;
  130780. return this;
  130781. };
  130782. /**
  130783. * Use this function to restart evaluating active meshes on every frame
  130784. * @returns the current scene
  130785. */
  130786. Scene.prototype.unfreezeActiveMeshes = function () {
  130787. this._activeMeshesFrozen = false;
  130788. return this;
  130789. };
  130790. Scene.prototype._evaluateActiveMeshes = function () {
  130791. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130792. return;
  130793. }
  130794. if (!this.activeCamera) {
  130795. return;
  130796. }
  130797. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130798. this.activeCamera._activeMeshes.reset();
  130799. this._activeMeshes.reset();
  130800. this._renderingManager.reset();
  130801. this._processedMaterials.reset();
  130802. this._activeParticleSystems.reset();
  130803. this._activeSkeletons.reset();
  130804. this._softwareSkinnedMeshes.reset();
  130805. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130806. var step = _a[_i];
  130807. step.action();
  130808. }
  130809. // Determine mesh candidates
  130810. var meshes = this.getActiveMeshCandidates();
  130811. // Check each mesh
  130812. var len = meshes.length;
  130813. for (var i = 0; i < len; i++) {
  130814. var mesh = meshes.data[i];
  130815. if (mesh.isBlocked) {
  130816. continue;
  130817. }
  130818. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130819. if (!mesh.isReady() || !mesh.isEnabled()) {
  130820. continue;
  130821. }
  130822. mesh.computeWorldMatrix();
  130823. // Intersections
  130824. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130825. this._meshesForIntersections.pushNoDuplicate(mesh);
  130826. }
  130827. // Switch to current LOD
  130828. var meshLOD = mesh.getLOD(this.activeCamera);
  130829. if (meshLOD === undefined || meshLOD === null) {
  130830. continue;
  130831. }
  130832. mesh._preActivate();
  130833. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  130834. this._activeMeshes.push(mesh);
  130835. this.activeCamera._activeMeshes.push(mesh);
  130836. mesh._activate(this._renderId);
  130837. if (meshLOD !== mesh) {
  130838. meshLOD._activate(this._renderId);
  130839. }
  130840. this._activeMesh(mesh, meshLOD);
  130841. }
  130842. }
  130843. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  130844. // Particle systems
  130845. if (this.particlesEnabled) {
  130846. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  130847. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  130848. var particleSystem = this.particleSystems[particleIndex];
  130849. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  130850. continue;
  130851. }
  130852. var emitter = particleSystem.emitter;
  130853. if (!emitter.position || emitter.isEnabled()) {
  130854. this._activeParticleSystems.push(particleSystem);
  130855. particleSystem.animate();
  130856. this._renderingManager.dispatchParticles(particleSystem);
  130857. }
  130858. }
  130859. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  130860. }
  130861. };
  130862. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  130863. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  130864. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  130865. mesh.skeleton.prepare();
  130866. }
  130867. if (!mesh.computeBonesUsingShaders) {
  130868. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  130869. }
  130870. }
  130871. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  130872. var step = _a[_i];
  130873. step.action(sourceMesh, mesh);
  130874. }
  130875. if (mesh !== undefined && mesh !== null
  130876. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  130877. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  130878. var len = subMeshes.length;
  130879. for (var i = 0; i < len; i++) {
  130880. var subMesh = subMeshes.data[i];
  130881. this._evaluateSubMesh(subMesh, mesh);
  130882. }
  130883. }
  130884. };
  130885. /**
  130886. * Update the transform matrix to update from the current active camera
  130887. * @param force defines a boolean used to force the update even if cache is up to date
  130888. */
  130889. Scene.prototype.updateTransformMatrix = function (force) {
  130890. if (!this.activeCamera) {
  130891. return;
  130892. }
  130893. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  130894. };
  130895. /**
  130896. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  130897. * @param alternateCamera defines the camera to use
  130898. */
  130899. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  130900. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  130901. };
  130902. Scene.prototype._renderForCamera = function (camera, rigParent) {
  130903. if (camera && camera._skipRendering) {
  130904. return;
  130905. }
  130906. var engine = this._engine;
  130907. this.activeCamera = camera;
  130908. if (!this.activeCamera) {
  130909. throw new Error("Active camera not set");
  130910. }
  130911. // Viewport
  130912. engine.setViewport(this.activeCamera.viewport);
  130913. // Camera
  130914. this.resetCachedMaterial();
  130915. this._renderId++;
  130916. this.updateTransformMatrix();
  130917. if (camera._alternateCamera) {
  130918. this.updateAlternateTransformMatrix(camera._alternateCamera);
  130919. this._alternateRendering = true;
  130920. }
  130921. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  130922. // Meshes
  130923. this._evaluateActiveMeshes();
  130924. // Software skinning
  130925. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  130926. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  130927. mesh.applySkeleton(mesh.skeleton);
  130928. }
  130929. // Render targets
  130930. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130931. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  130932. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  130933. }
  130934. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  130935. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  130936. }
  130937. // Collects render targets from external components.
  130938. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  130939. var step = _a[_i];
  130940. step.action(this._renderTargets);
  130941. }
  130942. if (this.renderTargetsEnabled) {
  130943. this._intermediateRendering = true;
  130944. if (this._renderTargets.length > 0) {
  130945. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130946. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  130947. var renderTarget = this._renderTargets.data[renderIndex];
  130948. if (renderTarget._shouldRender()) {
  130949. this._renderId++;
  130950. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  130951. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  130952. }
  130953. }
  130954. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130955. this._renderId++;
  130956. }
  130957. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  130958. var step = _c[_b];
  130959. step.action(this.activeCamera);
  130960. }
  130961. this._intermediateRendering = false;
  130962. if (this.activeCamera.outputRenderTarget) {
  130963. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  130964. if (internalTexture) {
  130965. engine.bindFramebuffer(internalTexture);
  130966. }
  130967. else {
  130968. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  130969. }
  130970. }
  130971. else {
  130972. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  130973. }
  130974. }
  130975. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130976. // Prepare Frame
  130977. if (this.postProcessManager) {
  130978. this.postProcessManager._prepareFrame();
  130979. }
  130980. // Before Camera Draw
  130981. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  130982. var step = _e[_d];
  130983. step.action(this.activeCamera);
  130984. }
  130985. // Render
  130986. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  130987. this._renderingManager.render(null, null, true, true);
  130988. this.onAfterDrawPhaseObservable.notifyObservers(this);
  130989. // After Camera Draw
  130990. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  130991. var step = _g[_f];
  130992. step.action(this.activeCamera);
  130993. }
  130994. // Finalize frame
  130995. if (this.postProcessManager) {
  130996. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  130997. }
  130998. // Reset some special arrays
  130999. this._renderTargets.reset();
  131000. this._alternateRendering = false;
  131001. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  131002. };
  131003. Scene.prototype._processSubCameras = function (camera) {
  131004. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131005. this._renderForCamera(camera);
  131006. return;
  131007. }
  131008. // rig cameras
  131009. for (var index = 0; index < camera._rigCameras.length; index++) {
  131010. this._renderForCamera(camera._rigCameras[index], camera);
  131011. }
  131012. this.activeCamera = camera;
  131013. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131014. };
  131015. Scene.prototype._checkIntersections = function () {
  131016. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  131017. var sourceMesh = this._meshesForIntersections.data[index];
  131018. if (!sourceMesh.actionManager) {
  131019. continue;
  131020. }
  131021. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  131022. var action = sourceMesh.actionManager.actions[actionIndex];
  131023. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131024. var parameters = action.getTriggerParameter();
  131025. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  131026. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  131027. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  131028. if (areIntersecting && currentIntersectionInProgress === -1) {
  131029. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  131030. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131031. sourceMesh._intersectionsInProgress.push(otherMesh);
  131032. }
  131033. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131034. sourceMesh._intersectionsInProgress.push(otherMesh);
  131035. }
  131036. }
  131037. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  131038. //They intersected, and now they don't.
  131039. //is this trigger an exit trigger? execute an event.
  131040. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131041. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131042. }
  131043. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  131044. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  131045. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  131046. return otherMesh === parameterMesh;
  131047. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131048. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  131049. }
  131050. }
  131051. }
  131052. }
  131053. }
  131054. };
  131055. /** @hidden */
  131056. Scene.prototype._advancePhysicsEngineStep = function (step) {
  131057. // Do nothing. Code will be replaced if physics engine component is referenced
  131058. };
  131059. /** @hidden */
  131060. Scene.prototype._animate = function () {
  131061. // Nothing to do as long as Animatable have not been imported.
  131062. };
  131063. /**
  131064. * Render the scene
  131065. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131066. */
  131067. Scene.prototype.render = function (updateCameras) {
  131068. if (updateCameras === void 0) { updateCameras = true; }
  131069. if (this.isDisposed) {
  131070. return;
  131071. }
  131072. this._frameId++;
  131073. // Register components that have been associated lately to the scene.
  131074. this._registerTransientComponents();
  131075. this._activeParticles.fetchNewFrame();
  131076. this._totalVertices.fetchNewFrame();
  131077. this._activeIndices.fetchNewFrame();
  131078. this._activeBones.fetchNewFrame();
  131079. this._meshesForIntersections.reset();
  131080. this.resetCachedMaterial();
  131081. this.onBeforeAnimationsObservable.notifyObservers(this);
  131082. // Actions
  131083. if (this.actionManager) {
  131084. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  131085. }
  131086. if (this._engine.isDeterministicLockStep()) {
  131087. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  131088. var defaultFPS = (60.0 / 1000.0);
  131089. var defaultFrameTime = this.getDeterministicFrameTime();
  131090. var stepsTaken = 0;
  131091. var maxSubSteps = this._engine.getLockstepMaxSteps();
  131092. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  131093. internalSteps = Math.min(internalSteps, maxSubSteps);
  131094. do {
  131095. this.onBeforeStepObservable.notifyObservers(this);
  131096. // Animations
  131097. this._animationRatio = defaultFrameTime * defaultFPS;
  131098. this._animate();
  131099. this.onAfterAnimationsObservable.notifyObservers(this);
  131100. // Physics
  131101. this._advancePhysicsEngineStep(defaultFrameTime);
  131102. this.onAfterStepObservable.notifyObservers(this);
  131103. this._currentStepId++;
  131104. stepsTaken++;
  131105. deltaTime -= defaultFrameTime;
  131106. } while (deltaTime > 0 && stepsTaken < internalSteps);
  131107. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  131108. }
  131109. else {
  131110. // Animations
  131111. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  131112. this._animationRatio = deltaTime * (60.0 / 1000.0);
  131113. this._animate();
  131114. this.onAfterAnimationsObservable.notifyObservers(this);
  131115. // Physics
  131116. this._advancePhysicsEngineStep(deltaTime);
  131117. }
  131118. // Before camera update steps
  131119. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  131120. var step = _a[_i];
  131121. step.action();
  131122. }
  131123. // Update Cameras
  131124. if (updateCameras) {
  131125. if (this.activeCameras.length > 0) {
  131126. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131127. var camera = this.activeCameras[cameraIndex];
  131128. camera.update();
  131129. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131130. // rig cameras
  131131. for (var index = 0; index < camera._rigCameras.length; index++) {
  131132. camera._rigCameras[index].update();
  131133. }
  131134. }
  131135. }
  131136. }
  131137. else if (this.activeCamera) {
  131138. this.activeCamera.update();
  131139. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131140. // rig cameras
  131141. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  131142. this.activeCamera._rigCameras[index].update();
  131143. }
  131144. }
  131145. }
  131146. }
  131147. // Before render
  131148. this.onBeforeRenderObservable.notifyObservers(this);
  131149. // Customs render targets
  131150. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131151. var engine = this.getEngine();
  131152. var currentActiveCamera = this.activeCamera;
  131153. if (this.renderTargetsEnabled) {
  131154. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131155. this._intermediateRendering = true;
  131156. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  131157. var renderTarget = this.customRenderTargets[customIndex];
  131158. if (renderTarget._shouldRender()) {
  131159. this._renderId++;
  131160. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  131161. if (!this.activeCamera) {
  131162. throw new Error("Active camera not set");
  131163. }
  131164. // Viewport
  131165. engine.setViewport(this.activeCamera.viewport);
  131166. // Camera
  131167. this.updateTransformMatrix();
  131168. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  131169. }
  131170. }
  131171. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131172. this._intermediateRendering = false;
  131173. this._renderId++;
  131174. }
  131175. // Restore back buffer
  131176. if (this.customRenderTargets.length > 0) {
  131177. engine.restoreDefaultFramebuffer();
  131178. }
  131179. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131180. this.activeCamera = currentActiveCamera;
  131181. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  131182. var step = _c[_b];
  131183. step.action();
  131184. }
  131185. // Clear
  131186. if (this.autoClearDepthAndStencil || this.autoClear) {
  131187. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  131188. }
  131189. // Collects render targets from external components.
  131190. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  131191. var step = _e[_d];
  131192. step.action(this._renderTargets);
  131193. }
  131194. // Multi-cameras?
  131195. if (this.activeCameras.length > 0) {
  131196. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131197. if (cameraIndex > 0) {
  131198. this._engine.clear(null, false, true, true);
  131199. }
  131200. this._processSubCameras(this.activeCameras[cameraIndex]);
  131201. }
  131202. }
  131203. else {
  131204. if (!this.activeCamera) {
  131205. throw new Error("No camera defined");
  131206. }
  131207. this._processSubCameras(this.activeCamera);
  131208. }
  131209. // Intersection checks
  131210. this._checkIntersections();
  131211. // Executes the after render stage actions.
  131212. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  131213. var step = _g[_f];
  131214. step.action();
  131215. }
  131216. // After render
  131217. if (this.afterRender) {
  131218. this.afterRender();
  131219. }
  131220. this.onAfterRenderObservable.notifyObservers(this);
  131221. // Cleaning
  131222. if (this._toBeDisposed.length) {
  131223. for (var index = 0; index < this._toBeDisposed.length; index++) {
  131224. var data = this._toBeDisposed[index];
  131225. if (data) {
  131226. data.dispose();
  131227. }
  131228. }
  131229. this._toBeDisposed = [];
  131230. }
  131231. if (this.dumpNextRenderTargets) {
  131232. this.dumpNextRenderTargets = false;
  131233. }
  131234. this._activeBones.addCount(0, true);
  131235. this._activeIndices.addCount(0, true);
  131236. this._activeParticles.addCount(0, true);
  131237. };
  131238. /**
  131239. * Freeze all materials
  131240. * A frozen material will not be updatable but should be faster to render
  131241. */
  131242. Scene.prototype.freezeMaterials = function () {
  131243. for (var i = 0; i < this.materials.length; i++) {
  131244. this.materials[i].freeze();
  131245. }
  131246. };
  131247. /**
  131248. * Unfreeze all materials
  131249. * A frozen material will not be updatable but should be faster to render
  131250. */
  131251. Scene.prototype.unfreezeMaterials = function () {
  131252. for (var i = 0; i < this.materials.length; i++) {
  131253. this.materials[i].unfreeze();
  131254. }
  131255. };
  131256. /**
  131257. * Releases all held ressources
  131258. */
  131259. Scene.prototype.dispose = function () {
  131260. this.beforeRender = null;
  131261. this.afterRender = null;
  131262. this.skeletons = [];
  131263. this.morphTargetManagers = [];
  131264. this._transientComponents = [];
  131265. this._isReadyForMeshStage.clear();
  131266. this._beforeEvaluateActiveMeshStage.clear();
  131267. this._evaluateSubMeshStage.clear();
  131268. this._activeMeshStage.clear();
  131269. this._cameraDrawRenderTargetStage.clear();
  131270. this._beforeCameraDrawStage.clear();
  131271. this._beforeRenderTargetDrawStage.clear();
  131272. this._beforeRenderingGroupDrawStage.clear();
  131273. this._beforeRenderingMeshStage.clear();
  131274. this._afterRenderingMeshStage.clear();
  131275. this._afterRenderingGroupDrawStage.clear();
  131276. this._afterCameraDrawStage.clear();
  131277. this._afterRenderTargetDrawStage.clear();
  131278. this._afterRenderStage.clear();
  131279. this._beforeCameraUpdateStage.clear();
  131280. this._beforeClearStage.clear();
  131281. this._gatherRenderTargetsStage.clear();
  131282. this._gatherActiveCameraRenderTargetsStage.clear();
  131283. this._pointerMoveStage.clear();
  131284. this._pointerDownStage.clear();
  131285. this._pointerUpStage.clear();
  131286. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131287. var component = _a[_i];
  131288. component.dispose();
  131289. }
  131290. this.importedMeshesFiles = new Array();
  131291. this.stopAllAnimations();
  131292. this.resetCachedMaterial();
  131293. // Smart arrays
  131294. if (this.activeCamera) {
  131295. this.activeCamera._activeMeshes.dispose();
  131296. this.activeCamera = null;
  131297. }
  131298. this._activeMeshes.dispose();
  131299. this._renderingManager.dispose();
  131300. this._processedMaterials.dispose();
  131301. this._activeParticleSystems.dispose();
  131302. this._activeSkeletons.dispose();
  131303. this._softwareSkinnedMeshes.dispose();
  131304. this._renderTargets.dispose();
  131305. this._registeredForLateAnimationBindings.dispose();
  131306. this._meshesForIntersections.dispose();
  131307. this._toBeDisposed = [];
  131308. // Abort active requests
  131309. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  131310. var request = _c[_b];
  131311. request.abort();
  131312. }
  131313. // Events
  131314. this.onDisposeObservable.notifyObservers(this);
  131315. this.onDisposeObservable.clear();
  131316. this.onBeforeRenderObservable.clear();
  131317. this.onAfterRenderObservable.clear();
  131318. this.onBeforeRenderTargetsRenderObservable.clear();
  131319. this.onAfterRenderTargetsRenderObservable.clear();
  131320. this.onAfterStepObservable.clear();
  131321. this.onBeforeStepObservable.clear();
  131322. this.onBeforeActiveMeshesEvaluationObservable.clear();
  131323. this.onAfterActiveMeshesEvaluationObservable.clear();
  131324. this.onBeforeParticlesRenderingObservable.clear();
  131325. this.onAfterParticlesRenderingObservable.clear();
  131326. this.onBeforeDrawPhaseObservable.clear();
  131327. this.onAfterDrawPhaseObservable.clear();
  131328. this.onBeforeAnimationsObservable.clear();
  131329. this.onAfterAnimationsObservable.clear();
  131330. this.onDataLoadedObservable.clear();
  131331. this.onBeforeRenderingGroupObservable.clear();
  131332. this.onAfterRenderingGroupObservable.clear();
  131333. this.onMeshImportedObservable.clear();
  131334. this.onBeforeCameraRenderObservable.clear();
  131335. this.onAfterCameraRenderObservable.clear();
  131336. this.onReadyObservable.clear();
  131337. this.onNewCameraAddedObservable.clear();
  131338. this.onCameraRemovedObservable.clear();
  131339. this.onNewLightAddedObservable.clear();
  131340. this.onLightRemovedObservable.clear();
  131341. this.onNewGeometryAddedObservable.clear();
  131342. this.onGeometryRemovedObservable.clear();
  131343. this.onNewTransformNodeAddedObservable.clear();
  131344. this.onTransformNodeRemovedObservable.clear();
  131345. this.onNewMeshAddedObservable.clear();
  131346. this.onMeshRemovedObservable.clear();
  131347. this.onNewMaterialAddedObservable.clear();
  131348. this.onMaterialRemovedObservable.clear();
  131349. this.onNewTextureAddedObservable.clear();
  131350. this.onTextureRemovedObservable.clear();
  131351. this.onPrePointerObservable.clear();
  131352. this.onPointerObservable.clear();
  131353. this.onPreKeyboardObservable.clear();
  131354. this.onKeyboardObservable.clear();
  131355. this.onActiveCameraChanged.clear();
  131356. this.detachControl();
  131357. // Detach cameras
  131358. var canvas = this._engine.getRenderingCanvas();
  131359. if (canvas) {
  131360. var index;
  131361. for (index = 0; index < this.cameras.length; index++) {
  131362. this.cameras[index].detachControl(canvas);
  131363. }
  131364. }
  131365. // Release animation groups
  131366. while (this.animationGroups.length) {
  131367. this.animationGroups[0].dispose();
  131368. }
  131369. // Release lights
  131370. while (this.lights.length) {
  131371. this.lights[0].dispose();
  131372. }
  131373. // Release meshes
  131374. while (this.meshes.length) {
  131375. this.meshes[0].dispose(true);
  131376. }
  131377. while (this.transformNodes.length) {
  131378. this.removeTransformNode(this.transformNodes[0]);
  131379. }
  131380. // Release cameras
  131381. while (this.cameras.length) {
  131382. this.cameras[0].dispose();
  131383. }
  131384. // Release materials
  131385. if (this.defaultMaterial) {
  131386. this.defaultMaterial.dispose();
  131387. }
  131388. while (this.multiMaterials.length) {
  131389. this.multiMaterials[0].dispose();
  131390. }
  131391. while (this.materials.length) {
  131392. this.materials[0].dispose();
  131393. }
  131394. // Release particles
  131395. while (this.particleSystems.length) {
  131396. this.particleSystems[0].dispose();
  131397. }
  131398. // Release postProcesses
  131399. while (this.postProcesses.length) {
  131400. this.postProcesses[0].dispose();
  131401. }
  131402. // Release textures
  131403. while (this.textures.length) {
  131404. this.textures[0].dispose();
  131405. }
  131406. // Release UBO
  131407. this._sceneUbo.dispose();
  131408. if (this._alternateSceneUbo) {
  131409. this._alternateSceneUbo.dispose();
  131410. }
  131411. // Post-processes
  131412. this.postProcessManager.dispose();
  131413. // Remove from engine
  131414. index = this._engine.scenes.indexOf(this);
  131415. if (index > -1) {
  131416. this._engine.scenes.splice(index, 1);
  131417. }
  131418. this._engine.wipeCaches(true);
  131419. this._isDisposed = true;
  131420. };
  131421. Object.defineProperty(Scene.prototype, "isDisposed", {
  131422. /**
  131423. * Gets if the scene is already disposed
  131424. */
  131425. get: function () {
  131426. return this._isDisposed;
  131427. },
  131428. enumerable: true,
  131429. configurable: true
  131430. });
  131431. /**
  131432. * Call this function to reduce memory footprint of the scene.
  131433. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131434. */
  131435. Scene.prototype.clearCachedVertexData = function () {
  131436. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131437. var mesh = this.meshes[meshIndex];
  131438. var geometry = mesh.geometry;
  131439. if (geometry) {
  131440. geometry._indices = [];
  131441. for (var vbName in geometry._vertexBuffers) {
  131442. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131443. continue;
  131444. }
  131445. geometry._vertexBuffers[vbName]._buffer._data = null;
  131446. }
  131447. }
  131448. }
  131449. };
  131450. /**
  131451. * This function will remove the local cached buffer data from texture.
  131452. * It will save memory but will prevent the texture from being rebuilt
  131453. */
  131454. Scene.prototype.cleanCachedTextureBuffer = function () {
  131455. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131456. var baseTexture = _a[_i];
  131457. var buffer = baseTexture._buffer;
  131458. if (buffer) {
  131459. baseTexture._buffer = null;
  131460. }
  131461. }
  131462. };
  131463. /**
  131464. * Get the world extend vectors with an optional filter
  131465. *
  131466. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131467. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131468. */
  131469. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131470. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131471. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131472. filterPredicate = filterPredicate || (function () { return true; });
  131473. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131474. mesh.computeWorldMatrix(true);
  131475. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131476. return;
  131477. }
  131478. var boundingInfo = mesh.getBoundingInfo();
  131479. var minBox = boundingInfo.boundingBox.minimumWorld;
  131480. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131481. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131482. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131483. });
  131484. return {
  131485. min: min,
  131486. max: max
  131487. };
  131488. };
  131489. // Picking
  131490. /**
  131491. * Creates a ray that can be used to pick in the scene
  131492. * @param x defines the x coordinate of the origin (on-screen)
  131493. * @param y defines the y coordinate of the origin (on-screen)
  131494. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131495. * @param camera defines the camera to use for the picking
  131496. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131497. * @returns a Ray
  131498. */
  131499. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131500. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131501. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131502. };
  131503. /**
  131504. * Creates a ray that can be used to pick in the scene
  131505. * @param x defines the x coordinate of the origin (on-screen)
  131506. * @param y defines the y coordinate of the origin (on-screen)
  131507. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131508. * @param result defines the ray where to store the picking ray
  131509. * @param camera defines the camera to use for the picking
  131510. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131511. * @returns the current scene
  131512. */
  131513. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131514. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131515. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131516. };
  131517. /**
  131518. * Creates a ray that can be used to pick in the scene
  131519. * @param x defines the x coordinate of the origin (on-screen)
  131520. * @param y defines the y coordinate of the origin (on-screen)
  131521. * @param camera defines the camera to use for the picking
  131522. * @returns a Ray
  131523. */
  131524. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131525. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131526. };
  131527. /**
  131528. * Creates a ray that can be used to pick in the scene
  131529. * @param x defines the x coordinate of the origin (on-screen)
  131530. * @param y defines the y coordinate of the origin (on-screen)
  131531. * @param result defines the ray where to store the picking ray
  131532. * @param camera defines the camera to use for the picking
  131533. * @returns the current scene
  131534. */
  131535. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131536. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131537. };
  131538. /** Launch a ray to try to pick a mesh in the scene
  131539. * @param x position on screen
  131540. * @param y position on screen
  131541. * @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
  131542. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131543. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131544. * @returns a PickingInfo
  131545. */
  131546. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131547. // Dummy info if picking as not been imported
  131548. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  131549. pi._pickingUnavailable = true;
  131550. return pi;
  131551. };
  131552. /** Use the given ray to pick a mesh in the scene
  131553. * @param ray The ray to use to pick meshes
  131554. * @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
  131555. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131556. * @returns a PickingInfo
  131557. */
  131558. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131559. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131560. };
  131561. /**
  131562. * Launch a ray to try to pick a mesh in the scene
  131563. * @param x X position on screen
  131564. * @param y Y position on screen
  131565. * @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
  131566. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131567. * @returns an array of PickingInfo
  131568. */
  131569. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131570. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131571. };
  131572. /**
  131573. * Launch a ray to try to pick a mesh in the scene
  131574. * @param ray Ray to use
  131575. * @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
  131576. * @returns an array of PickingInfo
  131577. */
  131578. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131579. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131580. };
  131581. /**
  131582. * Force the value of meshUnderPointer
  131583. * @param mesh defines the mesh to use
  131584. */
  131585. Scene.prototype.setPointerOverMesh = function (mesh) {
  131586. if (this._pointerOverMesh === mesh) {
  131587. return;
  131588. }
  131589. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131590. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131591. }
  131592. this._pointerOverMesh = mesh;
  131593. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131594. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131595. }
  131596. };
  131597. /**
  131598. * Gets the mesh under the pointer
  131599. * @returns a Mesh or null if no mesh is under the pointer
  131600. */
  131601. Scene.prototype.getPointerOverMesh = function () {
  131602. return this._pointerOverMesh;
  131603. };
  131604. // Misc.
  131605. /** @hidden */
  131606. Scene.prototype._rebuildGeometries = function () {
  131607. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131608. var geometry = _a[_i];
  131609. geometry._rebuild();
  131610. }
  131611. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131612. var mesh = _c[_b];
  131613. mesh._rebuild();
  131614. }
  131615. if (this.postProcessManager) {
  131616. this.postProcessManager._rebuild();
  131617. }
  131618. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131619. var component = _e[_d];
  131620. component.rebuild();
  131621. }
  131622. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131623. var system = _g[_f];
  131624. system.rebuild();
  131625. }
  131626. };
  131627. /** @hidden */
  131628. Scene.prototype._rebuildTextures = function () {
  131629. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131630. var texture = _a[_i];
  131631. texture._rebuild();
  131632. }
  131633. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  131634. };
  131635. // Tags
  131636. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131637. if (tagsQuery === undefined) {
  131638. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131639. return list;
  131640. }
  131641. var listByTags = [];
  131642. forEach = forEach || (function (item) { return; });
  131643. for (var i in list) {
  131644. var item = list[i];
  131645. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131646. listByTags.push(item);
  131647. forEach(item);
  131648. }
  131649. }
  131650. return listByTags;
  131651. };
  131652. /**
  131653. * Get a list of meshes by tags
  131654. * @param tagsQuery defines the tags query to use
  131655. * @param forEach defines a predicate used to filter results
  131656. * @returns an array of Mesh
  131657. */
  131658. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131659. return this._getByTags(this.meshes, tagsQuery, forEach);
  131660. };
  131661. /**
  131662. * Get a list of cameras by tags
  131663. * @param tagsQuery defines the tags query to use
  131664. * @param forEach defines a predicate used to filter results
  131665. * @returns an array of Camera
  131666. */
  131667. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131668. return this._getByTags(this.cameras, tagsQuery, forEach);
  131669. };
  131670. /**
  131671. * Get a list of lights by tags
  131672. * @param tagsQuery defines the tags query to use
  131673. * @param forEach defines a predicate used to filter results
  131674. * @returns an array of Light
  131675. */
  131676. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131677. return this._getByTags(this.lights, tagsQuery, forEach);
  131678. };
  131679. /**
  131680. * Get a list of materials by tags
  131681. * @param tagsQuery defines the tags query to use
  131682. * @param forEach defines a predicate used to filter results
  131683. * @returns an array of Material
  131684. */
  131685. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131686. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131687. };
  131688. /**
  131689. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131690. * This allowed control for front to back rendering or reversly depending of the special needs.
  131691. *
  131692. * @param renderingGroupId The rendering group id corresponding to its index
  131693. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131694. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131695. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131696. */
  131697. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131698. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131699. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131700. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131701. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131702. };
  131703. /**
  131704. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131705. *
  131706. * @param renderingGroupId The rendering group id corresponding to its index
  131707. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131708. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131709. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131710. */
  131711. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131712. if (depth === void 0) { depth = true; }
  131713. if (stencil === void 0) { stencil = true; }
  131714. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131715. };
  131716. /**
  131717. * Gets the current auto clear configuration for one rendering group of the rendering
  131718. * manager.
  131719. * @param index the rendering group index to get the information for
  131720. * @returns The auto clear setup for the requested rendering group
  131721. */
  131722. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131723. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131724. };
  131725. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131726. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131727. get: function () {
  131728. return this._blockMaterialDirtyMechanism;
  131729. },
  131730. set: function (value) {
  131731. if (this._blockMaterialDirtyMechanism === value) {
  131732. return;
  131733. }
  131734. this._blockMaterialDirtyMechanism = value;
  131735. if (!value) { // Do a complete update
  131736. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  131737. }
  131738. },
  131739. enumerable: true,
  131740. configurable: true
  131741. });
  131742. /**
  131743. * Will flag all materials as dirty to trigger new shader compilation
  131744. * @param flag defines the flag used to specify which material part must be marked as dirty
  131745. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131746. */
  131747. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131748. if (this._blockMaterialDirtyMechanism) {
  131749. return;
  131750. }
  131751. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131752. var material = _a[_i];
  131753. if (predicate && !predicate(material)) {
  131754. continue;
  131755. }
  131756. material.markAsDirty(flag);
  131757. }
  131758. };
  131759. /** @hidden */
  131760. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131761. var _this = this;
  131762. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131763. this._activeRequests.push(request);
  131764. request.onCompleteObservable.add(function (request) {
  131765. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131766. });
  131767. return request;
  131768. };
  131769. /** @hidden */
  131770. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131771. var _this = this;
  131772. return new Promise(function (resolve, reject) {
  131773. _this._loadFile(url, function (data) {
  131774. resolve(data);
  131775. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131776. reject(exception);
  131777. });
  131778. });
  131779. };
  131780. // Statics
  131781. Scene._uniqueIdCounter = 0;
  131782. /** The fog is deactivated */
  131783. Scene.FOGMODE_NONE = 0;
  131784. /** The fog density is following an exponential function */
  131785. Scene.FOGMODE_EXP = 1;
  131786. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131787. Scene.FOGMODE_EXP2 = 2;
  131788. /** The fog density is following a linear function. */
  131789. Scene.FOGMODE_LINEAR = 3;
  131790. /**
  131791. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131793. */
  131794. Scene.MinDeltaTime = 1.0;
  131795. /**
  131796. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131797. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131798. */
  131799. Scene.MaxDeltaTime = 1000.0;
  131800. /** The distance in pixel that you have to move to prevent some events */
  131801. Scene.DragMovementThreshold = 10; // in pixels
  131802. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131803. Scene.LongPressDelay = 500; // in milliseconds
  131804. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131805. Scene.DoubleClickDelay = 300; // in milliseconds
  131806. /** If you need to check double click without raising a single click at first click, enable this flag */
  131807. Scene.ExclusiveDoubleClickMode = false;
  131808. return Scene;
  131809. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131810. /***/ }),
  131811. /***/ "./sceneComponent.ts":
  131812. /*!***************************!*\
  131813. !*** ./sceneComponent.ts ***!
  131814. \***************************/
  131815. /*! exports provided: SceneComponentConstants, Stage */
  131816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131817. "use strict";
  131818. __webpack_require__.r(__webpack_exports__);
  131819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131821. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131822. /**
  131823. * Groups all the scene component constants in one place to ease maintenance.
  131824. * @hidden
  131825. */
  131826. var SceneComponentConstants = /** @class */ (function () {
  131827. function SceneComponentConstants() {
  131828. }
  131829. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  131830. SceneComponentConstants.NAME_LAYER = "Layer";
  131831. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  131832. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  131833. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  131834. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  131835. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  131836. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  131837. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  131838. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  131839. SceneComponentConstants.NAME_SPRITE = "Sprite";
  131840. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  131841. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  131842. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  131843. SceneComponentConstants.NAME_OCTREE = "Octree";
  131844. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  131845. SceneComponentConstants.NAME_AUDIO = "Audio";
  131846. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  131847. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131848. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  131849. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131850. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  131851. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  131852. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  131853. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  131854. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  131855. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  131856. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  131857. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  131858. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  131859. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  131860. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  131861. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  131862. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  131863. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  131864. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  131865. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  131866. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  131867. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  131868. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  131869. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  131870. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  131871. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  131872. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  131873. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  131874. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  131875. return SceneComponentConstants;
  131876. }());
  131877. /**
  131878. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  131879. * @hidden
  131880. */
  131881. var Stage = /** @class */ (function (_super) {
  131882. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  131883. /**
  131884. * Hide ctor from the rest of the world.
  131885. * @param items The items to add.
  131886. */
  131887. function Stage(items) {
  131888. return _super.apply(this, items) || this;
  131889. }
  131890. /**
  131891. * Creates a new Stage.
  131892. * @returns A new instance of a Stage
  131893. */
  131894. Stage.Create = function () {
  131895. return Object.create(Stage.prototype);
  131896. };
  131897. /**
  131898. * Registers a step in an ordered way in the targeted stage.
  131899. * @param index Defines the position to register the step in
  131900. * @param component Defines the component attached to the step
  131901. * @param action Defines the action to launch during the step
  131902. */
  131903. Stage.prototype.registerStep = function (index, component, action) {
  131904. var i = 0;
  131905. var maxIndex = Number.MAX_VALUE;
  131906. for (; i < this.length; i++) {
  131907. var step = this[i];
  131908. maxIndex = step.index;
  131909. if (index < maxIndex) {
  131910. break;
  131911. }
  131912. }
  131913. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  131914. };
  131915. /**
  131916. * Clears all the steps from the stage.
  131917. */
  131918. Stage.prototype.clear = function () {
  131919. this.length = 0;
  131920. };
  131921. return Stage;
  131922. }(Array));
  131923. /***/ })
  131924. /******/ });
  131925. });
  131926. //# sourceMappingURL=babylon.max.js.map